Skip to content

Implement slash command system #11773

Closed as not planned
Closed as not planned

Description

@randomm

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

Activity

  1. added
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on Feb 2, 2026
  2. github-actions commented on Feb 2, 2026

    @github-actions
    Contributor

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

  3. randomm commented on Feb 3, 2026

    @randomm
    Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

opentuiThis relates to changes in v1.0, now that opencode uses opentui

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions