Skip to content

Conversation

@JosXa
Copy link
Contributor

@JosXa JosXa commented Jan 16, 2026

Summary

Implements dynamic placeholder hints that display the current agent's description instead of static randomized hints, except in build mode.

Closes #8804

WindowsTerminal_NgMLh7dY26.mp4

Changes

  • Agent descriptions as placeholders: When a custom agent has a description, it's now shown in the placeholder text
  • Fallback to randomized hints: Build agent and agents without descriptions continue using the existing randomized hint rotation. The rationale for the build agent retaining the cool generated placeholder texts is that it is the default mode and it should look good for newcomers who aren't into customization yet.

Implementation Details

CLI/TUI (packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx)

  • Added placeholderText memo that reactively returns agent description or randomized hint
  • Updates when switching between agents

Web App (packages/app/src/components/prompt-input.tsx)

  • Added placeholderText memo with same logic as CLI
  • Added shouldRotatePlaceholder memo to control hint rotation
  • Rotation stops when showing agent descriptions, resumes for build/no-description agents

Known Issues & Workarounds

Text Rendering Ghosting Bug

When switching between agents, ghost characters from the previous placeholder could remain visible due to browser/terminal text layout caching.

Workaround: Added .padEnd(70, " ") to force full-width text rendering which overwrites stale cached text.

TODO: This is a temporary fix. Investigate why OpenTUI textarea / browser doesn't invalidate text rendering cache, it should properly flush the input.

Testing

  • Tested switching between agents with descriptions
  • Tested build agent shows randomized hints
  • Tested agents without descriptions fall back to hints
  • Verified no visual ghosting with padding fix
  • Confirmed rotation behavior (stops for descriptions, continues for hints)
  • Test web version

Files Changed

  • packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx (+14, -1)
  • packages/app/src/components/prompt-input.tsx (+23, -4)

- Show agent description in placeholder when available
- Fall back to randomized hints for build agent or no description
- Implement in both CLI (TUI) and app (web) components
- Add .padEnd(70) workaround for text rendering ghosting bug

Fixes issue where switching agents caused visual corruption with
ghost characters from previous placeholder remaining visible.

TODO: Find proper fix for text layout cache invalidation instead
of padding workaround.
@github-actions
Copy link
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

// placeholder remain visible when switching to shorter text. Browser doesn't properly
// clear cached text layout with truncate/ellipsis CSS. Proper fix would be to force
// element recreation or use a different rendering approach.
return `Ask anything... "${PLACEHOLDERS[store.placeholder]}"`.padEnd(70, " ")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please advise. I'm not sure how to get around this ghosting of the previous cycle without the padEnd hack:

WindowsTerminal_genyHK2HUT.mp4

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prompted opencode for it and it had no idea after 10 attempts.

if (params.id) return
if (params.id || !shouldRotatePlaceholder()) return
const interval = setInterval(() => {
setStore("placeholder", (prev) => (prev + 1) % PLACEHOLDERS.length)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/oc Ah, I suppose we should only increment the placeholder index when we actually saw a placeholder

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.

Use agent description as prompt placeholder text

1 participant