Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions cli/src/modules/common/slashCommands.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,16 @@ describe('listSlashCommands', () => {
'plan',
'default',
'init',
'compact',
'clear',
]))
// Anything covered by composer buttons, plus aliases and unsupported
// placeholders, must stay out of the autocomplete menu — the resolver
// still accepts them when typed manually.
for (const hidden of ['model', 'reasoning', 'effort', 'permissions', 'permission', 'clear', 'compact']) {
// model/reasoning/effort/permissions have dedicated composer buttons and
// permission is an alias of permissions, so they stay out of the
// autocomplete menu (the resolver still accepts them when typed
// manually). compact/clear have no composer button and are now fully
// supported (native compaction via the OpenCode REST bridge), so they
// are surfaced here.
for (const hidden of ['model', 'reasoning', 'effort', 'permissions', 'permission']) {
expect(names).not.toContain(hidden)
}
})
Expand Down
2 changes: 2 additions & 0 deletions shared/src/slashCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export const BUILTIN_SLASH_COMMANDS = {
{ name: 'plan', description: 'Enable plan mode; use /plan off to return to default', source: 'builtin' },
{ 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' },

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[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'
)

],
cursor: [
{ name: 'compress', description: 'Compress conversation context to free window space (pass-through to Cursor agent)', source: 'builtin' },
Expand Down
13 changes: 13 additions & 0 deletions web/src/lib/codexSlashCommands.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@ describe('getBuiltinSlashCommands', () => {
expect(commands.map((command) => command.name)).toContain('compact')
})

it('exposes OpenCode compact and clear builtins for the remote web menu', () => {
const commands = getBuiltinSlashCommands('opencode')
expect(commands.map((command) => command.name)).toEqual(expect.arrayContaining([
'compact',
'clear',
'help',
'status',
'plan',
'default',
'init',
]))
})

it('does not fall back to Claude commands for kimi', () => {
expect(getBuiltinSlashCommands('kimi')).toEqual([])
})
Expand Down
Loading