Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

fix(ci): hermetic opencode plugin test + swallowed post-shutdown usage polls

enesb078b05c5347
diff --git a/src/core/agents/hooks/opencode.test.ts b/src/core/agents/hooks/opencode.test.ts
index 0c587fd5d..a016b0285 100644
--- a/src/core/agents/hooks/opencode.test.ts
+++ b/src/core/agents/hooks/opencode.test.ts
@@ -15,8 +15,14 @@ let tmp: string
beforeEach(() => {
tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'nt-oc-'))
vi.spyOn(os, 'homedir').mockReturnValue(tmp)
+ // CI runners export XDG_CONFIG_HOME (GitHub Actions: /home/runner/.config), which wins
+ // over the mocked homedir in opencodeConfigDir() — the installer then writes outside the
+ // temp dir and every read here misses. Clear it so the homedir fallback is what's tested;
+ // the XDG describe block below stubs its own value on top.
+ vi.stubEnv('XDG_CONFIG_HOME', '')
})
afterEach(() => {
+ vi.unstubAllEnvs()
vi.restoreAllMocks()
fs.rmSync(tmp, { recursive: true, force: true })
})
diff --git a/src/core/usage/usage-service.ts b/src/core/usage/usage-service.ts
index 86b418d72..eb6956bdf 100644
--- a/src/core/usage/usage-service.ts
+++ b/src/core/usage/usage-service.ts
@@ -346,14 +346,17 @@ export function startUsageService(opts: UsageServiceOptions = {}): UsageService
// still fronts the whole sweep.
const pollAll = (): void => {
if (!shouldPoll()) return
- void run()
+ // Fire-and-forget: a poll that lands after shutdown (or a test's platform reset) throws
+ // from platform()-dependent fetch paths — in an un-awaited chain that is an unhandled
+ // rejection, not a signal (same hardening as push()'s broadcast).
+ void run().catch(() => {})
let ids: string[] = []
try {
ids = opts.localAccounts?.() ?? []
} catch {
ids = [] // a throwing provider must never break the poll
}
- for (const id of ids) if (id) void run(id)
+ for (const id of ids) if (id) void run(id).catch(() => {})
}
// The warm-up fetch goes through the same gate as the poll: it IS a poll, just the first one.
@@ -369,7 +372,7 @@ export function startUsageService(opts: UsageServiceOptions = {}): UsageService
fetch: (accountId?: string) => run(accountId),
refresh: (accountId?: string) => run(accountId),
refreshIfStale: () => {
- if (Date.now() - (lastFetchAt.get('') ?? 0) >= REFETCH_DEBOUNCE_MS) void run()
+ if (Date.now() - (lastFetchAt.get('') ?? 0) >= REFETCH_DEBOUNCE_MS) void run().catch(() => {})
},
snapshot: () =>
// System account (key '') first, then managed accounts in insertion order.