Skip to content

Pi / OpenCode native TUI slash commands don't execute in composer (+ unified /clear, /tree family) #138

Description

@PratikRai0101

Pi / OpenCode native TUI slash commands don't work in composer

Version: v0.1.40
OS: macOS
Harness: Pi (primary), OpenCode (same class of issue)

What happened

Typing Pi-native commands (/new, /sessions, /resume, /tree, /fork, /clone, /compact, /export, /session) or OpenCode-native commands (/sessions, /new, /compact, /export, /undo) in MonoCode's composer (Ask, build, / for commands...) does not execute them. They get sent as plain LLM prompt text.

Expected: they execute the harness-native action (or a MonoCode equivalent), like they do in pi TUI / opencode TUI.

Root cause (checked in source)

  1. MonoCode spawns Pi as pi --mode rpc (src/lib/harness/piProtocol.ts:buildPiSpawnArgs). Per Pi docs/rpc.md: "Built-in TUI commands (/settings, /hotkeys, etc.) are not included [in get_commands]. They would not execute if sent via prompt."
  2. src/lib/harness/piAdapter.tsdiscover: () => discoverPiSkills()piSkillsFromRpcData (src/lib/harness/piSkills.ts) filters to only source==="skill" + skill: prefix. Built-in TUI commands never enter the / picker.
  3. Only omp sets rawSlashCommands:true (src/lib/harness/piFamily.ts:157). pi doesn't, so isNativeCommandPrompt("/new","pi") is false (src/lib/skills.ts:114) and the text goes to the model.
  4. MonoCode session layer (monocode.db sessions + resumeByThread in piFamily.ts / opencode.ts) already owns tabs/sidebar — it just needs slash shims calling existing RPCs.

Proposed fix

Phase 1 — portable Pi + OpenCode shims (intercept in promptPreparation.ts + App.tsx:3538 before sendTurn, list in Composer.tsx picker):

Slash Pi native OpenCode native MonoCode mapping
/new /new /new (/clear) new tab
/clear — (new, unified) alias of /new same tab, new_session RPC + rebind, reset context meter, divider in blocks_json
/sessions + /resume, /continue /resume /sessions, /resume, /continue focus Sessions sidebar picker
/compact + /summarize /compact /compact, /summarize existing compactPiContext / compactOpenCodeContext
/export /export /export pi export_html RPC / opencode markdown export
/copy /copy copy last assistant block (harness-agnostic)
/models, /thinking /model, /thinking /models, /thinking aliases to model/thinking dropdowns (set_model / set_thinking_level)

Unknown /xxx on pi/opencode should show "TUI-only, not supported in MonoCode" instead of sending to the model.

Phase 2 — Pi session tree (pi-only):

  • /tree (read-only first): get_tree RPC → picker of prompts/branches
  • /tree:switch: jump + continue in same tab
  • /fork <n>: fork(entryId) (get_fork_messages) → new tab prefilled
  • /clone: clone RPC → duplicate tab

Phase 3: /share//unshare, /undo//redo (opencode git-backed vs pi /tree — needs workspace_snapshot UI), /init.

Don't port: /login, /logout, /connect, /settings, /themes, /editor, /exit, /trust, /scoped-models, /llama.

Files to touch

  • src/lib/harness/piAdapter.ts — shim command list
  • src/lib/promptPreparation.ts, src/App.tsx:3538 — intercept before sendTurn
  • src/chrome/Composer.tsx:496/ picker entries

Happy to PR Phase 1 (/new + /clear + /sessions + /compact + unknown-slash warning) if maintainers agree with the mapping.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions