Skip to content

refactor(cli): drop redundant explicit Effect.ensuring(store.dispose)#25503

Merged
kitlangton merged 1 commit intodevfrom
kit/cli-cleanup-explicit-dispose
May 3, 2026
Merged

refactor(cli): drop redundant explicit Effect.ensuring(store.dispose)#25503
kitlangton merged 1 commit intodevfrom
kit/cli-cleanup-explicit-dispose

Conversation

@kitlangton
Copy link
Copy Markdown
Contributor

Summary

#25481 folded auto-dispose into `effectCmd` itself. The per-handler `Effect.ensuring(store.dispose(ctx))` calls (and the `InstanceRef`/`InstanceStore.Service` yields that exist solely to set up that wrap) are now redundant — drop them across all converted commands.

Net change: 11 files, -111 lines.

Files

  • `import.ts`, `export.ts`, `stats.ts`, `session.ts` (delete + list)
  • `debug/config.ts`, `skill.ts`, `snapshot.ts` (×3), `lsp.ts` (×3), `ripgrep.ts` (×3), `file.ts` (×5), `agent.ts`

For commands where `ctx` was ONLY used for `store.dispose(ctx)`: drops the `InstanceRef` yield + null check + `InstanceStore.Service` yield + unused imports.

For commands using `ctx` for other purposes (`ctx.project.id` in import/stats, `ctx.directory` in ripgrep, full `ctx` in debug/agent): keeps the `InstanceRef` yield but drops the `store` yield and the explicit `Effect.ensuring` wrap.

Behavior preservation

Exact. `disposeEntry` is idempotent: the second auto-dispose call hits `if (cache.get(directory) !== entry) return false` and skips `disposeContext` — already proven during the #25481 review and verified by smoke tests.

Test plan

  • `bun run typecheck`
  • `bun run test test/cli/` — 137 pass
  • Smoke: `session list --max-count 2` → table with 2 rows
  • Smoke: `debug skill` → skill JSON
  • Smoke: `session delete bogus-id` → `Error: Session not found: bogus-id` exit 1

#25481 folded auto-dispose into effectCmd, so the per-handler
Effect.ensuring(store.dispose(ctx)) calls are now redundant (idempotent
double-dispose). Drop them across all converted commands.

Files:
- import.ts, export.ts, stats.ts, session.ts (delete + list)
- debug/config.ts, skill.ts, snapshot.ts (×3), lsp.ts (×3),
  ripgrep.ts (×3), file.ts (×5), agent.ts

For commands where ctx was ONLY used for dispose, drops the InstanceRef
yield + null check + InstanceStore.Service yield + unused imports too.
For commands using ctx for other purposes (project.id, directory),
keeps the InstanceRef yield but drops everything else.

Behavior preserved exactly — disposeEntry is idempotent (cache.get
returns mismatched entry on the second call and skips disposeContext).
@kitlangton kitlangton merged commit 68b3448 into dev May 3, 2026
12 checks passed
@kitlangton kitlangton deleted the kit/cli-cleanup-explicit-dispose branch May 3, 2026 00:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant