Files
kandev/apps/backend/internal
João Salavisa eee547d891 refactor(handlers): use GetOrEnsureExecution for workspace ops (#786)
* refactor(handlers): use GetOrEnsureExecution for workspace ops

Per CLAUDE.md, workspace-oriented handlers should use GetOrEnsureExecution
so they survive backend restarts. Two git ops in this file (wsGitCommits,
wsCumulativeDiff) already followed this pattern; the shared helper and the
shell.subscribe handler did not.

Changes:
- git_handlers.getAgentCtlClient: now takes ctx and uses GetOrEnsureExecution.
  Propagates to all 14 git ops routing through the helper (pull, push, rebase,
  merge, abort, commit, stage, unstage, discard, createPR, revertCommit,
  renameBranch, reset, commitDiff).
- shell_handlers.wsShellSubscribe: matches wsShellStatus in the same file.

Left alone (intentional):
- shell_handlers.wsShellInput: the 5s workspace-stream wait is too short to
  absorb a cold-start of agentctl, so we still require an existing execution.
- passthrough_handlers: stdin/resize require a live agent process per the rule.
- git_handlers post-success/failure callbacks: just look up TaskID; ensuring
  would be wasteful.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* test(handlers): cover wsShellSubscribe no-instance path

Mirrors TestWsShellInput_NoInstanceFound. Closes a coverage gap flagged in
PR review — the handler was switched to GetOrEnsureExecution but had no
direct tests for the lookup-failure path.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

---------

Co-authored-by: Kandev Agent <agent@kandev.dev>
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-02 22:57:13 +01:00
..