Repository navigation
feat(tui): expand pasted text - #39920
Merged
Merged
Conversation
kitlangton
enabled auto-merge (squash)
July 31, 2026 18:05
hunterchristian
added a commit
to chipp-ai/opencode
that referenced
this pull request
Sep 23, 2026
A pasted [Pasted ~N lines] placeholder in the prompt can now be expanded to its full content and collapsed back -- click it, or run "Expand/collapse pasted text" (prompt.paste.toggle) from the palette or a keybind. Ported from upstream anomalyco#8501 (325 reactions -- the highest of any issue found across a full survey of this repo's open issues). A trivial 1-file fix already merged upstream as anomalyco#39920 isn't even on this fork's history and is a one-way, no-collapse expand anyway, not the real ask. Richer attempts were all closed by the automated PR-cleanup bot and never reviewed: - PR anomalyco#41813 "paste expand toggle" is the primary source: a pasted- text part remembers its original placeholder so it can collapse again, the chip is swapped by deleting its extmark, replacing the selected text, and recreating the extmark over the new text. - PR anomalyco#33700 fixed a real, separate bug reused as-is: expandPastedTextPlaceholders substituted text back in via String.replace(str, str2), which treats $&/$$/etc. in the pasted text as special replacement patterns and silently corrupts it -- fixed by passing a replacer function instead of a literal string. - PR anomalyco#37052 contributed only the idea of a palette command to expand chips (its own version was one-way, expand-all); this fork's version is a proper per-chip toggle. New: older saved prompts with no stored placeholder can still be expanded (anomalyco#41813's version would lock them collapsed-only). Two pure functions (togglePastedText, replaceVirtualExtmarkText) were extracted into packages/tui/src/prompt/part.ts so anomalyco#41813's logic is unit- testable outside the full Prompt component. Known gaps: the full Prompt component's mouse-click path has no automated test (no existing fixture mounts it with SDK/sync/route providers -- checked manually against a bare textarea instead); clicking a chip's very last character can miss the same way it does in anomalyco#41813; an expanded chip is viewable but not editable in place. New tests in packages/tui/test/prompt/part.test.ts and a new packages/tui/test/prompt/paste-toggle.test.tsx (using this repo's existing testRender/mockMouse helpers). Verified against this fork's current dev (not just the agent's own stale worktree base): bun typecheck clean; full packages/tui suite 215 pass. Co-Authored-By: Claude Sonnet 5 <[email protected]>
jinhuang712
pushed a commit
to jinhuang712/opencode
that referenced
this pull request
Sep 26, 2026
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
Allow collapsed pasted text in the TUI composer to be expanded without opening an editor:
[Pasted ~N lines]placeholder to expand it in placeExpansion affects only the selected or matching pasted block. Other pasted blocks, file mentions, and agent mentions remain tracked.
How
packages/tui/src/component/prompt/index.tsxnow replaces a tracked pasted extmark with its original text, removes that pasted part from prompt metadata, and realigns later pasted-part indexes.Mouse expansion resolves the exact extmark at the clicked cursor offset. Repeated paste expansion reuses the first collapsed pasted part whose normalized content matches the incoming paste.
Scope
This applies only to text that the composer would already collapse under the existing paste threshold. Short pastes and
prompt.paste: "full"retain their current behavior. Attachments are unchanged.Testing
bun typecheckinpackages/tuibun run test test/prompt/part.test.tsinpackages/tuiDemo
Simulated OpenCode Drive session. Static control dead time was trimmed from the recording; interaction transitions remain at normal speed.
expand-pasted-text-demo.mp4