Skip to content

fix(dispatch): create new agent in focused lane's project in Tiled Dispatch (#266) - #267

Merged
Juliusolsson05 merged 1 commit into
mainfrom
fix/266-tiled-dispatch-new-agent-project
Jun 7, 2026
Merged

Juliusolsson05 merged 1 commit into
mainfrom
fix/266-tiled-dispatch-new-agent-project

Conversation

@Juliusolsson05

Copy link
Copy Markdown
Owner

Closes #266.

Problem

In Tiled (stacked) Dispatch, creating a new agent filed it under the wrong project — the stale active tab (the "final"/last project) instead of the project shown in the focused lane the user is commanding. Classic single-view Dispatch was unaffected.

Regression from the Tiled Dispatch PR #264 (issue #248): the PR added a new selection surface (lanes) but the new-agent spawn path was never taught to read the focused lane.

Root cause

createDetachedDispatchAgent and splitFocused (hook/actions/pane.ts) resolved the target from two fields:

  • cwd ← dispatchMode.focusedSessionId
  • projectTabId ← activeTabId

These agree in classic Dispatch because focusDispatchSession syncs both. In Tiled Dispatch, lane focus/selection (setTiledFocusedLane / setTiledLaneSession) writes only tiled.focusedLane and lanes[].selectedSessionId — never the classic focus fields. So the spawn path fell back to the stale active tab.

Fix

  • New selector resolveDispatchSpawnTarget(state) resolves { tabId, cwdSessionId, laneIndex } from a single source: the focused lane in Tiled mode, the focused session in classic mode. cwd and projectTab now always come from the same project.
  • Both spawn actions use it; a shared applyDispatchSpawnFocus helper places the new agent into the focused lane so it appears where the user is looking (classic behavior: it becomes the single focus).
  • Empty focused lane falls back to classic focus / active tab but keeps targeting the focused lane for placement.

Tests

  • New dispatchSelectors.test.ts (4 cases) including the regression: focused lane shows project B while activeTabId/classic focus point at project A → target resolves to B, lane 1.
  • Full unit project green (7 tests). tsc -p tsconfig.web.json introduces no new errors (pre-existing TS6305 stale-build-artifact noise only).

Verification notes

Verified via unit tests and typecheck. Not yet exercised by launching the Electron app end-to-end.

🤖 Generated with Claude Code

…spatch (#266)

In Tiled Dispatch, creating a new agent filed it under the stale active
tab (the "final"/last project) instead of the project shown in the
focused lane the user is commanding. Classic Dispatch was unaffected.

Root cause: the spawn actions `createDetachedDispatchAgent` and
`splitFocused` read cwd from `dispatchMode.focusedSessionId` but the
project tab from `activeTabId`. Those agree in classic Dispatch
(focusDispatchSession syncs both) but DIVERGE in Tiled Dispatch, whose
lane focus/selection (setTiledFocusedLane / setTiledLaneSession) writes
only `tiled.focusedLane` / `lanes[].selectedSessionId` and never the
classic focus fields. So the spawn path was blind to the focused lane.

Fix: add `resolveDispatchSpawnTarget`, a single selector that resolves
the spawn target (project tab + cwd source + lane) from the focused lane
in Tiled mode and the focused session in classic mode — keeping cwd and
projectTab on the SAME project for both surfaces. New agents now also
take over the focused lane so they appear where the user is looking.

Adds unit coverage for the selector, including the regression case where
the focused lane's project differs from the active tab.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dispatch: new agent created in wrong project (active tab) instead of focused lane in Tiled Dispatch

1 participant