Skip to content

Add first prompt to agent session history rows - #12085

Merged
AmethystLiang merged 13 commits into
mainfrom
add-first-prompt-to-agent-session-history-row-wip
Aug 3, 2026
Merged

AmethystLiang merged 13 commits into
mainfrom
add-first-prompt-to-agent-session-history-row-wip

Conversation

@AmethystLiang

Copy link
Copy Markdown
Contributor

Summary

  • capture and carry whether the session preview window truncated older messages
  • avoid presenting a recent preview turn as the first prompt
  • extract AI Vault resume-command construction into a dedicated module

Verification

  • pnpm exec vitest run --config config/vitest.config.ts src/main/ai-vault/session-scanner-preview-window-truncation.test.ts src/renderer/src/components/right-sidebar/ai-vault-session-display.test.ts src/shared/ai-vault-resume-command.test.ts src/shared/ai-vault-session-display.test.ts
  • pnpm run typecheck
  • focused oxlint

All focused tests passed (21 tests).

Re-parse transcripts on demand to extract and display the untruncated first
user prompt for copy/reuse. List scans omit the body (payload/perf); UI loads
it when session details expand. Grok sessions extract the typed ask from
<user_query> envelope, skipping injected <user_info> bootstrap rows. Supports
Claude, Codex, Grok, and OpenCode agents.
AiVaultSessionDetails exceeded the 400-line oxlint limit after adding
first-prompt UI; move SessionTime into its own module.
Corrupt transcripts now resolve null instead of rejecting the IPC call, matching behavior for other unavailable cases. OpenCode SQLite parsing now correctly captures all text parts from the earliest user message only, fixing truncation of large prompts and padding of small ones. Add stale-response guard in the UI to prevent late results from overwriting the current session when tabs switch. Consolidate text slicing via `sliceAtCodeUnitLimit` to avoid surrogate-pair splits across all callers.
Ensure truncation at safety limits doesn't split UTF-16 surrogate pairs,
preventing corruption of astral characters in captured prompts.
Remounting the card on session switches prevents late responses from
a previous load from writing stale data into the component's refs.
Also improves conversation-turn key stability.
@greptile-apps

greptile-apps Bot commented Aug 2, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR introduces three cohesive changes: it adds a previewMessagesTruncated flag that propagates from the accumulator ring-buffer through to the session type, uses that flag to prevent a recent preview turn from being incorrectly returned as the "first prompt," and extracts AI Vault resume-command construction from ai-vault-types.ts into a dedicated shared/ai-vault-resume-command.ts module. The Copilot, Cursor, Hermes, and OpenCode (JSON) parsers are also split from session-scanner-secondary-parsers.ts into their own files.

  • previewMessagesTruncated is set by the accumulator ring-buffer (file-based parsers) or by a LIMIT N+1 probe (OpenCode SQLite), then checked by sessionFirstPrompt to avoid presenting a recent turn under a "first prompt" label on long sessions.
  • FirstPromptCard starts an on-demand re-parse immediately on mount, races it against a 15-second deadline, and correctly drains the dedupe handle on StrictMode remount so the card never strands in "Loading…".
  • The resume-command extraction and parser file splits are straightforward refactors with no behavioral changes.

Confidence Score: 5/5

Safe to merge; all behavioral changes are gated behind the new truncation flag and the on-demand re-parse path ensures the user always sees the correct first prompt even in degraded cases.

The core logic — ring-buffer eviction sets the flag, sessionFirstPrompt gates on it, FirstPromptCard always falls back to the on-demand re-parse — is correct and well-tested. The refactoring of resume-command construction and parser file splits is purely additive. The one notable edge case (SQLite probe counting parts instead of messages) has no data-correctness impact and degrades only to an extra loading spinner.

Files Needing Attention: src/main/ai-vault/session-scanner-opencode-sqlite.ts — the LIMIT N+1 probe works at part granularity rather than message granularity, which can cause unnecessary on-demand re-parses for sessions whose messages carry multiple text parts.

Important Files Changed

Filename Overview
src/main/ai-vault/session-scanner-accumulator.ts Adds previewMessagesTruncated flag, seedFirstUserPrompt guard, and addPreviewContent helper; ring-buffer eviction now sets the flag when the window overflows. Logic is correct.
src/main/ai-vault/session-scanner-opencode-sqlite.ts Adds LIMIT N+1 probe to detect preview-window truncation in the SQLite path. The probe counts part-table rows (not distinct messages), so a message with multiple text parts can produce a false-positive previewMessagesTruncated; consequence is an unnecessary on-demand re-parse rather than wrong data.
src/shared/ai-vault-session-display.ts New sessionFirstPrompt function correctly gates on previewMessagesTruncated before using the sliding preview window as a first-prompt source. Logic and tests are complete.
src/shared/ai-vault-resume-command.ts Pure extraction of resume-command construction from ai-vault-types.ts; all quoting helpers, codex-home env prefix, and platform routing are moved verbatim.
src/renderer/src/components/right-sidebar/ai-vault-first-prompt-card.tsx FirstPromptCard correctly initializes loading state lazily, races the on-demand re-parse against a 15 s deadline, and clears the dedupe handle on StrictMode cleanup so remounts never strand in loading state.
src/main/ai-vault/session-scanner-opencode-parser.ts Extracted from secondary-parsers; seedFullFirstUserPrompt is called from real message.content (not the AI summary fallback), fixing the summary-seeding bug; addPreviewMessage receives seedFirstUserPrompt: false to avoid double-seeding.
src/main/ai-vault/session-scanner-agent-parser.ts Clean router that dispatches to the per-agent parse functions; all agents accounted for in the switch.
src/main/ai-vault/session-first-user-prompt-read.ts On-demand re-parse entry point; routes OpenCode SQLite sessions to readFirstUserPromptFromOpenCodeDb (direct DB query) instead of the preview-window path, correctly bypassing truncation issues.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["List scan / on-demand re-parse"] --> B["addPreviewMessage / addPreviewContent"]
    B --> C{"previewMessages.length > 5?"}
    C -- "No" --> D["previewMessagesTruncated = false"]
    C -- "Yes (ring-buffer evicts oldest)" --> E["previewMessagesTruncated = true"]
    F["OpenCode SQLite path"] --> G["LIMIT N+1 probe"]
    G --> H{"probedRows.length > N?"}
    H -- "No" --> D
    H -- "Yes" --> E
    D & E --> I["finalizeSession → AiVaultSession"]
    I --> J["sessionFirstPrompt()"]
    J --> K{"firstUserPrompt stored?"}
    K -- "Yes" --> L["Return stored full prompt"]
    K -- "No" --> M{"previewMessagesTruncated?"}
    M -- "Yes" --> N["Return null → trigger on-demand re-parse"]
    M -- "No" --> O["Return earliest user preview turn"]
    N --> P["FirstPromptCard: on-demand getFirstUserPrompt IPC"]
    P --> Q["15 s deadline race"]
    Q --> R["Display full prompt text"]
Loading

Reviews (5): Last reviewed commit: "capture first user prompt by ordering Op..." | Re-trigger Greptile

@coderabbitai

coderabbitai Bot commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

AI Vault session scanning now records preview truncation and full first-user prompts. Local sessions can reparse transcripts through a validated IPC API, while remote sessions return no prompt. The renderer displays fallback or loaded prompts and supports copying. Copilot, Cursor, Hermes, and OpenCode parsing now uses dedicated modules. Resume command construction moved to a shared module with shell-specific quoting and Codex environment handling. SSH proxy handling moved to a dedicated utility module. SSH and relay formatting changes preserve behavior.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description includes a summary and verification details but omits the required Screenshots, AI Review Report, Security Audit, and Notes sections. Add all missing template sections and complete the testing checklist, including the required cross-platform AI review and security audit details.
Docstring Coverage ⚠️ Warning Docstring coverage is 9.52% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary user-visible change: adding the first prompt to agent session history rows.
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.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/ai-vault/session-scanner-accumulator.ts (1)

155-190: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Move firstUserPrompt seeding before the preview-empty return.

addPreviewMessage returns before the inline seeding block when text is empty after normalizePreviewText, but the raw args.text may still be a valid full first prompt. consumeOpenCodeMessages and consumeCopilotRecordLine rely on this inline seeding, so the first-user-turn suppression now has to match both preview and full-prompt normalization rules. Try seeding from args.text before returning, and still avoid adding any preview-only normalization as firstUserPrompt.

🧹 Nitpick comments (2)
src/renderer/src/lib/ai-vault-resume-command.ts (1)

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

Consider renaming the renderer wrapper to avoid a same-name collision with the new shared module.

This file and src/shared/ai-vault-resume-command.ts share the exact same basename. Mobile's equivalent wrapper avoids this by using a distinct name (ai-vault-resume-launch.ts). A shared basename between the builder module and its renderer wrapper makes editor file-search and import autocomplete ambiguous.

Rename this file to something like ai-vault-resume-launch.ts or ai-vault-resume-command-renderer.ts to match the mobile naming pattern.

src/main/ai-vault/session-first-user-prompt-read.test.ts (1)

124-137: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a case for the non-local executionHostId guard.

readAiVaultFirstUserPrompt returns { prompt: null } for any host other than LOCAL_EXECUTION_HOST_ID. The web preload fallback and the renderer canLoadFullFirstPrompt guard both depend on that contract. No test covers it, so a change to the host check would pass silently.

💚 Proposed test for the remote-host guard
+  it('returns null for non-local execution hosts without reading the transcript', async () => {
+    const root = await mkdtemp(join(tmpdir(), 'orca-first-prompt-remote-'))
+    tempRoots.push(root)
+    const filePath = join(root, 'session.jsonl')
+    await writeFile(
+      filePath,
+      JSON.stringify({
+        type: 'user',
+        sessionId: 'remote-session',
+        timestamp: '2026-05-01T10:00:00.000Z',
+        message: { role: 'user', content: 'Should not be returned' }
+      })
+    )
+
+    await expect(
+      readAiVaultFirstUserPrompt({
+        agent: 'claude',
+        filePath,
+        executionHostId: 'ssh:build-box'
+      })
+    ).resolves.toEqual({ prompt: null })
+  })

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ef8d3291-62a4-4ec0-9c75-27c16a8b84d4

📥 Commits

Reviewing files that changed from the base of the PR and between 1e545f9 and 4bd7510.

📒 Files selected for processing (46)
  • mobile/src/session/ai-vault-resume-launch.ts
  • src/main/ai-vault/runtime-session-scanner.ts
  • src/main/ai-vault/session-first-user-prompt-read.test.ts
  • src/main/ai-vault/session-first-user-prompt-read.ts
  • src/main/ai-vault/session-scanner-accumulator.ts
  • src/main/ai-vault/session-scanner-first-user-prompt-capture.ts
  • src/main/ai-vault/session-scanner-first-user-prompt.test.ts
  • src/main/ai-vault/session-scanner-first-user-prompt.ts
  • src/main/ai-vault/session-scanner-grok-parser.test.ts
  • src/main/ai-vault/session-scanner-grok-parser.ts
  • src/main/ai-vault/session-scanner-grok-user-text.test.ts
  • src/main/ai-vault/session-scanner-grok-user-text.ts
  • src/main/ai-vault/session-scanner-injected-title.test.ts
  • src/main/ai-vault/session-scanner-opencode-sqlite.test.ts
  • src/main/ai-vault/session-scanner-opencode-sqlite.ts
  • src/main/ai-vault/session-scanner-preview-window-truncation.test.ts
  • src/main/ai-vault/session-scanner-primary-parsers.ts
  • src/main/ai-vault/session-scanner-secondary-parsers.ts
  • src/main/ai-vault/session-scanner-text-normalization.ts
  • src/main/ai-vault/session-scanner-types.ts
  • src/main/ai-vault/session-scanner-values.test.ts
  • src/main/ai-vault/session-scanner-values.ts
  • src/main/ai-vault/session-scanner.test.ts
  • src/main/ipc/ai-vault.ts
  • src/preload/api-types.ts
  • src/preload/index.ts
  • src/renderer/src/components/right-sidebar/AiVaultSessionDetails.tsx
  • src/renderer/src/components/right-sidebar/AiVaultSessionRow.tsx
  • src/renderer/src/components/right-sidebar/ai-vault-first-prompt-card.tsx
  • src/renderer/src/components/right-sidebar/ai-vault-session-display.test.ts
  • src/renderer/src/components/right-sidebar/ai-vault-session-display.ts
  • src/renderer/src/components/right-sidebar/ai-vault-session-row-display.tsx
  • src/renderer/src/components/right-sidebar/ai-vault-session-time.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-command.ts
  • src/renderer/src/web/web-preload-api.ts
  • src/shared/ai-vault-resume-command.test.ts
  • src/shared/ai-vault-resume-command.ts
  • src/shared/ai-vault-session-display.ts
  • src/shared/ai-vault-types.ts
  • src/shared/harness-injected-user-turns.test.ts
  • src/shared/harness-injected-user-turns.ts

@AmethystLiang

Copy link
Copy Markdown
Contributor Author

@coderabbitai[bot] fixed

@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@AmethystLiang Confirmed. I marked this review comment as addressed.


If you found this review helpful, would you consider giving us a shout-out on X?

Thank you for using CodeRabbit!

You are interacting with an AI system.

- Add 15s timeout to full-prompt load to prevent indefinite loading states
- Extract seedFullFirstUserPrompt helper for reuse across parsers
- Prevent AI-generated summaries from becoming the copyable first prompt
- Fix truncation detection in OpenCode SQLite by probing for N+1 rows
- Optimize text bounding to apply safety limit before toLowerCase
- Gate synthetic OpenCode path detection on agent type, not just # presence
- Add test coverage for remote execution host handling
Clears loadPromiseRef during cleanup to prevent the dedupe handle from
causing StrictMode remounts to await stale in-flight requests. Stops loading
when session becomes non-loadable mid-request. Adds tests for StrictMode
double-invoke resolution and main-process timeout scenarios.
@AmethystLiang

Copy link
Copy Markdown
Contributor Author

@coderabbitai[bot] fixed

@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@AmethystLiang Confirmed. I marked this review comment as addressed.

You are interacting with an AI system.

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/ai-vault/session-scanner-secondary-parsers.ts (1)

239-263: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Seed firstUserPrompt from the earliest message by message.time.created.

consumeOpenCodeMessages seeds the first prompt from the first directory entry it reads, but readdir does not preserve transcript order. Parse the valid .json messages, sort them by message.time.created, seed once from the first user turn, and add a regression test where file order differs from creation order.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ac9ef74c-1e97-44b3-ab71-6045aadfcc8a

📥 Commits

Reviewing files that changed from the base of the PR and between 4bd7510 and fe8148f.

📒 Files selected for processing (11)
  • src/main/ai-vault/session-first-user-prompt-read.test.ts
  • src/main/ai-vault/session-first-user-prompt-read.ts
  • src/main/ai-vault/session-scanner-accumulator.ts
  • src/main/ai-vault/session-scanner-first-user-prompt.ts
  • src/main/ai-vault/session-scanner-injected-title.test.ts
  • src/main/ai-vault/session-scanner-opencode-sqlite.ts
  • src/main/ai-vault/session-scanner-secondary-parsers.ts
  • src/main/ssh/ssh-connection-utils.ts
  • src/main/ssh/ssh-connection.test.ts
  • src/main/ssh/ssh-connection.ts
  • src/relay/git-handler.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • src/main/ai-vault/session-scanner-first-user-prompt.ts
  • src/main/ai-vault/session-first-user-prompt-read.test.ts
  • src/main/ai-vault/session-scanner-opencode-sqlite.ts
  • src/main/ai-vault/session-scanner-injected-title.test.ts
  • src/main/ai-vault/session-first-user-prompt-read.ts

Split secondary-parsers into individual files per agent type (copilot,
cursor, hermes, opencode) for improved modularity. Add test coverage
for first-user-prompt envelope handling: unwrap user_query tags and
reject bare user_info dumps.

@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

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7d30646a-239b-4284-9d89-8164dfc09cf2

📥 Commits

Reviewing files that changed from the base of the PR and between fe8148f and 6cff169.

📒 Files selected for processing (10)
  • src/main/ai-vault/remote-session-scanner-sources.ts
  • src/main/ai-vault/session-scanner-agent-parser.ts
  • src/main/ai-vault/session-scanner-copilot-parser.ts
  • src/main/ai-vault/session-scanner-cursor-parser.ts
  • src/main/ai-vault/session-scanner-first-user-prompt.test.ts
  • src/main/ai-vault/session-scanner-first-user-prompt.ts
  • src/main/ai-vault/session-scanner-hermes-parser.ts
  • src/main/ai-vault/session-scanner-opencode-parser.ts
  • src/main/ai-vault/session-scanner-parse-cache.ts
  • src/main/ai-vault/session-scanner-secondary-parsers.ts
💤 Files with no reviewable changes (1)
  • src/main/ai-vault/session-scanner-secondary-parsers.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/ai-vault/session-scanner-first-user-prompt.ts

Collapse an accidental multi-line regex wrap in ssh-connection-utils that
pushed counted lines to 301. Harden the latched-readiness test's ready
transition so CI load can re-observe attach after MutationObserver gaps.
Move resolveEffectiveProxy/spawnProxyCommand out of ssh-connection-utils
so oxfmt line wrapping cannot push that file over the 300-line lint cap.

@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

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 010c8093-9398-4b76-a60f-89c52cbf0384

📥 Commits

Reviewing files that changed from the base of the PR and between 6cff169 and ebb3072.

📒 Files selected for processing (1)
  • src/renderer/src/components/activity/activity-portal-readiness-loop.react185.test.tsx

@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

🧹 Nitpick comments (1)
src/main/ssh/ssh-proxy-command.ts (1)

92-105: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Propagate backpressure from the proxy's stdout.

onStdoutData ignores stream.push(data)'s return value. If the consumer reads slower than the proxy writes, data buffers unboundedly on the Duplex instead of pausing proc.stdout.

♻️ Proposed fix
   const onStdoutData = (data: Buffer): void => {
-    stream.push(data)
+    if (!stream.push(data)) {
+      proc.stdout!.pause()
+    }
   }
...
   const stream = new Duplex({
-    read() {},
+    read() {
+      proc.stdout!.resume()
+    },

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5c1d339b-2448-412a-a633-1fda20abd16e

📥 Commits

Reviewing files that changed from the base of the PR and between ebb3072 and 89bf312.

📒 Files selected for processing (4)
  • src/main/ssh/ssh-connection-utils.test.ts
  • src/main/ssh/ssh-connection-utils.ts
  • src/main/ssh/ssh-connection.ts
  • src/main/ssh/ssh-proxy-command.ts
💤 Files with no reviewable changes (1)
  • src/main/ssh/ssh-connection-utils.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/ssh/ssh-connection.ts

Comment thread src/main/ssh/ssh-proxy-command.ts Resolved
Comment thread src/main/ssh/ssh-proxy-command.ts Resolved
Comment thread src/main/ssh/ssh-proxy-command.ts Resolved
@AmethystLiang

Copy link
Copy Markdown
Contributor Author

@coderabbitai[bot] resolved

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

@AmethystLiang Confirmed. I will resolve the CodeRabbit review comments.

✅ Action performed

Comments resolved. Approval is disabled; enable reviews.request_changes_workflow to allow explicit top-level @coderabbitai resolve or @coderabbitai approve commands.

- Add `readOpenCodeMessagesInOrder` to rebuild transcript by timestamp, handling
  corrupt/partial files gracefully instead of discarding sessions
- Extract SSH proxy command tests to dedicated file; add backpressure handling
  and stderr draining to prevent proxy process stalls
- On Windows, reject unsafe characters in ProxyCommand values instead of
  pretending to escape them; properly format cmd.exe invocation with verbatim
  arguments
- Expand ProxyJump chains into -J plus final hop, mirroring OpenSSH behavior
- Decouple portal readiness reapply budget from flip-count budget via explicit
  constant
@AmethystLiang
AmethystLiang merged commit a000839 into main Aug 3, 2026
44 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* Add first user prompt to AI Vault session history rows

Re-parse transcripts on demand to extract and display the untruncated first
user prompt for copy/reuse. List scans omit the body (payload/perf); UI loads
it when session details expand. Grok sessions extract the typed ask from
<user_query> envelope, skipping injected <user_info> bootstrap rows. Supports
Claude, Codex, Grok, and OpenCode agents.

* fix(ai-vault): split SessionTime out to pass max-lines lint

AiVaultSessionDetails exceeded the 400-line oxlint limit after adding
first-prompt UI; move SessionTime into its own module.

* fix(ai-vault): handle corrupt transcripts and fix OpenCode prompt captur

Corrupt transcripts now resolve null instead of rejecting the IPC call, matching behavior for other unavailable cases. OpenCode SQLite parsing now correctly captures all text parts from the earliest user message only, fixing truncation of large prompts and padding of small ones. Add stale-response guard in the UI to prevent late results from overwriting the current session when tabs switch. Consolidate text slicing via `sliceAtCodeUnitLimit` to avoid surrogate-pair splits across all callers.

* test(ai-vault): add first-user-prompt UTF-16 safety tests

Ensure truncation at safety limits doesn't split UTF-16 surrogate pairs,
preventing corruption of astral characters in captured prompts.

* fix(ai-vault): key first-prompt-card by session.id

Remounting the card on session switches prevents late responses from
a previous load from writing stale data into the component's refs.
Also improves conversation-turn key stability.

* fix(ai-vault): preserve first prompt after preview truncation

* refactor(ai-vault): improve first user prompt capture robustness and per

- Add 15s timeout to full-prompt load to prevent indefinite loading states
- Extract seedFullFirstUserPrompt helper for reuse across parsers
- Prevent AI-generated summaries from becoming the copyable first prompt
- Fix truncation detection in OpenCode SQLite by probing for N+1 rows
- Optimize text bounding to apply safety limit before toLowerCase
- Gate synthetic OpenCode path detection on agent type, not just # presence
- Add test coverage for remote execution host handling

* Fix FirstPromptCard loading state stranded by stale promise reuse

Clears loadPromiseRef during cleanup to prevent the dedupe handle from
causing StrictMode remounts to await stale in-flight requests. Stops loading
when session becomes non-loadable mid-request. Adds tests for StrictMode
double-invoke resolution and main-process timeout scenarios.

* refactor(ai-vault): split session parsers into modular files

Split secondary-parsers into individual files per agent type (copilot,
cursor, hermes, opencode) for improved modularity. Add test coverage
for first-user-prompt envelope handling: unwrap user_query tags and
reject bare user_info dumps.

* fix(ci): clear max-lines and flaky portal readiness check

Collapse an accidental multi-line regex wrap in ssh-connection-utils that
pushed counted lines to 301. Harden the latched-readiness test's ready
transition so CI load can re-observe attach after MutationObserver gaps.

* fix(ssh): extract proxy command helpers to pass max-lines

Move resolveEffectiveProxy/spawnProxyCommand out of ssh-connection-utils
so oxfmt line wrapping cannot push that file over the 300-line lint cap.

* capture first user prompt by ordering OpenCode messages by creation time

- Add `readOpenCodeMessagesInOrder` to rebuild transcript by timestamp, handling
  corrupt/partial files gracefully instead of discarding sessions
- Extract SSH proxy command tests to dedicated file; add backpressure handling
  and stderr draining to prevent proxy process stalls
- On Windows, reject unsafe characters in ProxyCommand values instead of
  pretending to escape them; properly format cmd.exe invocation with verbatim
  arguments
- Expand ProxyJump chains into -J plus final hop, mirroring OpenSSH behavior
- Decouple portal readiness reapply budget from flip-count budget via explicit
  constant
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