Repository navigation
chat: a click away from selected text clears it - #9
Merged
Merged
Conversation
foxnne
marked this pull request as ready for review
October 16, 2026 14:53
foxnne
added this pull request to stack #13
October 16, 2026 14:53
A selection in the transcript stayed when the person clicked empty space, another message or the message box, so two or three messages could show a selection at once and none went away. Now the selection goes when focus leaves the text it is in, as in a document. dvui keeps a text layout's selection after it loses focus. The chat tracks which widget inside the transcript holds focus (`lastFocusedIdInFrameSince` around the scroll area) and, when that changes, tells the old text to select nothing with `Window.addEventTextSelect` at the top of the next frame (the plugin's `beginFrame`, before any widget runs, as dvui asks of added events). dvui scrolls a text's cursor into view when it is given a selection, so that frame keeps the viewport where it was put.
foxnne
force-pushed
the
chat/select-clear
branch
from
October 16, 2026 15:37
fa4b851 to
a70b523
Compare
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.
A selection in the transcript stayed when the person clicked empty space, another message or the message box, so several messages could show a selection at once and none went away. Now a selection goes when the person presses anywhere outside the text it is in: another message, empty space, the message box, elsewhere in fizzy. Copy (⌘C) of a selection still works.
How
dvui keeps a
TextLayoutWidget's selection after it loses focus. The chat tracks which widget inside the transcript holds focus (dvui.lastFocusedIdInFrameSincearound the scroll area: a text the person pressed in, or the scroll area after a click on empty space). When that changes, it tells the old text to select nothing withWindow.addEventTextSelect(.{ .start = 0, .end = 0, .target_id = old })at the top of the next frame. That is the plugin'sbeginFrame, before any widget runs, which is when dvui asks for added events. A text given a selection scrolls its cursor into view, so on that frame the chat puts the viewport back where it set it.drawTranscript's height and scroll code is otherwise unchanged: one call before the scroll area, one after.Selection across messages: what's missing
A selection that spans several messages, the way a document's does, isn't possible from the plugin:
TextLayoutWidget, as byte offsets into its own text, and a drag is captured by the layout it started in. Nothing lets a drag continue into a sibling layout, and nothing asks a layout which byte is under a point without capturing (findPointis private). A multi-layout selection needs a selection owned above the layouts (anchor and focus as layout + byte), handed to each layout throughInitOptions.selection(already public), plus a public point-to-byte query and a way to keep a drag going across layouts.markdown.Api.renderInline), one layout per paragraph, andInlineOptionshas onlywidth,image_base_dirandid_extra. The service can't take a selection, report the selected text, or clear it. The seam is anInlineOptionsfield for a caller-owned selection (orselectedText(id_extra)/clearSelection(id_extra)on the service). That's an SDK change in fizzy, and once it exists this PR's focus tracking becomes a direct clear.Within one paragraph, selecting, double/triple-click and copy are dvui's, as before.
Seen
macOS, in a sandbox profile with a seeded sample transcript, driven by a demo tape (no OS events), with captures before and after:
zig fmt --check src plugin.zigclean; built against the fizzymainSDK (--fork).🤖 Generated with Claude Code