Skip to content

Conversation

@nwthomas
Copy link
Contributor

@nwthomas nwthomas commented Oct 31, 2025

I have another PR for OpenTUI changes pointed at branch dev: #3636

Problem

Pressing ctrl+d should terminate OpenCode. Claude Code and Codex support similar behavior (Claude Code with two presses, Codex with one), and Unix tools typically require one press to exit programs as well.

See #3025 for more details of the problem statement.

Solution

I opted to roll this new functionality into the existing AppExitCommand code. I added a separate block to control the new ctrl+d app exit (on single press) but also preserved the existing forward delete functionality when the text editor has content in it.

I also updated all locations I could find with the new keybinding information, including where it's displayed for /help.

Testing

Below is videos showing testing on all major platforms.

MacOS 15.7.1 Windows 11 (26120.6982) Linux (Ubuntu 24.04)
Screen.Recording.2025-10-31.at.11.27.15.AM.mov
Screen.Recording.2025-10-31.at.11.44.51.AM.mov
Screencast.from.2025-10-31.14-30-01.webm

.describe("Leader key for keybind combinations"),
app_help: z.string().optional().default("<leader>h").describe("Show help dialog"),
app_exit: z.string().optional().default("ctrl+c,<leader>q").describe("Exit the application"),
app_exit: z.string().optional().default("ctrl+d,ctrl+c,<leader>q").describe("Exit the application"),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've updated all locations the exit commands are enumerated

@nwthomas nwthomas force-pushed the feat/allow-ctrl-d-app-exit branch 2 times, most recently from 00e992e to 6a02b7f Compare October 31, 2025 17:01
@rekram1-node
Copy link
Collaborator

Is this still draft or is it ready for review?

@rekram1-node rekram1-node self-requested a review October 31, 2025 17:25
@nwthomas nwthomas force-pushed the feat/allow-ctrl-d-app-exit branch from 6a02b7f to bc8f1ed Compare October 31, 2025 18:22
@nwthomas
Copy link
Contributor Author

Is this still draft or is it ready for review?

Still draft. Finishing testing changes from our talk in the thread.

Description: "exit the app",
Keybindings: parseBindings("ctrl+c", "<leader>q"),
// NOTE: ctrl+c requires a double press to exit while ctrl+d requires a single press
Keybindings: parseBindings("ctrl+c", "ctrl+d", "<leader>q"),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This appears to be pulled directly into the user-facing UI for available commands, another reason I decided to continue using the existing AppExitCommand:

Screenshot 2025-10-31 at 11 24 52 AM

}

// 9. Handle exit key debounce for app exit when using non-leader command
if exitCommand.Matches(msg, a.app.IsLeaderSequence) && keyString != "ctrl+d" {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I decided a separate block was cleanest. exitCommand is now defined here and used in this block and just below.

}
// Skip ctrl+d immediate exit key if the editor has content. Allow editor update commands to handle it as forward delete.
if exitCommand.Matches(msg, a.app.IsLeaderSequence) && keyString == "ctrl+d" && a.editor.Length() > 0 {
return a, nil
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This allows the later fall through on next cycle into step 12 further below.

@nwthomas nwthomas marked this pull request as ready for review October 31, 2025 18:53
@nwthomas
Copy link
Contributor Author

@rekram1-node whenever you have time, it's out of draft. Tests for Go and TS passed locally. I'm going to look at the opentui codebase now.

@nwthomas nwthomas force-pushed the feat/allow-ctrl-d-app-exit branch from bc8f1ed to 695355f Compare October 31, 2025 19:11
@rekram1-node
Copy link
Collaborator

anddd the opentui version just shipped

I would've said something if I knew it was shipping today

I can still merge this into old branch tho since we are keeping v0 alive for time being

@nwthomas
Copy link
Contributor Author

anddd the opentui version just shipped

I would've said something if I knew it was shipping today

I can still merge this into old branch tho since we are keeping v0 alive for time being

RIP. Okay. Before putting time into the opentui fix, is someone already handling it there or can I go ahead?

@rekram1-node
Copy link
Collaborator

U can go ahead!

This adds support for ctrl+d to exit the app. It follows the unix convention
of only requiring a single press of the command. Additionally, it updates
the help menu to reflect the new keybind.
@nwthomas nwthomas force-pushed the feat/allow-ctrl-d-app-exit branch from 695355f to 913a0fb Compare October 31, 2025 20:16
@nwthomas nwthomas changed the base branch from dev to v0 October 31, 2025 20:16
@nwthomas
Copy link
Contributor Author

@rekram1-node rebased to point this branch at v0. Will open another for dev.

@rekram1-node
Copy link
Collaborator

amazin

@nwthomas nwthomas changed the title feat: allow ctrl+d to exit the app feat: allow ctrl+d to exit the app (v0) Oct 31, 2025
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