diff --git a/CHANGELOG.md b/CHANGELOG.md index f9afaa6c..0234cea1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ - **The Capacity Dock card and the popover quota rows no longer print a pace verdict under each window.** The "On pace" / "Lasts until reset" caption from #1314 added a third line to every window cell and made the card read as clutter; the cells are back to percent, label and countdown, up to three windows share one row again with a fourth wrapping to a second, and the pace math still feeds the tooltip and the agent-tab card. ### Fixed +- **OpenCode sessions stay counted after you archive them in the app.** The provider's discovery query and its recursive subtree walks all filtered on `time_archived IS NULL`, with no stated reason, so archiving a session in OpenCode made it vanish from the sessions list, from per-project views, and from any cache rebuild — and on a fresh parse the lifetime totals themselves dropped. OpenCode's archive is organizational: the rows stay in the database, so the filters are gone and archived roots and children parse like any other session (verified against a copy of a real OpenCode database: three archived roots stopped exactly three sessions and 656 calls from counting). Kilo Code shares this parser and is covered by the same change. Both providers' parse versions move so a warm cache re-derives: an archived root came back on its own (it was evicted as an undiscovered source), but a root whose child was archived stayed a present, unchanged source and kept serving the parse that dropped the child. Fixes #1362. - **The startup splash flame floats on the dark canvas again instead of on a grey checkerboard.** Re-encoding `splash-loader.webm` to halve its size dropped the VP9 alpha plane while leaving the container's `alpha_mode` flag set, so the checkerboard the source art carries under its transparent pixels became visible. The original alpha-carrying file is restored; the file is 2.5 MB again, because the same CRF with alpha preserved encodes no smaller. - **The macOS app icon is the flame at every size, not a bordered thumbnail in Finder lists and System Settings.** electron-builder generated all ten icns sizes by downsampling one 1024 px master whose dark-bodied, binary-textured flame covers only the middle of its tile; below 64 px that collapses into a brown square. The bundle now ships a hand-built `icon.icns` whose 16, 32 and 64 px entries carry a solid orange flame on the same dark rounded tile, with 128 px and above unchanged from the master. - **A Warp database macOS will not let CodeBurn open no longer freezes the whole run.** Warp keeps its SQLite file inside a Group Container, which macOS puts behind Full Disk Access. Without that permission, and with no way to show the prompt, the open never returns: `codeburn status` printed nothing at all, and the resident `serve` process the desktop and menubar talk to hung with it, so every surface went blank with no error. Any database under `~/Library/Group Containers` is now opened first in a short-lived child process that can be killed; if that child does not come back within three seconds, or is refused, the database is skipped, one line on stderr says so and names Full Disk Access as the fix, and Warp is reported as a provider whose discovery failed rather than one with no sessions, so the rest of the run keeps its own numbers. The check is remembered for a minute, so the resident process does not repeat it per request and granting access is picked up on the next refresh without a restart. diff --git a/docs/providers/opencode.md b/docs/providers/opencode.md index fbb5faff..f297b628 100644 --- a/docs/providers/opencode.md +++ b/docs/providers/opencode.md @@ -54,8 +54,9 @@ Per `:`. - **Schema validation is loud.** When a required table is missing, the parser logs an actionable warning telling the user which table is gone and what version of OpenCode it expects. This is the right behavior; do not silently swallow these. - Source paths are encoded as `:`. - Discovery only emits root sessions (`parent_id IS NULL`) to avoid double - counting. Parsing a root session walks the unarchived `session.parent_id` - subtree, so child and grandchild agent sessions contribute their message, + counting. Parsing a root session walks the whole `session.parent_id` subtree, + archived children included — OpenCode's archive is organizational, the rows + stay — so child and grandchild agent sessions contribute their message, token, and tool usage back to the root session. - Each message's `parts` are indexed; preserving the order matters for reasoning-token correctness. - Tokens are reported across `input`, `output`, `reasoning`, `cache.read`, and `cache.write`. Anthropic semantics. diff --git a/src/providers/sqlite-session-parser.ts b/src/providers/sqlite-session-parser.ts index 67a65ab1..d9d6bbfb 100644 --- a/src/providers/sqlite-session-parser.ts +++ b/src/providers/sqlite-session-parser.ts @@ -268,7 +268,6 @@ export function createSqliteSessionParser( SELECT child.id FROM session_v2 child JOIN session_tree parent ON child.parent_id = parent.id - WHERE child.time_archived IS NULL ) SELECT session_id, id, type, seq, time_created, CAST(data AS BLOB) AS data FROM session_message @@ -287,7 +286,6 @@ export function createSqliteSessionParser( SELECT child.id FROM session child JOIN session_tree parent ON child.parent_id = parent.id - WHERE child.time_archived IS NULL ) SELECT session_id, id, time_created, CAST(data AS BLOB) AS data FROM message @@ -303,7 +301,6 @@ export function createSqliteSessionParser( SELECT child.id FROM session child JOIN session_tree parent ON child.parent_id = parent.id - WHERE child.time_archived IS NULL ) SELECT message_id, CAST(data AS BLOB) AS data FROM part @@ -462,7 +459,7 @@ export async function discoverSqliteSessions( const table = generation === 'v2' ? 'session_v2' : 'session' const rows = db.query( `SELECT id, CAST(directory AS BLOB) AS directory, CAST(title AS BLOB) AS title, time_created - FROM ${table} WHERE time_archived IS NULL AND parent_id IS NULL ORDER BY time_created DESC`, + FROM ${table} WHERE parent_id IS NULL ORDER BY time_created DESC`, ) for (const row of rows) { diff --git a/src/session-cache.ts b/src/session-cache.ts index c748d4c8..e491fe9b 100644 --- a/src/session-cache.ts +++ b/src/session-cache.ts @@ -436,7 +436,13 @@ export const PROVIDER_PARSE_VERSIONS: Record = { pi: 'cwd-project-path-v1-project-group-by-abs-v1', // project-group-by-abs-v1: shared Pi/OMP serve grouping uses abs identity. omp: 'nested-agent-v1-reported-cost-v2-cwd-project-path-v1-project-group-by-abs-v1', - opencode: 'session-model-v1', + // archived-subtree-v1 (#1362): the subtree walk no longer filters + // `time_archived IS NULL`. An archived ROOT self-heals — it was evicted as an + // undiscovered non-durable source and comes back new — but a root whose CHILD + // was archived stays a present, unchanged source: every opencode entry + // fingerprints the same database file, so a warm cache keeps serving the + // parse that dropped the child's calls until the database is written again. + opencode: 'session-model-v1-archived-subtree-v1', quickdesk: 'emf-sqlite-v2-est-cost', // session-lineage-capture-v1: SessionLineage (CB-1, slice 1) is now carried // on the cached file for every kimicode wire. Child evidence is the @@ -447,7 +453,8 @@ export const PROVIDER_PARSE_VERSIONS: Record = { // additive; every cost / token / call total is byte-identical to a build // that omits it. kimicode: 'wire-usage-v1-est-cost-session-lineage-capture-v1', - 'kilo-code': 'worktree-project-grouping-v1-session-model-v1', + // archived-subtree-v1: KiloCode shares the SQLite parser and the same schema. + 'kilo-code': 'worktree-project-grouping-v1-session-model-v1-archived-subtree-v1', 'roo-code': 'worktree-project-grouping-v1', warp: 'worktree-project-grouping-v1-est-cost', antigravity: 'worktree-project-grouping-v6', diff --git a/tests/providers/opencode.test.ts b/tests/providers/opencode.test.ts index 79a0217b..2733e863 100644 --- a/tests/providers/opencode.test.ts +++ b/tests/providers/opencode.test.ts @@ -183,7 +183,7 @@ skipUnlessSqlite('opencode provider - session discovery', () => { expect(sessions[0]!.path).toBe(`${dbPath}:sess-1`) }) - it('excludes archived sessions', async () => { + it('discovers archived sessions (#1362: the archive is organizational, the rows stay)', async () => { const dbPath = createTestDb(tmpDir) withTestDb(dbPath, (db) => { insertSession(db, 'sess-archived', { archived: 1700000001000 }) @@ -191,7 +191,8 @@ skipUnlessSqlite('opencode provider - session discovery', () => { const provider = createOpenCodeProvider(tmpDir) const sessions = await provider.discoverSessions() - expect(sessions).toHaveLength(0) + expect(sessions).toHaveLength(1) + expect(sessions[0]!.path).toBe(`${dbPath}:sess-archived`) }) it('excludes child sessions', async () => { @@ -757,7 +758,7 @@ skipUnlessSqlite('opencode provider - session parsing', () => { expect(calls[2]!.bashCommands).toEqual(['npm']) }) - it('does not include archived child sessions in the root subtree', async () => { + it('includes archived child sessions in the root subtree (#1362)', async () => { const dbPath = createTestDb(tmpDir) withTestDb(dbPath, (db) => { insertSession(db, 'root') @@ -780,8 +781,9 @@ skipUnlessSqlite('opencode provider - session parsing', () => { const calls = await collectCalls(createOpenCodeProvider(tmpDir), dbPath, 'root') - expect(calls).toHaveLength(1) + expect(calls).toHaveLength(2) expect(calls[0]!.deduplicationKey).toBe('opencode:root:msg-root-assistant') + expect(calls[1]!.deduplicationKey).toBe('opencode:archived-child:msg-child-assistant') }) it('joins multiple text parts in user messages', async () => { @@ -1208,6 +1210,23 @@ skipUnlessSqlite('opencode provider - v2 generation (session_v2 + session_messag expect(calls[0]!.inputTokens).toBe(7) }) + it('walks archived v2 child sessions too (#1362: the archive is organizational)', async () => { + const dbPath = createV2TestDb(tmpDir) + withTestDb(dbPath, (db) => { + insertV2Session(db, 'ses_parent') + insertV2Session(db, 'ses_archived_child', { parentId: 'ses_parent', archived: 1700000009000 }) + insertV2Message(db, 'msg_ac1', 'ses_archived_child', 'assistant', 1, 1700000000500, { + model: { id: 'm', providerID: 'opencode' }, + content: [{ type: 'text', text: 'archived child work' }], + tokens: { input: 11, output: 4, reasoning: 0, cache: { read: 0, write: 0 } }, + }) + }) + + const calls = await collectCalls(createOpenCodeProvider(tmpDir), dbPath, 'ses_parent') + expect(calls).toHaveLength(1) + expect(calls[0]!.inputTokens).toBe(11) + }) + it('prefers the v2 generation on an upgraded database with both table sets', async () => { const dbPath = createV2TestDb(tmpDir, { withLegacy: true }) withTestDb(dbPath, (db) => {