Skip to content

fix: highlight inactive terminal output#19

Open
htazq wants to merge 3 commits into
GOODBOY008:mainfrom
htazq:fix/issue-15-terminal-unread-output
Open

fix: highlight inactive terminal output#19
htazq wants to merge 3 commits into
GOODBOY008:mainfrom
htazq:fix/issue-15-terminal-unread-output

Conversation

@htazq

@htazq htazq commented May 28, 2026

Copy link
Copy Markdown
Contributor

Root cause

PTY output was written directly into each xterm instance, but the terminal tab state had no transient activity flag. Hidden terminal tabs could receive output while remaining visually identical to inactive idle tabs, and there was no reducer path to clear an activity marker when the user switched back.

Fix

  • Added transient hasUnreadOutput tab state and a MARK_TAB_UNREAD_OUTPUT reducer action.
  • Mark output only when the tab is not currently visible; clear it on ACTIVATE_TAB and when activating a group whose active tab has unread output.
  • Added an onOutput callback to PtyTerminal using a ref so tab switching does not rebuild xterm, WebSocket, or PTY sessions.
  • Rendered a distinct blue pulsing unread-output indicator in the terminal tab bar while preserving the existing connection-status dot.
  • Kept unread output transient: startup and persistence clear/strip the flag, and saveState now tolerates older state without tabToGroupMap.

Closes #15

Verification

RED/GREEN:

  • RED confirmed: pnpm.cmd test src/__tests__/terminal-group-reducer.test.ts failed on unread mark/clear assertions before the fix.
  • RED confirmed: pnpm.cmd test src/__tests__/pty-terminal-activation.test.tsx failed because PTY Output did not notify React state.
  • RED confirmed: pnpm.cmd test src/__tests__/group-tab-bar-unread-output.test.tsx failed because no unread indicator was rendered.
  • All three passed after implementation.

Passed:

  • pnpm.cmd test src/__tests__/terminal-group-reducer.test.ts src/__tests__/terminal-group-reducer.property.test.ts
  • pnpm.cmd test src/__tests__/group-tab-bar-unread-output.test.tsx src/__tests__/pty-terminal-activation.test.tsx
  • pnpm.cmd test src/__tests__/terminal-group-serializer.test.ts
  • pnpm.cmd exec tsc --noEmit
  • pnpm.cmd lint (0 errors; existing warnings remain)
  • pnpm.cmd build

Known local failures unrelated to this change:

  • pnpm.cmd test now has 23 passing files and 2 failing existing suites: src/__tests__/connection.test.ts needs a Tauri runtime/invoke bridge, and src/__tests__/file-entry-types.test.ts has Windows path separator expectation failures. The Feature request: Highlight inactive terminal tabs when new output arrives #15 tests pass in the full run.
  • cd src-tauri && cargo test was checked during this issue pass and fails locally because openssl-sys cannot find perl while building vendored OpenSSL.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds transient unread-output state for terminal tabs so background terminal activity can be visually indicated and cleared when the tab/group is activated.

Changes:

  • Adds hasUnreadOutput tab state and reducer actions/clearing behavior.
  • Wires PTY output events into terminal group state without rebuilding PTY sessions.
  • Adds a blue pulsing unread-output indicator and related tests.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/lib/terminal-group-types.ts Adds unread-output tab state and action type.
src/lib/terminal-group-serializer.ts Strips transient unread state from persisted terminal layout.
src/lib/terminal-group-reducer.ts Marks/clears unread output in terminal group state.
src/lib/terminal-group-context.tsx Resets unread state during startup restoration.
src/components/terminal/terminal-group-view.tsx Dispatches unread-output state updates from PTY output.
src/components/terminal/group-tab-bar.tsx Renders the unread-output indicator.
src/components/pty-terminal.tsx Adds PTY output callback support.
src/__tests__/terminal-group-reducer.test.ts Covers unread mark/clear reducer behavior.
src/__tests__/pty-terminal-activation.test.tsx Covers PTY output notification.
src/__tests__/group-tab-bar-unread-output.test.tsx Covers unread indicator rendering.

Comment thread src/lib/terminal-group-reducer.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Comment thread src/components/terminal/group-tab-bar.tsx
Comment thread src/components/pty-terminal.tsx
Comment on lines +189 to +193
<span
data-testid={`tab-unread-output-${tab.id}`}
aria-label="Unread terminal output"
className="absolute -right-1.5 -top-1.5 h-2 w-2 rounded-full bg-sky-500 ring-2 ring-background animate-pulse"
/>
Comment thread src/components/pty-terminal.tsx
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.

Feature request: Highlight inactive terminal tabs when new output arrives

2 participants