Skip to content

feat(ui): rebuild the composer - #886

Merged
small-angel merged 1 commit into
mainfrom
clo/markdown-composer
Nov 4, 2026
Merged

small-angel merged 1 commit into
mainfrom
clo/markdown-composer

Conversation

@small-angel

@small-angel small-angel commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

The composer was a plain textarea. Attachments sat in a thumbnail row, and skills were painted on by a mirror behind the text. It is now a CodeMirror markdown editor, using alphaXiv's live preview: formatting renders in place, and /commands, @paths, pasted images and PDFs, and message refs appear as inline chips. Model, effort and permissions sit in a compact bar under the box.

A few behaviours to know about:

  • Formatting marks appear only once the mouse button comes up, so a drag doesn't chase them.
  • An image is sent only while its [Image #n] chip is still in the draft, numbered in the order the chips appear, so the agent sees where each image belongs.
  • Claude's ultracode is a toggle on top of XHigh effort.
  • It replaces the textarea resizer that feat: make the chat composer resizable #863 added, using the same storage keys.
  • @ opens one add-context menu: files, alphaXiv library papers and chats in this project. A paper goes into the draft as a markdown link to its alphaXiv page and shows as a chip, as do papers added from the library button, which now sits in the bar beside data sources. A chat goes in as its id, which agents can read.
  • Copy link on a message copies its ref (msg_…). A pasted ref becomes a chip showing who wrote the message and its first words. Until now, a ref the user typed reached the agent as an id it couldn't look up; refs in the user's own messages now expand to the cited message, the same way refs in agents' messages do.

Proved by driving the dev server in headless Chromium in light and dark themes (typing, chips, paste, drag-select, resize, menus, Copy link, the @ menu, library papers, and each review fix). For the ref expansion, a fresh OpenCode chat was asked for the secret word in a ref to another chat's message; it answered without calling any tool, both as a new turn and when steered into a running Claude turn. Also ran pnpm typecheck, lint:i18n, lint:styles and pnpm test (624 pass), plus cargo fmt, clippy and cargo test.

Reviewed with sol-loop: 3 rounds with gpt-6.1-sol. Sol verdict: approved in round 2; round 3's one finding (refs in steered messages) fixed as suggested

Assisted-by: claude-opus-5.5
Assisted-by: gpt-6.1-sol

@small-angel
small-angel force-pushed the clo/agent-orchestration branch from 8a6c698 to 9166caf Compare November 4, 2026 19:18
@small-angel
small-angel force-pushed the clo/markdown-composer branch from b68c21d to 0803f1c Compare November 4, 2026 19:21
@greptile-apps

greptile-apps Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 3/5

[Medium impact] The changes affect the chat-writing workflow and its settings for chat users.

Fix shared undo history across chats and Enter handling in Markdown lists before merging.

Findings

  1. P1 Undo restores another chat's text ▶
  2. P1 Enter does not send lists ▶
  3. P2 Effort choices leave the screen ▶
  4. P2 File loading replaces selected text ▶
  5. P2 Skill previews require a mouse ▶
Fix with agent prompt
### Issue 1
ui/src/components/ComposerEditor.tsx:386-391
`ComposerEditor` resets its history only when `value` changes. If a user types and then deletes a draft in chat A, switching to another empty chat leaves A's undo history in the editor. Undo in chat B can then bring back A's text, which the user may send to the wrong agent. Reset the editor when the composer changes chats, even when both drafts have the same text.

### Issue 2
ui/src/components/ComposerEditor.tsx:210-211
`markdown()` installs its own Enter binding unless `addKeymap` is disabled. In a list such as `- investigate this`, that binding continues the list before the lowest-priority `onSubmit` handler runs. Enter therefore adds a line instead of sending lists and quotes. Set `addKeymap: false`; `livePreview` already provides the intended code-block Enter and Shift+Enter bindings.

```suggestion
const markdownSource = markdown({
  addKeymap: false,
  base: markdownLanguage,
```

### Issue 3
ui/src/components/ModelPicker.tsx:712
The effort popup lost its `maxHeight`. In a short window, `overflow-y-auto` alone does not limit its height, so choices can extend outside the screen without a scrollable popup. Restore a height bound based on `--available-height`, as the permissions popup still does.

```suggestion
                <Menu.Popup aria-label={m.model_picker_effort()} className={MENU_POPUP} style={{ width: "min(240px, calc(100vw - 16px))", maxHeight: "min(400px, var(--available-height))" }}>
```

### Issue 4
ui/src/components/ChatPanel.tsx:5282-5283
`addFiles` waits for `FileReader.onload` before calling `insertToken`, which replaces whatever selection exists at that later moment. If a user selects other draft text while a large PDF or image is being read, finishing the read deletes that newly selected text. Capture the insertion position when the file is added and keep it aligned with later edits instead of using the eventual selection.

### Issue 5
ui/src/components/ComposerEditor.tsx:502-506
Skill previews now open only through `onMouseOver`. The old skill token supported focus, Enter, Space, and keyboard scrolling, but `ChipWidget` creates a non-focusable span with no replacement keyboard action. Keyboard-only users can no longer inspect a skill's instructions before sending it. Keep a keyboard-accessible way to open and read `SkillPreviewCard`.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Replaces the textarea with a CodeMirror Markdown composer.

  • The chat composer renders Markdown as you write.
  • Commands, paths, and attachments appear as chips in the draft.
  • Chat settings and active controls sit below the editor.

Fix the chat-history boundary and Markdown Enter binding before merging. The remaining comments cover popup sizing, delayed file insertion, and keyboard access.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Draft[Markdown draft] --> Editor[CodeMirror editor]
  Files[Images and PDFs] --> Tokens[Inline attachment tokens]
  Tokens --> Editor
  Editor --> Citations[Find cited attachments]
  Citations --> Ordered[Renumber outgoing text and order files]
  Ordered --> Send[Send or queue message]
  Send -->|Failure| Restore[Restore original draft and attachment IDs]
Loading

Reviews (1) · Last reviewed commit: "feat(ui): a markdown composer with chips..." · Reviewed by Greptile

Comment thread ui/src/components/ComposerEditor.tsx Resolved
Comment thread ui/src/components/ComposerEditor.tsx Resolved
Comment thread ui/src/components/ModelPicker.tsx Resolved
Comment thread ui/src/components/ChatPanel.tsx Resolved
Comment thread ui/src/components/ComposerEditor.tsx Resolved
@small-angel
small-angel added this pull request to stack #888 November 4, 2026 19:27
@small-angel small-angel changed the title feat(ui): write messages in a live markdown editor with inline chips feat(ui): rebuild the composer Nov 4, 2026
@small-angel
small-angel force-pushed the clo/markdown-composer branch from 0803f1c to 59cde16 Compare November 4, 2026 19:48
@small-angel
small-angel force-pushed the clo/agent-orchestration branch from bbd7aac to 5bc0015 Compare November 4, 2026 19:50
@small-angel
small-angel removed this pull request from stack #888 November 4, 2026 20:12
@small-angel
small-angel changed the base branch from clo/agent-orchestration to main November 4, 2026 20:12
@small-angel
small-angel force-pushed the clo/markdown-composer branch 4 times, most recently from 45d09a8 to 7eea267 Compare November 4, 2026 22:34
The composer is now a CodeMirror editor running a port of alphaXiv's
markdown live preview: formatting renders in place and its marks reveal
under the caret. Reveals wait for the mouse button to come up, so a drag
selects the text it started on instead of chasing marks that appear
under the pointer; a drag that covers a span's text then grows to take
its marks. Colors come from the theme's syntax and link tokens,
so both themes hold.

/commands, @paths that exist in the checkout, and attachments render as
atomic chips. Pasted, dropped and uploaded files are cited in the draft
as [Image #n] / [PDF #n] at the caret; a send carries only the cited
attachments, renumbered in order of mention, so deleting a chip deletes
the attachment and the agent sees where each image belongs. This
replaces the thumbnail row and the textarea mirror that painted skill
chips.

Below the box, a Knife-style bar: data sources and mode chips on the
left; model, effort and permissions on the right. Effort and
permissions split out of the old settings menu, and autonomy joins
permissions as a second section. Claude's ultracode, xhigh plus dynamic
workflows, toggles beneath the effort levels. The box grows to eight lines, then
scrolls; its top edge drags to a remembered height, replacing the
textarea resizer from #863 under the same storage keys.

Message refs (`msg_…`) paste into the draft as chips with the cited
message's author and first words, and read as pills in sent messages.
Copy link on a message puts its ref on the clipboard. A ref in the
user's own message now expands for the agent like one an agent sends,
so the agent reads the cited words instead of an id it cannot look up.

`@` opens one add-context menu: files, alphaXiv library papers and
chats in the project. A paper enters the draft as a markdown link to its
alphaXiv page and shows as a chip, as does one added from the library
button, now beside data sources in the bar; a chat enters as its id.

Assisted-by: claude-opus-5.5
@small-angel
small-angel force-pushed the clo/markdown-composer branch from 7eea267 to 0f32663 Compare November 4, 2026 22:45
@small-angel
small-angel merged commit 2bfcdd3 into main Nov 4, 2026
13 checks passed
@small-angel
small-angel deleted the clo/markdown-composer branch November 4, 2026 23:06
@myles332 myles332 mentioned this pull request Nov 6, 2026
3 of 5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant