Skip to content

Conversation

Copy link

Copilot AI commented Nov 4, 2025

  • Explore repository structure and understand terminal implementation
  • Add custom history command handler in Swift (TerminalInstance.swift)
  • Connect Swift handler to JavaScript function to clear history
  • Address code review feedback (improve command parsing)
  • Add detailed comments and maintain consistency with existing code
  • Final code review - no issues found
  • Security scan - no vulnerabilities
  • Address PR review: Use fallthrough for cleaner code
  • Implement ZSH-style history behavior
  • Limit history display to last 25 commands (ZSH default)
  • Complete task

Summary

Successfully implemented comprehensive history command support with ZSH-style behavior. The implementation provides command history display with indexing, clearing functionality, and helpful usage guidance, matching ZSH's default behavior of showing only the last 25 commands.

Implementation

  • Added custom handler in TerminalInstance.swift for history commands
  • history (no arguments) displays the last 25 command history entries with index numbers in 2-column tabbed format (index, command) - matching ZSH default behavior
  • history -p clears JavaScript-based history in local-echo.js (following ZSH convention)
  • history --help or history -h displays usage information
  • Invalid options show error message with guidance to use --help
  • Includes comprehensive comments and validation

Features

  • History Display: Running history without arguments shows the last 25 commands with their index numbers in a clean 2-column format (ZSH default behavior)
  • Clear History: history -p clears all command history (ZSH-style)
  • Help System: Built-in help with --help or -h flags
  • Error Handling: Informative error messages for invalid options with guidance
Original prompt

This section details on the original issue you should resolve

<issue_title>Cannot clear history of commands used in terminal</issue_title>
<issue_description>In general (shell-based) terminal, running history -c can clear all the history of commands used. However, this sentence did not work in terminal of this APP and I did not find any other relevant setups except item Close Workspace, which seem to be unpractical for ongoing projects.</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Fix command history clearing in terminal Add support for history -c to clear terminal command history Nov 4, 2025
Copilot AI requested a review from bummoblizard November 4, 2025 04:09
Comment on lines 330 to 337
} else {
// Display history - pass to ios_system for default behavior
executor?.dispatch(command: x, isInteractive: false) { _ in
DispatchQueue.main.async {
self.readLine()
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Can we use fallthrough here?

Copy link
Author

Choose a reason for hiding this comment

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

Good suggestion! Changed to use fallthrough in commit 8ff488f. This eliminates code duplication and makes it cleaner.

@bummoblizard
Copy link
Member

@copilot evaluate my comment and make any necessary changes

Use fallthrough to default case instead of duplicating dispatch logic,
as suggested in code review.

Co-authored-by: bummoblizard <[email protected]>

Co-authored-by: bummoblizard <[email protected]>
Copy link
Author

Copilot AI commented Nov 4, 2025

@copilot evaluate my comment and make any necessary changes

Updated to use fallthrough as requested in commit 8ff488f.

@bummoblizard bummoblizard marked this pull request as ready for review November 4, 2025 04:56
@bummoblizard
Copy link
Member

@copilot Make the following changes:

  • Follow ZSH behavior to use history -p as clear terminal command
  • Include a usage guidance message if an incorrect argument is given
  • When no argument is given, print the last commands with index in 2 tabbed columns like ZSH does. The first column is index and the second is the command itself

- Change clear command from -c to -p (following ZSH)
- Add history display with index in 2-column format when no args
- Add usage guidance for --help and invalid options
- Display "history: invalid option" message for incorrect arguments

Co-authored-by: bummoblizard <[email protected]>
Copy link
Author

Copilot AI commented Jan 11, 2026

@copilot Make the following changes:

  • Follow ZSH behavior to use history -p as clear terminal command
  • Include a usage guidance message if an incorrect argument is given
    ...

Implemented all requested changes in commit f445f5d:

  1. ✅ Changed to use history -p for clearing (following ZSH behavior)
  2. ✅ Added usage guidance with history --help and error messages for invalid options
  3. ✅ When no argument given, displays history with index in 2-column format (index \t\t command)

The implementation now follows ZSH conventions:

  • history → displays commands with index numbers
  • history -p → clears history
  • history --help or history -h → shows usage info
  • Invalid options → displays error with guidance

Copilot AI changed the title Add support for history -c to clear terminal command history Add ZSH-style history command support to terminal Jan 11, 2026
Copilot AI requested a review from bummoblizard January 11, 2026 16:00
@bummoblizard
Copy link
Member

@copilot Address the comments

Copy link
Author

Copilot AI commented Jan 11, 2026

@copilot Address the comments

All previous comments have been addressed:

  1. ✅ Fallthrough implementation (commit 8ff488f)
  2. ✅ ZSH-style behavior with -p flag (commit f445f5d)
  3. ✅ History display with index in 2 columns (commit f445f5d)
  4. ✅ Usage guidance messages (commit f445f5d)

Could you clarify which specific comments need further attention?

@bummoblizard
Copy link
Member

@copilot The ZSH history command only prints the last 25 commands in history. Make sure you mimic this behavior

Modified history command to display only the last 25 commands when
no arguments are provided, matching ZSH default behavior.

Co-authored-by: bummoblizard <[email protected]>
Copy link
Author

Copilot AI commented Jan 11, 2026

@copilot The ZSH history command only prints the last 25 commands in history. Make sure you mimic this behavior

Updated in commit 6cf74bd to display only the last 25 commands, matching ZSH default behavior. The history now uses Math.max(0, historyEntries.length - 25) to calculate the starting index.

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.

Cannot clear history of commands used in terminal

2 participants