feat: /undo & /redo slash commands — revert/restore messages + file changes #293

Closed
opened 2026-07-12 01:29:38 +02:00 by dries · 0 comments
Owner

Part of OpenCode command parity (transparent-layer goal). OpenCode's TUI has /undo and /redo to revert the last message + its file changes and restore them. These are git-backed inside OpenCode.

Approach (decided): proxy the OpenCode API — do NOT reimplement git in ocman

OpenCode's SDK/HTTP exposes session revert/unrevert:

  • session.revert({ path, body }) → returns Session (maps to /undo)
  • session.unrevert({ path }) → returns Session (maps to /redo)
    Ref: https://opencode.ai/docs/sdk (Sessions table)

Scope

  • Add a mutation path in the OpenCode adapter (internal/platforms/opencode) that proxies revert/unrevert on the live HTTP instance.
  • Surface via sessionsvc so REST handlers reuse the one mutation code path.
  • Add undo/redo to BUILTIN_COMMANDS; /redo only meaningful after /undo.
  • Requires a live OpenCode instance (revert/unrevert are runtime, not DB-readable) and a git repo. Gate the command / show a clear message when the instance isn't running.
  • Refresh the thread after revert so the reverted state + restored user message render (matches TUI behaviour).

Notes

Biggest functional gap of the batch. Because it mutates files on disk, confirm the API contract (what a message id means for revert, partial vs full) with a small spike before wiring the UI.

Part of OpenCode command parity (transparent-layer goal). OpenCode's TUI has `/undo` and `/redo` to revert the last message + its file changes and restore them. These are git-backed **inside OpenCode**. ## Approach (decided): proxy the OpenCode API — do NOT reimplement git in ocman OpenCode's SDK/HTTP exposes session revert/unrevert: - `session.revert({ path, body })` → returns Session (maps to /undo) - `session.unrevert({ path })` → returns Session (maps to /redo) Ref: https://opencode.ai/docs/sdk (Sessions table) ## Scope - Add a mutation path in the OpenCode adapter (internal/platforms/opencode) that proxies revert/unrevert on the live HTTP instance. - Surface via sessionsvc so REST handlers reuse the one mutation code path. - Add `undo`/`redo` to `BUILTIN_COMMANDS`; `/redo` only meaningful after `/undo`. - Requires a **live** OpenCode instance (revert/unrevert are runtime, not DB-readable) and a git repo. Gate the command / show a clear message when the instance isn't running. - Refresh the thread after revert so the reverted state + restored user message render (matches TUI behaviour). ## Notes Biggest functional gap of the batch. Because it mutates files on disk, confirm the API contract (what a message id means for revert, partial vs full) with a small spike before wiring the UI.
dries closed this issue 2026-07-19 18:07:15 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
dries/ocman#293
No description provided.