Skip to content

feat: add open_diff, open_readonly, and readonly open_file plugin APIs - #438

Open
eugenioenko wants to merge 2 commits into
mainfrom
feat/open-diff-api
Open

feat: add open_diff, open_readonly, and readonly open_file plugin APIs#438
eugenioenko wants to merge 2 commits into
mainfrom
feat/open-diff-api

Conversation

@eugenioenko

Copy link
Copy Markdown
Owner

Summary

  • Adds ttt.open_diff(title, old_lines, new_lines, file_path) Lua API — opens a native styled diff tab using the existing DiffViewWidget, enabling plugins to render side-by-side diffs from arbitrary content (e.g. git commit diffs)
  • Adds ttt.open_readonly(title, lines, file_path) Lua API — opens a readonly buffer tab with content provided directly, with syntax highlighting based on file_path extension (e.g. viewing a file at a specific git commit)
  • Extends ttt.open_file(path, line, readonly) with optional third boolean argument for readonly mode
  • Adds ReadOnly flag to editorTab and EditorPaneWidget that blocks all mutations (typing, enter, backspace, delete, tab/backtab) and refuses to save
  • Both open_diff and open_readonly require panel.editor permission

These are the core primitives needed for a git-history plugin to show per-file commit history with native diff rendering and historical file viewing.

Test plan

  • E2E tests: TestOpenDiff, TestOpenBufferReadOnly, TestOpenFileReadOnly, TestOpenBufferReadOnlyReuseTab
  • Functional tests: open_diff opens diff tab, open_readonly opens readonly tab, readonly blocks typing, open_file with readonly flag
  • Full test suite passes (go test ./...)

🤖 Generated with Claude Code

eugenioenko and others added 2 commits August 3, 2026 21:34
Expose three new Lua plugin APIs for the git history plugin:
- ttt.open_diff(title, old_lines, new_lines, file_path) — opens a
  native styled diff tab using the existing DiffViewWidget
- ttt.open_readonly(title, lines, file_path) — opens a buffer tab
  with content provided directly, in readonly mode
- ttt.open_file(path, line, readonly) — extended with optional third
  argument to open files in readonly mode

Readonly tabs block all mutations (typing, enter, backspace, delete,
tab/backtab) and refuse to save.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
These APIs open read-only tabs, same as open_file — no permission needed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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