Skip to content

fix(ai-vault): resume a server session whose workspace was deleted; show remote hit previews - #33965

Merged
nwparker merged 1 commit into
mainfrom
fix/26509-remote-resume-deleted-workspace
Oct 26, 2026
Merged

nwparker merged 1 commit into
mainfrom
fix/26509-remote-resume-deleted-workspace

Conversation

@nwparker

@nwparker nwparker commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​177 $\color{#cf222e}{\Huge{\mathbf{−}}}$​10 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​167
Prod 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​122 $\color{#cf222e}{\Huge{\mathbf{−}}}$​13 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​109

ELI5

When a session in Agent Session History lived on a paired Orca server, or on an SSH host Orca now runs a managed server on, and its workspace had been deleted, resuming it failed: Orca told the agent to cd into the folder that no longer existed. Now Orca asks the server whether the folder is still there, and if it's gone the session resumes at the selected workspace's root. Sessions on a server found through search also show their conversation preview instead of "No conversation preview available."

What Changed

  • Before:
    • Resuming a server-hosted session whose workspace was deleted ran cd '<deleted folder>' && … and failed.
    • A search-hit card for that session said "No first prompt available" and "No conversation preview available", even when it reported dozens of messages.
  • After:
  • Mechanism:
    • Since refactor(ssh): connect fails for hosts orcad can't serve; remove the relay client path #27214, every SSH session is retagged runtime:<env>, so fix(ai-vault): resume sessions whose worktree was deleted #24236's dropDeletedSshResumeCwd only ever ran for the legacy ssh: spelling.
    • It is now dropDeletedRemoteResumeCwd, and it also covers runtime hosts. It probes the folder with the existing files.browseServerDir RPC, which takes an absolute path. files.stat can't do this because it needs the workspace, and the workspace is gone.
    • Only a definite ENOENT/ENOTDIR answer drops the cwd and the prebuilt cd. An unreachable or older host keeps today's behaviour, and so does a "not found" that only appears inside a message. Kimi and Muse still resume only in their recorded folder.
    • On a Windows server whose rows carry no platform stamp, the rebuilt command is marked win32, so it quotes for PowerShell.
    • A missing folder whose path style doesn't match the host is kept. For example, a WSL session's Linux cwd on a Windows host: the host can't stat it, which proves nothing. The host's path style comes from one browse of ~, cached per pairing. A cwd the browser would trim, expand or resolve is kept rather than probed as a different folder.
    • Search hits carry no turns, and a remote host can't reparse the first prompt, so withAiVaultHistoryPreviews copies the preview turns and first prompt of the matching history row. Relay hits are redacted of their transcript path, so the match uses host, agent and session id, and ambiguous matches are skipped.

Why

Both fixes reuse what already exists: the server's directory probe, and the previews the server already sends in the list. No new RPC or wire field, so mixed versions are unaffected.

Linked Issue

Fixes #26509

Visual Proof

N/A: the card is unchanged except that it now shows the existing preview text. The resume difference is in the command the terminal runs. A paired server is needed to show either.

Testing

  • ai-vault-session-resume-preparation.test.ts:

    • drops a server session's folder only when the server reports it missing (fails on main);
    • keeps it when the folder exists, when the server can't be reached, or when the error isn't a missing-path one;
    • keeps a WSL Linux cwd on a Windows host;
    • stamps a Windows server's rebuilt resume as win32;
    • keeps a cwd the server's browser would trim.
  • ai-vault-resume-command.test.ts: a server Codex session whose folder was deleted resumes at the workspace root with tui.resume_cwd=current and no cd (fails on main).

  • ai-vault-search-session.test.ts: a server hit gets its history row's turns and first prompt, and keeps the host's resume command (fails on main).

  • Passing: the 14 importer test files, plus pnpm tc, pnpm lint, oxfmt, type-aware oxlint, check:code-quality:changed and react-doctor.

  • Not run: a live paired server.

  • I manually tested these changes locally

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

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Follow-ups:
    • A hit outside the loaded history page still has no preview. Fixing that needs the host to include preview turns in search hits (an optional field).
    • "Jump to original pane" matches by session id only, not by host.
  • Mobile: mobile refuses history resume into runtime-hosted workspaces ("Resume from history is not available in runtime-hosted workspaces.") and has its own preview path. Left out of scope.
  • Folder workspaces: the fallback target is the selected workspace on the same host, whether it's a git worktree or a folder.

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)

@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Walkthrough

Resume preparation now checks deleted working directories for SSH and runtime hosts. Confirmed missing paths clear the session’s working directory and resume command; other check failures preserve the session. Search results now receive missing preview fields from matching history rows before the panel displays them.

Priority: Normal

Severity of issue fixed: Medium

Merge Risk: Minimal · up to 23af8

The unsupported-server case retains the recorded workspace, and no actionable runtime risk remains. The resume-command test should be strengthened, but this does not block merging.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 8 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 both main changes: fixing resume behavior for deleted remote workspaces and restoring previews for remote search hits.
Description check Passed The description follows the template and explains the user impact, mechanism, rationale, linked issue, visual proof, testing, scope, and checklist status. It also documents known limitations and the a…
Linked Issues check Passed [#26509] The PR preserves the recorded cwd when the SSH or runtime host confirms that the folder exists. It removes cwd and the prebuilt resumeCommand only after a definite missing-path result, …
Out of Scope Changes check Passed The changed production code and tests directly support [#26509]. The resume helper extends the existing SSH behavior to runtime hosts, and the search integration supplies the missing preview data from…
Full details: Description check

Explanation

The description follows the template and explains the user impact, mechanism, rationale, linked issue, visual proof, testing, scope, and checklist status. It also documents known limitations and the absence of live paired-server testing.

Full details: Linked Issues check

Explanation

[#26509] The PR preserves the recorded cwd when the SSH or runtime host confirms that the folder exists. It removes cwd and the prebuilt resumeCommand only after a definite missing-path result, so resume uses the selected workspace on the same host. It also preserves the recorded folder when the probe is inconclusive or the agent requires that folder. withAiVaultHistoryPreviews copies preview turns and firstUserPrompt from an unambiguous loaded history row for remote search hits. The added tests cover the missing-folder fallback, existing and inconclusive probes, path flavors, command rebuilding, and search-hit previews.

Full details: Out of Scope Changes check

Explanation

The changed production code and tests directly support [#26509]. The resume helper extends the existing SSH behavior to runtime hosts, and the search integration supplies the missing preview data from existing history. The changes do not add unrelated product behavior. Documented limits for unloaded history rows, mobile, and live-server testing do not indicate out-of-scope code.

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: 1


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3ae79137-dc61-45fa-a875-c8af961a4a8c
Commits

Reviewing files that changed from the base of the PR and between 8cfbfa5 and 3a88915.

Files selected for processing: 8
  • src/renderer/src/components/right-sidebar/AiVaultPanel.tsx
  • src/renderer/src/components/right-sidebar/ai-vault-search-session.test.ts
  • src/renderer/src/components/right-sidebar/ai-vault-search-session.ts
  • src/renderer/src/components/right-sidebar/ai-vault-session-launch-actions.test.ts
  • src/renderer/src/components/right-sidebar/ai-vault-session-launch-actions.ts
  • src/renderer/src/lib/ai-vault-resume-command.test.ts
  • src/renderer/src/lib/ai-vault-session-resume-preparation.test.ts
  • src/renderer/src/lib/ai-vault-session-resume-preparation.ts

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

Comment on lines +233 to +234
if (isMissingRuntimePathError(error)) {
return false

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.

Major · Functional Correctness · Quick win

🔎 Supported by static analysis

Script executed:

#!/bin/bash
# Inspect RPC error construction and directory-browser failure handling.
rg -n -C 3 'browseServerDir|method not found|Method not found|environment not found|isMissingRuntimePathError' src

Repository: stablyai/orca

Length of output: 41436


Script executed:

set -u
printf '%s\n' '--- runtime-file-metadata-client.ts ---'
nl -ba src/renderer/src/runtime/runtime-file-metadata-client.ts | sed -n '1,105p'
printf '%s\n' '--- ai-vault-session-resume-preparation.ts ---'
nl -ba src/renderer/src/lib/ai-vault-session-resume-preparation.ts | sed -n '190,255p'
printf '%s\n' '--- runtime-server-directory-browser.ts ---'
nl -ba src/renderer/src/runtime/runtime-server-directory-browser.ts | sed -n '1,45p'
printf '%s\n' '--- runtime RPC error definitions and response handling ---'
rg -n -C 5 -F -- 'class RuntimeRpcCallError' src/renderer/src/runtime src/shared src/main src/wsl-guest || test "$?" -eq 1
rg -n -C 5 -e 'method_not_found' -e 'Method not found' -e 'code: -32601' src/renderer/src/runtime src/shared src/main src/wsl-guest || test "$?" -eq 1
printf '%s\n' '--- relevant error-classification tests ---'
nl -ba src/renderer/src/runtime/runtime-path-existence-error-parity.test.ts | sed -n '1,110p'

Repository: stablyai/orca

Length of output: 41949


Do not treat an unsupported RPC method as a missing directory.

An older host can return Method not found: files.browseServerDir. isMissingRuntimePathError matches not found, so runtimeServerDirectoryExists returns false. The resume flow then clears cwd and resumeCommand, even when the recorded directory still exists. Exclude method_not_found before applying message-based path classification.

Suggested fix
 import { browseRuntimeServerDirectory } from '@/runtime/runtime-server-directory-browser'
 import { isMissingRuntimePathError } from '@/runtime/runtime-file-metadata-client'
+import { RuntimeRpcCallError } from '@/runtime/runtime-rpc-result'
 import { readIpcErrorMessage } from './ipc-error'
@@
   } catch (error) {
+    if (error instanceof RuntimeRpcCallError && error.code === 'method_not_found') {
+      throw error
+    }
     if (isMissingRuntimePathError(error)) {
       return false
     }

Source: Learnings

…how remote hit previews

Since #27214 every SSH session is retagged runtime:<env>, so the #24236
check that drops a deleted cwd (and its prebuilt `cd`) before resuming
only ever ran for the legacy ssh: spelling. Resume on a paired or
SSH-managed server therefore ran `cd '<deleted folder>' &&` and failed.
The check now covers runtime hosts too, probing the folder with the
existing files.browseServerDir RPC; only a definite "missing" answer
drops the cwd, so an older or unreachable host keeps today's behaviour.

Search-hit cards carry no turns and remote hosts cannot reparse a first
prompt, so a server session found through search showed "No first
prompt" and "No conversation preview". Hits now borrow the preview of
their scanned history row.
@nwparker
nwparker force-pushed the fix/26509-remote-resume-deleted-workspace branch from 3a88915 to 23af80b Compare October 26, 2026 15:23

@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.

🧹 Nitpick comments: 1
src/renderer/src/components/right-sidebar/ai-vault-search-session.test.ts: 1

26-26: Trivial · Maintainability & Code Quality · Quick win

Give the history row a distinct resume command.

The history row copies resumeCommand from hitSession through its object spread. withAiVaultHistoryPreviews never copies a row's resumeCommand into the hit. Both values are host-resume-command, so the assertion on line 37 would still pass if the merge started copying the row's command. Give the history row its own command so the assertion detects that regression.

Suggested fix
         {
           ...hitSession,
           id: 'runtime:env-1:codex:host-session:/host/transcript.jsonl',
           filePath: '/host/transcript.jsonl',
+          resumeCommand: 'history-resume-command',
           previewMessages: turns,
           firstUserPrompt: 'Fix the flaky test'
         }

Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f61ba997-1564-42ff-95f2-bfa6c2b961f3
Commits

Reviewing files that changed from the base of the PR and between 3a88915 and 23af80b.

Files selected for processing: 5
  • src/renderer/src/components/right-sidebar/ai-vault-search-session.test.ts
  • src/renderer/src/components/right-sidebar/ai-vault-search-session.ts
  • src/renderer/src/lib/ai-vault-resume-command.test.ts
  • src/renderer/src/lib/ai-vault-session-resume-preparation.test.ts
  • src/renderer/src/lib/ai-vault-session-resume-preparation.ts

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

@nwparker
nwparker merged commit d7cf9d2 into main Oct 26, 2026
33 checks passed
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.

[Bug]: Agent Session History sessions on a remote Orca server cannot be opened after their tab is closed or their workspace is deleted

1 participant