Repository navigation
fix(dispatch): create new agent in focused lane's project in Tiled Dispatch (#266) - #267
Merged
Merged
Conversation
…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>
This was referenced Jun 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
createDetachedDispatchAgentandsplitFocused(hook/actions/pane.ts) resolved the target from two fields:dispatchMode.focusedSessionIdactiveTabIdThese agree in classic Dispatch because
focusDispatchSessionsyncs both. In Tiled Dispatch, lane focus/selection (setTiledFocusedLane/setTiledLaneSession) writes onlytiled.focusedLaneandlanes[].selectedSessionId— never the classic focus fields. So the spawn path fell back to the stale active tab.Fix
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.applyDispatchSpawnFocushelper places the new agent into the focused lane so it appears where the user is looking (classic behavior: it becomes the single focus).Tests
dispatchSelectors.test.ts(4 cases) including the regression: focused lane shows project B whileactiveTabId/classic focus point at project A → target resolves to B, lane 1.unitproject green (7 tests).tsc -p tsconfig.web.jsonintroduces no new errors (pre-existingTS6305stale-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