fix(tasks): restore focus to the last used region on task re-entry#2931
Open
kchung wants to merge 2 commits into
Open
fix(tasks): restore focus to the last used region on task re-entry#2931kchung wants to merge 2 commits into
kchung wants to merge 2 commits into
Conversation
Task views now remember whether the main panes or the terminal drawer owned focus and restore that region when the task becomes active again, instead of the drawer terminal always winning the autofocus race. Autofocus effects gate on the remembered region and skip via shouldSkipAutofocus when the user is already in a typing surface in the same region, so passive region flips never steal focus. Stale snapshots with a closed drawer but a 'bottom' region normalize back to 'main'. Fixes generalaction#2930 (switching back to a task always focuses the terminal drawer) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
kchung
marked this pull request as ready for review
July 20, 2026 22:14
Contributor
Greptile SummaryThis PR restores the last focused task region when users return to a task. The main changes are:
Confidence Score: 5/5The latest changes look safe to merge.
|
| Filename | Overview |
|---|---|
| apps/emdash-desktop/src/renderer/lib/region-focus.ts | Adds shared logic for preventing autofocus from replacing focus on an active typing surface. |
| apps/emdash-desktop/src/renderer/features/tasks/stores/workspace-view-model.tsx | Tracks the focused task region and restores valid focus state from task snapshots. |
| apps/emdash-desktop/src/renderer/features/tasks/view/task-main-column.tsx | Marks task focus regions and updates focus ownership during pane interaction and terminal moves. |
| apps/emdash-desktop/src/renderer/features/browser/browser-toolbar.tsx | Prevents deferred URL autofocus from replacing focus on an active typing surface. |
Reviews (2): Last reviewed commit: "fix(tasks): ignore hidden active element..." | Re-trigger Greptile
A hidden element can linger as document.activeElement when a view is hidden instead of unmounted; it is not a place the user can type, so it must not suppress autofocus. Feature-detected since jsdom lacks checkVisibility. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
Author
|
@greptile review |
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.
Description
Switching back to a task always focused the drawer terminal, even if you left off in the chat composer: both autofocus on task activation and the terminal wins.
Task views now remember which region owned focus (main panes vs terminal drawer) and restore it on re-entry. Autofocus effects gate on that region and skip when the user is already in a typing surface (
shouldSkipAutofocus, rationale in its doc comment).Related issues
Fixes #2930
Testing
Screenshot/Recording (if applicable)
Screen.Recording.2026-07-20.at.3.01.39.PM.mov
Checklist