Skip to content

fix(ui): stop terminal auto-select from stealing copilot input focus#4201

Merged
waleedlatif1 merged 1 commit intostagingfrom
waleedlatif1/fix-copilot-focus-loss
Apr 16, 2026
Merged

fix(ui): stop terminal auto-select from stealing copilot input focus#4201
waleedlatif1 merged 1 commit intostagingfrom
waleedlatif1/fix-copilot-focus-loss

Conversation

@waleedlatif1
Copy link
Copy Markdown
Collaborator

Summary

  • Remove focusTerminal() call from terminal's auto-select effect so new console entries don't steal focus from the copilot textarea
  • Terminal still visually selects the latest entry — focus is only moved on explicit user interaction (clicking an entry or keyboard nav)

Type of Change

  • Bug fix

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 16, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Apr 16, 2026 7:41pm

Request Review

@cursor
Copy link
Copy Markdown

cursor bot commented Apr 16, 2026

PR Summary

Medium Risk
Terminal change is straightforward, but the duplicated callback declarations and removal of the catch wrapper around stopGeneration() could introduce build errors or unhandled promise rejections depending on stopGeneration’s return type.

Overview
Prevents the terminal’s auto-select-on-new-logs effect from calling focusTerminal(), so selecting the newest log entry no longer steals focus from the Copilot textarea.

Also updates the chat stop-generation callbacks in home.tsx and the workflow panel.tsx (including duplicated handle*StopGeneration declarations in the diff) to call stopGeneration() directly rather than wrapping it in void ...catch(...).

Reviewed by Cursor Bugbot for commit 4677f01. Configure here.

@waleedlatif1 waleedlatif1 force-pushed the waleedlatif1/fix-copilot-focus-loss branch from 4677f01 to 53edd74 Compare April 16, 2026 19:41
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 16, 2026

Greptile Summary

Removes focusTerminal() from the terminal's auto-select useEffect, preventing the terminal from stealing keyboard focus from the copilot textarea whenever new console entries arrive. The terminal still visually highlights the latest entry; focus is only moved on explicit user interaction (clicking an entry or keyboard navigation). The focusTerminal reference is correctly removed from the effect's dependency array as well.

Confidence Score: 5/5

Safe to merge — minimal, targeted change with no functional regression risk.

The change removes a single focusTerminal() call and its corresponding dep from an auto-select effect. All explicit user-interaction paths (handleSelectEntry, navigateToEntry) still call focusTerminal(), preserving keyboard navigation. No logic, state, or rendering is otherwise affected.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/terminal/terminal.tsx Removes focusTerminal() call and its dep from the auto-select effect — surgical, correct fix for the focus-stealing bug.
apps/sim/app/workspace/[workspaceId]/home/home.tsx Included via a secondary commit in the PR branch (v0.6.29 login/posthog improvements); no issues identified.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/panel.tsx Included via a secondary commit in the PR branch (v0.6.29 login/posthog improvements); no issues identified.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[New console entry arrives] --> B{autoSelectEnabled?}
    B -- No --> Z[No-op]
    B -- Yes --> C[Set selectedEntryId to latest entry]
    C --> D[Expand parent nodes if needed]
    D --> E[Terminal visually highlights entry]
    E --> F{Before fix: focusTerminal called?}
    F -- Yes BEFORE --> G[terminalRef.focus - Steals focus from copilot textarea]
    F -- No AFTER --> H[Focus stays on copilot textarea]
    I[User clicks entry] --> J[handleSelectEntry]
    J --> K[focusTerminal called explicitly]
    K --> L[Terminal receives focus for keyboard nav]
Loading

Reviews (1): Last reviewed commit: "fix(ui): stop terminal auto-select from ..." | Re-trigger Greptile

@waleedlatif1 waleedlatif1 merged commit e16c8e6 into staging Apr 16, 2026
9 checks passed
@waleedlatif1 waleedlatif1 deleted the waleedlatif1/fix-copilot-focus-loss branch April 16, 2026 19:44
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.

1 participant