claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

Desktop: decorations on $.prompt.fill are not painted (the terminal paints them)

Open wkasekende opened this issue 1 month ago • 2 comments

On Claude Code Desktop (Code tab, Local session, Windows, Claude Code 2.1.293), a mod's $.prompt.fill({ text, mode, decorations }) fills the box (isFilled: true) but the runs are never painted, in every mode (replace, append, insert). The same decorations returned from a prompt.edit answer are painted, and the same fill in the terminal paints them.

Repro: a mod whose prompt.edit hook, on the draft filltest, calls after 500 ms $.prompt.fill({ text: 'FILLED', mode: 'replace', decorations: [{ start: 0, end: 6, color: 'yellow', underline: true }] }). Terminal: FILLED shows yellow and underlined. Desktop: plain, until the next key's prompt.edit answer repaints.

import type { On } from 'claude-code'

export function register(on: On): void {
  on('prompt.edit', async ($, e, next) => {
    const r = await next(e)
    if (r.text === 'filltest') setTimeout(() => {
      void $.prompt.fill({ text: 'FILLED', mode: 'replace', decorations: [{ start: 0, end: 6, color: 'yellow', underline: true }] })
    }, 500)
    return r
  })
}

Why it matters: a mod that paints between keystrokes (a note that arrives after a pause, an answer that lands) can only do it with a fill, so on Desktop its paint lags one keystroke behind. Related: the paint-only call asked for in #91870 (comment).

wkasekende avatar Oct 10 '26 22:10 wkasekende

Same here, with what looks like the cause.

Environment: Claude desktop app 2.31226.1 (Windows, MSIX), Code tab sessions running in WSL2 through the app's remote server; Claude Code CLI 2.1.295 (the app's bundled ccd-cli). Plugins with UI (ui.render panes and the AbovePrompt band, prompt.edit hooks) loaded with CLAUDE_CODE_PLUGIN_DIRS.

Effect: a plugin that computes highlights asynchronously (e.g. a spell/grammar check that finishes ~1–2 s after the last key) cannot show them until the user types or moves the caret again; users have to click in the prompt text to see them.

Why (from reading the shipped app, read-only): the composer paints decorations only from the answer to a person's ui_prompt_edit. $.prompt.fill decorations are documented as painted ("the app paints them as given"), but the desktop main process forwards ui_prompt_fill with text and mode only, the window's fill schema keeps only text and mode, and a fill is reported back as an app edit whose answer decorations are skipped. The composer also has an internal paint subscription with no publisher.

Ask: forward and paint ui_prompt_fill.decorations, or add a paint-only message (no text change, no caret move) a plugin can send when its marks are ready.

Also: the prompt.edit dispatch has a 50 ms budget in the CLI that the plugin types do not document (they state 10 s per dispatch), so a plugin cannot wait for its result inside the edit answer either.

Thanks!

0xSwapFeeder avatar Oct 12 '26 21:10 0xSwapFeeder

Re-tested on Windows desktop 3.6556.2.0 (bundled Claude Code 2.1.308), Local Code tab, same mod.

  1. Fills still drop their decorations. $.prompt.fill({ text, mode: 'replace', decorations }) resolves isFilled: true, $.prompt.read() returns the text, and nothing is painted. The terminal paints the same calls (2.1.309 and 2.1.310).
  2. Edit answers paint dimColor but not virtualText. In the same session the prompt.edit answer carries a dimColor run and a virtualText run. The dim paints; the virtual text line does not appear. The types list the cases where virtualText isn't drawn (empty box, remote host, screen-reader mode) but not the desktop.

The cause traced above for 1 (the fill reaches the window with text and mode only) still fits. For 2, is virtualText expected on the desktop, and if so is it planned?

wkasekende avatar Oct 24 '26 22:10 wkasekende