Skip to content

Commit e5ccf07

Browse files
authored
feat(bot): add /messages command and support for fork and revert for ecah message (#136)
1 parent 5005532 commit e5ccf07

14 files changed

Lines changed: 1611 additions & 3 deletions

File tree

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ OPENCODE_MODEL_ID=big-pickle
6464
# Maximum number of sessions shown in /sessions (default: 10)
6565
# SESSIONS_LIST_LIMIT=10
6666

67+
# Maximum number of user messages shown per page in /messages (default: 10)
68+
# MESSAGES_LIST_LIMIT=10
69+
6770
# Maximum number of projects shown in /projects (default: 10)
6871
# PROJECTS_LIST_LIMIT=10
6972

PRODUCT.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ Current command set:
102102
- `/abort` - stop the current task
103103
- `/detach` - detach the bot from the current session without stopping it
104104
- `/sessions` - show and switch recent sessions
105+
- `/messages` - browse user messages in the current session
105106
- `/projects` - show and switch projects
106107
- `/worktree` - show and switch existing git worktrees for the current repository
107108
- `/tts` - toggle global audio replies
@@ -121,7 +122,7 @@ Text messages (non-commands) are treated as prompts for OpenCode only when no bl
121122

122123
Interaction routing rules:
123124

124-
- Only one interactive flow can be active at a time (inline menu, permission, question, rename, commands, skills)
125+
- Only one interactive flow can be active at a time (inline menu, permission, question, rename, commands, skills, messages)
125126
- While an interaction is active, unrelated input is blocked with a contextual hint
126127
- Allowed utility commands during active interactions: `/help`, `/status`, `/abort`, `/detach`
127128
- Unknown slash commands return an explicit fallback message
@@ -166,12 +167,12 @@ Model picker behavior:
166167
- [x] `/mcps` command: browse available MCP servers
167168
- [x] Optional local OpenCode server monitoring with automatic restart
168169
- [x] Interactive project file browsing and file download from Telegram (`/ls`)
170+
- [x] `/messages` command: browse session messages with revert and fork functionality
169171

170172
## Current Task List
171173

172174
Open tasks for upcoming iterations:
173175

174-
- [ ] `/messages` command: browse session messages with fork/revert actions
175176
- [ ] Model search in model switcher
176177
- [ ] Docker runtime support and deployment guide
177178
- [ ] Add a bot settings command with in-chat UI

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ opencode-telegram config
134134
| `/abort` | Abort the current task |
135135
| `/detach` | Detach from the current session without stopping it |
136136
| `/sessions` | Browse and switch between recent sessions |
137+
| `/messages` | Browse user messages, revert or fork from a previous state |
137138
| `/projects` | Switch between OpenCode projects |
138139
| `/worktree` | Switch between existing git worktrees |
139140
| `/open` | Add a project by browsing directories |
@@ -153,6 +154,14 @@ Any regular text message is sent as a prompt to the coding agent only when no bl
153154

154155
When the current project is a git repository, `/worktree` shows the existing worktrees for that repository. Status and pinned updates display the main project path with the active branch, and show a separate `Worktree` line when a linked worktree is selected.
155156

157+
## Message History, Revert, and Fork
158+
159+
The `/messages` command displays all user messages in the current session, sorted by time (newest first). Select a message to view its full text and access the **Revert** and **Fork** actions.
160+
161+
**Revert** rolls back the session state to the selected message, discarding all subsequent messages and agent responses. This is useful when you want to retry a different approach from a specific point in the conversation.
162+
163+
**Fork** creates a new session that branches from the selected message. The original session remains unchanged, and you can continue working in the new forked session. This is useful when you want to explore an alternative approach without losing the original conversation history.
164+
156165
## Scheduled Tasks
157166

158167
Scheduled tasks let you prepare prompts in advance and run them automatically later or on a recurring schedule. This is useful for periodic checks, routine code maintenance, or tasks you want OpenCode to execute while you are away from your computer. Use `/task` to create a scheduled task and `/tasklist` to review or delete existing ones.
@@ -210,6 +219,7 @@ When installed via npm, the configuration wizard handles the initial setup. The
210219
| `OPENCODE_MODEL_ID` | Default model ID | Yes | `big-pickle` |
211220
| `BOT_LOCALE` | Bot UI language (supported locale code, e.g. `en`, `de`, `es`, `fr`, `ru`, `zh`) | No | `en` |
212221
| `SESSIONS_LIST_LIMIT` | Sessions per page in `/sessions` | No | `10` |
222+
| `MESSAGES_LIST_LIMIT` | User messages per page in `/messages` | No | `10` |
213223
| `PROJECTS_LIST_LIMIT` | Projects per page in `/projects` | No | `10` |
214224
| `OPEN_BROWSER_ROOTS` | Comma-separated paths `/open` is allowed to browse (supports `~`) | No | `~` (home directory) |
215225
| `COMMANDS_LIST_LIMIT` | Items per page in `/commands` and `/skills` | No | `10` |

src/bot/commands/definitions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const COMMAND_DEFINITIONS: BotCommandI18nDefinition[] = [
2626
{ command: "abort", descriptionKey: "cmd.description.stop" },
2727
{ command: "detach", descriptionKey: "cmd.description.detach" },
2828
{ command: "sessions", descriptionKey: "cmd.description.sessions" },
29+
{ command: "messages", descriptionKey: "cmd.description.messages" },
2930
{ command: "tts", descriptionKey: "cmd.description.tts" },
3031
{ command: "projects", descriptionKey: "cmd.description.projects" },
3132
{ command: "worktree", descriptionKey: "cmd.description.worktree" },

0 commit comments

Comments
 (0)