Skip to content

feat: default to blocks tool display + native edit diff viewer#12

Merged
justin-carper merged 1 commit into
mainfrom
blocks-default-rich-displ
Jun 10, 2026
Merged

feat: default to blocks tool display + native edit diff viewer#12
justin-carper merged 1 commit into
mainfrom
blocks-default-rich-displ

Conversation

@justin-carper

Copy link
Copy Markdown
Collaborator

Summary

Make "blocks" the default tool display and render Cursor file edits with opencode's native diff viewer.

Cursor's internal tool activity previously defaulted to compact "reasoning" lines. This switches the default to "blocks" (structured, provider-executed tool parts) and, for edits specifically, lights up opencode's built-in diff viewer.

Changes

Default → "blocks"

  • cursorEventsToStream / cursorEventsToContent default to "blocks"; createCursor sets toolDisplay: options.toolDisplay ?? "blocks".
  • "reasoning" remains the documented fallback for older / non-V3 hosts (opencode < 1.16). README + CHANGELOG updated.

Native diff viewer for edits

  • Cursor edit activity is emitted under opencode's registered edit tool so its built-in diff viewer renders; the real unified diff (Cursor's result.value.diffString) is passed via metadata.diff.
  • opencode's edit schema requires oldString/newString, which Cursor does not expose — these are reconstructed from the diff's -/+ lines purely to satisfy schema validation. The call is provider-executed, so they are never applied to disk.
  • The edit tool-call is buffered until its result (the diff only arrives with the result), then emitted call→result.
  • Any edit without a usable diff (errors, unexpected shapes, or a host without a registered edit tool) falls back to a safe cursor_edit block. All other tools remain cursor_* prefixed blocks.

Test infrastructure

  • tsconfig.json now covers test/; a new tsconfig.build.json handles the src-only declaration emit (wired into tsup). This surfaced and fixed 10 stale-type test bugs the previously-excluded test/ dir had hidden.

Verification

  • npm run typecheck, npm run build, and npm test (128 tests) all pass.
  • Manually verified against opencode: Cursor edits render in the native diff viewer; non-edit tools render as cursor_* blocks.

Notes

  • Reconstructed oldString/newString are faithful for single-hunk edits and approximate (concatenated) for multi-hunk; they appear in the transcript but are never executed.

Default toolDisplay to "blocks" so Cursor's tool activity renders as
structured tool blocks out of the box. "reasoning" stays available as
the documented fallback for pre-1.16 / non-V3 opencode hosts.

Map Cursor `edit` activity onto opencode's native `edit` tool so its
built-in diff viewer renders: the real unified diff is passed via
metadata.diff and oldString/newString are reconstructed from it (the
call is provider-executed, so they are never applied to disk). Edits
without a usable diff fall back to a safe cursor_edit block; all other
tools remain cursor_* prefixed blocks.

Test infra: typecheck now covers test/ via a dedicated build config
(tsconfig.build.json handles src-only emit), surfacing and fixing 10
stale-type test bugs that the excluded test dir had hidden.
@justin-carper justin-carper merged commit d0b28a5 into main Jun 10, 2026
6 checks passed
@justin-carper justin-carper deleted the blocks-default-rich-displ branch June 10, 2026 22:51
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