Skip to content

fix(terminal): chat input not focused after switching tasks between projects#1030

Merged
arnestrickmann merged 1 commit intogeneralaction:mainfrom
jschwxrz:fix/chat-input-focus
Feb 22, 2026
Merged

fix(terminal): chat input not focused after switching tasks between projects#1030
arnestrickmann merged 1 commit intogeneralaction:mainfrom
jschwxrz:fix/chat-input-focus

Conversation

@jschwxrz
Copy link
Contributor

terminalpane useeffect dependency array included props (remote, theme, env, callbacks, etc.) that are only used at PTY spawn time. Parent rerenders created new object/function references, triggering unnecessary detach/attach cycles that moved the terminal DOM offscreen and lost focus.

Move all props except id to refs so the effect only reruns when switching to a different terminal. add a separate theme effect that calls settheme() without detach/attach.

fixes #549

@vercel
Copy link

vercel bot commented Feb 21, 2026

@jschwxrz is attempting to deploy a commit to the General Action Team on Vercel.

A member of the Team first needs to authorize it.

@arnestrickmann
Copy link
Contributor

thanks for opening the pr jona!
Will check and test asap.

@greptile-apps
Copy link

greptile-apps bot commented Feb 21, 2026

Greptile Summary

This PR fixes a focus loss bug where the chat input lost focus when switching tasks between projects. The root cause was parent component rerenders creating new object/function references for props (remote, env, callbacks, etc.), triggering the terminal useEffect's dependency array and causing unnecessary detach/attach cycles that moved the terminal DOM offscreen.

Key changes:

  • Converted all props except id to refs in TerminalPane.tsx so the main effect only reruns when switching terminals
  • Separated theme updates into a dedicated effect that calls setTheme() without detaching
  • Added focus state tracking (hadFocusBeforeDetach) in TerminalSessionManager.ts to restore terminal focus after attach
  • Callback wrappers properly access current ref values to ensure latest callbacks are invoked

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes are well-targeted, use established React patterns (refs for stable values), and directly address the root cause (unnecessary effect reruns due to prop reference changes). The focus restoration logic is defensive and preserves user experience.
  • No files require special attention

Important Files Changed

Filename Overview
src/renderer/components/TerminalPane.tsx Converted props to refs to prevent spurious useEffect reruns; separated theme updates into dedicated effect; correctly passes callback refs through wrapper functions
src/renderer/terminal/TerminalSessionManager.ts Added focus state tracking (hadFocusBeforeDetach) and restoration logic to preserve terminal focus across detach/attach cycles

Last reviewed commit: ac6e75e

@arnestrickmann
Copy link
Contributor

Thanks Jona! Good stuff. LGTM. Merging.

@arnestrickmann arnestrickmann merged commit 54b8299 into generalaction:main Feb 22, 2026
3 of 4 checks passed
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.

[bug]: Chat input not focused after switching tasks

2 participants