Skip to content

fix(native-chat): verify the actual CLI conversation during resume - #29124

Merged
brennanb2025 merged 33 commits into
mainfrom
brennanb2025/rcc-b-source-admission
Oct 17, 2026
Merged

brennanb2025 merged 33 commits into
mainfrom
brennanb2025/rcc-b-source-admission

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 10 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​367 $\color{#cf222e}{\Huge{\mathbf{−}}}$​49 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​318
Prod 34 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​732 $\color{#cf222e}{\Huge{\mathbf{−}}}$​181 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​551

ELI5

Resuming a saved CLI conversation could fail when its terminal reported a filename different from the conversation ID, another configured account was inaccessible, or Codex history was prepared somewhere other than the new chat's execution home. Closing or replacing the source terminal during preparation could also invalidate a resume that had already reached the host.

The host now admits the saved conversation during chat creation and keeps the original source evidence for that request. A dispatched resume can finish after its source terminal closes, using the original conversation and account. A source already invalid when the host receives the request is refused.

What Changed

  • Create can accept optional workspace/pane identity under agent-session.structured.cli-source.v1. The host derives the path from its own provider status, checks recognized account containment, and validates provider identity and recorded directory during the existing import. Clients supply no paths or credentials. This PR adds host admission; the sender and visible destination publication belong to Resume terminal conversations in native chat without waiting for History #29150.
  • Account admission stops at the first canonical match. An unrelated later account cannot block a readable source; relevant access errors still refuse. The existing locator can recover a missing exact file only within the admitted account.
  • Confirmed missing content or a successful zero-byte read uses the existing not-saved result. Nonempty malformed, metadata-only or contradictory adopted content remains a load error. Ordinary journal hydration retains its existing no-message behavior.
  • Native Codex adoption resolves one execution home, supplies it to existing preparation, then verifies and pins that same home/file. A custom History directory does not become the chat's credential or configuration home; ordinary History preparation retains its configured target.
  • CLI source evidence is copied once at host request admission before preparation yields. Later pane closure or in-place identity/path replacement cannot change that request. Existing-owner and exact committed-replay answers remain ahead of source validation, including when capturing source rows failed.

Corrected #29119 was integrated with a normal merge for ownership/replay and missing/empty/unreadable behavior. No new saved fields, source store, discovery service, parser or wire operation is added. Existing ID-only callers remain compatible; the dependent sender must negotiate the optional capability.

Why

The command already names one conversation. The common pattern keeps the conversation identity with the execution host and carries resolved facts through preparation and launch. Reusing create, the existing account resolver and import stream keeps consequential checks together without adding another discovery phase. Request-owned evidence also lets pane teardown proceed normally.

Linked Issue

Part B of the resume-action stack, based on #29119 and consumed by #29150. The stack replaces the approach in #28284. No issue or other PR is closed automatically.

Visual Proof

Rendered QA covered by #29150 integrated QA, pending the refreshed stack.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated

Existing import tests cover host path/account containment, provider directory/identity, first-account success despite a later inaccessible account, relevant access failure, zero-byte versus malformed content, and actual Codex materialization with different History and execution homes.

The real-runtime/RPC replay fixture uses an explicit routing gate to close a source after unary dispatch and mutate its nested identity/path after streaming-unary dispatch. It requires the original imported text/account and one acquisition. Before-dispatch absent/replaced evidence remains refused even if live rows return; absent/error evidence cannot override existing-owner or exact replay answers. Deleted-file, account-drift and caller/operation isolation controls remain.

Final head a836a6c77b1b81db7af7120d0afd466576735304: full PR workflow 38745721909, attempt 1, passed, including the actual PR checks passed aggregate, static analysis/typecheck, all five unit shards, both packages, relay integration, cross-version wire and unit-selection evidence. The final-head log explicitly records both runtime/RPC regression cases and all 59 existing routing tests passing. Supporting macOS/Linux/Windows runtime and transcript-reader contracts, Mobile verify and the test-size gate also passed. Earlier lint and obsolete exact mock-shape failures were corrected; no local pnpm, install, test, lint, typecheck, build or app launch was run. No standalone rendered or live-provider pass is claimed.

Review

Independent review confirmed the account-order, empty-source, Codex-home and source-close findings. Their corrections followed fresh bounded technical rulings. Independent final source verification and the narrow static-correction check accepted production head 8cd662b72e6, with no new proven behavioral finding. The subsequent test-only correction updates three existing routing matchers for the approved host-only argument; it changes no production behavior. Full CI passed on that final head. This description makes no merge-readiness or rendered-QA claim.

Agent skill upstream boundary

  • Not applicable: no upstream skill-installer source or supporting material is copied or translated.

Notes

Intended product requirement: Orca imports external transcripts into its journal and supports several account homes, so canonical file admission and provider-specific validation remain necessary. Folder workspaces and typed OpenCode accounts remain supported. CLI adoption remains local; SSH/WSL sources are refused. No changed credential default or platform/remote support is introduced.

Existing fallback traversal can still be slow. Canonical admission and the later file read can still race with filesystem changes; no bounded reproduction established a new defect, and this PR makes no latency or filesystem-atomicity guarantee. These existing concerns are deferred.

Temporary stack dependency: #29150 owns the renderer sender, deferred visible destination and integrated QA. B alone does not claim removal of the action's History wait or the completed no-destination refusal result.

Author: @BrennanKB5.

Checklist

  • This PR is small and focused
  • I explained the user-facing change, mechanism and reason for the approach
  • Integrated before/after screenshots or videos pending in Resume terminal conversations in native chat without waiting for History #29150
  • Self-reviewed for correctness, security and performance
  • Cross-platform, SSH/remote, folder-workspace and compatibility impact considered
  • Full hosted CI passes on the current head; local checks prohibited for this builder

@brennanb2025
brennanb2025 force-pushed the brennanb2025/rcc-b-source-admission branch from 99d9236 to 7cf362c Compare October 15, 2026 12:03
@brennanb2025
brennanb2025 changed the base branch from main to brennanb2025/rcc-a-owner-refusal October 15, 2026 12:03
@brennanb2025

brennanb2025 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor Author

The conversation-store refactor prevents admission and fallback lookup from independently choosing different locations. Each candidate account now resolves its store once, and admission, lookup and re-admission use that same store while keeping the original account used to resume. Users can still open the saved terminal conversation with its history; an unsaved conversation stays in its terminal and explains when to retry.

Current reviewed head: 0fdce1355fa28faa156168c43b461e86f98e5e8d.

Source review accepted the complete refactor, all six provider registrations and the CLI-fork caller, with no confirmed new behavioral defect. The adopted plan corrections match the implementation. Empty or relative stores remain unavailable, and OpenCode keeps exact database matching.

Focused real-app QA ran on integrated #29150 ba1dd8f2b8b48e3ffa0291d692b6bc5434b250fa, including #29124 0fdce1355fa28faa156168c43b461e86f98e5e8d, using real signed-in Claude on the qa-gate-admitted Mac. The actual terminal-tab Resume in New Native Chat action imported the exact saved user/assistant history, with matching provider identity, message identities and account home; the source stayed open and exactly one destination appeared. Before that same source saved its first message, the action showed “Claude hasn't saved this conversation yet. Try again after it replies.” and observers recorded no destination or blank-tab flash.

Current QA covered the inherited default Claude account and a local Git workspace. Other providers were source-reviewed; SSH, folder workspaces, named multi-account selection, native continuation and context-window preservation were not re-tested in this focused round. Earlier broader QA below remains qualified to its recorded heads.

The initial imported composer briefly showed Sonnet before settling to Opus. This visible mismatch also reproduced on main 776c791554bf4a4dfd4298cb57cddf60316c9d2c: Session History showed the same source as claude-opus-5-5, and its imported composer changed from Sonnet to Opus after 1.094 seconds without interaction. Main used the Session History entry point rather than the branch terminal menu. The visible issue is pre-existing and outside this refactor; the cause, continuation model and 1M context retention remain unverified.

Both test copies and the QA driver were stopped by their recorded PIDs, real Claude/Codex configuration hashes were unchanged, temporary homes were removed, and qa-gate ticket 104 was released.

Main comparison: transient and settled model labels

Same real source transcript; fresh main app profile. Initial Sonnet:

main-import-initial.png

Settled Opus:

main-import-settled.png

For Brennan's review — fresh whole-window screenshots on the integrated head:

Saved source:

store-source.png

Imported history:

store-imported.png

Not yet saved, with source retained:

store-unsaved.png

Earlier review and QA evidence, retained at the heads stated below

All “current” statements in this retained section describe the earlier heads named here. The latest focused review and QA are above.

Saved conversations could be refused because create checked unrelated accounts, treated an empty source as unreadable, verified Codex history in a different home from preparation, or reread a terminal's identity after it had closed. These failures could prevent a valid conversation from opening in a new native chat.

The host now admits one source account, classifies actual read evidence, uses the same Codex execution home throughout preparation and launch, and keeps a copy of source evidence for the dispatched request. Closing or changing the source afterward cannot reattribute that request. Existing ownership/retry answers and file, provider, directory and account checks remain authoritative. The renderer action is supplied by #29150.

Three review rounds finished with four confirmed P2 findings fixed and a final KEEP ruling. The additional QA-discovered failure for an unsaved transcript under a symlinked account folder was fixed in 9ce2f30364f: a missing path resolves through its deepest existing ancestor; dangling links are refused and other filesystem errors still propagate. A focused regression covers the not-saved result. Existing fallback traversal cost and admission-to-read filesystem races remain deferred concerns; no new failing input was established.

The current head is 1a6d44ae226d747a870526d6036aa9f4e4d96572. Final narrow source review accepted the earlier path correction, unchanged newest-item helper extraction and squash resolutions, followed by Pi's normalized-root correction in 9f3adee9549 and the conflict-free main merge 9f3adee9549..1a6d44ae226. Pi admission now uses the same sessions root as discovery, including custom folders and paths ending in sessions; containment and actual-source validation remain in place. The latest merge has no manual resolution changes, and every added or removed line in this PR's diff against its base remains unchanged. The streaming import retains the source observer and bounds Grok summary reads by the record limit. No open P0/P1 was found. The coordinator confirmed full CI green and CLEAN on this exact head and authorized this marker refresh; this review did not run tests or start another CI watch.

Integrated A+B+C rendered QA is complete on the Mac: main 69ff84db234 versus branch 6634a1119dcccc909c0981409338952547c4464c, with some unchanged earlier rows on a6c15818825. The symlinked unsaved-source fix, correct imported provider identity/account home, existing-owner feedback, unreadable history and source closure during create were verified. These are earlier integrated-build results, not a new run on 1a6d44ae226. The focused merged-menu recheck passed on 5bdfe33331d; the screenshots below retain both sets of proof.

Twenty-two focused source-admission and renderer contract tests passed on 6634a1119dc. The owned-conversation History guard was rendered, but the stale-row ownership race is contract-tested, not rendered. Real Pi, Codex, phone, SSH/WSL and paired-host behavior are not claimed. Provider continuation is not affected by this stack; the provider resume path is unchanged. All owned QA rigs and throwaway homes were cleaned, and real settings/hooks hashes matched the immediate Mac baseline. Earlier shared-machine hash drift remains unattributed.

For Brennan's review: the paired screenshots show the intended behavior. The main header was already visible; the improvement is removal of its History lookup. Shared pending is supported by the timestamped observations described above. The deliberate menu/header distinction preserves navigation on the header and feedback without navigation in the menu.

Flow Main Branch
Busy History Main: Busy History Branch: Busy History
Imported history Main: Imported history Branch: Imported history
Existing owner, header Main: Existing owner, header Branch: Existing owner, header
Existing owner, menu Main: Existing owner, menu Branch: Existing owner, menu
Nothing saved yet Main: Nothing saved yet Branch: Nothing saved yet
Unreadable history Main: Unreadable history Branch: Unreadable history
Shared pending Main: Shared pending Branch: Shared pending
Source closes during create Main: Source closes during create Branch: Source closes during create

Focused final merge re-check (whole-window screenshots; timestamped DOM/request records prove overlap):

CLI tab: Resume in New Native Chat Native chat tab: Resume in New CLI
CLI menu Native chat menu

Native-to-CLI preparation: disabled item and spinner

New CLI retains the imported conversation

…folder

A missing transcript stayed unresolved while its account root resolved through
symlinks, so containment failed and a not-yet-saved conversation showed a load
error instead of the unsaved notice.
…ner-refusal

# Conflicts:
#	src/main/native-chat/agent-session-journal/journal-legacy-import.ts
…' into brennanb2025/rcc-b-source-admission

# Conflicts:
#	src/main/native-chat/agent-session-journal/journal-legacy-import.ts
#	src/main/runtime/construction/runtime-construction.ts
#	src/main/runtime/construction/runtime-host-services.ts
@brennanb2025
brennanb2025 marked this pull request as ready for review October 16, 2026 06:29
…n module

Keeps journal-legacy-import.ts under the line limit after the source
identity observer landed on top of the streaming import.
…ner-refusal

# Conflicts:
#	src/renderer/src/lib/structured-agent-session-launch-admission.ts
@brennanb2025
brennanb2025 changed the base branch from brennanb2025/rcc-a-owner-refusal to main October 16, 2026 22:58
…urce-admission

# Conflicts:
#	src/main/native-chat/agent-session-journal/journal-legacy-import.ts
#	src/main/runtime/orca-runtime-structured-agent-session-create-intent.test.ts
#	src/main/runtime/session-tabs/structured-session-create-support.ts
#	src/main/runtime/structured-agent-session-create-adoption.ts
@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 10 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a0e62bb2-dba3-4415-aadc-4c0f01d7f08d
📥 Commits

Reviewing files that changed from the base of the PR and between a2e56d3 and 0fdce13.

📒 Files selected for processing: 44
  • src/main/ai-vault/session-scanner-discovery-wsl-gate.test.ts
  • src/main/ai-vault/session-scanner-discovery.ts
  • src/main/ai-vault/structured-chat-cli-fork.ts
  • src/main/claude/claude-cli-conversations.ts
  • src/main/codex/codex-ai-vault-session-resume.ts
  • src/main/codex/codex-cli-conversations.ts
  • src/main/grok/grok-transcript-import.ts
  • src/main/native-chat/agent-session-journal/adopted-transcript-source.ts
  • src/main/native-chat/agent-session-journal/journal-legacy-import.ts
  • src/main/native-chat/agent-session-journal/journal-newest-item-window.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-adopted-import.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-attach.ts
  • src/main/native-chat/codex-adoption-preparation.ts
  • src/main/native-chat/session-file-resolver.ts
  • src/main/native-chat/structured-agent-cli-conversation-adoption.test.ts
  • src/main/native-chat/structured-agent-cli-conversations.ts
  • src/main/native-chat/structured-agent-cli-source.ts
  • src/main/native-chat/structured-agent-session-source-admission.test.ts
  • src/main/native-chat/transcript-opencode-sqlite-query.test.ts
  • src/main/native-chat/transcript-opencode-sqlite-query.ts
  • src/main/native-chat/transcript-opencode2-sqlite.test.ts
  • src/main/native-chat/transcript-opencode2-sqlite.ts
  • src/main/native-chat/transcript-path-admission.ts
  • src/main/omp/omp-session-cwd-lookup.test.ts
  • src/main/omp/omp-session-cwd-lookup.ts
  • src/main/omp/omp-transcript-import.ts
  • src/main/opencode/opencode-transcript-import.ts
  • src/main/pi/pi-transcript-import.ts
  • src/main/runtime/orca-runtime-structured-agent-session-create-intent.test.ts
  • src/main/runtime/rpc/core.ts
  • src/main/runtime/rpc/dispatcher-stream-options.ts
  • src/main/runtime/rpc/methods/structured-agent-session-adoption-replay.test.ts
  • src/main/runtime/rpc/methods/structured-agent-session-create-handler.ts
  • src/main/runtime/rpc/methods/structured-agent-session-create.ts
  • src/main/runtime/rpc/methods/structured-agent-session.test.ts
  • src/main/runtime/session-tabs/structured-session-create-support.ts
  • src/main/runtime/structured-agent-session-create-adoption.ts
  • src/main/startup/main-process-runtime-service.ts
  • src/shared/protocol-version.ts
  • src/shared/rpc-contract/structured-agent-session-params.ts
  • src/shared/structured-agent-session-create.test.ts
  • src/shared/structured-agent-session-create.ts
  • src/shared/structured-agent-session-mutation.ts
  • src/shared/structured-agent-session-surface-capabilities.ts
📝 Walkthrough

Structured session creation now accepts CLI-source workspace and pane identity and captures provider-session evidence for source selection. Transcript adoption checks that paths fall within admitted account storage and validates provider session IDs and workspace CWD against transcript metadata. Transcript lookup supports strict filesystem error handling. Codex adoption can prepare a transcript for a selected account home, and OpenCode transcript signals include CWD when available.

Priority: ➖ Normal

Merge Risk: 🟡 Moderate · up to a2e56

Some resumes can be refused despite an available transcript, while an unavailable selected CLI source can instead resolve to another transcript. Correct these paths before merging.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 32.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 50 functions across 42 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly identifies the main change: verifying the actual CLI conversation during native-chat resume.
Description check Passed The description is detailed and covers the change, rationale, linked work, testing, review, compatibility, and scope. Visual proof is deferred to the dependent PR, but the description explains this li…
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: Description check

Explanation

The description is detailed and covers the change, rationale, linked work, testing, review, compatibility, and scope. Visual proof is deferred to the dependent PR, but the description explains this limitation and states that no rendered or live-provider validation is claimed.

✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9b9687ac-9e73-4933-b498-274c419ff959
📥 Commits

Reviewing files that changed from the base of the PR and between 6dd7ab5 and a2e56d3.

📒 Files selected for processing: 42
  • src/main/ai-vault/session-scanner-discovery-wsl-gate.test.ts
  • src/main/ai-vault/session-scanner-discovery.ts
  • src/main/claude/claude-cli-conversations.ts
  • src/main/codex/codex-ai-vault-session-resume.ts
  • src/main/codex/codex-cli-conversations.ts
  • src/main/grok/grok-transcript-import.ts
  • src/main/native-chat/agent-session-journal/adopted-transcript-source.ts
  • src/main/native-chat/agent-session-journal/journal-legacy-import.ts
  • src/main/native-chat/agent-session-journal/journal-newest-item-window.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-adopted-import.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-attach.ts
  • src/main/native-chat/codex-adoption-preparation.ts
  • src/main/native-chat/session-file-resolver.ts
  • src/main/native-chat/structured-agent-cli-conversation-adoption.test.ts
  • src/main/native-chat/structured-agent-cli-conversations.ts
  • src/main/native-chat/structured-agent-cli-source.ts
  • src/main/native-chat/structured-agent-session-source-admission.test.ts
  • src/main/native-chat/transcript-opencode-sqlite-query.test.ts
  • src/main/native-chat/transcript-opencode-sqlite-query.ts
  • src/main/native-chat/transcript-opencode2-sqlite.test.ts
  • src/main/native-chat/transcript-opencode2-sqlite.ts
  • src/main/native-chat/transcript-path-admission.ts
  • src/main/omp/omp-session-cwd-lookup.ts
  • src/main/omp/omp-transcript-import.ts
  • src/main/opencode/opencode-transcript-import.ts
  • src/main/pi/pi-transcript-import.ts
  • src/main/runtime/orca-runtime-structured-agent-session-create-intent.test.ts
  • src/main/runtime/rpc/core.ts
  • src/main/runtime/rpc/dispatcher-stream-options.ts
  • src/main/runtime/rpc/methods/structured-agent-session-adoption-replay.test.ts
  • src/main/runtime/rpc/methods/structured-agent-session-create-handler.ts
  • src/main/runtime/rpc/methods/structured-agent-session-create.ts
  • src/main/runtime/rpc/methods/structured-agent-session.test.ts
  • src/main/runtime/session-tabs/structured-session-create-support.ts
  • src/main/runtime/structured-agent-session-create-adoption.ts
  • src/main/startup/main-process-runtime-service.ts
  • src/shared/protocol-version.ts
  • src/shared/rpc-contract/structured-agent-session-params.ts
  • src/shared/structured-agent-session-create.test.ts
  • src/shared/structured-agent-session-create.ts
  • src/shared/structured-agent-session-mutation.ts
  • src/shared/structured-agent-session-surface-capabilities.ts

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

Comment thread src/main/grok/grok-transcript-import.ts Resolved
Comment thread src/main/pi/pi-transcript-import.ts Resolved
…ry walks

A PI_CODING_AGENT_DIR that already ends in sessions, or any custom folder,
made admission expect <dir>/sessions while the lookup searched <dir>, so a
found conversation was refused.
… per account

Each agent's import described where an account keeps its conversations twice,
once for the path check and once for the lookup, and the two could disagree
(the linked-folder and Pi custom-root refusals). The import now names one
conversation store per account; the create path resolves it once and both the
hook-path check and the fallback lookup judge that same store. OpenCode's
store is its exact database.
@brennanb2025
brennanb2025 merged commit 002320c into main Oct 17, 2026
41 checks passed
@brennanb2025
brennanb2025 deleted the brennanb2025/rcc-b-source-admission branch October 17, 2026 04:15
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