Skip to content

feat(tui): add optimize prompt workflow#18759

Open
wangxumarshall wants to merge 5 commits intoanomalyco:devfrom
wangxumarshall:dev
Open

feat(tui): add optimize prompt workflow#18759
wangxumarshall wants to merge 5 commits intoanomalyco:devfrom
wangxumarshall:dev

Conversation

@wangxumarshall
Copy link

### Issue for this PR

Closes #

### Type of change

- [ ] Bug fix
- [x] New feature
- [ ] Refactor / code improvement
- [ ] Documentation

### What does this PR do?

This PR adds the `optimize` feature to the TUI.

Users can now optimize the prompt they are writing before sending it. The feature includes:

- an `optimize` action in the prompt UI
- a `/optimize` slash command
- a `Ctrl+O` keyboard shortcut
- a loading state while optimization is running
- an editable review dialog before applying the optimized prompt

On the backend, the optimize flow sends the current prompt and optional recent session context to the server, selects an available model, rewrites the prompt into a clearer and more actionable version, and keeps the output in the same language as the input.

This PR also includes the plugin-facing pieces needed for the feature:
- `tui.ui.interact` support
- a sample `prompt-optimizer` plugin
- config to load that plugin from `.opencode/opencode.jsonc`

Why this works:
the feature now has a complete flow from the TUI interaction, to the server optimization request, to the returned optimized prompt, and back into the composer with a confirmation/edit step before replacing the original text.

### How did you verify your code works?

- Ran `bun test test/optimize/ui-interact.test.ts` in `packages/opencode`
- Ran `bun typecheck` in `packages/plugin`
- Ran `bun run build` in `packages/opencode`

### Screenshots / recordings

_Not included._

### Checklist

- [x] I have tested my changes locally
- [x] I have not included unrelated changes in this PR

WangxuMarshall added 5 commits March 19, 2026 21:56
- Add optimize button and Ctrl+O shortcut in TUI prompt
- Add /tui/optimize-prompt endpoint using AI to enhance prompts
- Add dialog-optimize.tsx for showing optimization preview
- Support conversation context for better optimization

Signed-off-by: WangxuMarshall <wangxumarshall@qq.com>
Entire-Checkpoint: 331bb04581fe
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.

1 participant