Skip to content

refactor(native-chat): remove the records-file and per-chat journal imports - #26038

Merged
brennanb2025 merged 4 commits into
mainfrom
brennanb2025/remove-json-based-native
Oct 7, 2026
Merged

brennanb2025 merged 4 commits into
mainfrom
brennanb2025/remove-json-based-native

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 26 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​122 $\color{#cf222e}{\Huge{\mathbf{−}}}$​3488 $\color{#cf222e}{\Huge{\mathbf{−}}}$​3366
Prod 55 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​132 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1867 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1735

ELI5

Native chat used to save its data in two older ways: a single JSON file listing every chat (agent-sessions.json), and one small database file per chat (journal.db). Later, everything moved into one app-wide chat database, and each launch copied anything still in the old files into it. Every native chat user is now on a build that has already done that copy, so the copying code no longer does anything. This PR deletes it.

What Changed

What users see: nothing. Chats, tabs and history load exactly as before, from the app-wide database. The difference is less work at startup: no file reads before the database opens, and no extra step when a chat opens.

Removed:

  • The records-file copy. When the database first moved to schema version 4, it read agent-sessions.json (falling back to its .bak) and copied every chat record into the database. If the file couldn't be read, a flag recorded that the copy was still owed, and every later launch retried it. That flag reached the chat host, the "does this profile have any chats" check, and startup tab restore. The copy, the flag, the backup salvage and fence-floor logic, and the file parser are all gone. The database open is now synchronous: create the tables, set the version.
  • The per-chat journal.db copy. Opening a chat checked for that chat's old per-chat file and copied it in. When startup restore opened a chat, the copy was deferred until first use, so the chat's write queue held every write behind it, and reads, sends and Stops each waited for it first. All of that is gone: the importer, the hold in the write queue, whenImported / importPending, and the per-chat folder paths.
  • The check for the even older log.jsonl format. An empty chat used to look for that format's leftovers and add a note saying where the old history went. Removed.
  • agent-session-record-store-file.ts was file-reading code apart from the store's state types. It's renamed to agent-session-store-state.ts and now holds only those types.

Kept on purpose:

  • The database's schema version stays at 4, and the three tables only older builds use (journal_repairs, journal_imports, journal_set_aside) are still created. A build from before this PR runs on the same schema version and queries those tables, so a rollback still opens every chat normally. Dropping the tables means bumping the version, and then any older build refuses every chat until the user updates again. So the tables stay until a schema bump is needed for some other reason; a bump made only to drop three empty tables would turn every older build's chats read-only for no benefit.
  • The minimumNextFence field on chat records stays. Records the old copy already brought in may carry it. It still stops a second process from taking over a chat, so only its comment changed.
  • The tab-restore fallback for profiles that never saved a tab list stays. It restores tabs from the saved workspace, a different legacy path from the ones removed here.
  • journal-legacy-import.ts stays. Despite its name, it reads Claude's and Codex's own transcript files when an existing conversation is adopted into native chat, not Orca's old storage.

Why

Native chat has no real users yet, so there is no older data these copies would ever need to bring in. What remained was cost with no benefit:

  • file reads before the database could open;
  • a durable "copy still owed" flag that the host, tab restore and the inventory check all had to respect;
  • a hold in every chat's write queue that made writes land later than the call that issued them.

That hold was the only real backlog a chat's write queue ever had. With it gone, every write lands by the time its call returns. The only exception is a write issued from inside another write (or queued behind one), and no production code does that.

The alternative was to leave the code until native chat goes public. But that means shipping a migration path to new users that none of them can ever hit, and keeping tests for a state that can no longer happen.

Linked Issue

N/A (maintainer cleanup; no existing issue).

Visual Proof

Nothing visible changes. These screenshots are from the running app on a Mac, using a separate test profile, and show that behaviour stays the same:

Before quit After relaunch
s1-before-quit s1-after-relaunch

Old-format files (agent-sessions.json, .bak, a per-chat journal.db, log.jsonl) planted in the profile are ignored: no error, no phantom chat, and the restored chat still sends and receives.

After launch After sending a new message Session list
s2-after-launch-legacy s2-after-send s2-session-list

A database labelled schema version 3 opens and upgrades to version 4: s3

Testing

  • pnpm tc:node passes.

  • pnpm run check:code-quality:changed passes.

  • Every test under src/main/native-chat/agent-session-journal/ and agent-session-wire/, plus the runtime agent-session-* / structured-agent-session-* tests and the structured chat RPC method tests, pass under Node.

  • The cross-version tests that hand this build's database to an older release (agent-session-stop-event-downgrade, agent-session-newer-chat-refusal) pass. That confirms a rollback still opens chats.

  • Tests that only covered the removed paths are deleted. Tests that used the import to hold writes in the queue now either make the journal open fail another way, or are removed where that state can no longer happen.

  • A new test checks that a released version-3 database gains the chat record tables without losing its rows.

  • Platform: macOS only. Nothing here is platform-specific; it's all main-process database and file code.

  • Not run: the full suite, the web and CLI typechecks (the only src/shared edits are comments), or the running app.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Old files on disk: nothing deletes leftover agent-sessions.json, per-chat journal.db or log.jsonl files; Orca just stops reading them. A chat whose history only exists in a log.jsonl folder is no longer restored at startup, and opens empty, without the note, if something attaches to it.
  • SSH / remote: a remote host runs this same code against its own database, so nothing changes on the wire.
  • Backwards compatibility: the schema stays at version 4, so rolling back to an earlier build reads the same database as before.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…mports

Every native chat user is on a build that already moved chat records and
history into the app-wide database, so the one-time copies are dead code:
the agent-sessions.json import and its owed-copy flag, the per-chat
journal.db import and the write-queue hold behind it, and the pre-SQLite
log.jsonl notice.
- JournalHostDatabase.unsyncedTransaction and the synchronous-pragma reset
  that undid it; JOURNAL_SYNCHRONOUS is now module-local. The stranded
  rollback test drives transaction() instead.
- deleteUnpublishedJournalRows and its SQL, plus its test.
- boundJournalStatusText.
- Stale comments naming the removed first-use copy (queued messages,
  send refusal example, JOURNAL_SYNCHRONOUS doc).
- Write-queue and readInOrder comments: a write also lags when issued
  behind one still waiting in line.
- Resolved-append ordering test binds the sink from inside a running read,
  so a resolver that read at handover now fails it.
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review summary (head a7e90dd41d1)

The problem this PR solves. Native chat used to keep its data in two older formats: one agent-sessions.json file listing every chat, and a small journal.db file per chat. When everything moved into one app-wide chat database, each launch copied anything still in those old files into it. Native chat has no real users yet, so there is no old data to copy. But the copying code still cost something on every launch:

  • file reads before the database opened;
  • a saved "copy still owed" flag that startup tab restore and the "does this profile have chats" check all had to respect;
  • a hold in each chat's write queue that made writes land later than the call that issued them.

What users see. Nothing changes. Chats, tabs and history load from the same database as before. Startup just does less work. Old files left on disk are ignored, not deleted.

What the review found and fixed

Four parallel reviewers covered: storage and schema; the write queue and the send/Stop paths; leftovers across the repo; and an independent architecture review. A second round reviewed the fixes, followed by a readiness pass. None of them found a P0, P1 or P2, or any user-visible problem. Fixed on this branch:

  • Dead code that only the deleted imports used: JournalHostDatabase.unsyncedTransaction and its pragma reset on rollback, deleteUnpublishedJournalRows and its SQL, and boundJournalStatusText. Also stale comments in five files that still described the removed copy. (59f38b493c1)
  • A kept ordering test that could no longer fail. Without the import, its journal never had writes waiting in line. It now builds a real backlog. Breaking the code on purpose turns it red ('c' instead of 'abc'), and the old form stayed green. (59f38b493c1)
  • CI: that test uses a real SQLite database, so it now runs in the SQLite test project. (a7e90dd41d1)
  • The PR description: corrected the stated reason (no real users), the old-table follow-up, the sentence about when writes land, and the note on leftover log.jsonl chats.
  • Merged current main (24ec2cf43f4) with no conflicts.

Deferred (separate PRs; each changes live behaviour rather than deleting dead code)

  • lease.minimumNextFence: nothing writes it any more, though released builds 1.4.220 to 1.4.222 did. It is still read when choosing the next fence. Removing it changes that choice, so it belongs in its own small PR.
  • Write queue (design follow-up): with the import gone, no production code issues a write from inside another write. So the queue's wait-in-line path and the event sink's handling of replaced publications only guard a case that never happens. Collapsing them changes the async signature of every write call.
  • Saved-tab fallback: startup still falls back to the profile's saved tabs when a tab list was never recorded. That is a legacy path too, but removing it changes which chats restore.
  • Old-build-only tables (journal_repairs, journal_imports, journal_set_aside): drop them in the next schema bump that's needed anyway. A bump made only for this would open every older build's chats read-only.
  • Nits:
    • ci-shard-timings.json still lists a deleted test.
    • Two row-table helpers no longer need to be exported.
    • When the "tabs recorded" marker is missing, the store still reads the tab rows and then discards them.

Verified

  • Typecheck and lint: the node typecheck passes on the merged result, and check:code-quality:changed reports 0 new findings.
  • Tests: the targeted files pass, about 215 tests across the journal, wire, runtime and rollback suites.
  • CI on a7e90dd41d1: 15 passed, 0 failed.
  • Live app on a Mac, separate test profile, driven through the DevTools protocol:
    • A chat and its history restore after quit and relaunch.
    • Planted old-format files (agent-sessions.json, .bak, per-chat journal.db, log.jsonl) are ignored. No error, no phantom chat, the files are unchanged, and the restored chat still sends and receives.
    • A database labelled schema version 3 opens and upgrades to version 4.
    • A reply lost after a relaunch in two early runs was caused by the stand-in agent reusing message ids. The same steps on main lose it the same way.
Before quit After relaunch
s1-before-quit s1-after-relaunch
Old-format files planted, after launch After sending a new message Session list
s2-after-launch-legacy s2-after-send s2-session-list

Version 3 database opens: s3

Not verified

  • Files written by a real older build: a real agent-sessions.json, a real per-chat journal.db, or a true version 3 database. The test files were synthetic.
  • Real Claude or Codex agents; the live test used a stand-in agent.
  • SSH remote hosts, Windows and Linux. Nothing here is platform-specific, and nothing crosses the wire.
  • The full local test suite. CI ran it.

@brennanb2025
brennanb2025 marked this pull request as ready for review October 7, 2026 05:39
@coderabbitai

coderabbitai Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7f073d1e-e5fe-4379-b167-0a7a9ff86085
📥 Commits

Reviewing files that changed from the base of the PR and between 923ef7c and a7e90dd.

📒 Files selected for processing (81)
  • config/scripts/vitest-sqlite-runtime-files.mjs
  • src/main/native-chat/agent-session-journal/journal-database-records-migration.test.ts
  • src/main/native-chat/agent-session-journal/journal-database-schema.ts
  • src/main/native-chat/agent-session-journal/journal-database.test.ts
  • src/main/native-chat/agent-session-journal/journal-database.ts
  • src/main/native-chat/agent-session-journal/journal-file-format-remnant.test.ts
  • src/main/native-chat/agent-session-journal/journal-file-format-remnant.ts
  • src/main/native-chat/agent-session-journal/journal-host-database-test-support.ts
  • src/main/native-chat/agent-session-journal/journal-host-database.test.ts
  • src/main/native-chat/agent-session-journal/journal-host-database.ts
  • src/main/native-chat/agent-session-journal/journal-open-failure.test.ts
  • src/main/native-chat/agent-session-journal/journal-open-failure.ts
  • src/main/native-chat/agent-session-journal/journal-owed-import-test-support.ts
  • src/main/native-chat/agent-session-journal/journal-paths.ts
  • src/main/native-chat/agent-session-journal/journal-per-session-import.test.ts
  • src/main/native-chat/agent-session-journal/journal-per-session-import.ts
  • src/main/native-chat/agent-session-journal/journal-per-session-reimport.ts
  • src/main/native-chat/agent-session-journal/journal-per-session-source.ts
  • src/main/native-chat/agent-session-journal/journal-prompt-body-bounds.ts
  • src/main/native-chat/agent-session-journal/journal-queued-messages.ts
  • src/main/native-chat/agent-session-journal/journal-row-table.ts
  • src/main/native-chat/agent-session-journal/journal-store-collaborators.ts
  • src/main/native-chat/agent-session-journal/journal-store-contracts.ts
  • src/main/native-chat/agent-session-journal/journal-store-open.ts
  • src/main/native-chat/agent-session-journal/journal-store-restore.ts
  • src/main/native-chat/agent-session-journal/journal-store.test.ts
  • src/main/native-chat/agent-session-journal/journal-store.ts
  • src/main/native-chat/agent-session-journal/journal-write-queue.test.ts
  • src/main/native-chat/agent-session-journal/journal-write-queue.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-chat-stop.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-conversation-lifetime.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-conversation-open.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-event-sink-queue.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-event-sink.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-host.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-import-mismatch.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-mutation-owed-import.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-queued-pause-lift.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-read-restore.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-read-restore.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-refusal-retry.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-resolved-append.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-restore-without-import.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-send-preparation.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-settled-attach-retry.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-stop-never-waits.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-thread-goal.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-transition.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-turns-cancel.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-turns.ts
  • src/main/runtime/agent-session-acquisition-failure-settlement.ts
  • src/main/runtime/agent-session-backup-recovery-fence.ts
  • src/main/runtime/agent-session-claim-key-retention.ts
  • src/main/runtime/agent-session-conversation-command-record.ts
  • src/main/runtime/agent-session-lease-renewal.ts
  • src/main/runtime/agent-session-legacy-record-import.test.ts
  • src/main/runtime/agent-session-legacy-record-import.ts
  • src/main/runtime/agent-session-operation-admission.ts
  • src/main/runtime/agent-session-record-rows.ts
  • src/main/runtime/agent-session-record-store-file.ts
  • src/main/runtime/agent-session-record-store-slot.ts
  • src/main/runtime/agent-session-record-store-test-harness.ts
  • src/main/runtime/agent-session-record-store.ts
  • src/main/runtime/agent-session-reservation-admission.test.ts
  • src/main/runtime/agent-session-reservation-admission.ts
  • src/main/runtime/agent-session-restart-reconciliation.ts
  • src/main/runtime/agent-session-store-draft.ts
  • src/main/runtime/agent-session-store-row-rules.ts
  • src/main/runtime/agent-session-store-state.ts
  • src/main/runtime/agent-session-store-transactions.ts
  • src/main/runtime/agent-session-tab-table.ts
  • src/main/runtime/orca-runtime-restore-structured-agent-session-tabs-once.ts
  • src/main/runtime/rpc/methods/structured-agent-session.test.ts
  • src/main/runtime/structured-agent-session-journal-open.ts
  • src/main/runtime/structured-agent-session-record-import-install.test.ts
  • src/main/runtime/structured-agent-session-rollback-compatibility.test.ts
  • src/main/runtime/structured-agent-session-runtime.test.ts
  • src/main/runtime/structured-agent-session-runtime.ts
  • src/main/runtime/structured-agent-session-startup-tab-restore.test.ts
  • src/shared/agent-session-next-fence.ts
  • src/shared/agent-session-record.ts
💤 Files with no reviewable changes (27)
  • src/main/native-chat/agent-session-journal/journal-per-session-import.test.ts
  • src/main/native-chat/agent-session-journal/journal-store-collaborators.ts
  • src/main/native-chat/agent-session-journal/journal-store-contracts.ts
  • src/main/native-chat/agent-session-journal/journal-file-format-remnant.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-mutation-owed-import.test.ts
  • src/main/native-chat/agent-session-journal/journal-store.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-queued-pause-lift.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-import-mismatch.test.ts
  • src/main/native-chat/agent-session-journal/journal-owed-import-test-support.ts
  • src/main/native-chat/agent-session-journal/journal-database-records-migration.test.ts
  • src/main/native-chat/agent-session-journal/journal-prompt-body-bounds.ts
  • src/main/native-chat/agent-session-journal/journal-row-table.ts
  • src/main/native-chat/agent-session-journal/journal-file-format-remnant.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-restore-without-import.test.ts
  • src/main/runtime/agent-session-backup-recovery-fence.ts
  • src/main/native-chat/agent-session-journal/journal-paths.ts
  • src/main/native-chat/agent-session-journal/journal-per-session-reimport.ts
  • src/main/runtime/structured-agent-session-record-import-install.test.ts
  • src/main/native-chat/agent-session-journal/journal-per-session-import.ts
  • src/main/runtime/agent-session-legacy-record-import.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-conversation-lifetime.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-transition.test.ts
  • src/main/runtime/agent-session-legacy-record-import.ts
  • src/main/runtime/agent-session-record-store-file.ts
  • src/main/native-chat/agent-session-journal/journal-per-session-source.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-event-sink.test.ts
  • src/main/native-chat/agent-session-journal/journal-store-open.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.


📝 Walkthrough

Walkthrough

The changes remove legacy per-chat journal import and JSON record-store loading. Journal opening now migrates older schemas directly, while journal replay and writes no longer use deferred import work. Session restoration and tab handling now use the host database and persisted tab index. Related APIs, tests, and legacy transcript-remnant disclosures were removed or updated.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to a7e90

Legacy chat files are intentionally ignored while database-backed chats remain supported. No actionable merge-blocking issue is established; proceed with normal checks.

🚥 Pre-merge checks | ✅ 4 | ❓ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ❓ Inconclusive Docstring coverage is 52.94% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 34 functions across 50 files. (4 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: removing the legacy records-file and per-chat journal imports.
Description check ✅ Passed The description covers the user impact, changes, rationale, compatibility, visual proof, and testing. It also identifies tests that were not run. The maintainer’s N/A issue note matches the template’s…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 52.94% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 34 functions across 50 files. (4 skipped: 4 over the file limit.)

✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@brennanb2025
brennanb2025 merged commit acea59c into main Oct 7, 2026
56 checks passed
Jinwoo-H added a commit that referenced this pull request Oct 7, 2026
…he restore-failed test (#26094)

#26038 removed JournalHostDatabase.legacyDirectoryFor while #25225's test still
spied on it, so typecheck fails on main. Use the replacement spy #26038 gave
its own tests.
brennanb2025 added a commit that referenced this pull request Oct 7, 2026
… live

Main's #26038 dropped stateDirectory from JournalHostDatabase; this PR's
runtime end records are read from and written beside it.
brennanb2025 added a commit that referenced this pull request Oct 7, 2026
…r Continue (#25675)

* feat(native-chat): say in the chat why Orca stopped a reply, and offer Continue

When the Orca that runs a structured chat (this computer or a paired server) quits, updates or
crashes mid-reply, the chat's stopped row now names the cause and the machine, and a Continue
button sends the existing restart continuation for that cut turn, with or without a restart offer.

- Host: a quit/update writes one turn-scoped row for the turn its stop cut, in today's words, with
  an optional `orcaStop` cause on the providerExited fact; restart adjudication stamps how the
  previous runtime ended on the deaths it proves (crash, or the quit/update it began), so the
  crash row names it too. Older clients keep their single row.
- Host: agentSession.continueInterrupted, capability-gated, rechecks under the session lock that
  the chat still sits on that cut, so a second click or a retry sends nothing.
- Client: the row's copy names the cause and machine; Continue sits above the composer.

* test(native-chat): Continue is not held by a recovery file that never answers

* fix(native-chat): bind an Orca stop's cause to the runtime that held the agent; neutral row, Continue explains itself

- The cause now rides on the host's row itself (`orcaStop` on the status row, beside today's
  words), the same row family and id scheme as the reopen's death row.
- Each recorded owner is stamped with the Orca runtime that holds it; a death proven later (at
  restart, or when recovery stops a survivor) names how that runtime ended: the quit or update it
  began, else a crash. Owners an older build recorded, a terminal's claim, an agent that died while
  its Orca ran, and unreadable quit records all keep the generic words.
- The quitting runtime's word is written first in teardown, before the recovery wait, through a
  bounded asynchronous writer apart from the chat database.
- Row copy: one neutral sentence naming the machine and cause; it drops "You can continue in this
  conversation." while Continue is offered, and Continue's tooltip says what it does.

* test(native-chat): type the Orca-stop test fixtures so the typecheck passes

The cut turn's outcome takes the journal's outcome type, and the stand-in close reads the
provider sink through a checked lookup instead of an index that may be absent.

* fix(native-chat): call a cut a crash only when Orca's runtime started and never ended

A chat said "Orca stopped unexpectedly" whenever its runtime left no quit record, and only the
desktop quit wrote one, so a headless server's restart or update, the Settings relaunch, and a
Windows logoff all read as crashes.

Each runtime now records its own start when its chat store opens, and every graceful exit records
its end through one synchronous entry point: the desktop quit's teardown, the headless server's
stop, the in-app relaunch, the GPU-fallback restarts, the update-install watchdog, and Windows
session end. A crash is a runtime that started and never ended; a runtime with no readable record
(never written, pruned, unreadable) names no cause, so the chat keeps its generic words. One file
per runtime, written durably and only by that runtime, so a damaged file never blocks a later
write and two processes never lose each other's record.

* fix(native-chat): Continue answers once Orca accepts it, not once the agent has started

On a paired server, Continue waited for the agent to start before answering, and the client
gives a paired call 15 s. A slow start (account switch, login shell, a long resume) showed
"Couldn't continue this chat" while the agent was in fact continuing.

Continue now answers when Orca has accepted the message, as a send does. The agent's start and
answer settle afterwards, and a start that fails is the chat's own note, as before. The restart
dialog's batch still waits for the handover, which is where it counts a start as done. The
verdict helpers move to their own module to keep the continuation file within its size limit.

* fix(native-chat): a reply the user steered, or a command run after the cut, still offers Continue

The cut detector stopped at the first user message after the cut turn, so a steer the turn had
taken, or a conversation command such as /context run after the cut, removed Continue while the
row still named the cause.

The rule for what is no request of its own (a conversation command, a row its turn produced, a
send handed into a running turn) moves out of the latest-request reader into one shared
predicate, which both that reader and the cut detector use. The host's "still wanted?" check
reads the same detector, so the client and host agree.

* fix(native-chat): a death proven after an earlier settle explains the turn it ends

When a chat was read before the restart proved its old agent dead, the read could only call the
turn unverifiable. The proof then revised the turn to interrupted, but the death row was scoped
by the turn still marked running, and none was, so it landed on the conversation instead of the
turn. That cut never offered Continue, and the row did not name it as the turn's explanation.

The row is now scoped to the newest root turn the settle actually ends, running or revised.

* fix(native-chat): the cause row's words stay put, and Continue waits out a resume already running

The row's "You can continue in this conversation." came and went with the button: it showed
while a paired host's answer was still on its way, vanished when the button appeared, and came
back the moment Continue was clicked. Continue also appeared on chats the restart prompt or the
launch's own resume was already carrying on.

The row now drops that sentence wherever the chat's host can continue a cut, counting a host
that has not answered yet as able (a host that writes cause rows has Continue), so its words
never change on screen. Continue is hidden while a resume is carrying that chat on.

* fix(native-chat): a refused Continue says so once, in the composer

A Continue the host refused before accepting anything wrote a red note into the chat and brought
the button back, so each retry added another identical note; a chat the host had no record of
was refused with no word at all.

Continue now reports every refusal the same way as a failed request: the existing composer line
"Couldn't continue this chat. Try again, or send a message.", which a retry replaces rather than
repeats. A refusal before acceptance writes no note. A failure after the message was accepted
(the agent could not start) is still the chat's own note, as for any send.

* fix(native-chat): the row naming Orca's stop carries its own presentation and never folds

A client that re-words host rows it cannot name (the draft that makes these cuts read as
interruptions) treated the cause row as an older red row and replaced its words, so the cause
never showed there. The row was also folded away under its collapsed turn once shown muted.

The host's cause row now names the presentation 'orca-stop' beside today's words, failure fact and
red tone, so a client that predates both changes still prints exactly today's row, red and on
screen, and a client that re-words unnamed rows passes it through. This build shows it muted,
counts it as no failure (the reply it cut stays the turn's answer), and never folds it; the fold
field becomes `explainsTurn`, as the other change names it.

* test(native-chat): pass the session-end event without a type assertion

* test(native-chat): the row naming Orca's stop renders neutral, whoever re-presented it

Pins the rendered tone on this build: the stored red row, and the same row after a reader
re-presents it in the neutral tone with its presentation and cause kept, both render muted and
never fold. The phone draws chat rows without tone styling, so it needs no change.

* fix(native-chat): the "Couldn't continue" line goes once the chat is continued

The composer line a failed or refused Continue set stayed on screen while the agent carried on:
after an answer lost in transit, or once another client or the restart prompt continued the
chat. Only the next Continue click or the user's own send cleared it, and a click also wiped an
unrelated composer error.

The line is now derived: shown only while the chat still sits on the cut that Continue failed
on, so it goes as soon as the journal shows the chat continued, from anywhere. A Continue click
clears only its own line, and a retry answered "already continued" leaves none.

* fix(native-chat): Continue waits while an opted-in launch may still resume the chat

With "resume automatically" on, Continue showed on a quit or update cut while the launch was still
waiting for its settings and reading the restart offer, then vanished when the launch's own
resume began; a click in between sent a competing continuation.

The launch's one decision (nothing offered, ask, or resume) is now published, and the chats it
resumes are named the moment it decides, with no gap. Until it decides, and while the setting
has not loaded or is on, Continue stays hidden on this machine's chats; a paired server's chats
are not the launch's to resume and keep it.

* fix(native-chat): a runtime's end survives a late reinstall, a failed write and any clean exit

Three ways the runtime record could still read a graceful stop as a crash:

- A chat host reinstalled during the quit (a request landing after teardown began) recorded the
  runtime's start again and erased the end it had just written. A second start of the same
  runtime now keeps that end.
- When the end could not be written (a full disk), the start alone stayed and read as a crash.
  The runtime now removes its record, so its chats name no cause.
- Each `app.exit(0)` had to remember to record the end. A process 'exit' with code 0 now records
  a quit when nothing else did: Electron emits it on every quit and exit once its loop runs
  (`app.exit` -> Browser::Shutdown -> the app's 'quit' -> process 'exit'), and Node on every
  `process.exit`. The relaunch and GPU-fallback calls it covers are dropped; the quit teardown,
  the headless server's stop, the update watchdog and Windows session end keep theirs, which run
  earlier or say more.

* test(native-chat): build the re-presented row as the plain status item it is

* fix(native-chat): a Continue click clears the composer's old error, so its own failure shows

Since the "Couldn't continue" line became derived, an older composer error (such as "Remove
attachments before using a chat-session command.") outranked it: a failed Continue showed the
old error instead, and a Continue that went through left the old error on screen.

A Continue click is the user's newer action, so it clears the composer's error again, as before;
the line then shows the Continue's own failure, if any. That failure still goes away by itself
once the chat is continued, and nothing but the user's own Continue click clears an unrelated
composer error.

* fix(native-chat): a chat start compares the owner process, not the runtime stamped on it

A chat start checks that the process it just started is the one the record names, by a deep
comparison of the stored owner with the adapter's process. The store stamps that owner with the
Orca runtime holding it, so the check passed only because the store happened to return the record
from before the stamp; returning the published record would have refused every chat start with
agent_session_ownership_unknown.

The start now compares the process identity without the runtime stamp, which says who holds the
process rather than which process it is.

* test(native-chat): count agentSession.continueInterrupted among the structured methods

* refactor(native-chat): derive the structured chat's transcript session in its own hook

Main's appearance work and this branch's Continue wiring together put NativeChatStructuredSession
past the 400-line limit for components. The session the transcript reads moves, unchanged, to
use-structured-chat-live-session.ts.

* refactor(native-chat): keep the Continue capability in its own module

Main grew protocol-version.ts to its line limit; the Continue capability moves to its own module,
as other capability groups have, and the runtime list still names it.

* refactor(native-chat): keep two shared files within their line limit after the main merge

Main left agent-session-record.ts and structured-agent-session-params.ts just under 300 lines,
and this branch's additions put them over. The account-home shape check moves next to the
account-home type it checks (written without a type assertion), and the Continue params move to
their own contract module; the params catalog is regenerated. No behavior change.

* test(native-chat): compare the store directory's files without depending on listing order

The corruption test checks that no file was created or removed by comparing two recursive
listings. Their order is the runtime's: with the per-runtime record directory nested under the
store, Bun returns the same entries in a different order than Node. Both listings are now sorted.

* fix: share the path bound main's launch-directory check needs

* test: give the stop-row fold rows the draws flag main's fold now reads

* refactor: mark the launch's resume decision where the resume begins

* test: count main's new structured method alongside agentSession.continueInterrupted

* fix: the journal database keeps its folder, where runtime end records live

Main's #26038 dropped stateDirectory from JournalHostDatabase; this PR's
runtime end records are read from and written beside it.
Sign up for free to 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.

1 participant