Skip to content

Conversation

@ThalesMMS
Copy link
Contributor

@ThalesMMS ThalesMMS commented Jan 11, 2026

Summary

  • Add Esc and Del buttons to the terminal keyboard toolbar.
  • Add Ctrl/Alt modifier toggles with active-state UI and generation tracking.
  • Apply modifier logic to terminal input (single chars, CSI/SS3 sequences) in the JS terminal layer.
  • Sync modifier resets between JS and Swift via notifications; reset modifiers after input or blur.

Changes

Terminal keyboard toolbar (TerminalKeyboardToolbar.swift):

  • Add controlActive/altActive state plus generation counters.
  • Add helpers to send input or cursor moves and then reset modifier state, plus a dedicated reset function.
  • Insert Esc, Ctrl, Alt, and Del buttons with accessibility labels and active-state highlighting for modifiers.
  • Route paste/tab/arrow actions through the modifier-reset helpers; reset modifiers on blur.
  • Listen for terminalControlReset/terminalAltReset notifications to clear the UI state when JS resets.

Terminal JavaScript (terminal.bundle/index.html):

  • Track modifier state and generation, expose setControlActive/setAltActive.
  • Apply Control/Alt to input, including CSI/SS3 sequences, and avoid applying modifiers to non-modifiable sequences.
  • Reset modifier state after use and notify Swift with generation-aware reset events.
  • Apply modifier processing inside term.onData before posting input to Swift.

Terminal instance (TerminalInstance.swift):

  • Handle ControlReset/AltReset messages from JS and post notifications with generation info.
  • Add methods to set Control/Alt state in the JS runtime.
  • Add terminalControlReset/terminalAltReset notification names.

Copilot AI review requested due to automatic review settings January 11, 2026 19:36
Copy link

Copilot AI left a comment

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 Esc and Ctrl key buttons to the terminal keyboard toolbar, enhancing terminal control capabilities on mobile devices. The Ctrl key features a toggle state with visual feedback and automatically resets after key presses.

Changes:

  • Added Esc button to send escape character to terminal
  • Added Ctrl button with toggle behavior and visual state
  • Implemented control character encoding (Ctrl+key combinations)

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
Dependencies/terminal.bundle/index.html Added JavaScript functions for control state management and control character encoding
CodeApp/Views/TerminalKeyboardToolbar.swift Added UI buttons for Esc and Ctrl keys with state management and notification handling
CodeApp/Managers/TerminalInstance.swift Added Swift methods to sync control state with JavaScript and handle control reset events

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ThalesMMS ThalesMMS force-pushed the Terminal-Keyboard-Ctrl-Esc branch 2 times, most recently from bb5d156 to 72b4b0b Compare January 11, 2026 20:07
@ThalesMMS ThalesMMS requested a review from Copilot January 11, 2026 20:10
Copy link

Copilot AI left a comment

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 3 out of 3 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Introduces Escape, Delete, and Control and Alt modifier buttons to the terminal keyboard toolbar, allowing users to send modified key sequences. Updates the Swift and JavaScript code to track modifier state, apply modifiers to terminal input, and synchronize state between the UI and the terminal. Modifier states are reset after use, and notifications are used to keep the UI in sync.
@ThalesMMS ThalesMMS force-pushed the Terminal-Keyboard-Ctrl-Esc branch from 1a388b8 to 10bd8c5 Compare January 11, 2026 20:42
@ThalesMMS ThalesMMS requested a review from Copilot January 11, 2026 20:43
@ThalesMMS ThalesMMS changed the title Add Esc and Ctrl keys to terminal keyboard toolbar Add Esc/Del and Ctrl/Alt modifier support to terminal toolbar Jan 11, 2026
Copy link

Copilot AI left a comment

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 3 out of 3 changed files in this pull request and generated 7 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Added a check to exclude ESC[200~ and ESC[201~ keycodes from being modified, preserving the integrity of the bracketed paste protocol in the terminal.
@bummoblizard
Copy link
Member

Thank you! I will review the changes in a bit

@ThalesMMS
Copy link
Contributor Author

Hello! Any update? 😊

@bummoblizard
Copy link
Member

Yes. I noticed the esc / control button stays on but it only takes effect once.

Should it be disabled after typing any character? Alternatively, the effect should be staying

TerminalInstance now handles 'ControlReset' and 'AltReset' events, posting notifications with generation info. Also refactored cursor movement to use inputWithModifiers, with corresponding helper added in terminal.bundle/index.html.
@ThalesMMS
Copy link
Contributor Author

Yes. I noticed the esc / control button stays on but it only takes effect once.

Should it be disabled after typing any character? Alternatively, the effect should be staying

Yes, as it is also the default behaviour of the iPad Shift key. Actually, the issue was that although it should be disabled after typing any character, the UI showed the key as still enabled. I just fixed that in this last commit.

Replaces the call to term.input with inputWithModifiers in the type(text:) method to handle input with modifier keys. This may improve support for complex input scenarios in the terminal.

Add lock functionality for Ctrl and Alt modifiers in terminal

Introduces the ability to lock the Control and Alt modifier keys in the terminal keyboard toolbar via double-tap, with visual feedback and state management. Updates Swift and JavaScript code to support locked states, ensuring modifiers remain active until explicitly unlocked, and modifies reset logic to respect locked states.
@ThalesMMS
Copy link
Contributor Author

Following your suggestion, I also added a “double-click Ctrl/Alt” option to lock the key, better imitating the Shift key’s default behavior.

@bummoblizard bummoblizard merged commit 5958c03 into thebaselab:main Jan 17, 2026
@bummoblizard
Copy link
Member

Thank you! It works very well during SSH sessions. A TestFlight build will be ready for people to test on soon.

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