Skip to content

fix (desktop): ctrl-d fix to kill terminal pane#972

Closed
AviPeltz wants to merge 1 commit into
mainfrom
ctrl-d-exploration
Closed

fix (desktop): ctrl-d fix to kill terminal pane#972
AviPeltz wants to merge 1 commit into
mainfrom
ctrl-d-exploration

Conversation

@AviPeltz
Copy link
Copy Markdown
Collaborator

@AviPeltz AviPeltz commented Jan 26, 2026

Description

Related Issues

Type of Change

  • Bug fix
  • New feature
  • Documentation
  • Refactor
  • Other (please describe):

Testing

Screenshots (if applicable)

Additional Notes

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Terminal now properly detects and responds to Ctrl+D (EOF) input, automatically closing the session when a clean exit occurs. This improves compatibility with standard terminal workflows.

✏️ Tip: You can customize this high-level summary in your review settings.


Open with Devin

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 26, 2026

📝 Walkthrough

Walkthrough

This change adds Ctrl+D (EOF) detection to the Terminal component, introducing a ref to track when Ctrl+D is sent and using it to automatically close the terminal pane when the exit code is 0 and the process wasn't forcefully killed.

Changes

Cohort / File(s) Summary
Terminal Ctrl+D ref tracking
apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/Terminal.tsx
Introduces ctrlDSentRef to track EOF signals and passes it as a dependency to useTerminalStream hook.
Terminal stream exit handler
apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/hooks/useTerminalStream.ts
Extends UseTerminalStreamOptions interface with ctrlDSentRef, implements auto-close logic in handleTerminalExit to remove the pane when Ctrl+D is sent with exit code 0 and process wasn't killed by user, and resets the ref after handling.

Sequence Diagram

sequenceDiagram
    actor User
    participant Terminal
    participant useTerminalStream
    participant TabsStore

    User->>Terminal: Sends Ctrl+D (0x04)
    Terminal->>Terminal: Detects data === "\x04"
    Terminal->>Terminal: Sets ctrlDSentRef.current = true
    
    Note over Terminal,useTerminalStream: Terminal process exits with code 0
    
    useTerminalStream->>useTerminalStream: handleTerminalExit triggered
    useTerminalStream->>useTerminalStream: Check: exitCode === 0?
    useTerminalStream->>useTerminalStream: Check: ctrlDSentRef.current === true?
    useTerminalStream->>useTerminalStream: Check: wasKilledByUser === false?
    
    alt All conditions met
        useTerminalStream->>TabsStore: removePane(paneId)
        TabsStore->>TabsStore: Close terminal pane
    else Condition not met
        useTerminalStream->>useTerminalStream: Reset ctrlDSentRef.current = false
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • Kitenite

Poem

🐰 A ref to track when Ctrl+D's sent,
Through streams it flows, heaven-bent,
Auto-close when exit's clean,
Terminal tabs bid adieu serene,
The signal echo'd, the pane is rest! 🌱

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description follows the required template structure but lacks substantive content in critical sections like Description, Related Issues, and Testing. Add a clear description of the changes, link any related issues using GitHub keywords, and document the testing steps performed to verify the Ctrl+D terminal pane fix.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: fixing Ctrl+D functionality to properly kill/close the terminal pane, which matches the code changes introducing ctrlDSentRef tracking.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@AviPeltz AviPeltz marked this pull request as ready for review January 27, 2026 03:26
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional flags.

Open in Devin Review

@Kitenite
Copy link
Copy Markdown
Collaborator

Closing: stale fix from Jan 26 with no recent activity. Terminal handling has been reworked since.

@Kitenite Kitenite closed this Mar 13, 2026
@Kitenite
Copy link
Copy Markdown
Collaborator

Hey — just a heads up, this was closed as part of an automated stale PR cleanup. If you think this was done in error, feel free to reopen it!

@Kitenite
Copy link
Copy Markdown
Collaborator

Hey — this was closed by an automated cleanup of PRs with major merge conflicts that are 3+ weeks old. If you think this was done incorrectly, please feel free to reopen it. Sorry for any inconvenience!

@Kitenite Kitenite deleted the ctrl-d-exploration branch March 15, 2026 16:07
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.

2 participants