Skip to content

feat(opencode): add /loop command - #51974

Closed
rudolf-blue wants to merge 3 commits into
anomalyco:devfrom
rudolf-blue:loop-command
Closed

rudolf-blue wants to merge 3 commits into
anomalyco:devfrom
rudolf-blue:loop-command

Conversation

@rudolf-blue

Copy link
Copy Markdown

Issue for this PR

Refs #41907. That issue asks for a count or retry-until-pass loop. This PR covers the timer form from #18001 and #23578, which were both auto-closed for inactivity.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds a built-in /loop command that sends a prompt right away and then again on a fixed interval, e.g. /loop 5m check whether the deploy finished. The interval is optional (defaults to 10m), and the prompt can be another command, so /loop 30m /review works. /loop stop ends it, and so does interrupting the session.

It lives on the server side, in SessionPrompt.command, so the TUI and web app get it without client changes. The registry entry has no template; command() spots it and runs the timer itself. Each session gets at most one timer, kept in a FiberMap: starting a new loop replaces the old one, and cancel() clears it. When a tick fires while the session is busy, it is skipped instead of queued behind the current turn. Custom loop commands from config or MCP still take precedence, because the check compares against the built-in entry, not the name.

This is narrower than #23575. There is no self-paced mode, no continue markers parsed out of model output, and no project default prompt file. It is only a timer.

How did you verify your code works?

  • Added six tests in test/session/prompt.test.ts: repeat until /loop stop, cancel stops the loop, cancel and stop both return promptly while a tick is mid-turn, looping another command, and the usage error for an empty prompt. I checked that the cancel test fails when the FiberMap.remove in cancel() is taken out.
  • bun test for test/session/prompt.test.ts, test/command, test/server, test/acp and test/cli/run passes, and bun run typecheck in packages/opencode is clean.
  • Ran opencode serve against a local OpenAI-compatible stub and drove it over HTTP: /loop 3s say hi ticked every ~3s, /loop stop and POST /session/:id/abort both ended it, and /loop shows up in GET /command.

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@matborowiak

Copy link
Copy Markdown

Just moved from CC to OpenCode, with one foot still in CC, mostly because of the /loop. We need this.

@thdxr

thdxr commented Oct 10, 2026

Copy link
Copy Markdown
Member

This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2.

— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

@thdxr thdxr closed this Oct 10, 2026
@rudolf-blue rudolf-blue mentioned this pull request Oct 11, 2026
3 of 6 tasks
rudolf-blue added a commit to rudolf-blue/opencode that referenced this pull request Oct 11, 2026
Sends a prompt now and again on an interval, e.g. /loop 5m check the
deploy. Port of anomalyco#51974 to v2 as a built-in command plugin.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants