Implement slash command system #8317

Closed
opened 2026-02-16 18:09:40 -05:00 by yindo · 2 comments
Owner

Originally created by @randomm on GitHub (Feb 2, 2026).

Originally assigned to: @thdxr on GitHub.

Parent Epic

Part of #11762 (Ink-based TUI Rewrite)

Objective

Port the existing slash command system to the Ink architecture.

Current Commands (from commands.ts)

Command Description
/help Show help
/clear Clear screen
/agent [name] Switch agent
/model [name] Switch model
/session [id] Switch session
/sessions List sessions
/new New session
/compact Toggle compact mode
/start Initialize context
/bug Report bug
/cost Show token costs
/config Edit config
/quit Exit

Architecture

// Command registry
interface Command {
  name: string
  description: string
  handler: (args: string[], context: CommandContext) => Promise<void>
}

interface CommandContext {
  dispatch: Dispatch<Action>
  session: SessionState
  setUIMode: (mode: UIMode) => void
}

const commands: Command[] = [
  {
    name: 'help',
    description: 'Show available commands',
    handler: async (args, ctx) => {
      ctx.dispatch({ type: 'SHOW_HELP' })
    }
  },
  {
    name: 'agent',
    description: 'Switch agent',
    handler: async (args, ctx) => {
      if (args[0]) {
        await switchAgent(args[0])
      } else {
        ctx.setUIMode('select')
        ctx.dispatch({ type: 'SHOW_AGENT_SELECT' })
      }
    }
  },
  // ...
]

// Command execution
function executeCommand(input: string, context: CommandContext) {
  const [cmd, ...args] = input.slice(1).split(' ')
  const command = commands.find(c => c.name === cmd)
  if (command) {
    return command.handler(args, context)
  }
  throw new Error(`Unknown command: ${cmd}`)
}

Tasks

  • Create src/cli/ink/commands/registry.ts - command definitions
  • Create src/cli/ink/commands/handlers/ - individual command handlers
  • Implement help command
  • Implement agent/model switching with SelectMenu
  • Implement session management commands
  • Implement utility commands (clear, compact, cost)
  • Implement /start command for context initialization
  • Wire up command execution in InputLine

Acceptance Criteria

  • All existing commands work
  • /help shows all commands
  • /agent and /model show selection menus
  • /sessions lists and allows selection
  • Unknown commands show error

Estimated Effort

1 day

Risk

Low - porting existing logic

Dependencies

Originally created by @randomm on GitHub (Feb 2, 2026). Originally assigned to: @thdxr on GitHub. ## Parent Epic Part of #11762 (Ink-based TUI Rewrite) ## Objective Port the existing slash command system to the Ink architecture. ## Current Commands (from commands.ts) | Command | Description | |---------|-------------| | `/help` | Show help | | `/clear` | Clear screen | | `/agent [name]` | Switch agent | | `/model [name]` | Switch model | | `/session [id]` | Switch session | | `/sessions` | List sessions | | `/new` | New session | | `/compact` | Toggle compact mode | | `/start` | Initialize context | | `/bug` | Report bug | | `/cost` | Show token costs | | `/config` | Edit config | | `/quit` | Exit | ## Architecture ```tsx // Command registry interface Command { name: string description: string handler: (args: string[], context: CommandContext) => Promise<void> } interface CommandContext { dispatch: Dispatch<Action> session: SessionState setUIMode: (mode: UIMode) => void } const commands: Command[] = [ { name: 'help', description: 'Show available commands', handler: async (args, ctx) => { ctx.dispatch({ type: 'SHOW_HELP' }) } }, { name: 'agent', description: 'Switch agent', handler: async (args, ctx) => { if (args[0]) { await switchAgent(args[0]) } else { ctx.setUIMode('select') ctx.dispatch({ type: 'SHOW_AGENT_SELECT' }) } } }, // ... ] // Command execution function executeCommand(input: string, context: CommandContext) { const [cmd, ...args] = input.slice(1).split(' ') const command = commands.find(c => c.name === cmd) if (command) { return command.handler(args, context) } throw new Error(`Unknown command: ${cmd}`) } ``` ## Tasks - [ ] Create `src/cli/ink/commands/registry.ts` - command definitions - [ ] Create `src/cli/ink/commands/handlers/` - individual command handlers - [ ] Implement help command - [ ] Implement agent/model switching with SelectMenu - [ ] Implement session management commands - [ ] Implement utility commands (clear, compact, cost) - [ ] Implement /start command for context initialization - [ ] Wire up command execution in InputLine ## Acceptance Criteria - [ ] All existing commands work - [ ] `/help` shows all commands - [ ] `/agent` and `/model` show selection menus - [ ] `/sessions` lists and allows selection - [ ] Unknown commands show error ## Estimated Effort 1 day ## Risk Low - porting existing logic ## Dependencies - #11764 (App component) - #11769 (TextInput) - #11770 (SelectMenu)
yindo added the opentui label 2026-02-16 18:09:40 -05:00
yindo closed this issue 2026-02-16 18:09:40 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Feb 2, 2026):

For keybind-related issues and command documentation, please also check our pinned keybinds documentation: #4997

@github-actions[bot] commented on GitHub (Feb 2, 2026): For keybind-related issues and command documentation, please also check our pinned keybinds documentation: #4997
Author
Owner

@randomm commented on GitHub (Feb 3, 2026):

Reopening - Phase 1 & 2 components merged successfully. Proceeding with slash commands.

@randomm commented on GitHub (Feb 3, 2026): Reopening - Phase 1 & 2 components merged successfully. Proceeding with slash commands.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#8317