From 627501673a4df40708e4b9e7384cf5f9e850860a Mon Sep 17 00:00:00 2001 From: Emergency Self-Construct Date: Mon, 7 Sep 2026 18:52:24 +0000 Subject: [PATCH] fix(cli): list sessions across all projects instead of crashing --- .changeset/fix-session-list-all.md | 5 +++++ packages/opencode/src/cli/cmd/session.ts | 2 +- .../opencode/test/cli/smokes/read-only.test.ts | 16 ++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 .changeset/fix-session-list-all.md diff --git a/.changeset/fix-session-list-all.md b/.changeset/fix-session-list-all.md new file mode 100644 index 000000000000..e02b898980c8 --- /dev/null +++ b/.changeset/fix-session-list-all.md @@ -0,0 +1,5 @@ +--- +"@kilocode/cli": patch +--- + +Fix `kilo session list --all` crashing with "undefined is not an object" instead of listing sessions across all projects. diff --git a/packages/opencode/src/cli/cmd/session.ts b/packages/opencode/src/cli/cmd/session.ts index d52ae1bff850..e4c5c5cc7054 100644 --- a/packages/opencode/src/cli/cmd/session.ts +++ b/packages/opencode/src/cli/cmd/session.ts @@ -99,7 +99,7 @@ export const SessionListCommand = effectCmd({ handler: Effect.fn("Cli.session.list")(function* (args) { // kilocode_change start const sessions = args.all - ? [...Session.listGlobal({ roots: true, limit: args.maxCount, search: args.search })] + ? yield* Session.Service.use((svc) => svc.listGlobal({ roots: true, limit: args.maxCount, search: args.search })) : yield* Session.Service.use((svc) => svc.list({ roots: true, limit: args.maxCount, search: args.search })) // kilocode_change end diff --git a/packages/opencode/test/cli/smokes/read-only.test.ts b/packages/opencode/test/cli/smokes/read-only.test.ts index e9ba04e9bc58..0224e4f09176 100644 --- a/packages/opencode/test/cli/smokes/read-only.test.ts +++ b/packages/opencode/test/cli/smokes/read-only.test.ts @@ -87,6 +87,22 @@ describe("opencode read-only commands (smoke)", () => { 60_000, ) + // kilocode_change start + // `session list --all` lists sessions across all projects via the global + // listing path (KiloSession.listGlobal). Regression: the handler used to + // spread the Effect returned by Session.listGlobal instead of yielding it, + // crashing the formatter with "undefined is not an object". + cliIt.live( + "session list --all: exits 0", + ({ opencode }) => + Effect.gen(function* () { + const r = yield* opencode.spawn(["session", "list", "--all"]) + opencode.expectExit(r, 0, "session list --all") + }), + 60_000, + ) + // kilocode_change end + // `stats` aggregates token usage from the session DB. Empty DB → all zeros. cliIt.live( "stats: exits 0",