* fix(web): replace mermaid bomb-icon error flood with toast notifications
mermaid.render() called without a container leaves orphaned error
elements (with bomb icons) in document.body on parse failures. Clean up
these orphans after every render and show an error toast instead.
* fix(web): address PR review — prevent toast flooding, include error detail, add hook tests
- Add latestRenderId guard in TipTap MermaidNodeView to skip stale
renders, preventing toast spam on every keystroke
- Include mermaid error message in toast description via CustomEvent detail
- Add useMermaidErrorToast hook tests (event listener + cleanup)
* style(web): format mermaid-error-toast test with prettier
* fix(web): include error message in MermaidBlock toast description
* fix(web): fix dock view task-switching regressions
Three bugs caused broken UI when switching tasks in the dock view:
1. Environment key migration was dead code — data stored under fallback
sessionId keys became invisible when the environmentIdBySessionId
mapping was later set, because migrateEnvKeyedData was never called
in production (only in tests via registerSessionEnvironment).
2. Orphaned portals leaked on every fast-path session switch — the
isRestoringLayout guard in setupPortalCleanup blocked portal release
for panels removed during the fast path, accumulating invisible React
trees with live WS subscriptions.
3. Chat panel gap during fast-path transition — old session tab was
removed synchronously but new tab was deferred to a useEffect,
leaving a brief layout gap.
* fix(web): remove superfluous args in test helper
Address CodeQL finding — createSessionSlice only takes `set`, not
`get` and `api`.
* fix(web): add addPanel test assertions and doc comment
Address claude-review blocker: assert that fast-path creates the
session panel with correct id/params, and skips creation when it
already exists. Add doc comment noting syncEnvironmentMapping
requires the combined store draft.
* test(web): add PanelPortalManager.reconcile tests
Export PanelPortalManager class for testability and add tests covering
reconcile removal, no-op, and listener notification paths.
* fix: use dynamic merge-base for git commits to filter main branch commits
When a feature branch is rebased on main, the stored base_commit_sha
becomes outdated. Using git log base_commit..HEAD would include main
branch commits that were merged after the stored base commit.
This fix adds dynamic merge-base calculation using the session's
base_branch (target branch like origin/main). When fetching commits:
- The backend computes git merge-base HEAD target_branch
- This returns only commits not yet merged into the target branch
- Works correctly even after rebases
Changes:
- Extended SessionReader interface with GetSessionBaseBranch method
- Added GetMergeBase to GitOperator for computing merge-base
- Updated git log API to accept target_branch parameter
- Modified wsGitCommits handler to pass target branch for filtering
* fix: update executor_test mock to match new GetGitLog signature
* fix: update remaining mocks to match new GetGitLog signature
* fix: update integration test mock for GetGitLog signature
* fix: address code review feedback
- Use GetOrEnsureExecution in wsGitCommits to recover workspaces after backend restarts
- Fix archive snapshot to use baseBranch for merge-base when baseCommit is empty
- Extended ExecutionLookup interface with GetOrEnsureExecution method
* fix: distinguish not-ready errors from unexpected errors in wsGitCommits
Address CodeRabbit review feedback:
- Use errors.Is() to detect ErrSessionWorkspaceNotReady sentinel error
- Return ready:false gracefully for workspace-not-ready and session-not-ready errors
- Return actual errors for unexpected failures (database errors, etc.)
- Add comprehensive tests for error handling paths
* feat(mcp): add start_agent and local_path params to create_task
Add control over task creation behavior in MCP create_task tool:
- Add start_agent boolean param (default true) to optionally skip
auto-starting an agent when creating tasks
- Add local_path param for specifying local repository folder path
when creating top-level tasks (worktree flow)
- Add repository_id and base_branch params for explicit repo config
- Improve tool description with clear guidance on when to use
parent_id='self' vs creating top-level tasks
- Update backend handler to respect start_agent flag
- Relax description requirement for subtasks when start_agent=false
This fixes the issue where agents creating tasks from plans would
always auto-start immediately and couldn't specify repositories
for top-level tasks.
* test(mcp): add integration tests for source_task_id inheritance paths
Cover the source-task path in resolveTaskRepositories that had no test
coverage at any layer: valid source_task_id inherits repos and missing
source_task_id silently falls through rather than failing.
Co-authored-by: João Salavisa <undefined@users.noreply.github.com>
---------
Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: João Salavisa <undefined@users.noreply.github.com>
* fix(worktree): handle submodules in worktree creation
Repos with git submodules failed during worktree creation when git-crypt
was also present. The `git checkout HEAD -- .` command in
unlockGitCryptAndCheckout() tried to process submodule gitlink entries,
but git resolved their git dirs relative to the worktree-specific git
dir instead of the common dir, causing "not a git repository" errors.
- Detect submodule paths via `git ls-tree -r HEAD` (mode 160000)
- Exclude submodule paths from git-crypt checkout using :(exclude) pathspecs
- Initialize submodules after worktree creation via `git submodule update --init`
(non-fatal — unreachable URLs are logged as warnings)
- Add submodule init to all worktree creation paths (git-crypt and non-git-crypt)
* fix(worktree): address review — recursive submodule init, consistent call sites
- Add --recursive to git submodule update --init for nested submodules
- Call initSubmodules unconditionally in git-crypt path (matching manager.go)
* fix(worktree): restore submodule index entries after git-crypt checkout
The :(exclude) pathspec used to skip submodules during git checkout also
prevents their gitlink entries from being written to the index. This
leaves git status showing them as staged deletions.
After checkout, run git reset HEAD for each excluded submodule path to
copy the gitlink entry from HEAD back into the index.
* test(worktree): add git status assertion to submodule unlock test
Validate that the index reset after :(exclude) checkout leaves no
staged deletions for submodule paths.
* fix(worktree): use literal pathspec for submodule exclusion
Use :(literal,exclude) instead of :(exclude) to prevent glob
metacharacters in submodule paths from being interpreted as patterns.
* fix(worktree): fix initSubmodules docstring to match --recursive flag
* refactor: re-key dockview panel state by environmentId instead of sessionId
- Remove terminal from SESSION_SCOPED_COMPONENTS (uses useEnvironmentSessionId internally)
- Convert ChangesContent and file-editor-panel to useEnvironmentSessionId()
- Re-key sessionCommits store from bySessionId to byEnvironmentId
- Re-key useCumulativeDiff cache by environmentId
- Update WS handler to resolve envKey before invalidating cumulative diff cache
- Update comments across portal manager, session switch, and layout files
* fix: revert useEnvironmentSessionId in file-editor-panel
file-editor is session-scoped and ephemeral — portal is destroyed on
session switch, so useEnvironmentSessionId() has no practical effect.
* fix: address CodeRabbit review comments
- Pass appStore to setupPortalCleanup so terminal tab close still calls
stopUserShell via activeSessionId fallback (entry.sessionId is now
undefined for global panels)
- Add request version guard to useCumulativeDiff to discard stale
responses after environment switches
* fix: scope activeSessionId fallback to terminal only in portal cleanup
vscode is session-scoped and always has entry.sessionId — the
activeSessionId fallback should only apply to terminal (now global).
* fix: migrate stranded env-keyed data on registerSessionEnvironment
When registerSessionEnvironment(sessionId, environmentId) is called,
any data previously stored under the fallback sessionId key is now
migrated to the proper environmentId key. This prevents data from
"vanishing" when selectors start reading by environmentId after the
mapping is registered.
Applies to: sessionCommits, gitStatus, shell outputs/statuses,
userShells.
* fix: extract migrateEnvKeyedData helper to fix lint max-lines
* fix: address CodeRabbit review comments
- Always delete orphaned sessionId key in migrateEnvKeyedData even when
environmentId key already exists (prevents stale accumulation)
- Reset loading state when switching to an envKey with warm cache to
avoid brief spinner flash
* fix: always reset loading on envKey switch in useCumulativeDiff
Prevents stuck loading state on rapid A→B→A env switches where the
stale in-flight response is discarded by version guard but loading
is never reset.
* fix: move sync effect before fetch effect in useCumulativeDiff
React 18 batches effects in declaration order. With the sync effect
after the fetch effect, setLoading(false) from the sync overrode
setLoading(true) from the fetch on cold-cache env switches. Moving
the sync effect first ensures the fetch effect's setLoading(true)
wins the batch.
* test: add migrateEnvKeyedData coverage for registerSessionEnvironment
Tests 4 cases: normal migration, don't-clobber existing data,
no-op when sessionId equals environmentId, and partial sub-key
migration.
* fix: close stale-diff gaps in useCumulativeDiff sync effect
- Bump requestVersionRef on envKey change so in-flight fetches for
the previous envKey are discarded
- Clear loadingState[envKey] so the fetch effect isn't blocked on
re-entry (A→B→A scenario)
* feat: add multi-select and drag-to-move for file tree and changes panel
Add Shift-click range and Ctrl/Cmd-click toggle selection to the file
tree and staged/unstaged changes sections. Includes bulk actions
(delete, stage, unstage, discard), drag-and-drop file moving into
directories, keyboard shortcuts (Escape, Ctrl+A), and E2E tests.
* fix: move bulk action components to file-row to fix max-lines lint
* style: apply prettier formatting to all changed files
* fix: bulk delete all selected items and update anchor on stale shift-click
* fix: address CodeRabbit review comments
- Keep original file-row-* data-testid for backwards compat
- Remove eager onClearSelection from bulk actions (auto-pruned by hook)
- Variant-scope bulk-discard/bulk-unstage test ids
- Remove index.lock deletion from E2E GitHelper retry loop
* fix: fix E2E tests — create files after session open, remove DnD test
- Create files AFTER opening session so WS detects git status changes
- Add proper git env vars (GIT_AUTHOR_NAME, etc.) matching existing tests
- Use element.press("Escape") instead of page keyboard for proper focus
- Remove drag-to-directory test (Playwright dragTo doesn't support HTML5
dataTransfer events needed by our DnD implementation)
* fix: rename E2E task titles to avoid ambiguous 'Changes' tab selector
* fix: make file list focusable for Escape key handler in E2E tests
* fix: improve selection styling and ignore right-clicks in selection handler
- Use text-accent-foreground on selected rows for dark mode readability
- Override child span colors with [&_span]:text-accent-foreground
- Use hover:bg-accent/80 instead of hover:bg-muted on selected items
- Skip selection handling on right-click (button === 2) so context menu
works without clearing multi-selection
* fix: plain click should not select — only Ctrl/Cmd+click and Shift+click
Plain click now clears any selection and performs the original action
(open file / toggle folder / open diff). Selection only happens with
modifier keys. handleClick returns boolean to indicate whether the
click was consumed by selection logic.
* fix: fix multi-select bugs and expand E2E test coverage
Bug fixes:
- Change isSelected from boolean to function prop so children compute
their own selection state (fixes nested file selection)
- Inline TreeNodeRow JSX into TreeNodeItem so ContextMenuTrigger asChild
can attach refs directly (fixes right-click context menu)
- Set lastClickedRef on plain click so shift-click has a valid anchor
- Add click-outside handler to clear selection
E2E tests expanded to 14 file-tree tests + 3 changes-panel tests:
- Ctrl-click select, toggle, multi-select
- Plain click clears selection
- Shift-click range after plain click and ctrl-click anchors
- Directory selection and nested file selection
- Right-click context menu (single + bulk delete)
- Click outside clears selection
- Escape clears selection
* fix: move AlertDialog outside ContextMenu to fix delete action
The AlertDialog wrapping the ContextMenu caused Radix focus management
to intercept context menu item selection, making Delete trigger Rename.
Moving AlertDialog to a sibling of ContextMenu fixes the conflict.
* fix: reorder context menu — Delete first, Rename second
Radix ContextMenu auto-focuses the first item on open, which caused
accidental Rename triggers. Putting Delete first (the more common
action for selection) avoids this.
* fix: don't clear selection when clicking context menu or dialog
The click-outside handler was clearing selection when clicking on
context menu items or confirmation dialog buttons (rendered in portals
outside the tree container). Now skips clearing for elements with
role=menu, role=alertdialog, or role=dialog.
Also extended the bulk delete E2E test to verify both files are
actually removed after confirming the dialog.
* fix: hide file count in delete dialog when folder children not loaded
When a folder hasn't been expanded, its children aren't loaded yet so
countFilesInTree returns 0. Instead of showing "0 files", hide the
count entirely and just show "delete <folder name>".
* fix: show confirmation dialog for bulk discard in changes panel
Bulk discard was calling git.discard() directly, bypassing the
confirmation dialog. Now routes through handleBulkDiscardClick which
opens the DiscardDialog with a bulk message ("discard changes to N
files") before executing.
* fix: address remaining CodeRabbit review comments
- Deduplicate filenames on move: when moving files with identical names
to the same directory, append "(1)", "(2)" etc. to avoid collisions.
Both tree update and rename API calls use the same deduplication.
- Replace void operator with .catch(() => {}) for bulk stage/unstage
to prevent unhandled promise rejections.
- Add document-level dragend listener as safety net to clear stuck drag
state if the element's onDragEnd doesn't fire (Escape, out-of-window).
* test: add unit tests for file tree move deduplication and visible paths
* fix: address all remaining PR review comments
- Move onSelectionChange out of React state updater (side effect fix)
- Stabilize keyboard listener deps (pass callbacks not object)
- Remove unnecessary useMemo in BulkActionBar
- Fix ghost-restore on partial bulk delete (remove all at once)
- Fix blank filename on single-file bulk discard
- Add aria-selected and role=treeitem for accessibility
- Extract computeNextSelection params into object (max-params lint)
* fix: add missing bulk action props to WorkingTreeProps type
WorkingTreeSections referenced onBulkStage, onBulkUnstage, and
onBulkDiscard but WorkingTreeProps Pick didn't include them, causing
a TypeScript build failure.
* fix: address final review comments
- Add unit tests for computeNextSelection (8 tests covering ctrl-click,
shift-click range, stale anchor, reverse range, shift+ctrl extend)
- Extract shared E2E helpers (GitHelper, makeGitEnv, openTaskSession,
createStandardProfile) to e2e/helpers/git-helper.ts
- Fix misleading comment in bulk delete (says "re-insert only failed"
but implementation restores full snapshot)
* fix: use Promise.all for bulk delete to prevent partial rollback
Individual .catch() handlers could restore already-deleted files
if a later delete failed. Now uses Promise.all so rollback only
happens if any delete rejects.
* test: add renderHook tests for useMultiSelect hook behaviors
- Stale-path pruning: items shrink → selected paths auto-pruned
- Plain click: returns false, clears existing selection
- selectAll/clearSelection: work correctly, fire onSelectionChange
- Install @testing-library/react for renderHook support
* fix: handle false returns from onDeleteFile in bulk delete Promise.all
* chore: remove unused @testing-library/react-hooks dependency
* fix(web): recalculate dockview layout after fast-path session switch
The fast path in tryFastSessionSwitch removed ephemeral panels but
never called api.layout() to redistribute column widths, leaving a
gap on the right side of the screen. Both slow-path branches already
make this call.
* test(web): add regression test for fast-path layout call
Verifies that performSessionSwitch calls api.layout() on both the
fast path and slow path, preventing the squished-layout regression.
* test(web): cover saved-layout fast path branch
* fix(web): replace no-explicit-any cast in test
* fix(web): fix test isolation with mockReturnValueOnce
Use mockReturnValueOnce and clearAllMocks for proper test isolation
between fast-path and slow-path test cases.
* test(web): fix mock shape to match LayoutGroupIds type
When creating a worktree from a remote-tracking ref (e.g. origin/feature/foo),
git automatically sets the new branch's upstream to that ref. This caused new
task branches to incorrectly track the original remote branch instead of
starting with no upstream.
Add -c branch.autoSetupMerge=false to gitAddWorktree and
gitAddWorktreeWithGitCrypt. The explicit CheckoutBranch flow (PR reviews)
is unaffected — it sets upstream via setUpstreamIfExists after creation.
Commit 348ee25e disabled the branch selector for local executors and
also blanked the branch value at submit time. This caused the backend
to fall back to Repository.DefaultBranch, which may contain whatever
branch was checked out at repo discovery time rather than "main".
Keep the selector disabled (cosmetic) but send the auto-selected
branch value so the backend uses the correct base branch.