Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

Search: only what was asked, from the Codex app and editors (#388)

Dee8e814775fe67
diff --git a/cli/src/lib/sessionSearch/store.spec.ts b/cli/src/lib/sessionSearch/store.spec.ts
index 6856ff86f..03360ebbe 100644
--- a/cli/src/lib/sessionSearch/store.spec.ts
+++ b/cli/src/lib/sessionSearch/store.spec.ts
@@ -253,7 +253,7 @@ describe('SessionSearchStore', () => {
expect(store.search('alpha', { now: NOW })).toHaveLength(1)
})
- it.each(['0', '8', '9'])('rebuilds an index written by schema %s', (version) => {
+ it.each(['0', '8', '9', '10'])('rebuilds an index written by schema %s', (version) => {
const dir = mkdtempSync(join(tmpdir(), 'session-search-'))
dirs.push(dir)
const path = join(dir, 'index.db')
diff --git a/cli/src/lib/sessionSearch/store.ts b/cli/src/lib/sessionSearch/store.ts
index abf0d61dd..3d0aadd7b 100644
--- a/cli/src/lib/sessionSearch/store.ts
+++ b/cli/src/lib/sessionSearch/store.ts
@@ -16,9 +16,8 @@ import { chmodSync, existsSync, rmSync } from 'node:fs'
import { builtinSqlite } from '../sqliteRead.js'
import type { IndexedTurn } from './turns.js'
-// Rebuild existing turns with the external-engine timestamps and Muse/Copilot stream filters.
-// Version 9 belongs to the Codex context-block change (#388), which may land in either order.
-const SCHEMA_VERSION = '10'
+// Rebuild schema 10's external-engine index with Codex app/editor context removed from asks.
+const SCHEMA_VERSION = '11'
/** The row that holds a session's name, title and folder: searchable beside its turns. */
export const HEADER_TURN = -1
diff --git a/cli/src/lib/sessionSearch/turns.spec.ts b/cli/src/lib/sessionSearch/turns.spec.ts
index f6ef7fead..18b1148d2 100644
--- a/cli/src/lib/sessionSearch/turns.spec.ts
+++ b/cli/src/lib/sessionSearch/turns.spec.ts
@@ -117,6 +117,26 @@ describe('what the person asked, and what they did not', () => {
expect(open?.ask).toBe('now flash it')
})
+ it("keeps only the request from what the Codex app and editors send around it", () => {
+ const turns = new TurnCollector(0)
+ turns.feed([ask('# Files mentioned by the user:\n\n## dial.png: /Users/you/Desktop/dial.png\n\n## My request for Codex:\nwhy does the dial scroll jump?\nit skips two rows')], 0, null)
+ turns.feed([ask('# In app browser:\n- Current page: http://localhost:3000/\n\n## My request for Codex:\nmake the header sticky')], 10, null)
+ turns.feed([ask('# Context from my IDE setup:\n\n## Active file: src/dial.ts\n\n## Open tabs:\n- dial.ts: src/dial.ts\n\n## My request for Codex:\nrename it')], 20, null)
+ // Newer versions head the request `## My request:`, and one message can hold two.
+ turns.feed([ask('# Files mentioned by the user:\n\n## shot.png: /tmp/shot.png\n\n## My request:\nlook at this\n\n# In app browser:\n- Current page: http://localhost:3000/\n\n## My request:\nand this page')], 25, null)
+ turns.feed([ask('# In app browser:\n- Current page: http://localhost:3000/\n\nno request heading, so all of it is the ask')], 28, null)
+ turns.feed([ask('# My plan\n\nno request heading, so all of it is the ask')], 30, null)
+ const { closed, open } = turns.finish()
+ expect(closed.map((turn) => turn.ask)).toEqual([
+ 'why does the dial scroll jump?\nit skips two rows',
+ 'make the header sticky',
+ 'rename it',
+ 'look at this\n\nand this page',
+ '# In app browser:\n- Current page: http://localhost:3000/\n\nno request heading, so all of it is the ask',
+ ])
+ expect(open?.ask).toBe('# My plan\n\nno request heading, so all of it is the ask')
+ })
+
it('counts a hand-back announced twice as one turn', () => {
const turns = new TurnCollector(0)
const report = 'Another Claude session sent a message: the audit is done'
diff --git a/cli/src/lib/sessionSearch/turns.ts b/cli/src/lib/sessionSearch/turns.ts
index 5001fb8fc..55e61e3ff 100644
--- a/cli/src/lib/sessionSearch/turns.ts
+++ b/cli/src/lib/sessionSearch/turns.ts
@@ -71,6 +71,19 @@ const PASTE_TAGS = /<\/?(?:pasted_content|agent-message)\b[^>]*>/g
*/
const AGENT_NOTES = /^Another \w+ session sent a message:[^\S\n]*|That "other \w+ session" is an agent working inside this same session[\s\S]*?permission laundering\.?/gm
+/**
+ * What the person typed, when the Codex app or an editor sent it with context in front: the files
+ * they attached (`# Files mentioned by the user:`), the page open in the app's browser (`# In app
+ * browser:`), the editor's open tabs (`# Context from my IDE setup:`). Each block ends at a
+ * `## My request:` heading (`## My request for Codex:` in older versions), and what follows is the
+ * request. The blocks were not said, so they are not the ask; a message can carry more than one.
+ */
+const CODEX_CONTEXT = /^# (?:Files mentioned by the user|In app browser|Context from my IDE setup):[\s\S]*?^#{1,2} My request(?: for Codex)?:[^\S\n]*\n?/gm
+
+export function personAsk(text: string): string {
+ return text.replace(CODEX_CONTEXT, '')
+}
+
/**
* Text as it is stored and searched: wrappers out, secrets blanked, bounded. Line breaks and each
* line's indentation stay, so a preview can show it as it was written; any other run of spaces is
@@ -238,7 +251,7 @@ export class TurnCollector {
this.draft = {
opener: ask,
turn: this.nextTurn++, offset, at,
- ask: kind === 'person' ? searchableText(ask, ASK_MAX) : '',
+ ask: kind === 'person' ? searchableText(personAsk(ask), ASK_MAX) : '',
answer: kind === 'agent' ? [ask] : [],
answerLength: kind === 'agent' ? ask.length : 0,
tools: [], toolsLength: 0,
diff --git a/docs/research/2026-09-26-session-search.md b/docs/research/2026-09-26-session-search.md
index 2799ecbaf..22184b33f 100644
--- a/docs/research/2026-09-26-session-search.md
+++ b/docs/research/2026-09-26-session-search.md
@@ -323,6 +323,12 @@ every engine that keeps them on this computer. Enter opens one as a harness resu
tidy away). An open one is refused with `SESSION_OPEN_IN_TERMINAL` or
`SESSION_BUSY_IN_TERMINAL` until `takeOver` (`idle`, `now` or `wait`) says how to take it over,
or with `SESSION_OPEN_ELSEWHERE` when an app has it.
+- **Only what was asked.** The Codex app and the editor extensions send a message with context
+ in front of it: the files attached (`# Files mentioned by the user:`), the page open in the app's
+ browser (`# In app browser:`), and the editor's open tabs (`# Context from my IDE setup:`). Each
+ block ends at a `## My request:` heading (`## My request for Codex:` in older versions). The index
+ drops those blocks, so asks, titles and snippets read as the person wrote them. This is schema 11,
+ and the index rebuilds once.
- ChatGPT conversations and Codex cloud tasks are not on disk, so they cannot be found.
- **The welcome page lists them too.** An empty tab shows up to nine rows beside its shortcuts,
numbered like the terminal client's home: the harnesses you were just with and these