Skip to content

feat: add keyboard shortcut Ctrl+L/Cmd+L to clear terminal#496

Open
grishabhatia wants to merge 1 commit into
piyushdotcomm:mainfrom
grishabhatia:main
Open

feat: add keyboard shortcut Ctrl+L/Cmd+L to clear terminal#496
grishabhatia wants to merge 1 commit into
piyushdotcomm:mainfrom
grishabhatia:main

Conversation

@grishabhatia

@grishabhatia grishabhatia commented Jun 14, 2026

Copy link
Copy Markdown

Changes

Testing

  • Press Ctrl+L or Cmd+L in terminal
  • Terminal clears successfully
  • Browser default behavior prevented

Summary by CodeRabbit

  • New Features
    • Added keyboard shortcut support for clearing the terminal: Ctrl+L (Windows/Linux) or Cmd+L (Mac)

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@github-actions github-actions Bot added the enhancement New feature or request label Jun 14, 2026
@github-actions

Copy link
Copy Markdown

👋 Thanks for opening a PR, @grishabhatia!

Your PR has entered the 🚦 PR Review Pipeline.

Standard PR detected — your PR will follow the standard review pipeline.


What happens next

Stage Reviewer Checks
Stage 1 — Automated Validation 🤖 Bot DCO · Format · AI/Slop · Duplicate
Stage 2 — Human Review 👥 Maintainer Code + Quality Review
Stage 3 — PA / Maintainer Review 🔑 Project Admin Final Merge Decision

A pipeline status comment will appear below and update automatically as your PR progresses.


While you wait

  • Sign all commits (git commit -s)
  • Link your issue (Closes #123)
  • Use a feature branch (not main)
  • Avoid unrelated changes

This comment is posted only once.

@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

TerminalInner in modules/webcontainers/components/terminal.tsx gains a new useEffect that registers a global keydown listener. When Ctrl+L (Windows/Linux) or Cmd+L (Mac) is detected, preventDefault is called and the same clearTerminal logic invoked by the UI button runs. All other terminal behavior is unchanged.

Changes

Terminal Clear Keyboard Shortcut

Layer / File(s) Summary
TerminalInner core setup and command execution
modules/webcontainers/components/terminal.tsx
Refs, state, theme map, prompt writer, useImperativeHandle contract, and async command execution (spawn, output piping, exit handling) are unchanged.
Ctrl/Cmd+L clear shortcut and lifecycle wiring
modules/webcontainers/components/terminal.tsx
Existing resize observer, WebContainer connection, and cleanup logic are preserved. A new useEffect registers a global keydown handler that calls clearTerminal on Ctrl+L / Cmd+L with preventDefault and deregisters on cleanup. Rendered terminal UI is unchanged.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

Poem

🐇 Hop hop, the terminal's tidy now,
Ctrl+L swoops in, takes a bow,
No more clutter, no more mess,
One quick key clears the excess.
The rabbit approves — fresh prompt, I vow! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning Description is incomplete; it lacks the required template structure with Type of change checkboxes, Validation section, and other standard sections. Provide a complete description following the repository template with Type of change, Validation (lint/test/build), and checklist sections.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed Title clearly and concisely summarizes the main change: adding keyboard shortcuts to clear the terminal.
Linked Issues check ✅ Passed PR implements the keyboard shortcut feature (Ctrl+L/Cmd+L) and tooltip update from issue #494, satisfying the main coding requirements.
Out of Scope Changes check ✅ Passed All changes are focused on adding the keyboard shortcut feature and updating tooltips; no out-of-scope modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@grishabhatia

Copy link
Copy Markdown
Author

Update on implementation

@piyushdotcomm
The Clear Terminal button was already implemented in the codebase.

Instead of adding a duplicate feature, I have:
✅ Added keyboard shortcut Ctrl+L / Cmd+L to clear terminal
✅ Updated the button tooltip to show the shortcut
✅ Prevented default browser behavior
please review

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
modules/webcontainers/components/terminal.tsx (1)

437-437: 💤 Low value

Remove the "✅ NEW" marker from the comment.

The "✅ NEW" prefix appears to be a development artifact. Consider either removing it or converting to a standard descriptive comment.

♻️ Suggested change
- // ✅ NEW: Keyboard shortcut for clearing terminal (Ctrl+L / Cmd+L)
+ // Keyboard shortcut for clearing terminal (Ctrl+L / Cmd+L)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@modules/webcontainers/components/terminal.tsx` at line 437, Remove the "✅
NEW:" marker from the comment at the terminal keyboard shortcut section. The
comment currently contains a development artifact prefix that should be removed,
leaving only the descriptive text about the keyboard shortcut functionality
(Ctrl+L / Cmd+L for clearing terminal). Convert it to a standard, clean comment
format without the emoji prefix.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@modules/webcontainers/components/terminal.tsx`:
- Around line 437-449: The keyboard shortcut listener in the useEffect hook is
attached globally to window and will trigger Ctrl+L/Cmd+L regardless of whether
the terminal is focused, potentially clearing all terminal instances and
interfering with other input fields. Add a focus check inside the
handleKeyboardShortcut function before calling clearTerminal to verify the
terminal has focus using the terminal instance's hasActiveFocus() method (or
equivalent focus state), ensuring the shortcut only works when the terminal is
actually focused, consistent with standard terminal behavior like VS Code and
native terminals.

---

Nitpick comments:
In `@modules/webcontainers/components/terminal.tsx`:
- Line 437: Remove the "✅ NEW:" marker from the comment at the terminal keyboard
shortcut section. The comment currently contains a development artifact prefix
that should be removed, leaving only the descriptive text about the keyboard
shortcut functionality (Ctrl+L / Cmd+L for clearing terminal). Convert it to a
standard, clean comment format without the emoji prefix.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b71b6ae6-38f2-47a7-bce7-71b24f6d72f7

📥 Commits

Reviewing files that changed from the base of the PR and between 46a072c and dc0d8cb.

📒 Files selected for processing (1)
  • modules/webcontainers/components/terminal.tsx

Comment thread modules/webcontainers/components/terminal.tsx
@grishabhatia

Copy link
Copy Markdown
Author

@piyushdotcomm pls review when you get chance;

@grishabhatia

Copy link
Copy Markdown
Author

✅ Build & Lint Passed

All checks have passed:

  • ✅ Lint: 0 errors
  • ✅ Build: Successful

Ready for review! 🚀

Changes:

  • Added keyboard shortcut Ctrl+L / Cmd+L to clear terminal
  • Updated button tooltip to show the shortcut

Testing:

  • Shortcut works on Windows (Ctrl+L)
  • Shortcut works on Mac (Cmd+L)
  • Does not conflict with browser defaults

@grishabhatia

Copy link
Copy Markdown
Author

@piyushdotcomm please review

@grishabhatia

Copy link
Copy Markdown
Author

@piyushdotcomm please review asap

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Add Clear Terminal Button to Terminal Panel

1 participant