Add local /clear command support in the composer#23
Conversation
Co-authored-by: OpenSource03 <29690431+OpenSource03@users.noreply.github.com>
/clear command support in the composer
There was a problem hiding this comment.
Pull request overview
Adds a local-only /clear composer command that triggers the existing “new chat” flow (instead of being forwarded to the active engine), and integrates it into the slash-command UX and types.
Changes:
- Introduces a built-in local
/clearslash command, plus shared helper utilities for command list composition and replacement text. - Wires the composer’s
/clearexecution to AppLayout’s “open new chat” flow via a newonClearcallback. - Extends
SlashCommand.sourcewith"local"and adds focused unit tests for helper behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/components/InputBar.tsx | Adds local /clear support, normalizes slash-command list/replacement logic, and routes /clear through onClear. |
| src/components/InputBar.test.ts | Adds unit tests for local command injection/deduping, detection, and replacement text. |
| src/components/AppLayout.tsx | Adds handleComposerClear to reuse the existing new-chat flow and passes it down to the composer. |
| shared/types/engine.ts | Extends SlashCommand.source union to include "local". |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 22bba45d99
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| interface InputBarProps { | ||
| onSend: (text: string, images?: ImageAttachment[], displayText?: string) => void; | ||
| onClear?: () => void | Promise<void>; |
There was a problem hiding this comment.
Require onClear prop for InputBar
/workspace/harnss/AGENTS.md explicitly forbids false optionals, but this change makes onClear optional even though the only runtime path (AppLayout → BottomComposer → InputBar) provides it. Keeping it optional weakens the contract and allows future call sites to render a visible /clear command that silently does nothing except clear the composer, which is a maintainability and behavior regression the type system could prevent.
Useful? React with 👍 / 👎.
| if (isClearCommandText(trimmed)) { | ||
| try { | ||
| await onClear?.(); | ||
| } finally { | ||
| clearComposer(el); |
There was a problem hiding this comment.
Prevent duplicate /clear submits while new chat is pending
This branch awaits onClear but does not set any in-flight guard before waiting, so when new-chat creation is slow users can press Enter (or click send) multiple times and trigger concurrent /clear executions. Because the composer is only cleared in finally, repeated submits can create multiple empty sessions from one intent; set a busy flag or clear/disable immediately before awaiting to make submission idempotent.
Useful? React with 👍 / 👎.
Summary
/clearslash command that is handled by Harnss instead of being forwarded to the active agent./clearthrough the existing new-chat flow so it behaves like clicking New Chat for the current project/session context./clearstill works even when ACP options are loading or normal send gating would otherwise block composer submission.Type of Change
Related Issues
How to Test
/in the composer./clearappears in slash command suggestions and inserts/clearlocally without forwarding anything to the active agent./clearand confirm it opens a fresh chat, including while ACP options are loading.Screenshots / Screen Recording
Checklist
pnpm build)anytypes introducedms-*/me-*instead ofml-*/mr-*)wrap-break-wordshared/types/, notsrc/types/Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.