fix(tui): remove disposable query index on exit
This commit is contained in:
@@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { randomUUID } from 'node:crypto'
|
import { randomUUID } from 'node:crypto'
|
||||||
|
import { rm } from 'node:fs/promises'
|
||||||
import { join, resolve } from 'node:path'
|
import { join, resolve } from 'node:path'
|
||||||
import { tmpdir } from 'node:os'
|
import { tmpdir } from 'node:os'
|
||||||
import { fileURLToPath } from 'node:url'
|
import { fileURLToPath } from 'node:url'
|
||||||
@@ -226,6 +227,7 @@ export async function runTui(
|
|||||||
? loadPersonalPatches(NAME) ?? []
|
? loadPersonalPatches(NAME) ?? []
|
||||||
: loadOverlayPatches(NAME, resolveConfigPath(resolve(config), undefined)),
|
: loadOverlayPatches(NAME, resolveConfigPath(resolve(config), undefined)),
|
||||||
]
|
]
|
||||||
|
const queryIndexPath = join(tmpdir(), SESSION_QUERY_DB)
|
||||||
const ctx = await boot(
|
const ctx = await boot(
|
||||||
NAME,
|
NAME,
|
||||||
replaceTree ? resolveConfigPath(resolve(configReplace), undefined) : BASE_CONFIG,
|
replaceTree ? resolveConfigPath(resolve(configReplace), undefined) : BASE_CONFIG,
|
||||||
@@ -246,7 +248,14 @@ export async function runTui(
|
|||||||
hostCtx.provide(CONFIGURED_AGENT_IDENTITIES_KEY, { [MAIN_AGENT_ID]: identity })
|
hostCtx.provide(CONFIGURED_AGENT_IDENTITIES_KEY, { [MAIN_AGENT_ID]: identity })
|
||||||
// The query database is a disposable derived index with single-process
|
// The query database is a disposable derived index with single-process
|
||||||
// ownership. Keep it process-local while it indexes the shared logs.
|
// ownership. Keep it process-local while it indexes the shared logs.
|
||||||
hostCtx.provide(SESSION_QUERY_SQLITE_PATH_KEY, join(tmpdir(), SESSION_QUERY_DB))
|
hostCtx.provide(SESSION_QUERY_SQLITE_PATH_KEY, queryIndexPath)
|
||||||
|
hostCtx.effect(() => async () => {
|
||||||
|
await Promise.all([
|
||||||
|
rm(queryIndexPath, { force: true }),
|
||||||
|
rm(`${queryIndexPath}-wal`, { force: true }),
|
||||||
|
rm(`${queryIndexPath}-shm`, { force: true }),
|
||||||
|
])
|
||||||
|
}, 'launcherSessionQueryPath.cleanup')
|
||||||
if (resumeHost !== undefined) hostCtx.provide('tuiResumeHost', resumeHost)
|
if (resumeHost !== undefined) hostCtx.provide('tuiResumeHost', resumeHost)
|
||||||
// Seed the first turn only for a fresh session, so resuming never
|
// Seed the first turn only for a fresh session, so resuming never
|
||||||
// re-invokes the skill.
|
// re-invokes the skill.
|
||||||
|
|||||||
Reference in New Issue
Block a user