Repository navigation
fix(terminal): hide SSH error toast under the reconnect banner - #10246
Conversation
The z-50 TerminalErrorToast was stacking over the non-blocking SSH reconnect banner with the raw ssh:connect failure. Suppress the toast while the banner owns recovery and clear matching toast text so it cannot flash after reconnect.
📝 WalkthroughWalkthroughAdds exported helpers to classify and strip SSH reconnect-owned terminal error lines, with tests for matching, removal, and preservation of unrelated messages. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: a3fa6eea-e340-4ed7-b1d6-0d5bcec41bfb
📒 Files selected for processing (3)
src/renderer/src/components/terminal-pane/TerminalErrorToast.test.tssrc/renderer/src/components/terminal-pane/TerminalErrorToast.tsxsrc/renderer/src/components/terminal-pane/TerminalPane.tsx
onPtyError newline-joins multiple PTY errors into one string, so the prior startsWith() classification misfired on aggregated errors: an unrelated error before the SSH failure left the stale ssh:connect text to flash after reconnect, and an SSH-first error discarded any unrelated error. Classify per line and drop only reconnect-owned lines, keeping the rest. Closes CodeRabbit's aggregation edge. Co-authored-by: Orca <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: a0537349-4bbe-4c41-8a51-75e9364c1938
📒 Files selected for processing (3)
src/renderer/src/components/terminal-pane/TerminalErrorToast.test.tssrc/renderer/src/components/terminal-pane/TerminalErrorToast.tsxsrc/renderer/src/components/terminal-pane/TerminalPane.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
- src/renderer/src/components/terminal-pane/TerminalErrorToast.tsx
| useEffect(() => { | ||
| if (!showSshReconnectOverlay || terminalError == null) { | ||
| return | ||
| } | ||
| const kept = stripSshReconnectOwnedErrorLines(terminalError) | ||
| if (kept !== terminalError) { | ||
| setTerminalError(kept) | ||
| } | ||
| }, [showSshReconnectOverlay, terminalError]) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Sanitize while reconnect recovery is active, not only while the overlay is rendered.
showSshReconnectOverlay requires the pane to be active and visible. An inactive/hidden pane can still receive onPtyErrorRef updates, so if SSH reconnect completes before the pane is activated, this effect never strips the stored SSH failure; Lines 2906-2912 can then show a stale toast.
Use a separate sshReconnectInProgress condition based only on the target/status for sanitization, while retaining showSshReconnectOverlay for rendering, and add a regression test for this inactive-pane sequence.
Suggested adjustment
+ const sshReconnectInProgress = Boolean(
+ sshReconnectTargetId &&
+ sshReconnectStatus &&
+ sshReconnectStatus !== 'connected'
+ )
+
useEffect(() => {
- if (!showSshReconnectOverlay || terminalError == null) {
+ if (!sshReconnectInProgress || terminalError == null) {
return
}
const kept = stripSshReconnectOwnedErrorLines(terminalError)
if (kept !== terminalError) {
setTerminalError(kept)
}
- }, [showSshReconnectOverlay, terminalError])
+ }, [sshReconnectInProgress, terminalError])📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| useEffect(() => { | |
| if (!showSshReconnectOverlay || terminalError == null) { | |
| return | |
| } | |
| const kept = stripSshReconnectOwnedErrorLines(terminalError) | |
| if (kept !== terminalError) { | |
| setTerminalError(kept) | |
| } | |
| }, [showSshReconnectOverlay, terminalError]) | |
| const sshReconnectInProgress = Boolean( | |
| sshReconnectTargetId && | |
| sshReconnectStatus && | |
| sshReconnectStatus !== 'connected' | |
| ) | |
| useEffect(() => { | |
| if (!sshReconnectInProgress || terminalError == null) { | |
| return | |
| } | |
| const kept = stripSshReconnectOwnedErrorLines(terminalError) | |
| if (kept !== terminalError) { | |
| setTerminalError(kept) | |
| } | |
| }, [sshReconnectInProgress, terminalError]) |
…yai#10246) * fix(terminal): hide SSH error toast under the reconnect banner The z-50 TerminalErrorToast was stacking over the non-blocking SSH reconnect banner with the raw ssh:connect failure. Suppress the toast while the banner owns recovery and clear matching toast text so it cannot flash after reconnect. * fix(terminal): strip only SSH-owned lines from aggregated terminal error onPtyError newline-joins multiple PTY errors into one string, so the prior startsWith() classification misfired on aggregated errors: an unrelated error before the SSH failure left the stale ssh:connect text to flash after reconnect, and an SSH-first error discarded any unrelated error. Classify per line and drop only reconnect-owned lines, keeping the rest. Closes CodeRabbit's aggregation edge. Co-authored-by: Orca <[email protected]> --------- Co-authored-by: Orca <[email protected]>
Summary
TerminalErrorToast(z-index: 50) was still painting over it with the rawssh:connectfailureWhy
Screenshot from the merged fix: left split shows the red "SSH connection failed: Error invoking remote method 'ssh:connect'..." toast on top of the "SSH connection required" banner. Same bottom strip, two competing recovery UIs.
Tests
pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/components/terminal-pane/TerminalErrorToast.test.ts(5/5)