-
Notifications
You must be signed in to change notification settings - Fork 3.8k
feat IDE Integration: Live text selection and diff review/approval. #5447
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
… into prompt context, diff display view
Suggested UX improvements for IDE selection displayHey @tcdent, great work on this PR! I've been testing it and made a few UX improvements that make the selection behavior closer to Claude Code: Changes:1. Compact footer display (
2. Persistent selection (
3. Invisible context for model (
Code changes:local.tsx - simplified formatted()formatted: () => {
const sel = selStore.current
if (!sel || !sel.text) return null
const lines = sel.text.split("\n").length
return \
},prompt/index.tsx - synthetic part for selectionparts: [
{
id: Identifier.ascending("part"),
type: "text",
text: inputText,
},
...(local.selection.current()?.text ? [{
id: Identifier.ascending("part"),
type: "text" as const,
text: \,
synthetic: true,
}] : []),
...nonTextParts.map((x) => ({
id: Identifier.ascending("part"),
...x,
})),
],prompt/index.tsx - remove selection.clear() after submit- local.selection.clear()Let me know if you'd like me to open a separate PR with these changes! |
|
Update: Also added IDE/selection display to \ footer, so it's visible from launch (not just inside sessions). |
- Add IDE connection via WebSocket with JSON-RPC - Live text selection from editor displayed in footer - Selection sent as synthetic part (invisible but included in context) - IDE status visible in home screen footer - Fix reactivity with reconcile for IDE status updates Based on initial work from sst#5447, with additional UX improvements.
|
@tofunori Stoked you're finding use for it. By all means continue to improve on this PR; I'm not emotionally attached to any of the implementation details. |
|
Cheers! Hope it could get merged ! |
Adds IDE integration with server APIs from sst#5447: - WebSocket-based IDE connections - IDE server endpoints and SDK types - Streamed cursor selection into prompt context - Diff display view for file edits This provides the backend foundation for IDE integration.
Forgive me for being a Claude Code user up until this point; excited about being able to contribute to an open workflow instead of opening tickets and watching them go stale. One aspect of my workflow I really enjoy is the ability to send my highlights directly into context, and also have diffs appear in my IDE.
This patch uses the existing
coder/claudecode.nvim(and probably the existing VSCode extension I haven't tested yet) to connectopencodeto the websocket server they provide.After installing the plugin, launch
opencodeand use the/idecommand to select from the available open sockets. In nvim visual mode your selection will be automatically updated in the prompt window. When the agent proposes a change the diff will appear in the IDE and can either be approved inside the IDE or in the terminal session.In order to not hard-code any third party references, I made a couple config updates to
opencode.jsonthat are necessary for this to work:{ "ide": { "lockfile_dir": "/Users/tcdent/.claude/ide/", "auth_header_name": "x-claude-code-ide-authorization" } }Also, in order to get diff approval to wait for input, setting permission is necessary:
{ "permission": { "edit": "ask" } }This is more of a PoC than a production-ready feature and I'm sure everyone on the team here has some opinion about this, so I'm happy to continue working on this. For one thing, we should coordinate with an existing plugin maintainer for an opencode-specific integration. For now, this has made
opencodea drop-in replacement for my existing workflow, and I'm excited to own my entire dev environment again.