Repository navigation
fix(tui): show the whole value when text goes in at the start of the Custom Command and Link editors - #785
Merged
sirmalloc merged 1 commit intoNov 5, 2026
Conversation
Ink 6.2.0's insertBeforeNode returns early when it inserts a node before an existing sibling, so it never marks the parent text dirty the way appendChildNode (and its own append branch) do. Yoga keeps the text's old measured size, and Ink wraps the line at the old width onto rows the layout never reserved, where the next row draws over it. It stays that way until something re-measures the text, such as the next key. The Custom Command and Link editors render the value as three sibling texts: the part before the cursor, the cursor cell and the rest. With the cursor at the start, as in an empty field, the part before it renders nothing, so the next input inserts a new text ahead of the cursor cell. Pasting "npx ccusage statusline" into an empty Custom Command field showed only "npx ccusage", though Enter saved the whole command. A URL or link text pasted into an empty Link field was cut the same way, with its cut-off end showing at the end of the next row. A key typed at the start of a command that was already the editor's widest row hid the command's last word. Add a hunk to the ink patch that marks the node dirty after both branches, as Ink does upstream from 6.8.0.
Contributor
|
Reproduced on current Red: the new Green: after a fresh
|
Owner
|
Nice one, this has always annoyed me. |
This was referenced Nov 7, 2026
Closed
Closed
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
Text pasted or typed into the Custom Command and Link editors with the cursor at the start, as in an empty field, now shows in full. On
mainthe field kept the line's old width, so it showed only part of the value until the next key, though Enter saved all of it.Why
Ink 6.2.0's
insertBeforeNode(build/dom.js) returns early when it inserts a node before an existing sibling. That skips themarkNodeAsDirtycall thatappendChildNodeand its own append branch make. Yoga then reuses the text's old measurement, and Ink wraps the line at the old width onto rows the layout never reserved, where the next row draws over them.The Custom Command and Link editors render the value as three siblings inside one
<Text>:value.slice(0, cursor), the cursor cell and the rest. With the cursor at the start, the first part is an empty string, which React renders as no node. So the next input inserts a new text node ahead of the cursor cell, which takes the early-return path.On
main:dist/in tmux (110 columns) under Bun 1.4.2 and Node 26.10.0, withnpx ccusage statuslinepasted in one write into an empty Custom Command field:Enter command path: npx ccusage.Custom Command (npx ccusage statu...).https://github.com/sirmalloc/ccstatusline: the field showsEnter URL (http/https): https://github, and the row below readsCurrent text: (uses URL)ine.ccstatusline on GitHub: the field showsEnter link text (blank uses URL):with nothing after it, and the row below readsCurrent URL: (none)Hub.npx -y ccusage@latest statusline --offline, Left to the start, thenx:Enter command path: xnpx -y ccusage@latest statusline.--offlinecomes back with the next key.The editor is as wide as its widest row, here the 38-column help line
←→ move cursor, Enter save, ESC cancel. Before the paste the field row was laid out at that width, and Yoga keeps it. Ink wraps the pasted line at 38 columns, and the next row draws over the second line. That's why the URL is cut at exactly column 38 and its tail (ine) shows past the end of the shorter row below.Ink fixed this upstream in 6.8.0: vadimdemedes/ink#879 (for vadimdemedes/ink#867) marks the node dirty after both branches.
How
patches/ink@6.2.0.patchgets a second hunk, forbuild/dom.js.insertBeforeNodeno longer returns early, so both the insert and the append branch reach the existingmarkNodeAsDirtycall. The function now matches Ink 6.8.0'sbuild/dom.jsline for line. The backspace hunk is unchanged.bun patch ink@6.2.0andbun patch --commit node_modules/ink, minus the empty.bun-tag-*file entry bun adds.package.jsonandbun.lockdon't change, since the lockfile records only the patch's path.bun install --frozen-lockfilefrom a clean checkout applies both hunks.dist/, so the built CLI carries the patchedinsertBeforeNode.src/tui/__tests__/ink-patch.test.tsx: a<Box><Text>with the editors' split ('Command: ', the part before the cursor, an inverse cursor cell, the rest).statuslinewith the cursor at the start, then rerendersnpx ccusage statuslinewith the cursor on the sames. Only the part before the cursor changes, from no node to a new one, and the test expects the whole line.mainwithReceived: "Command: npx".AGENTS.md(whichCLAUDE.mdlinks to) now lists both fixes in the patch and how to regenerate it. The install note indocs/DEVELOPMENT.mdnames both.Left as is:
Demo
The real TUI on
main(before) and this branch (after).npx ccusage statuslineis pasted into the empty Custom Command (e)dit cmd field in one write, the way a terminal pastes, then Enter saves it. Before, the field shows onlynpx ccusage, although the widget row (npx ccusage statu...) and the preview (cmd: npx ccusage statusli...) then show that more than that was saved. After, the field shows all of it.Powerline
Before:
After:
Plain
Before:
After:
Testing
mainas of fix: use env override and settings for usable context ratio calculation #407 (71e8b42): merges cleanly,bun run lintis clean, andbun testgives 3939 pass, 0 fail. The built CLI under Bun 1.4.4 and Node 26.13.0 matchesmainin plain and Powerline mode with the baseline configs, and the TUI opens and exits cleanly. It adds no JavaScript or Node API newer than Node 14, the build's target.bun run lint: clean.bun test: 3169 pass, 0 fail across 179 files. Withmain's patch: 3168 pass, 1 fail (the new test) across 179 files.node node_modules/vitest/vitest.mjs run), 3146 tests in 179 files:main's patch: 2959 pass, 187 fail.main's patch (expected 'Command: npx') and passes here.vi.spyOnonos.homedir,child_processexports and others) and theusage-fetchsubprocess suite.runtime-check.shon Bun 1.4.2 and Node 26.10.0: piped renders in plain and Powerline mode are the same asmain, with both runtimes agreeing. The TUI opens and exits cleanly on both.dist/in tmux under Bun 1.4.2 and Node 26.10.0, withnpx ccusage statuslinepasted into an empty Custom Command field:mainshowsnpx ccusage, and this branch showsnpx ccusage statuslineon both runtimes.