Skip to content

Commit 39a5a42

Browse files
committed
fix: respect DEEPLAKE_CAPTURE=false across all hooks
session-end and codex/stop now skip wiki worker when capture is disabled. session-start-setup always runs table sync (ensureTable/ensureSessionsTable) but skips placeholder creation when DEEPLAKE_CAPTURE=false. Previously the entire setup block was skipped, which broke table sync and caused stale query results in the fast path.
1 parent 5927891 commit 39a5a42

File tree

8 files changed

+28
-7
lines changed

8 files changed

+28
-7
lines changed

claude-code/bundle/session-end.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ LENGTH LIMIT: Keep the total summary under 4000 characters. Be dense and concise
147147
async function main() {
148148
if (process.env.DEEPLAKE_WIKI_WORKER === "1")
149149
return;
150+
if (process.env.DEEPLAKE_CAPTURE === "false")
151+
return;
150152
const input = await readStdin();
151153
const sessionId = input.session_id;
152154
const cwd = input.cwd ?? "";

claude-code/bundle/session-start-setup.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,14 +394,17 @@ async function main() {
394394
} catch {
395395
}
396396
}
397+
const captureEnabled = process.env.DEEPLAKE_CAPTURE !== "false";
397398
if (input.session_id) {
398399
try {
399400
const config = loadConfig();
400401
if (config) {
401402
const api = new DeeplakeApi(config.token, config.apiUrl, config.orgId, config.workspaceId, config.tableName);
402403
await api.ensureTable();
403404
await api.ensureSessionsTable(config.sessionsTableName);
404-
await createPlaceholder(api, config.tableName, input.session_id, input.cwd ?? "", config.userName, config.orgName, config.workspaceId);
405+
if (captureEnabled) {
406+
await createPlaceholder(api, config.tableName, input.session_id, input.cwd ?? "", config.userName, config.orgName, config.workspaceId);
407+
}
405408
log3("setup complete");
406409
}
407410
} catch (e) {

codex/bundle/session-start-setup.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,14 +398,17 @@ async function main() {
398398
} catch {
399399
}
400400
}
401+
const captureEnabled = process.env.DEEPLAKE_CAPTURE !== "false";
401402
if (input.session_id) {
402403
try {
403404
const config = loadConfig();
404405
if (config) {
405406
const api = new DeeplakeApi(config.token, config.apiUrl, config.orgId, config.workspaceId, config.tableName);
406407
await api.ensureTable();
407408
await api.ensureSessionsTable(config.sessionsTableName);
408-
await createPlaceholder(api, config.tableName, input.session_id, input.cwd ?? "", config.userName, config.orgName, config.workspaceId);
409+
if (captureEnabled) {
410+
await createPlaceholder(api, config.tableName, input.session_id, input.cwd ?? "", config.userName, config.orgName, config.workspaceId);
411+
}
409412
log3("setup complete");
410413
}
411414
} catch (e) {

codex/bundle/stop.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,8 @@ async function main() {
420420
log3(`capture failed: ${e.message}`);
421421
}
422422
}
423+
if (!CAPTURE)
424+
return;
423425
const cwd = input.cwd ?? "";
424426
const memoryTable = config.tableName;
425427
const sessionsTable = config.sessionsTableName;

src/hooks/codex/session-start-setup.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,18 @@ async function main(): Promise<void> {
133133
} catch { /* non-fatal */ }
134134
}
135135

136-
// Table setup + placeholder
136+
// Table setup + sync — always sync, only skip placeholder when capture disabled
137+
const captureEnabled = process.env.DEEPLAKE_CAPTURE !== "false";
137138
if (input.session_id) {
138139
try {
139140
const config = loadConfig();
140141
if (config) {
141142
const api = new DeeplakeApi(config.token, config.apiUrl, config.orgId, config.workspaceId, config.tableName);
142143
await api.ensureTable();
143144
await api.ensureSessionsTable(config.sessionsTableName);
144-
await createPlaceholder(api, config.tableName, input.session_id, input.cwd ?? "", config.userName, config.orgName, config.workspaceId);
145+
if (captureEnabled) {
146+
await createPlaceholder(api, config.tableName, input.session_id, input.cwd ?? "", config.userName, config.orgName, config.workspaceId);
147+
}
145148
log("setup complete");
146149
}
147150
} catch (e: any) {

src/hooks/codex/stop.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ async function main(): Promise<void> {
189189
}
190190
}
191191

192-
// 2. Spawn wiki worker (session summary generation)
192+
// 2. Spawn wiki worker (session summary generation) — skip when capture disabled
193+
if (!CAPTURE) return;
193194
const cwd = input.cwd ?? "";
194195
const memoryTable = config.tableName;
195196
const sessionsTable = config.sessionsTableName;

src/hooks/session-end.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ LENGTH LIMIT: Keep the total summary under 4000 characters. Be dense and concise
100100
async function main(): Promise<void> {
101101
// Skip if this is a sub-session spawned by the wiki worker itself
102102
if (process.env.DEEPLAKE_WIKI_WORKER === "1") return;
103+
// Skip when capture is disabled (e.g. benchmark runs)
104+
if (process.env.DEEPLAKE_CAPTURE === "false") return;
103105

104106
const input = await readStdin<StopInput>();
105107
const sessionId = input.session_id;

src/hooks/session-start-setup.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,20 @@ async function main(): Promise<void> {
124124
} catch { /* non-fatal */ }
125125
}
126126

127-
// Table setup + placeholder (fire-and-forget, async hook)
127+
// Table setup + sync (fire-and-forget, async hook)
128+
// Always sync tables so queries return fresh data.
129+
// Only skip the placeholder when capture is disabled (e.g. benchmark runs).
130+
const captureEnabled = process.env.DEEPLAKE_CAPTURE !== "false";
128131
if (input.session_id) {
129132
try {
130133
const config = loadConfig();
131134
if (config) {
132135
const api = new DeeplakeApi(config.token, config.apiUrl, config.orgId, config.workspaceId, config.tableName);
133136
await api.ensureTable();
134137
await api.ensureSessionsTable(config.sessionsTableName);
135-
await createPlaceholder(api, config.tableName, input.session_id, input.cwd ?? "", config.userName, config.orgName, config.workspaceId);
138+
if (captureEnabled) {
139+
await createPlaceholder(api, config.tableName, input.session_id, input.cwd ?? "", config.userName, config.orgName, config.workspaceId);
140+
}
136141
log("setup complete");
137142
}
138143
} catch (e: any) {

0 commit comments

Comments
 (0)