Skip to content

[Feature] Add Clear Terminal Button to Terminal Panel #494

Description

@grishabhatia

Problem statement

Feature Description

Add a "Clear Terminal" button to the terminal panel that clears all terminal output with one click.

Current Problem

Currently, terminal output accumulates over time. Users have to manually type the clear command or refresh the page, which is not convenient, especially on mobile devices.

Proposed Solution

Add a "Clear Terminal" button (trash can 🗑️ or broom 🧹 icon) to the terminal component's top-right corner (or existing button panel). When clicked:

  1. All terminal text/history is cleared
  2. A fresh prompt shows (like $ or > )
  3. Only visible output is cleared - WebContainer terminal instance does NOT reset

Expected Behavior

  • Terminal clears instantly on button click
  • No undo needed (clear is a one-way action)
  • Optional keyboard shortcut: Ctrl/Cmd + L (standard terminal convention)

Alternative Approaches Considered

  • User types clear command (current workaround)
  • Right-click context menu with "Clear" option (more complex)

Additional Context

  • All popular IDEs (VS Code, Cursor, Windsurf) have a clear terminal button
  • Very helpful for mobile users who can't easily type clear on soft keyboard
  • Simple implementation: Use xterm.js clear() method

Mockup

Terminal header should have delete icon:
[Terminal] [🐚 bash] [🗑️ Clear] [✖️ Close]

Labels requested: gssoc26, gssoc:approved, level:intermediate

Proposed solution

Add a "Clear Terminal" button (trash can 🗑️ icon) to the terminal panel's top-right corner.

Implementation details:

  1. Locate terminal component file: modules/terminal/components/terminal.tsx
  2. Add a new Button component next to existing buttons (close, expand, etc.)
  3. Use xterm.js built-in clear() method:
    const clearTerminal = () => {
      if (terminal.current) {
        terminal.current.clear();
      }
    };

Alternatives considered

  1. Manual clear command - User types "clear" in terminal (current workaround but inconvenient on mobile)
  2. Right-click context menu - Adds complexity and not discoverable
  3. Auto-clear on new command - Would remove useful history, user has no control
  4. Keyboard shortcut only - Not discoverable for new users, especially on mobile

Estimated scope

Small

Primary area

Playground editor

Additional context

No response

Confirmation

  • I searched existing issues before opening this request.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions