You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 012b8eb
Browse filesBrowse the repository at this point in the historyBrowse files
feat(tui): make pasted-text placeholders expandable and collapsible
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]>
Copy file name to clipboardExpand all lines: FORK_CHANGES.md
+11Lines changed: 11 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,17 @@ Each entry names the upstream gap it addresses, whether it originated as our own
6
6
7
7
## Implemented
8
8
9
+
### Expandable pasted-text placeholders
10
+
11
+
A pasted `[Pasted ~N lines]` placeholder in the TUI 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 command palette or a keybind.
12
+
13
+
-**Upstream gap:**[anomalyco/opencode#8501](https://github.com/anomalyco/opencode/issues/8501) — **325 reactions**, the single highest-reaction issue found across a full survey of this repo's open issues. A trivial 1-file fix already merged upstream as PR #39920, but the issue stayed open because that fix is a one-way, no-collapse click-to-expand, not the real ask — and it isn't even present on this fork's history (its merge commit exists but isn't an ancestor of `dev`). Richer attempts, all closed by the automated PR-cleanup bot (>1 month old, <2 reactions) and never reviewed: [PR #41813](https://github.com/anomalyco/opencode/pull/41813) "paste expand toggle" (primary source), [PR #33700](https://github.com/anomalyco/opencode/pull/33700) "expand pasted text placeholders literally", and the tokens/sec-bundled [PR #37052](https://github.com/anomalyco/opencode/pull/37052) (only its expand-related idea used; the rest is unrelated and was independently ported for the tokens/sec feature above).
14
+
- **Origin:** implemented by an Opus 5 agent. #41813's logic is reused almost as-is: a pasted-text part remembers its original placeholder so it can collapse again after expanding, the chip is swapped by deleting its extmark, replacing the selected text, and recreating the extmark over the new text, and a guard stops the prompt's own content-change sync from dropping the part mid-swap. #33700 fixed a real, separate bug reused as-is: `expandPastedTextPlaceholders` used to substitute pasted 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. #37052 contributed only the idea of a palette command to expand chips (its own version was one-way, collapse-all); this fork's version is a proper toggle on the chip under the cursor. Two pure, newly-extracted, unit-tested functions (`togglePastedText`, `replaceVirtualExtmarkText` in `packages/tui/src/prompt/part.ts`) hold #41813's logic so it's testable outside the full `Prompt` component. New: older saved prompts with no stored placeholder (from before this field existed) can still be expanded, where #41813's own version would lock them collapsed-only; `try`/`finally` around the swap was dropped per this repo's avoid-`try`/`catch` convention.
15
+
-**Where:**`packages/tui/src/component/prompt/index.tsx` (click handling + the new `prompt.paste.toggle` command), `packages/tui/src/prompt/part.ts` (the two extracted pure functions), `packages/tui/src/prompt/history.tsx` (a `placeholder` field on the saved pasted-text-part type), `packages/tui/src/config/keybind.ts` (a `prompt_paste_toggle` keybind slot, unbound by default like other prompt commands).
16
+
-**Known gaps:** the full `Prompt` component's actual mouse-click path (as opposed to the pure toggle/swap functions) has no test — mounting it needs SDK/sync/route providers with no existing fixture for that; the click behavior was checked manually against a bare `<textarea>` firing the same mouse events instead. Clicking a chip's very last character can miss (the cursor then sits just past the chip's end, which the editor library's extmark lookup doesn't count as "inside" it) — the same limitation exists in #41813. An expanded chip remains a single cursor unit with the paste-highlight style; its text is viewable but not editable in place, matching #41813.
17
+
-**Verified:**`bun typecheck` clean in `packages/tui`. New tests in `packages/tui/test/prompt/part.test.ts` (pure toggle/collapse cases) and a new `packages/tui/test/prompt/paste-toggle.test.tsx` (using a real `<textarea>` via this repo's existing `testRender`/`mockMouse` test helpers, matching `test/cli/tui/dialog-prompt.test.tsx`'s established pattern) covering expand/collapse in place, later chips shifting correctly after a swap, and the cursor landing inside the chip after a click. Full `packages/tui` suite (re-verified against this fork's current `dev`, not just the agent's own stale worktree base, and after the tokens/sec feature above): 215 pass.
The primary agent can now override which model a specific `task` dispatch uses (`model: "provider/model-id"`, plus an optional `variant`), instead of every dispatch always using the subagent's statically-configured model.
0 commit comments