Skip to content

Fix AI Vault scanning for runtime hosts - #7631

Merged
Jinwoo-H merged 5 commits into
stablyai:mainfrom
sdhilip200:fix/ai-vault-runtime-hosts
Jul 8, 2026
Merged

Jinwoo-H merged 5 commits into
stablyai:mainfrom
sdhilip200:fix/ai-vault-runtime-hosts

Conversation

@sdhilip200

Copy link
Copy Markdown
Contributor

Summary

  • Add a runtime RPC path for AI Vault session listing on paired Orca server hosts.
  • Include paired runtime:* hosts when AI Vault scans "All hosts".
  • Keep remote runtime results tagged with their concrete execution host id, so local, SSH, and runtime sessions stay distinct.

Fixes #7589

Test plan

  • PATH=/Users/dhilipsubramanian/.cache/codex-runtimes/codex-primary-runtime/dependencies/node/bin:$PATH pnpm test src/main/ipc/ai-vault.test.ts src/main/runtime/rpc/methods/ai-vault.test.ts src/main/ipc/register-core-handlers.test.ts
  • PATH=/Users/dhilipsubramanian/.cache/codex-runtimes/codex-primary-runtime/dependencies/node/bin:$PATH pnpm run typecheck
  • PATH=/Users/dhilipsubramanian/.cache/codex-runtimes/codex-primary-runtime/dependencies/node/bin:$PATH pnpm exec oxlint src/main/ipc/ai-vault.ts src/main/ipc/ai-vault.test.ts src/main/ipc/register-core-handlers.ts src/main/ipc/register-core-handlers.test.ts src/main/runtime/rpc/methods/ai-vault.ts src/main/runtime/rpc/methods/ai-vault.test.ts src/main/runtime/rpc/methods/index.ts
  • PATH=/Users/dhilipsubramanian/.cache/codex-runtimes/codex-primary-runtime/dependencies/node/bin:$PATH pnpm exec oxfmt --check src/main/ipc/ai-vault.ts src/main/ipc/ai-vault.test.ts src/main/ipc/register-core-handlers.ts src/main/ipc/register-core-handlers.test.ts src/main/runtime/rpc/methods/ai-vault.ts src/main/runtime/rpc/methods/ai-vault.test.ts src/main/runtime/rpc/methods/index.ts
  • pnpm run build:native with normal compiler cache permissions

Not fully clean locally:

  • pnpm lint currently fails outside this change in src/renderer/src/components/right-sidebar/source-control-manual-review-url.ts on an existing switch-exhaustiveness issue.
  • Full pnpm test is not usable in my sandbox: unrelated daemon/socket/browser integration suites hit local environment failures such as Unix socket EPERM and long timeouts.
  • Full pnpm build passed desktop/web stages, then the native stage initially failed because the sandbox blocked Swift's clang module cache under ~/.cache; rerunning pnpm run build:native with normal cache permissions passed.

Review notes

  • Cross-platform: the new path uses existing execution host ids and runtime transport; no platform-specific path assumptions were added.
  • SSH/local/remote: local and SSH scan behavior is unchanged. Runtime hosts use the paired server to scan its own local session stores.
  • Performance: All hosts already fans out scans; this adds one scan per saved paired runtime host and keeps the existing AI Vault cache keying.
  • UI: no visual changes.
  • X handle: not provided.

@coderabbitai

coderabbitai Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds runtime AI Vault session listing and resume support across the main process, renderer, and web preload layers. It introduces runtime session scanning utilities, extends AI Vault IPC and RPC handling to route runtime execution hosts, wires the core handlers to discover and scan runtime hosts, updates renderer host-scope selection and resume logic for runtime targets, and adds preload API plus localization changes for runtime-host availability messages.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is missing required template sections like Screenshots, AI Review Report, Security Audit, and Notes. Add the missing template sections, including screenshots or no visual change, a full AI review report, a security audit, and notes.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed Clear, concise title matches the main change: adding runtime-host support to AI Vault scanning.
Linked Issues check ✅ Passed The changes add runtime-host scanning, include runtime hosts in All hosts, update host selection, and route runtime resume/scan paths as requested.
Out of Scope Changes check ✅ Passed No clear unrelated changes stand out; the renderer, preload, and i18n updates support the runtime-host AI Vault flow.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

🧹 Nitpick comments (2)
src/main/runtime/rpc/methods/ai-vault.ts (1)

6-11: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Avoid double-computing normalizeExecutionHostId.

refine and transform each call normalizeExecutionHostId(value) independently, computing the same result twice per parse.

♻️ Compute once
 const executionHostIdSchema = z
   .string()
-  .refine((value) => normalizeExecutionHostId(value) !== null, {
-    message: 'Invalid execution host id'
-  })
-  .transform((value) => normalizeExecutionHostId(value) as ExecutionHostId)
+  .transform((value) => normalizeExecutionHostId(value))
+  .refine((value): value is ExecutionHostId => value !== null, {
+    message: 'Invalid execution host id'
+  })
src/main/ipc/register-core-handlers.ts (1)

211-213: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Unvalidated cast of remote RPC response.

response.result as AiVaultListResult trusts the remote Orca server's payload shape without runtime validation. Since the client and paired server can run different app versions, a shape drift could pass malformed session data straight to the renderer.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 5469c5e6-7d8b-4ec1-b5a6-6f09b15535c1

📥 Commits

Reviewing files that changed from the base of the PR and between 4cbf699 and ddc88e1.

📒 Files selected for processing (7)
  • src/main/ipc/ai-vault.test.ts
  • src/main/ipc/ai-vault.ts
  • src/main/ipc/register-core-handlers.test.ts
  • src/main/ipc/register-core-handlers.ts
  • src/main/runtime/rpc/methods/ai-vault.test.ts
  • src/main/runtime/rpc/methods/ai-vault.ts
  • src/main/runtime/rpc/methods/index.ts

@sdhilip200

Copy link
Copy Markdown
Contributor Author

Addressed the two CodeRabbit items in 162af99. The runtime RPC host-id schema now normalizes once before refining, and the runtime AI Vault bridge now validates the remote \ payload before passing it through. Invalid runtime responses now degrade into a scan issue instead of trusting a mismatched shape.\n\nVerification run locally:\n- \undefined
 ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL  Command "vitest" not found\n- \n\nThe repo hook tried to reinstall dependencies during commit and was blocked by DNS/network access in this environment, so I used the already-passing focused verification above for this change.

@sdhilip200

Copy link
Copy Markdown
Contributor Author

Addressed the two CodeRabbit items in 162af99. The runtime RPC host-id schema now normalizes once before refining, and the runtime AI Vault bridge now validates the remote aiVault.listSessions payload before passing it through. Invalid runtime responses now degrade into a scan issue instead of trusting a mismatched shape.

Verification run locally:

  • pnpm exec vitest run --config config/vitest.config.ts src/main/runtime/rpc/methods/ai-vault.test.ts src/main/ipc/register-core-handlers.test.ts
  • git diff --check

The repo hook tried to reinstall dependencies during commit and was blocked by DNS/network access in this environment, so I used the already-passing focused verification above for this change.

@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/main/ipc/register-core-handlers.test.ts (1)

507-524: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Brittle exact-match on Zod's internal error message text.

Line 520 asserts the literal message 'Invalid input: expected array, received string', which is Zod's own generated error text. This couples the test to Zod's internal wording/format rather than the app's own validation logic — a Zod version bump (e.g., v3→v4 changed default messages from "Expected array, received string" to "Invalid input: expected array, received string") would break this test even though nothing in register-core-handlers.ts changed.

Consider asserting only on the fields your code controls (executionHostId, agent, path) and using a looser matcher for message (e.g., expect.stringContaining('Invalid aiVault.listSessions response')).

♻️ Suggested loosened assertion
     ).resolves.toEqual({
       sessions: [],
       issues: [
-        {
+        expect.objectContaining({
           executionHostId: 'runtime:env-123',
           agent: 'codex',
           path: 'env-123',
-          message: 'Invalid aiVault.listSessions response: Invalid input: expected array, received string'
-        }
+          message: expect.stringContaining('Invalid aiVault.listSessions response')
+        })
       ],
       scannedAt: expect.any(String)
     })

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e9398b08-12f4-40c2-9b6b-1dcfe78a506b

📥 Commits

Reviewing files that changed from the base of the PR and between ddc88e1 and 162af99.

📒 Files selected for processing (4)
  • src/main/ipc/register-core-handlers.test.ts
  • src/main/ipc/register-core-handlers.ts
  • src/main/runtime/rpc/methods/ai-vault.test.ts
  • src/main/runtime/rpc/methods/ai-vault.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/main/runtime/rpc/methods/ai-vault.test.ts
  • src/main/runtime/rpc/methods/ai-vault.ts
  • src/main/ipc/register-core-handlers.ts

@sdhilip200

Copy link
Copy Markdown
Contributor Author

Addressed the follow-up CodeRabbit note in a57619d by loosening the runtime-response assertion so it no longer depends on Zod's exact error wording. The assertion now checks the fields we own plus an Invalid aiVault.listSessions response prefix.

I could not rerun the focused Vitest command in this worktree after the earlier Husky reinstall attempt removed the local vitest package from node_modules. git diff --check still passes, and the code change is limited to the assertion shape.

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

Thanks, this is ready to land. I pushed two follow-up commits to harden the runtime-host scan path and enable runtime-host resume parity.

Validated locally:

  • focused AI Vault/runtime tests and typecheck passed before ship
  • paired \ e2e: runtime RPC \ returned a seeded Codex session stamped as , and \ created an active runtime terminal from the resume command
  • SSH e2e: throwaway Linux Docker target, real Orca SSH relay deploy on linux-arm64, remote git repo at , and AI Vault scan returned the seeded remote Codex session stamped as \

Performance risk checked: runtime scans remain bounded by the requested limit/cache and use one RPC per active runtime host, with the existing all-host timeout.

@Jinwoo-H

Jinwoo-H commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Correction to my approval note above: the inline-code snippets were mangled by my shell quoting. The intended validation evidence is:

  • Paired orca serve e2e: runtime RPC aiVault.listSessions returned a seeded Codex session stamped as runtime:<env>, and session.tabs.createTerminal created an active runtime terminal from the resume command.
  • SSH e2e: throwaway Linux Docker target, real Orca SSH relay deploy on linux-arm64, remote git repo at /work/demo-project, and AI Vault scan returned the seeded remote Codex session stamped as ssh:<target>.

The approval stands.

@Jinwoo-H
Jinwoo-H merged commit 38e82b4 into stablyai:main Jul 8, 2026
2 checks passed

@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: 4

🧹 Nitpick comments (4)
src/main/ai-vault/session-list-results.ts (1)

28-48: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add direct unit tests for mergeAiVaultListResults.

This is the core merge/dedupe/sort/limit logic behind the new "All hosts" combined AI Vault scan (dedup by session id, sort by sessionSortTime, and clamp to limit), but there's no dedicated test file for it in this PR. Coverage exists indirectly via ipc/ai-vault.test.ts, but a focused unit test here would pin down edge cases (duplicate ids across hosts, limit <= 0, empty results) independent of the IPC wiring.

src/main/ai-vault/runtime-session-scanner.ts (1)

159-176: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Reuse aiVaultScanIssueResult instead of duplicating it.

runtimeScanIssueResult re-implements the same shape as aiVaultScanIssueResult exported from session-list-results.ts (empty sessions, one issue with hardcoded agent: 'codex', scannedAt timestamp) — only the field name (path vs environmentId) differs. Reusing the shared helper avoids two places drifting apart if the issue shape changes.

♻️ Proposed refactor to reuse the shared helper
+import { aiVaultScanIssueResult } from './session-list-results'
+
 function runtimeScanIssueResult(args: {
   executionHostId: `runtime:${string}`
   environmentId: string
   message: string
 }): AiVaultListResult {
-  return {
-    sessions: [],
-    issues: [
-      {
-        executionHostId: args.executionHostId,
-        agent: 'codex',
-        path: args.environmentId,
-        message: args.message
-      }
-    ],
-    scannedAt: new Date().toISOString()
-  }
+  return aiVaultScanIssueResult({
+    executionHostId: args.executionHostId,
+    path: args.environmentId,
+    message: args.message
+  })
 }
src/main/ai-vault/runtime-session-scanner.test.ts (1)

29-111: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add tests for the RPC-failure and invalid-response branches.

All tests here exercise the successful response.ok === true + valid-schema path. There's no test for response.ok === false (transport/server failure) or for a malformed response.result failing aiVaultListResultSchema.safeParse — both of which are the specific fix highlighted in this PR's comments ("Invalid runtime responses now become a scan issue instead of trusting a mismatched shape"). Without a test, a future refactor could silently reintroduce trusting a mismatched shape.

🧪 Suggested additional test cases
it('returns an issue result when the runtime call fails', async () => {
  mocks.callRuntimeEnvironment.mockResolvedValueOnce({
    ok: false,
    error: { message: 'Remote Orca server is unavailable.' }
  })

  const scanResult = await scanRuntimeAiVaultSessions('/user-data', 'env-1', {})

  expect(scanResult.sessions).toEqual([])
  expect(scanResult.issues).toEqual([
    expect.objectContaining({
      executionHostId: 'runtime:env-1',
      message: 'Remote Orca server is unavailable.'
    })
  ])
})

it('returns an issue result when the response fails schema validation', async () => {
  mocks.callRuntimeEnvironment.mockResolvedValueOnce({
    ok: true,
    result: { sessions: 'not-an-array', issues: [], scannedAt: '2026-07-04T00:00:00.000Z' }
  })

  const scanResult = await scanRuntimeAiVaultSessions('/user-data', 'env-1', {})

  expect(scanResult.sessions).toEqual([])
  expect(scanResult.issues[0]).toEqual(
    expect.objectContaining({ executionHostId: 'runtime:env-1' })
  )
})
src/renderer/src/components/tab-group/AiVaultSessionDropLayer.tsx (1)

202-235: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider extracting the runtime launch result handling into a shared helper.

The launchResult → tabId === null → runtimeLaunch.then(...) → toast pattern is duplicated between this file (lines 202-235) and ai-vault-session-launch-actions.ts (lines 103-136). A shared helper would ensure consistent error handling (including the missing .catch()) and reduce drift risk.

♻️ Example helper extraction
// e.g. in ai-vault-session-launch-actions.ts or a focused module
export function handleAiVaultLaunchResult(
  launchResult: { tabId: string | null; runtimeLaunch: Promise<boolean> },
  options: {
    agentLabel: string
    onQueued: () => void
  }
): void {
  const showError = (): void => {
    toast.error(
      translate(
        'auto.lib.launch.agent.in.new.tab.11cce5cc77',
        'Could not launch {{value0}} in a new terminal.',
        { value0: options.agentLabel }
      )
    )
  }
  if (launchResult.tabId === null) {
    void launchResult.runtimeLaunch
      .then((created) => {
        if (!created) {
          showError()
          return
        }
        options.onQueued()
      })
      .catch(() => {
        showError()
      })
    return
  }
  options.onQueued()
}

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 6d090906-939b-4fcf-856f-9d7a5b01d19f

📥 Commits

Reviewing files that changed from the base of the PR and between a57619d and 352eb7c.

📒 Files selected for processing (28)
  • src/main/ai-vault/runtime-session-scanner.test.ts
  • src/main/ai-vault/runtime-session-scanner.ts
  • src/main/ai-vault/session-list-results.ts
  • src/main/ipc/ai-vault.test.ts
  • src/main/ipc/ai-vault.ts
  • src/main/ipc/register-core-handlers.test.ts
  • src/main/ipc/register-core-handlers.ts
  • src/main/runtime/rpc/methods/ai-vault.test.ts
  • src/main/runtime/rpc/methods/ai-vault.ts
  • src/renderer/src/components/right-sidebar/AiVaultPanel.tsx
  • src/renderer/src/components/right-sidebar/AiVaultPanelControls.tsx
  • src/renderer/src/components/right-sidebar/AiVaultPanelHeader.tsx
  • src/renderer/src/components/right-sidebar/ai-vault-host-scope.test.ts
  • src/renderer/src/components/right-sidebar/ai-vault-host-scope.ts
  • src/renderer/src/components/right-sidebar/ai-vault-session-launch-actions.ts
  • src/renderer/src/components/right-sidebar/ai-vault-session-resume.test.ts
  • src/renderer/src/components/tab-group/AiVaultSessionDropLayer.tsx
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/lib/ai-vault-resume-target.test.ts
  • src/renderer/src/lib/ai-vault-resume-target.ts
  • src/renderer/src/lib/launch-ai-vault-session.test.ts
  • src/renderer/src/lib/launch-ai-vault-session.ts
  • src/renderer/src/web/web-preload-api.test.ts
  • src/renderer/src/web/web-preload-api.ts
✅ Files skipped from review due to trivial changes (2)
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/zh.json
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/main/runtime/rpc/methods/ai-vault.test.ts
  • src/main/runtime/rpc/methods/ai-vault.ts
  • src/main/ipc/register-core-handlers.test.ts

Comment on lines +87 to +94
export function getSavedRuntimeAiVaultHostInfos(
userDataPath: string
): readonly RuntimeAiVaultHostInfo[] {
return listEnvironments(userDataPath).map((environment) => ({
environmentId: environment.id,
executionHostId: toRuntimeExecutionHostId(environment.id)
}))
}

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.

🚀 Performance & Scalability | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Confirm whether getSavedRuntimeAiVaultHostInfos is filtered to active hosts
# before being wired as getActiveRuntimeAiVaultHostInfos.
rg -n -C4 'getActiveRuntimeAiVaultHostInfos|getSavedRuntimeAiVaultHostInfos' --type=ts

Repository: stablyai/orca

Length of output: 151


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n## files\n'
git ls-files | rg '(^|/)(ipc/ai-vault\.ts|register-core-handlers\.ts|runtime-session-scanner\.ts|session-list-results\.ts|.*ai-vault.*|.*runtime.*scanner.*|.*core-handlers.*)$'

printf '\n## symbol search\n'
rg -n -C3 'ai-vault|runtime session|runtimeAiVault|get.*Runtime.*HostInfos|host infos|active.*host' --type=ts .

printf '\n## targeted tree around likely files\n'
for f in $(git ls-files | rg '(^|/)(ipc/ai-vault\.ts|register-core-handlers\.ts|runtime-session-scanner\.ts|session-list-results\.ts)$'); do
  echo "\n### $f"
  wc -l "$f"
  ast-grep outline "$f" --view expanded || true
done

Repository: stablyai/orca

Length of output: 50370


🏁 Script executed:

#!/bin/bash
set -euo pipefail

for f in src/main/ai-vault/runtime-session-scanner.ts src/main/ipc/ai-vault.ts src/main/register-core-handlers.ts src/main/session-list-results.ts; do
  if [ -f "$f" ]; then
    echo "### $f"
    wc -l "$f"
    cat -n "$f" | sed -n '1,260p'
    echo
  fi
done

Repository: stablyai/orca

Length of output: 16022


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n## assignments and registrations\n'
rg -n -C4 'handlerOptions\s*=|getActiveRuntimeAiVaultHostInfos|scanRuntimeAiVaultSessions|registerCoreHandlers|register-core-handlers|ai-vault' src/main

printf '\n## likely core handler file(s)\n'
for f in $(git ls-files | rg '(^|/)register-core-handlers\.ts$|(^|/)ipc/ai-vault\.ts$|(^|/)main\.ts$|(^|/)index\.ts$'); do
  echo "\n### $f"
  wc -l "$f"
  ast-grep outline "$f" --view expanded || true
done

Repository: stablyai/orca

Length of output: 50369


Filter runtime hosts before exposing All hosts register-core-handlers.ts wires getActiveRuntimeAiVaultHostInfos to getSavedRuntimeAiVaultHostInfos(...), so All hosts scans every saved runtime environment, including disconnected ones. Narrow this to currently reachable hosts, or each offline environment will consume the 3s timeout on every scan.

Comment on lines +219 to +232
if (launchResult.tabId === null) {
void launchResult.runtimeLaunch.then((created) => {
if (!created) {
toast.error(
translate(
'auto.lib.launch.agent.in.new.tab.11cce5cc77',
'Could not launch {{value0}} in a new terminal.',
{ value0: payload.agent }
)
)
return
}
showQueuedToast()
})

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.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the target file and the related launch-actions file for comparable promise handling.
git ls-files 'src/renderer/src/components/tab-group/AiVaultSessionDropLayer.tsx' \
             'src/renderer/src/components/tab-group/ai-vault-session-launch-actions.ts' \
             'src/renderer/src/components/tab-group/*launch*' \
             'src/renderer/src/components/tab-group/*AiVault*' \
  | sed 's#^`#FILE` #'

echo
echo '--- outline: AiVaultSessionDropLayer.tsx ---'
ast-grep outline src/renderer/src/components/tab-group/AiVaultSessionDropLayer.tsx --view expanded || true

echo
echo '--- outline: ai-vault-session-launch-actions.ts ---'
ast-grep outline src/renderer/src/components/tab-group/ai-vault-session-launch-actions.ts --view expanded || true

echo
echo '--- search for runtimeLaunch.then usage ---'
rg -n "runtimeLaunch\\.then|runtimeLaunch" src/renderer/src/components/tab-group -S

Repository: stablyai/orca

Length of output: 993


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Read the relevant slice of the target file with line numbers.
FILE='src/renderer/src/components/tab-group/AiVaultSessionDropLayer.tsx'
wc -l "$FILE"
echo
sed -n '180,270p' "$FILE" | cat -n

echo
echo '--- related file slice ---'
FILE2='src/renderer/src/components/tab-group/ai-vault-session-launch-actions.ts'
wc -l "$FILE2"
echo
sed -n '1,260p' "$FILE2" | cat -n

Repository: stablyai/orca

Length of output: 3838


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Find the definition of runtimeLaunch and inspect its error handling contract.
rg -n "runtimeLaunch\s*[:=]" src/renderer/src src/main src -S || true

echo
echo '--- broader usages ---'
rg -n "\.runtimeLaunch\b" src -S || true

Repository: stablyai/orca

Length of output: 1030


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the runtimeLaunch contract and the other caller with the same pattern.
FILE='src/renderer/src/lib/launch-ai-vault-session.ts'
wc -l "$FILE"
echo
sed -n '1,220p' "$FILE" | cat -n

echo
echo '--- right-sidebar caller ---'
FILE2='src/renderer/src/components/right-sidebar/ai-vault-session-launch-actions.ts'
wc -l "$FILE2"
echo
sed -n '80,170p' "$FILE2" | cat -n

Repository: stablyai/orca

Length of output: 7750


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Find any existing catch/await handling around runtimeLaunch in the renderer.
rg -n "runtimeLaunch.*catch|catch\\(.*runtimeLaunch|await .*runtimeLaunch|then\\(\\(created\\).*catch" src/renderer/src -S

Repository: stablyai/orca

Length of output: 269


Add a rejection handler to runtimeLaunch.
void launchResult.runtimeLaunch.then(...) can reject without surfacing any user feedback here. Add a .catch() and show the same error toast.

Comment on lines +4 to +16
import { getRuntimeEnvironmentIdForWorktree } from '@/lib/worktree-runtime-owner'
import {
createWebRuntimeSessionTerminal,
isWebRuntimeSessionActive
} from '@/runtime/web-runtime-session'
import type { AiVaultAgent } from '../../../shared/ai-vault-types'
import type { SleepingAgentLaunchConfig } from '../../../shared/agent-session-resume'
import type { TabSplitDirection } from '@/store/slices/tabs'

export type LaunchAiVaultSessionInNewTabResult =
| { tabId: string; groupId?: string }
| { tabId: null; groupId?: string; runtimeLaunch: Promise<boolean> }

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.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# 1. Find all callers of launchAiVaultSessionInNewTab and check how they handle the result.
rg -n 'launchAiVaultSessionInNewTab' --type=ts -g '!**/*.test.ts' -C10

# 2. Check if createWebRuntimeSessionTerminal can reject (look for throw/reject in its body).
rg -n 'export.*createWebRuntimeSessionTerminal' --type=ts -A30

# 3. Check if isWebRuntimeSessionActive handles null/undefined input.
rg -n 'export.*isWebRuntimeSessionActive' --type=ts -A15

# 4. Check how callers handle the runtimeLaunch promise (look for .catch, try/catch, or await).
rg -n 'runtimeLaunch' --type=ts -g '!**/*.test.ts' -C5

Repository: stablyai/orca

Length of output: 151


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate the target file and nearby callers/usages.
git ls-files | rg 'launch-ai-vault-session|ai-vault-session-launch-actions|web-runtime-session|agent-session-resume|ai-vault-types'

# Read the target file with line numbers.
sed -n '1,220p' src/renderer/src/lib/launch-ai-vault-session.ts | cat -n

# Find all references to the launch helper and the runtime launch promise.
rg -n --context 4 'launchAiVaultSessionInNewTab|runtimeLaunch|createWebRuntimeSessionTerminal|isWebRuntimeSessionActive' src/renderer/src

Repository: stablyai/orca

Length of output: 50370


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Show the caller that consumes launchAiVaultSessionInNewTab.
sed -n '180,245p' src/renderer/src/components/tab-group/AiVaultSessionDropLayer.tsx | cat -n

# Inspect the runtime-session helper implementation and its rejection paths.
sed -n '1,260p' src/renderer/src/runtime/web-runtime-session.ts | cat -n

# Inspect the specific createWebRuntimeSessionTerminal test cases for failure/resolve behavior.
sed -n '403,620p' src/renderer/src/runtime/web-runtime-session.test.ts | cat -n

Repository: stablyai/orca

Length of output: 21486


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Check whether splitDirection is used anywhere for web-runtime terminal creation.
rg -n --context 3 'splitDirection|targetGroupId' src/renderer/src/lib/launch-ai-vault-session.ts src/renderer/src/components/tab-group/AiVaultSessionDropLayer.tsx src/renderer/src/runtime/web-runtime-session.ts src/renderer/src/components/tab-group/useTabGroupWorkspaceModel.ts src/renderer/src/components/Terminal.tsx

# Find any other callers of launchAiVaultSessionInNewTab.
rg -n --context 3 'launchAiVaultSessionInNewTab\(' src/renderer/src

Repository: stablyai/orca

Length of output: 26021


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the second caller that consumes the union result.
sed -n '80,170p' src/renderer/src/components/right-sidebar/ai-vault-session-launch-actions.ts | cat -n

# Inspect the launch-helper tests around the runtime branch and split handling.
sed -n '120,190p' src/renderer/src/lib/launch-ai-vault-session.test.ts | cat -n

# Inspect any direct expectations around tabId/runtimeLaunch shape.
sed -n '1,140p' src/renderer/src/lib/launch-ai-vault-session.test.ts | cat -n

Repository: stablyai/orca

Length of output: 12320


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Find whether splitDirection is used for runtime-hosted AI Vault launches anywhere else.
rg -n --context 3 'splitDirection' src/renderer/src/lib src/renderer/src/components src/renderer/src/runtime src/shared

# Check if any runtime-session helper or test expects splitDirection for terminal creation.
rg -n --context 3 'createWebRuntimeSessionTerminal\(|session\.tabs\.createTerminal|rightSplit|leftSplit' src/renderer/src/runtime src/renderer/src/lib src/renderer/src/components/tab-group

Repository: stablyai/orca

Length of output: 30912


Preserve splitDirection for runtime-hosted launches
src/renderer/src/lib/launch-ai-vault-session.ts:29-56 — the web-runtime branch returns before the split-group creation, so drops onto a split target ignore the split and open in the existing group. Route the runtime path through the same split logic, or create the split before the early return.

Comment on lines +605 to +607
it('routes session scans through the paired runtime host', async () => {
const runtimeCalls: { method: string; params: unknown }[] = []
const scanResult = {

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.

🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

Duplicate const runtimeCalls declaration — syntax error.

Both new tests declare const runtimeCalls: { method: string; params: unknown }[] = [] twice in the same scope. This is a duplicate-identifier syntax error that would prevent this test file from being parsed at all, failing the whole suite rather than just these two tests.

🐛 Proposed fix
   it('routes session scans through the paired runtime host', async () => {
     const runtimeCalls: { method: string; params: unknown }[] = []
-    const runtimeCalls: { method: string; params: unknown }[] = []
     const scanResult = {
   it('returns unavailable history for explicit non-runtime host scopes', async () => {
     const runtimeCalls: { method: string; params: unknown }[] = []
-    const runtimeCalls: { method: string; params: unknown }[] = []
     vi.doMock('./web-runtime-client', () => ({

Also applies to: 654-656

brennanb2025 added a commit that referenced this pull request Jul 10, 2026
…ts-to-mobile

Reconciles the mobile aiVault.listSessions RPC with main's runtime-host
scanning (#7631), OMP sessions (#7618/#7628), host-aware attribution
(#7367), and zero-turn recovery (#7889):

- One aiVault.listSessions serves mobile (no executionHostId), the desktop
  parent, and web clients: bounded params kept, results served from the
  shared host-local cache and restamped per-caller at the RPC edge.
- Desktop's runtime-host RPC client caps scopePaths to the shared bound so
  large desktops degrade gracefully instead of failing validation.
- Desktop IPC local scope delegates to the shared cache module (single
  cache with the RPC path); ssh/runtime/all merges keep main's outer cache.
- Main's zero-turn empty-session semantics and ExecutionHostId-typed
  project attribution replayed onto the /shared lifted filter core.
- Mobile resume forwards session.filePath so OMP resumes by absolute
  transcript path (desktop parity).

Co-authored-by: Orca <[email protected]>
@AmethystLiang AmethystLiang added the orca-remote-server Remote Orca Server / orca serve / paired remote runtime label Jul 22, 2026
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* Fix AI Vault runtime host scanning

* fix runtime ai vault response validation

* test runtime ai vault validation more loosely

* fix(ai-vault): harden runtime host scanning

Co-authored-by: Orca <[email protected]>

* fix(ai-vault): resume runtime host sessions

Co-authored-by: Orca <[email protected]>

---------

Co-authored-by: Jinwoo-H <[email protected]>
Co-authored-by: Orca <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

orca-remote-server Remote Orca Server / orca serve / paired remote runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Agent Session History does not scan Remote Orca Server (runtime) hosts — "All hosts" excludes the paired server

3 participants