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
Ghost-text next-prompt suggestion in the composer (Tab to prefill, Enter to send) #1166
After a turn finishes, show a one-line suggestion of the most likely next prompt as dimmed ghost text in an empty composer. Tab prefills it (editable), Enter sends it, Esc or typing anything dismisses it.
Implementation notes:
At most one small/cheap model call per completed turn, only when the composer is empty and the session is idle — not per keystroke.
Never written into the buffer before Tab is pressed; the buffer stays empty until then.
Visible inline hint ("Tab to prefill · Enter to send") so the affordance is discoverable rather than a mystery box.
Skipped in plan mode, after an interrupted run, and when the last turn ended with an error.
Opt-in via a setting (e.g. suggestNextPrompt: false) and never shown headless.
Use Case
Every turn ends with the user deciding "what next", and both major competing harnesses ship exactly this, at the same cost model — one cheap call per turn:
Claude Code: "After a task finishes, Claude will occasionally show a followup suggestion in ghost text. Press Enter to send it or Tab to prefill your next prompt."
Oh My Pi (github.com/can1357/oh-my-pi): a dedicated predictor — crates/predict/ with ngram, apple and smollm backends, rendered by packages/tui/src/prompt/word-completion.ts.
It removes a full stop from every single turn, which is where most of the interaction time goes.
Additional Context
This already existed in Command Code and was rolled back — changelog 0.17.4: "revert: dynamic Haiku-predicted placeholder in input field (#509) (#614)". So the plumbing is largely there; the ask is to bring it back as an opt-in rather than default-on, which also addresses whatever cost or latency drove the revert.
A narrower variant still ships today: a ghost suggestion after /pr-comments that prefills "Fix all review comments" — same rendering, one hardcoded case.
One pitfall to avoid, seen upstream: when the suggestion appears with no visible Tab hint, users don't know it is acceptable (anthropics/claude-code#76591). Hence the inline hint above.
I built this as a user-space mod against the current public ModApi — it loads today with cmd --mod ./next-prompt.ts. cmd mods inspect reports: hooks: transformInput, onRunEnd, registers: slash command, widget.
It covers the whole feature except the Tab key: onRunEnd → one cmd.model.complete (24 output tokens max, 5 s minimum gap, skipped on interrupted / max_turns / terminate / permission_denied and headless) → the line renders in an above-editor widget → Accept is a one-key button (hotkey: 'a') or /next.
importtype{ModApi}from'@commandcode/harness';constKNOBS={maxOutputTokens: 24,minGapMs: 5_000,userChars: 300,assistantChars: 600,maxSuggestionChars: 140,hardStops: newSet(['interrupted','max_turns','terminate','permission_denied']),};constSYSTEM=['You predict the next message the user will send to a coding agent.','Reply with ONE imperative line, at most 12 words, no quotes, no preamble, no trailing period.','Reply exactly NONE when the next step is not obvious.',].join(' ');functiontext_of(content: unknown): string{if(typeofcontent==='string')returncontent;if(Array.isArray(content)){returncontent.map((part)=>typeofpart==='string'
? part
: typeofpart==='object'&&part!==null&&'text'inpart
? String((partas{text?: unknown}).text??'')
: '',).join(' ');}return'';}functionbuild_context(state: unknown): string|null{constmessages=((stateas{messages?: {role?: string;content?: unknown}[]}|undefined)?.messages??[]);letuser='';for(leti=messages.length-1;i>=0;i--){if(messages[i]?.role==='user'){user=text_of(messages[i].content).slice(0,KNOBS.userChars);break;}}if(!user)returnnull;letassistant='';for(leti=messages.length-1;i>=0;i--){if(messages[i]?.role==='assistant'){assistant=text_of(messages[i].content).slice(-KNOBS.assistantChars);break;}}return`Previous user message:\n${user}\n\nLast assistant reply (tail):\n${assistant}`;}functionclean(raw: string): string|null{constline=raw.split('\n').map((l)=>l.trim()).filter(Boolean)[0];if(!line)returnnull;consttext=line.replace(/^[-*•]\s*/,'').replace(/^["'`]+|["'`]+$/g,'').replace(/\.$/,'').trim();if(!text||/^none$/i.test(text))returnnull;if(text.length>KNOBS.maxSuggestionChars)returnnull;returntext;}exportdefaultfunctionmod(cmd: ModApi){letpending: {text: string}|null=null;letinflight=false;letlast_at=0;cmd.hooks({onRunEnd: async({ state, result })=>{if(inflight||!cmd.ui.capabilities.status)return;if(KNOBS.hardStops.has(String((resultas{stopReason?: unknown})?.stopReason??'')))return;if(Date.now()-last_at<KNOBS.minGapMs)return;constctx=build_context(state);if(!ctx)return;inflight=true;try{constr=awaitcmd.model.complete({system: SYSTEM,prompt: ctx,maxOutputTokens: KNOBS.maxOutputTokens});last_at=Date.now();consttext=r.isAnswered ? clean(r.text) : null;pending=text ? { text } : null;cmd.ui.refreshWidgets();}catch{pending=null;}finally{inflight=false;}},transformInput: ()=>{pending=null;cmd.ui.refreshWidgets();return{action: 'continue'};},});cmd.ui.widget({placement: 'above-editor',render: ()=>{if(!pending)return[];return[{type: 'text',text: `↹ ${pending.text}`,dim: true},{type: 'button',label: 'Accept',hotkey: 'a',onPress: ()=>{consttext=pending?.text;pending=null;cmd.ui.refreshWidgets();if(text)cmd.prompt.submit(text);},},];},});cmd.addCommand({name: 'next',description: 'Send the suggested next prompt',handler: ()=>{if(!pending)return{message: 'no suggestion yet'};consttext=pending.text;pending=null;return{prompt: text};},});}
What the real Tab UX needs (small host delta)
Three changes, in order of value:
cmd.prompt.prefill(text) — write text into the composer without submitting. The textarea state and cursor already exist in the host; this is the only genuinely missing primitive.
A ghost slot inside the composer — draw the pending line dimmed after the cursor when the buffer is empty, instead of a band above the input.
Tab arbitration — when the composer is empty and a ghost is present, Tab prefills instead of cycling pane focus. This is the single product decision in the whole feature; everything else is plumbing.
With those three, the mod above loses its button and /next and becomes exactly the Claude Code interaction.
Cost and kill criteria
One completion per run, 24 output tokens, skipped on hard stops, minimum 5 s apart, opt-out setting.
Instrument accept rate (accepted / shown) and cost per session.
If accept rate stays under ~15% the feature is not earning its keep — turn it off.
Activity
web3wannabe commentedon Nov 20, 2026
Working prototype (no product changes)
I built this as a user-space mod against the current public
ModApi— it loads today withcmd --mod ./next-prompt.ts.cmd mods inspectreports:hooks: transformInput, onRunEnd,registers: slash command, widget.It covers the whole feature except the Tab key:
onRunEnd→ onecmd.model.complete(24 output tokens max, 5 s minimum gap, skipped oninterrupted/max_turns/terminate/permission_deniedand headless) → the line renders in anabove-editorwidget → Accept is a one-key button (hotkey: 'a') or/next.What the real Tab UX needs (small host delta)
Three changes, in order of value:
cmd.prompt.prefill(text)— write text into the composer without submitting. The textarea state and cursor already exist in the host; this is the only genuinely missing primitive.With those three, the mod above loses its button and
/nextand becomes exactly the Claude Code interaction.Cost and kill criteria
vipulgupta2048 commentedon Nov 23, 2026
@web3wannabe thanks for the feature request. This is on the roadmap. Let me create a PR to get this going.