agent-orchestrator/packages
suraj-markup 945a7ef96d fix(cli): preserve sessions across ao stop → ao update → ao start (#1743)
The ao stop → ao update → ao start flow could drop the restore prompt
when last-stop.json went missing on disk by the time ao start looked
for it. Two layered fixes plus a cross-project follow-up:

1. ao start falls back to scanning recently `manually_killed` sessions
   (terminated within 10 minutes, reason=manually_killed) when
   last-stop.json is absent. The restore prompt surfaces them with the
   same UX as the existing record so a regression in the write
   pipeline cannot silently drop the user's in-flight work. The
   fallback uses the GLOBAL config so cross-project sessions appear in
   `otherProjects` (mirrors the existing restore step's global-config
   load).

2. writeLastStop now uses an fsync'd atomic write (atomicWriteFileSyncDurable)
   so the record survives a hard kill that lands immediately after the
   rename — renameSync is atomic but the data blocks aren't durable
   until fsync. The temp file is also unlinked on writeFileSync /
   fsyncSync throw (Greptile P2 #1 follow-up).

3. After any user decision on a restore prompt (declined / all-restored /
   empty), runStartup writes an empty marker via the new
   markLastStopAcknowledged() helper instead of unlinking the file.
   The fallback gate is tightened from `!lastStopHasContent` to
   `!lastStop` (file truly absent) so a second ao start within the
   10-minute window does not re-surface sessions the user already
   declined (Greptile P1 review on PR #1780).

Tests:
- last-stop-fallback unit tests (5)
- stop → simulated update → start integration test (2)
- writeLastStop fsync test (1)
- writeLastStop temp-file cleanup on write throw (1)
- otherProjects round-trip through readLastStop (1)
- markLastStopAcknowledged round-trip (1)
- ao update no-touch regression (1)
- start.ts: fallback finds recent killed sessions (1)
- start.ts: fallback respects window (1)
- start.ts: fallback uses global config for cross-project (1)
- start.ts: empty marker prevents re-prompt after decline (1)
- start.ts: every-session-restored writes marker (not unlink) (1)

Closes #1743

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 04:52:22 +05:30
..
ao fix(cli): rebuild better-sqlite3 on install + quieter ABI-mismatch warning (closes #1822) (#1824) 2026-05-18 04:02:26 +05:30
cli fix(cli): preserve sessions across ao stop → ao update → ao start (#1743) 2026-05-21 04:52:22 +05:30
core fix(cli,release): repair nightly updates and snapshots (#1960) 2026-05-20 21:55:21 +05:30
integration-tests feat(notifier): make notifier system robust with manual harness and desktop setup (#1736) 2026-05-19 14:48:40 +05:30
notifier-macos feat(notifier): make notifier system robust with manual harness and desktop setup (#1736) 2026-05-19 14:48:40 +05:30
plugins refactor(agent-claude-code): replace terminal-regex activity detection with hooks (closes #1941) (#1945) 2026-05-20 18:17:35 +05:30
web feat(cli): support AO_PUBLIC_URL for reverse-proxied dashboards (#1757) 2026-05-20 23:09:04 +05:30