Repository navigation
feat(cli): show orca search now the settings toggle ships #20677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 9 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
d483d6d
feat(cli): orca search over the agent session index
Jinwoo-H 1c9cc44
refactor(cli): drop the search type assertions main's casting gate no…
Jinwoo-H c4744da
fix(cli): sanitize host strings and scope pre-command repeatable flags
Jinwoo-H 3c86c7c
refactor(cli): resolve repeatable flag rules once per command
Jinwoo-H a211210
fix(cli): clarify session search availability and SSH scope
Jinwoo-H 2b012c1
feat(cli): hide orca search until the settings toggle ships
Jinwoo-H 8f8d2e3
merge: integrate remote session-search-pr6-cli before push
Jinwoo-H 18fa46c
feat(cli): show orca search now the settings toggle ships
Jinwoo-H 4aa008a
docs(skills): teach the orca-cli guide the search command
Jinwoo-H bf267eb
docs(skills): shape the search section like the other command sections
Jinwoo-H 5875eb1
Merge remote-tracking branch 'origin/main' into session-search-pr6-cli
Jinwoo-H 0ae5754
Merge branch 'session-search-pr6-cli' into session-search-unhide-cli
Jinwoo-H 2126979
Merge remote-tracking branch 'origin/main' into session-search-pr6-cli
Jinwoo-H 2ae0d25
Merge branch 'session-search-pr6-cli' into session-search-unhide-cli
Jinwoo-H 4947350
Merge remote-tracking branch 'origin/main' into session-search-unhide…
Jinwoo-H File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,296 @@ | ||
| import { describe, expect, it } from 'vitest' | ||
| import { | ||
| formatSessionSearchResponse, | ||
| formatSessionSearchStatus, | ||
| terminalSafe | ||
| } from './agent-session-search-format' | ||
| import type { | ||
| AiVaultSearchHit, | ||
| AiVaultSearchResponse, | ||
| AiVaultSearchStatus | ||
| } from '../shared/ai-vault-search-types' | ||
|
|
||
| const localHit: AiVaultSearchHit = { | ||
| agent: 'claude', | ||
| executionHostId: 'ssh:build-01', | ||
| sessionId: 'session-1', | ||
| title: 'Terminal resize race on Windows', | ||
| cwd: 'C:\\src\\orca', | ||
| branch: 'main', | ||
| updatedAt: '2026-09-12T18:04:11.000Z', | ||
| messageCount: 214, | ||
| score: 12.5, | ||
| source: { presence: 'present', filePath: '/transcripts/session-1.jsonl' }, | ||
| evidence: { | ||
| snippet: 'the [[resize]] handler drops the first event', | ||
| role: 'assistant', | ||
| timestamp: '2026-09-12T18:04:11.000Z' | ||
| }, | ||
| resumeCommand: 'claude --resume session-1' | ||
| } | ||
|
|
||
| const evidencelessHit: AiVaultSearchHit = { | ||
| agent: 'codex', | ||
| sessionId: 'session-2', | ||
| title: 'Index sweep budget', | ||
| cwd: null, | ||
| branch: null, | ||
| updatedAt: null, | ||
| messageCount: 4, | ||
| score: 3, | ||
| source: { presence: 'unverifiable' }, | ||
| evidence: null | ||
| } | ||
|
|
||
| function results(overrides: Partial<Extract<AiVaultSearchResponse, { kind: 'results' }>> = {}) { | ||
| return { | ||
| kind: 'results' as const, | ||
| hits: [localHit], | ||
| page: { cursor: null, hasMore: false }, | ||
| generation: 42, | ||
| truncated: { candidates: false, snippets: 0, query: false, freshness: false }, | ||
| durationMs: 18, | ||
| ...overrides | ||
| } | ||
| } | ||
|
|
||
| describe('formatSessionSearchResponse: results', () => { | ||
| it('prints one line per hit with the snippet indented under it', () => { | ||
| expect(formatSessionSearchResponse(results())).toBe( | ||
| [ | ||
| 'Claude 2026-09-12T18:04:11.000Z Terminal resize race on Windows host=ssh:build-01', | ||
| ' assistant: the [[resize]] handler drops the first event', | ||
| ' resume: claude --resume session-1', | ||
| '', | ||
| '1 result on this page, 18 ms.' | ||
| ].join('\n') | ||
| ) | ||
| }) | ||
|
|
||
| it('leaves the [[ ]] match marks exactly as the engine wrote them', () => { | ||
| expect(formatSessionSearchResponse(results())).toContain('[[resize]]') | ||
| }) | ||
|
|
||
| it('omits the host and the resume line a paired host withheld', () => { | ||
| const { executionHostId: _host, resumeCommand: _resume, ...withheld } = localHit | ||
| expect(formatSessionSearchResponse(results({ hits: [withheld] }))).toBe( | ||
| [ | ||
| 'Claude 2026-09-12T18:04:11.000Z Terminal resize race on Windows', | ||
| ' assistant: the [[resize]] handler drops the first event', | ||
| '', | ||
| '1 result on this page, 18 ms.' | ||
| ].join('\n') | ||
| ) | ||
| }) | ||
|
|
||
| it('says so when a hit matched with no text evidence', () => { | ||
| expect(formatSessionSearchResponse(results({ hits: [evidencelessHit] }))).toContain( | ||
| 'Codex unknown time Index sweep budget\n no text evidence for this match' | ||
| ) | ||
| }) | ||
|
|
||
| it('reports zero hits as an answer, not a failure', () => { | ||
| expect(formatSessionSearchResponse(results({ hits: [] }))).toBe( | ||
| ['No sessions match this query.', '', '0 results on this page, 18 ms.'].join('\n') | ||
| ) | ||
| }) | ||
|
|
||
| it('prints the cursor a caller passes back for the next page', () => { | ||
| expect( | ||
| formatSessionSearchResponse(results({ page: { cursor: 'eyJ2IjoxfQ', hasMore: true } })) | ||
| ).toContain('more pages: re-run with --cursor eyJ2IjoxfQ') | ||
| }) | ||
|
|
||
| it('admits more pages exist when the host issued no cursor', () => { | ||
| expect( | ||
| formatSessionSearchResponse(results({ page: { cursor: null, hasMore: true } })) | ||
| ).toContain('more pages exist, but this host issued no cursor for them') | ||
| }) | ||
|
|
||
| it('renders every truncation flag in words', () => { | ||
| const text = formatSessionSearchResponse( | ||
| results({ truncated: { candidates: true, snippets: 3, query: true, freshness: true } }) | ||
| ) | ||
| expect(text).toContain( | ||
| 'ranking saw only the first batch of candidate sessions, so a better match may be missing' | ||
| ) | ||
| expect(text).toContain('query was cut') | ||
| expect(text).toContain( | ||
| 'freshness wait timed out; these results come from the index as it stood' | ||
| ) | ||
| expect(text).toContain('3 snippets were shortened') | ||
| }) | ||
|
|
||
| it('prints nothing about truncation when nothing was truncated', () => { | ||
| expect(formatSessionSearchResponse(results())).not.toContain('truncat') | ||
| }) | ||
|
|
||
| it('prints the planner route only when the host sent debug', () => { | ||
| expect(formatSessionSearchResponse(results())).not.toContain('debug:') | ||
| expect( | ||
| formatSessionSearchResponse( | ||
| results({ | ||
| debug: { | ||
| route: 'typo+phrase', | ||
| repairedTerms: ['resize'], | ||
| plannerReport: { route: 'typo+phrase', repairedTerms: ['resize'], scope: 'all' } | ||
| } | ||
| }) | ||
| ) | ||
| ).toContain( | ||
| ['debug:', ' route: typo+phrase', ' repairedTerms: resize', ' plannerScope: all'].join( | ||
| '\n' | ||
| ) | ||
| ) | ||
| }) | ||
| }) | ||
|
|
||
| describe('formatSessionSearchResponse: non-result answers', () => { | ||
| it('reports a disabled index', () => { | ||
| expect(formatSessionSearchResponse({ kind: 'unavailable', reason: 'disabled' })).toBe( | ||
| 'Session search is off on this host.' | ||
| ) | ||
| }) | ||
|
|
||
| it('names an index that has not started', () => { | ||
| expect(formatSessionSearchResponse({ kind: 'unavailable', reason: 'not-ready' })).toContain( | ||
| 'not ready on this host yet' | ||
| ) | ||
| }) | ||
|
|
||
| it('tells an old host apart as a host with no service', () => { | ||
| expect(formatSessionSearchResponse({ kind: 'unavailable', reason: 'no-service' })).toBe( | ||
| [ | ||
| 'This host runs no session search service.', | ||
| 'An Orca host older than session search answers the same way; update it and try again.' | ||
| ].join('\n') | ||
| ) | ||
| }) | ||
|
|
||
| it('says the index moved and to drop the cursor', () => { | ||
| expect(formatSessionSearchResponse({ kind: 'stale-cursor', generation: 7 })).toBe( | ||
| [ | ||
| 'The index moved on since that page, so the cursor no longer names a place in it.', | ||
| 'Re-run the same search without --cursor to start again from page 1.' | ||
| ].join('\n') | ||
| ) | ||
| }) | ||
| }) | ||
|
|
||
| describe('terminal safety', () => { | ||
| it('strips escape sequences a transcript could carry into the reader terminal', () => { | ||
| expect(terminalSafe('before\u001b]52;c;cGF5bG9hZA==\u0007after')).toBe('beforeafter') | ||
| expect(terminalSafe('red \u001b[31mtext\u001b[0m')).toBe('red text') | ||
| }) | ||
|
|
||
| it.each([ | ||
| ['updatedAt', { updatedAt: '2026-09-12\u001b[31mT18:04:11.000Z' }, '\u001b'], | ||
| ['executionHostId', { executionHostId: 'ssh:\u001b]0;pwned\u0007build-01' }, '\u001b'], | ||
| ['title', { title: 'resize\u001b[2Jrace' }, '\u001b'], | ||
| ['evidence snippet', { evidence: { ...localHit.evidence!, snippet: 'a\u001b[1mb' } }, '\u001b'], | ||
| ['resumeCommand', { resumeCommand: 'claude \u001b[3Jresume' }, '\u001b'] | ||
| ])('strips an escape sequence a host put in %s', (_field, override, escape) => { | ||
| const text = formatSessionSearchResponse(results({ hits: [{ ...localHit, ...override }] })) | ||
|
|
||
| expect(text).not.toContain(escape) | ||
| }) | ||
|
|
||
| it('strips an escape sequence a host put in the next-page cursor', () => { | ||
| const text = formatSessionSearchResponse( | ||
| results({ page: { cursor: 'eyJ2\u001b[31mIjoxfQ', hasMore: true } }) | ||
| ) | ||
|
|
||
| expect(text).toContain('more pages: re-run with --cursor eyJ2IjoxfQ') | ||
| expect(text).not.toContain('\u001b') | ||
| }) | ||
|
|
||
| it('strips an escape sequence a host put in a repaired term', () => { | ||
| const text = formatSessionSearchResponse( | ||
| results({ | ||
| debug: { | ||
| route: 'typo+phrase', | ||
| repairedTerms: ['resize\u001b[31m', '\u001b]0;t\u0007race'], | ||
| plannerReport: { route: 'typo+phrase', scope: 'all' } | ||
| } | ||
| }) | ||
| ) | ||
|
|
||
| expect(text).toContain(' repairedTerms: resize race') | ||
| expect(text).not.toContain('\u001b') | ||
| }) | ||
|
|
||
| it.each([ | ||
| ['root', { root: '/Users/me/\u001b[31m.codex', reason: 'EACCES' }], | ||
| ['reason', { root: '/r', reason: 'EACCES\u001b]0;x\u0007' }] | ||
| ])('strips an escape sequence a host put in a degraded %s', (_field, degradedRoot) => { | ||
| const text = formatSessionSearchStatus({ | ||
| enabled: true, | ||
| phase: 'degraded', | ||
| filesIndexed: 1, | ||
| filesDue: 0, | ||
| filesFailed: 1, | ||
| degradedRoots: [degradedRoot], | ||
| lastReconcileAt: null, | ||
| lastSweepCompletedAt: null, | ||
| generation: 1 | ||
| }) | ||
|
|
||
| expect(text).not.toContain('\u001b') | ||
| }) | ||
|
|
||
| it('keeps a snippet on the one indented line it was given', () => { | ||
| const text = formatSessionSearchResponse( | ||
| results({ | ||
| hits: [ | ||
| { | ||
| ...localHit, | ||
| title: 'wrapped\ntitle', | ||
| evidence: { ...localHit.evidence!, snippet: 'first\nsecond\u0007' } | ||
| } | ||
| ] | ||
| }) | ||
| ) | ||
| expect(text).toContain('Claude 2026-09-12T18:04:11.000Z wrapped title host=ssh:build-01') | ||
| expect(text).toContain(' assistant: first second') | ||
| }) | ||
| }) | ||
|
|
||
| describe('formatSessionSearchStatus', () => { | ||
| const status: AiVaultSearchStatus = { | ||
| enabled: true, | ||
| phase: 'indexing', | ||
| filesIndexed: 5535, | ||
| filesDue: 12, | ||
| filesFailed: 1, | ||
| degradedRoots: [{ root: '/Users/me/.codex', reason: 'EACCES' }], | ||
| lastReconcileAt: 1789000000000, | ||
| lastSweepCompletedAt: null, | ||
| generation: 42 | ||
| } | ||
|
|
||
| it('reports the indexer observations one per line', () => { | ||
| expect(formatSessionSearchStatus(status)).toBe( | ||
| [ | ||
| 'enabled: true', | ||
| 'phase: indexing', | ||
| 'filesIndexed: 5535', | ||
| 'filesDue: 12', | ||
| 'filesFailed: 1', | ||
| 'lastReconcileAt: 2026-09-10T00:26:40.000Z', | ||
| 'lastSweepCompletedAt: never', | ||
| 'generation: 42', | ||
| 'degradedRoots: 1', | ||
| ' /Users/me/.codex: EACCES' | ||
| ].join('\n') | ||
| ) | ||
| }) | ||
|
|
||
| it('keeps the count when a paired host withheld the root', () => { | ||
| expect( | ||
| formatSessionSearchStatus({ | ||
| ...status, | ||
| degradedRoots: [{ reason: 'Source root could not be verified.' }] | ||
| }) | ||
| ).toContain('degradedRoots: 1\n (withheld): Source root could not be verified.') | ||
| }) | ||
| }) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This promises every hit carries a
resumeCommand, but the exposure contract withholdsresumeCommandand source paths from relay/paired callers — the paired server this same sentence names. A search routed to--environment/--pairing-codetherefore returns hits without one (andevidencecan be null for operator-only matches). Worth scoping the claim to the local host, e.g. "on this machine each hit also names aresumeCommand".