Repository navigation
feat: modernize diff display and migrate Charm UI stack to v2 - #576
Merged
Merged
Conversation
Replaces the hand-rolled parallel-array algorithm in DiffRenderer with a new diffview package built on aymanbagabas/go-udiff. The previous code marked every line after a mid-file insertion as both added and removed; the new implementation produces correct line shifts. - New internal/ui/components/diffview/ package with fluent builder - go-udiff for LCS-based diff computation - chroma syntax highlighting inside diff lines (opt-in via ChromaStyle) - Background-tinted insert/delete rows (GitHub-style) - Width-adaptive Auto layout (split when width >= 160, else unified) - Dark + light default styles tuned to existing themes Legacy DiffRenderer becomes a thin adapter forwarding to DiffView. Public surface unchanged; SetWidth(int) added for terminal-width-aware layout selection. Provider.GetCurrentTheme() exposed so the renderer can pick light/dark style by luminance of the assistant text color.
Imports moved from github.com/charmbracelet/{bubbletea,lipgloss,bubbles,
glamour} to the charm.land/{...}/v2 vanity domains. Mechanical compile
fixes follow from the v2 API differences:
- tea.Model.View() returns tea.View (struct), not string. The 14
affected types either inline-wrap (tea.NewView(x.Render())) or factor
the body into a private viewContent() string with a thin View()
wrapper. Sub-View() callers in chat.go consume .Content.
- bubbles/v2 viewport: Width/Height/YOffset are methods, not fields.
Constructor takes ...Option (WithWidth/WithHeight). All read and
write sites updated.
- bubbles/v2 progress: WithDefaultGradient was removed; switched to
WithDefaultBlend (the v2 equivalent).
- tea.MouseMsg is now an interface; wheel-up handling switched to the
concrete MouseWheelMsg with Button == MouseWheelUp.
- tea.KeyMsg is now an interface; struct literals in tests and the
pending-handler call site switched to tea.KeyPressMsg with the v2 Key
fields (Code for non-printables, Text for printable input). The same
pattern applied in init_github_action_view's text input handler.
- tea.EnableMouseCellMotion / tea.DisableMouse / tea.WithMouseCellMotion
/ tea.WithReportFocus removed; v2 controls these via View.MouseMode
and View.ReportFocus. The toggle-mouse keybinding now drives only the
state and status message; honoring the state in View is a follow-up.
- glamour.WithAutoStyle removed; v2 defaults to dark when no style
option is supplied, matching v1 behavior on dark terminals.
- lipgloss.Color is now a constructor returning color.Color rather
than a string-typed type. colors.GetLipglossColor's return type
becomes color.Color; the in-diff background extraction reads RGBA
from color.Color and re-encodes as hex for the chroma formatter.
- colors_test compares via reflect.DeepEqual instead of stringifying.
All tests pass; lint clean; binary builds.
A fourth built-in theme alongside Tokyo Night, GitHub Light, and Dracula. Uses the official Charm semantic tokens from github.com/charmbracelet/x/exp/charmtone - Sapphire as the primary blue, Cherry for errors, Julep for success, Charple for status, Smoke and Iron for neutrals, Salt for assistant text. Charmtone Keys implement color.Color and expose .Hex(), so each Theme getter just forwards. Registered as "charm" in the default theme provider; users select it via the existing /theme picker or by setting it as the active theme in config. The on-screen luminance check still classifies it as dark, so diffview keeps the dark Style and diff backgrounds read correctly.
edenreich
force-pushed
the
feat/modernize-diff-display
branch
from
June 2, 2026 08:15
a873a2f to
e5503bb
Compare
CI lint started reporting 103 SA5011 "possible nil-pointer dereference"
warnings on this branch in files my changes never touched (config/*_test.go,
internal/utils/shell_tracker_test.go, etc.). The pattern is the standard
`if x == nil { t.Fatal(...) }; useX(x)`. testing.T.Fatal is NoReturn, so
the dereference is safe; local staticcheck recognises that and reports
0 issues, but CI's flagged it. Exclude SA5011 in *_test.go to make the
two environments agree.
edenreich
force-pushed
the
feat/modernize-diff-display
branch
from
June 2, 2026 08:46
adf0787 to
d0ee4a2
Compare
…nput
Bubble Tea v2 changed what KeyMsg.String() returns for named printable
keys. For a space press, v1 returned " " and v2 returns "space". The
input handler used String() both for keybinding lookups *and* for
inserting the literal character into the buffer:
if keys.IsPrintableCharacter(keyStr) {
return handlePrintableCharacter(keyStr, inputView)
}
So pressing space tried to insert "space" (5 chars, IsPrintableCharacter
fails) and the input swallowed the keystroke entirely.
Introduce keys.PrintableText(KeyMsg) that pulls from KeyPressMsg.Text
(the v2 field carrying the literal typed text — " " for space, "a" for
a, "" for Enter/Backspace/arrows/modifier combos). Switch CanInputHandle
and the printable branch of handleCharacterInput to use it. The
keybinding-lookup path keeps using String() for named keys.
Also widen the cursor advance from +1 to +len(literal) so multi-byte
runes (é, 中, etc.) move the cursor past the full insertion.
Two regressions from the Bubble Tea v2 migration prevented conversation-
history scrolling:
1. Mouse wheel had no effect. v2 reads mouse mode from `tea.View.MouseMode`
on every render rather than from a one-shot `tea.EnableMouseCellMotion`
command (which we removed). With MouseMode defaulting to
MouseModeNone, no mouse/wheel events ever reached the program, so
neither the viewport's built-in wheel scrolling nor the userScrolledUp
tracker fired. ChatApplication.View now sets MouseMode to
MouseModeCellMotion whenever app.mouseEnabled is true — so ctrl+s
actually takes effect again.
2. Page Down had no effect. v2's KeyPressMsg{Code: KeyPgDown}.String()
returns "pgdown"; v1 returned "pgdn". The page_down binding only
listed "pgdn" / "page_down", so the v2 keystroke never matched.
Accept "pgdown" as a third alias in the binding and add it to
AllKnownKeys so it isn't misclassified as paste either.
The Nix build runs `go test` in a hermetic sandbox with no git on PATH, so the gitdiff tests failed with "exec: git: executable file not found". Skip them when git is absent (only TestParsePatch needs no git), so the suite and the Nix build pass. The software does not require git to run: gitdiff.IsRepo returns false when git is missing and /diff degrades to a "not a git repository" message.
edenreich
force-pushed
the
feat/modernize-diff-display
branch
from
June 4, 2026 19:41
42cbb8b to
9bc72c1
Compare
inference-gateway-releaser Bot
pushed a commit
that referenced
this pull request
Jun 5, 2026
## [0.118.0](v0.117.1...v0.118.0) (2026-06-05) ### 🚀 Features * add file explorer panel with tree view, preview, and fuzzy finder ([#589](#589)) ([2b73fcc](2b73fcc)), closes [#588](#588) * **cli:** adopt fang for styled help, errors, version and completions ([#592](#592)) ([b7f649e](b7f649e)) * **tui:** animate loading states and modernise progress/cursor styling ([#594](#594)) ([06057d7](06057d7)) * **tui:** drive diff colours from the active theme ([#598](#598)) ([f279c1c](f279c1c)) * modernize diff display and migrate Charm UI stack to v2 ([#576](#576)) ([6bf8ac6](6bf8ac6)) * **tui:** rebuild GitHub Action setup wizard with huh forms ([#597](#597)) ([c875e84](c875e84)) * theme collapsed tool result previews ([#603](#603)) ([ffc2ee9](ffc2ee9)) ### 🐛 Bug Fixes * **pricing:** flag Pro-subscription Ollama Cloud models in model picker ([#604](#604)) ([5ec0298](5ec0298)) * **tools:** make bash whitelist shell-aware to fix benign-command rejections ([#581](#581)) ([#605](#605)) ([6119f2a](6119f2a)) ### ♻️ Code Refactoring * **tui:** migrate theme selector to bubbles/v2/list ([#596](#596)) ([a46079c](a46079c)) * move git branch indicator to input view border ([#602](#602)) ([7132237](7132237)) * remove redundant comment ([8e3210d](8e3210d)) * **tui:** render help bar with bubbles/v2/help ([#595](#595)) ([5aed140](5aed140)) * **cli:** render list commands with native lipgloss tables ([#593](#593)) ([28a0e55](28a0e55)) * **config:** replace bespoke config commands with generic get/set ([#601](#601)) ([c80321a](c80321a)), closes [#600](#600) * separate git branch into own status bar row ([#591](#591)) ([9afbeb4](9afbeb4)) ### 💄 Styles * standardize log message capitalization ([e8ae466](e8ae466)) ### 🔧 Build System * **deps:** bump modernc.org/sqlite from 1.50.1 to 1.51.0 in the gomod group ([#584](#584)) ([908cfc4](908cfc4)) * **deps:** bump the github-actions group with 3 updates ([#585](#585)) ([a14de3e](a14de3e)) * **deps:** upgrade fang to charm.land/fang/v2 v2.0.1 ([d1b861f](d1b861f)) ### 👷 CI/CD * centralize claude.yml via reusable workflow ([#583](#583)) ([9a6839d](9a6839d)) * replace Nix build check with adl-cli recompute pattern ([#586](#586)) ([9c5f7cc](9c5f7cc)), closes [#585](#585) [#585](#585) [#585](#585) ### 🧹 Maintenance * **deps:** bump claude-code 2.1.148 -> 2.1.158 ([#582](#582)) ([5e8d0b5](5e8d0b5)) * **deps:** bump infer CLI v0.117.0 -> v0.117.1, infer-action v0.9.1 -> v0.11.1 ([#580](#580)) ([90ddcf3](90ddcf3)) * **deps:** bump infer-action v0.11.1 -> v0.11.2 ([#587](#587)) ([56f2df8](56f2df8)) * regenerate keybindings from earlier features ([ff09192](ff09192))
Contributor
|
🎉 This PR is included in version 0.118.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Closed
This was referenced Jun 30, 2026
edenreich
added a commit
that referenced
this pull request
Jun 30, 2026
…ard (#697) ## Summary In the chat TUI input, `opt+backspace` (macOS) / `alt+backspace` and `ctrl+backspace` no longer deleted the previous word — only `ctrl+w` did. This restores the readline/macOS convention. Closes #689 ## Root cause The chat input is a custom `InputView` (introduced in the Charm UI v2 migration, #576), driven by the keybinding registry rather than a native bubbles `textarea`. The `delete_word_backward` action carried over only `ctrl+w`. An unbound `alt+backspace` flows `ProcessKey → handleSingleKey`, fails `registry.Resolve`, and falls through to `handleCharacterInput`, where `keys.CanInputHandle` returns `false` (not in `InputHandlerKeys`, no printable text) — so it is a no-op. Verified in the Bubble Tea v2 / ultraviolet source that `keyMsg.String()` emits exactly `"alt+backspace"` (`Keystroke()` prepends `alt+`; `keyTypeString[KeyBackspace] = "backspace"`), so binding the key dispatches the existing `handleDeleteWordBackward` handler. ## Changes - **`internal/ui/keybinding/actions.go`** — registry default for `delete_word_backward`: `ctrl+w` → `ctrl+w, alt+backspace, ctrl+backspace`. - **`config/keybindings.go`** — the config default (`GetDefaultKeybindings`) kept in sync. This is the *effective* binding for normal sessions: `ApplyConfigOverrides` runs by default (`Chat.Keybindings.Enabled = true`) and **full-replaces** an action's keys, so both default sources must agree. - **`internal/ui/keybinding/registry_test.go`** — `TestDeleteWordBackwardBindings` asserts both default paths (registry default and the config-override path that mirrors chat startup), guarding the two-source sync. - **`docs/configuration-reference.md`** — macOS terminal note ("Use Option as Meta key"). `ctrl+backspace` is included for cross-platform parity (word-delete convention on Windows/Linux); no existing binding/conflict, harmless where a terminal doesn't emit it. No change to `InputHandlerKeys`/`CanInputHandle` is needed — the registry resolves and dispatches the key before that fallback. ## Testing - `task build` ✓ - `task test` (full suite) ✓ - `task lint` (golangci-lint 0 issues + markdownlint) ✓ Manual: `./infer chat`, type `hello world foo`, press opt+backspace → `hello world ` (word deleted); `ctrl+w` still deletes a word. ## Note for users Anyone with an existing `keybindings.yaml` from a prior `infer init` has `delete_word_backward` pinned to `ctrl+w` only; that file overrides the new default. They can pick up the new keys with `infer keybindings reset` (or by re-generating the file). Fresh installs and the in-code defaults get them immediately.
inference-gateway-releaser Bot
added a commit
that referenced
this pull request
Jun 30, 2026
## [0.126.0](v0.125.0...v0.126.0) (2026-06-30) ### 🚀 Features * add persistent memory tool for agent ([#679](#679)) ([a487b13](a487b13)) * **agent:** interactive subagent management and unified background-work tracking ([#684](#684)) ([343e083](343e083)) ### 🐛 Bug Fixes * **chat:** bind opt+backspace and ctrl+backspace to delete-word-backward ([#697](#697)) ([173fe83](173fe83)), closes [#689](#689) [#576](#576) * **a2a:** retain completed background tasks in /tasks ([#691](#691)) ([#701](#701)) ([43b8e13](43b8e13)) * **autocomplete:** surface arguments for one-of/all-optional tool schemas ([#698](#698)) ([655b2e4](655b2e4)) ### ♻️ Code Refactoring * add .gitignore by default to the projects dir ([4717deb](4717deb)) * enable memory by default ([86c2158](86c2158)) * make infer config userspace-first ([#682](#682)) ([1e77e42](1e77e42)), closes [#680](#680) * **tui:** single event-loop ingress - one notifier, no self-rescheduling pollers ([#700](#700)) ([2ab8854](2ab8854)) * standardize comment punctuation by replacing em dashes with hyphens ([78f53a8](78f53a8)) ### 📚 Documentation * fix docs/ drift found by the README-to-codebase audit ([#687](#687)) ([413047a](413047a)), closes [#572](#572) [#686](#686) * sync README and reference docs with the codebase ([#685](#685)) ([c328423](c328423)), closes [#572](#572) [#684](#684) [#684](#684) ### 👷 CI/CD * **deps:** update CLAUDE workflow to version 0.14.5 ([eaba2b3](eaba2b3)) ### 🧹 Maintenance * add .infer to .gitignore ([08ef319](08ef319)) * **deps:** bump infer CLI v0.124.0 -> v0.125.0, infer-action v0.19.0 -> v0.19.1 ([#681](#681)) ([e9e7e21](e9e7e21)) * remove agent definitions ([4f7fd7d](4f7fd7d)) * remove unused configuration and shortcut files ([4c611db](4c611db)) * update claude-code to 2.1.191 ([729e81c](729e81c))
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.
Summary
aymanbagabas/go-udiff+alecthomas/chroma/v2. The legacyDiffRendererwalked old/new line arrays in parallel and misrepresented every mid-file insert as a cascade of paired add/delete; the newinternal/ui/components/diffview/package produces correct line shifts, optional in-line syntax highlighting, GitHub-style tinted backgrounds, and a width-adaptive split/unified layout (split at ≥160 cols, unified below). The legacyDiffRendereris now a thin adapter — public API unchanged.charm.land/{bubbletea,lipgloss,bubbles,glamour}/v2). Touches imports across ~60 files and includes the mechanical API fixes:tea.Model.View()now returnstea.View(14 sites), viewportWidth/Height/YOffsetare methods andviewport.NewtakesOptions,tea.MouseMsg/tea.KeyMsgare now interfaces (wheel handler switched toMouseWheelMsg, key struct literals switched totea.KeyPressMsgwithCode/Textfields),glamour.WithAutoStyleremoved,lipgloss.Coloris now acolor.Colorconstructor,progress.WithDefaultGradient→WithDefaultBlend.charmtheme built ongithub.com/charmbracelet/x/exp/charmtonesemantic tokens (Sapphire / Cherry / Julep / Charple / Smoke / Iron / Salt over Pepper). Selectable via the existing/themepicker.Three commits, 70 files, +1533 / −831.
Follow-ups (not in this PR)
chat.diff.layout/chat.file_iconsconfig knobs (thediffviewbuilder already supports both; just needs wiring inconfig/config.go).app.GetMouseEnabled()into the roottea.View.MouseMode(v2 removed the imperative enable/disable commands).