Skip to content

fix: terminal auto-focus, unread auto-clear, projects collapsed - #93

Merged
aterrylu merged 1 commit into
mainfrom
terry/fix-mermaid-v2
Mar 28, 2026
Merged

fix: terminal auto-focus, unread auto-clear, projects collapsed#93
aterrylu merged 1 commit into
mainfrom
terry/fix-mermaid-v2

Conversation

@aterrylu

Copy link
Copy Markdown
Owner

Summary

  • Terminal auto-focus — clicking a session in the sidebar now focuses the terminal for immediate typing
  • Unread auto-clear — notification badges clear automatically when viewing the active session
  • Projects collapsed — projects section starts collapsed, no more auto-expand on session switches

Problem

  1. Clicking a session in the sidebar left focus on the sidebar button — user had to click inside the terminal to type
  2. Unread notification badges persisted when already viewing the active session (effect only fired on isActive transitions, not new notifications)
  3. Projects section auto-expanded every time a session was clicked, even when already collapsed

Solution

Terminal focus: Global terminalRegistry Map lets sidebar call focusTerminal(sessionId) directly from click handlers. Uses rAF polling (up to 10 frames) with offsetParent check to wait until the terminal container is visible before calling .focus(). onMouseDown={(e) => e.preventDefault()} on all sidebar buttons prevents browser from stealing focus.

Unread clear: Separate useEffect watches notificationCounts[sessionId] — fires whenever the count changes while the session is active, not just on isActive transitions.

Projects: Removed hasActiveSession auto-expand logic and unused activePane/sessions props from ProjectItem.

Test plan

  • Build passes, biome clean
  • /polish — all three review agents run, findings addressed
  • Deployed and tested on forge — terminal receives focus on click
  • Rapid session switching doesn't cause focus flicker (cancellation logic)
  • Unread badges clear when viewing active session + new notification arrives

🤖 Generated with Claude Code

Terminal focus:
- Global terminal registry + focusTerminal() called directly from sidebar clicks
- rAF polling waits until terminal container is visible (offsetParent check)
- onMouseDown preventDefault on all sidebar buttons prevents browser focus steal
- Cancels pending focus poll on rapid session switches

Unread notifications:
- Separate effect watches notificationCounts for active session
- Auto-clears within one poll cycle, even for notifications arriving while in session
- Group header/member clicks also clear synchronously

Projects section:
- Starts collapsed by default, no auto-expand on session switches
- Removed unused activePane/sessions props from ProjectItem

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@aterrylu
aterrylu merged commit ccaadeb into main Mar 28, 2026
@aterrylu
aterrylu deleted the terry/fix-mermaid-v2 branch March 28, 2026 10:20
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