Skip to content

fix: preserve active terminal across reconnects - #196

Closed
Lint111 wants to merge 2 commits into
Ark0N:masterfrom
Lint111:agent/split-server-init-lifecycle
Closed

fix: preserve active terminal across reconnects#196
Lint111 wants to merge 2 commits into
Ark0N:masterfrom
Lint111:agent/split-server-init-lifecycle

Conversation

@Lint111

Copy link
Copy Markdown
Contributor

Summary

Preserve the active terminal across same-process SSE reconnects instead of clearing state and replaying terminal history.

Extracted from #173 as a focused lifecycle fix.

Behavior

  • Add a stable serverStartedAt process epoch to both SSE init and /api/status.
  • Treat an initial load, same-process reconnect, and changed server process as distinct cases.
  • Reconcile authoritative session, cost, timer, subagent, and workflow metadata in place on reconnect.
  • Preserve the active xterm instance, buffer, geometry, scroll position, input, and terminal caches.
  • Persist available draft/input state and reload once when the server process changes.
  • Ignore stale HTTP fallback responses and equal/older init snapshots.
  • Drop terminal frames after a replacement page has been requested.
  • Keep repository-viewer scope synchronized when a reconnect reveals a changed active working directory.

Commits

  1. feat(server): identify init snapshots by process
  2. fix(client): preserve terminal across reconnects

Verification

  • npx vitest run test/server-init-lifecycle.test.ts - 7 tests passed
  • npx vitest run test/sse-events.test.ts - 7 tests passed
  • npm run check:lockfile
  • npm run typecheck
  • npm run lint
  • npm run check:frontend-syntax
  • npm run check:public-assets
  • npm run format:check
  • npm run build
  • Playwright at a 390x844 touch viewport against the production bundle:
    • one newer snapshot reconciled in place
    • an immediate duplicate snapshot was ignored
    • zero app resets and zero session reselections
    • active session, xterm instance, buffer object, and terminal geometry remained identical

Scope

No terminal rendering, input parsing, gesture controls, shutdown behavior, or repository-browser implementation is included. Optional draft and repository-viewer hooks compose with their separate PRs without making them dependencies.

@Ark0N

Ark0N commented Aug 5, 2026

Copy link
Copy Markdown
Owner

Hi Lior, closing this one as part of a cleanup of the seventeen PRs currently open from you. The full explanation is in #173, and I would rather you read that one than this note, because it is the honest version and it is not a dismissal of your work.

The short form: sixteen PRs opened in a single day, roughly 42,000 added lines in total, landing mostly on the same few files (nine touch app.js, eight touch terminal-ui.js), with five already conflicting against master and none carrying CI results. I cannot review that at the standard this codebase needs, and merging it at a lower standard would be worse than not merging it.

Going forward, please keep no more than three open PRs at a time, each one a single behavior change that stands on its own, with a test that fails on master and passes with the fix. #214 and #215, merged today, are good models.

If this particular change fixes something that genuinely annoys you in daily use, it is a good candidate to be the first one you reopen on its own, rebased on current master. I will review it properly.

Thanks for the effort you put in, and sorry to close it this way.

@Ark0NArk0N closed this Aug 5, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@Lint111@Ark0N