feat: add semantic UI snapshots#40
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Expose OpenCode's versioned semantic UI tree through Drive.
Programs can now call
ui.snapshot(), poll one exact node withui.getNode(), and pass the resulting semantic node toui.click(). Nodes carry stable IDs, optional occurrence identity, role, label, hierarchy, component-owned state, and a transient renderer handle.Semantic snapshots and atomic semantic clicks are negotiated independently. Older OpenCode checkouts keep ordinary UI control, while unsupported semantic operations fail locally with typed
UiCapabilityErrorinstead of sending an unsafe request.How
ui.snapshotRPC, andui.click.semanticcapability from OpenCode.driver/ui.ts.{ id, instance, element }on semantic clicks so OpenCode validates live identity before mouse dispatch.--command.ui.snapshotwith the same optional-capability guard as the programmatic API.opencode-drive.Scope
This PR consumes the canonical producer shipped by OpenCode PRs #37802 and #37808. It does not add semantic IDs for more TUI components or implement the separate arbitrary-tool lifecycle protocol.
Testing
bun run release:validateinpackages/drivebun run testinapps/catalog: 28 passedgit diff --checkFlow
sequenceDiagram participant Program as Drive program participant Drive participant OpenCode as OpenCode UI endpoint participant TUI Drive->>OpenCode: simulation.handshake(optional ui.snapshot, ui.click.semantic) Program->>Drive: ui.getNode(query) loop until one exact match Drive->>OpenCode: ui.snapshot OpenCode->>TUI: read live semantic tree TUI-->>Drive: versioned nodes end Program->>Drive: ui.click(node) Drive->>OpenCode: ui.click(target, position, semantic identity) OpenCode->>TUI: validate identity and dispatch click TUI-->>Program: updated UI state