feat(web): surface opencode /compact and /clear in the slash command menu - #1675
feat(web): surface opencode /compact and /clear in the slash command menu#1675rzsgsfm wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Findings
-
[Minor] Gate the OpenCode
/clearmenu entry by session origin — the shared list now advertises it for terminal-started sessions, but the runtime rejects that command unless the session is runner-backed. Evidenceshared/src/slashCommands.ts:52; rejection pathcli/src/opencode/runOpencode.ts:264.Suggested fix:
const merged = query.data?.success && query.data.commands ? mergeSlashCommands([...builtin, ...query.data.commands]) : builtin return merged.filter((command) => command.source !== 'builtin' || agentType !== 'opencode' || command.name !== 'clear' || startedBy === 'runner' )
Summary
- Review mode: initial
- One Minor finding: make
/clearavailability capability-aware so terminal-started sessions do not offer a command they cannot execute.
Testing
- Not run (automation). GitHub's test job is still in progress; integration and fixture drift checks passed. Add coverage for both runner-backed and terminal-started OpenCode command lists.
HAPI Bot
| { name: 'default', description: 'Return OpenCode permission mode to default', source: 'builtin' }, | ||
| { name: 'init', description: 'Generate or refresh AGENTS.md for this project', source: 'builtin' }, | ||
| { name: 'compact', description: 'Compact (summarize) the OpenCode session context (remote sessions only)', source: 'builtin' }, | ||
| { name: 'clear', description: 'Archive this HAPI session and open a fresh OpenCode session', source: 'builtin' }, |
There was a problem hiding this comment.
[MINOR] Gate /clear on runner-backed OpenCode sessions
This unconditional built-in is consumed by the web fallback and by the CLI slash-command RPC for every OpenCode session. However, cli/src/opencode/runOpencode.ts:264-275 explicitly rejects /clear when startedBy !== 'runner'. Terminal-started sessions can be handed off to remote control, so those users will now see and select a menu item that only returns an error. Thread session.metadata.startedBy (or an equivalent capability) into command enumeration and filter only the built-in row, preserving custom commands named clear.
Suggested fix:
return merged.filter((command) =>
command.source !== 'builtin'
|| agentType !== 'opencode'
|| command.name !== 'clear'
|| startedBy === 'runner'
)
Motivation
On the remote web/phone UI, the opencode
/autocomplete menu is built fromBUILTIN_SLASH_COMMANDSinshared/src/slashCommands.ts. It exposes onlyhelp / status / plan / default / init, intentionally omittingcompactandclear.That omission traces back to #753, when the OpenCode ACP backend had no compaction RPC —
/compactand/clearwere unsupported placeholders, so hiding them from the menu made sense.Since then,
compactbecame fully supported via the native OpenCode compaction bridge (#1252, + retries in #1433) andclearis a real implementation, but the menu list and the CLI test that locks the "hidden" set were never updated. The rationale for hiding them is now stale:compact/clearhave no composer button (unlike model/reasoning/permissions).So they are being surfaced in the menu, matching other flavors (pi, codex, grok, claude already list
compact).Change
shared/src/slashCommands.ts: addcompactandclearto the opencode builtin list.cli/src/modules/common/slashCommands.test.ts: movecompact/clearfrom the "hidden" set into the expected opencode builtin list; keep model/reasoning/effort/permissions hidden (they have composer buttons / are aliases).web/src/lib/codexSlashCommands.test.ts: add a web-side assertion that opencode exposescompactandclear.Verification
/compact(kind: 'compact') and/clear(kind: 'clear');/helpalready lists/compact.