[PR #5117] Add short_description field for agents and agent details dialog #11249

Closed
opened 2026-02-16 18:16:03 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/5117

State: closed
Merged: No


Closes #4825

Summary

Previously, when you created an agent via opencode agent create, the description field was populated with a long prompt intended for the model. In /agents, this made the list view almost unreadable.

This PR introduces three changes:

  1. short_description field

    • New field used for displaying agents in /agents.
    • If short_description is not set, the UI falls back to a truncated version of description.
  2. Agent details dialog (Ctrl+E)

    • You can now open a scrollable details dialog for custom agents.
    • The dialog shows the whenToUse (description) text, so the list can stay compact while the full content is still accessible when needed.
  3. Dynamic description truncation

    • Descriptions in /agents are now truncated based on the current terminal width, so they fit neatly into the dialog without overflowing.

Why this approach

  • short_description gives us a dedicated, human‑readable summary for the UI instead of trying to reuse the full whenToUse text.
  • The details dialog preserves the ability to inspect the full prompt when needed without cluttering the main list.
  • Truncation based on terminal width keeps /agents readable across different environments and terminal sizes.

Focus bug fix

While implementing the details dialog, a focus bug surfaced: switching between dialogs (e.g., /agents ↔ agent details) caused the main input to lose focus.

Root cause:

  • There was a race between keyboard handlers when dialogs were opened/closed in quick succession.
  • replace() could overwrite an existing valid saved focus reference.
  • refocus() was being called even when a new dialog was about to open immediately after.

Fix:

  • Prevent replace() from clobbering a valid saved focus reference.
  • Skip refocus() when a new dialog is opened right after closing the previous one.

How to test

  • Have an agent that was created before the update (to verify backward compatibility).

  • Create a new agent with short_description set.

  • Open /agents.

  • Confirm both agents show a visible description:

    • New agent shows short_description.
    • Old agent shows a truncated description.
  • Verify that text is truncated correctly according to the dialog/terminal width.

  • Focus a native agent and verify the footer is not shown.

  • Focus a custom agent and check that the Ctrl+E hotkey is shown in the footer.

  • Press Ctrl+E on a custom agent and confirm the agent details dialog opens.

  • In the details dialog, verify that the scrollbar works with both keyboard and mouse.

  • Close the details dialog and confirm the /agents dialog reappears with the same selection preserved.

  • Open other dialogs (e.g., /models, /sessions) and confirm their behavior and focus handling are unchanged.

Demo

Demo

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/5117 **State:** closed **Merged:** No --- Closes #4825 ## Summary Previously, when you created an agent via `opencode agent create`, the `description` field was populated with a long prompt intended for the model. In `/agents`, this made the list view almost unreadable. This PR introduces three changes: 1. **`short_description` field** * New field used for displaying agents in `/agents`. * If `short_description` is not set, the UI falls back to a truncated version of `description`. 2. **Agent details dialog (`Ctrl+E`)** * You can now open a scrollable details dialog for custom agents. * The dialog shows the `whenToUse` (description) text, so the list can stay compact while the full content is still accessible when needed. 3. **Dynamic description truncation** * Descriptions in `/agents` are now truncated based on the current terminal width, so they fit neatly into the dialog without overflowing. ## Why this approach * `short_description` gives us a dedicated, human‑readable summary for the UI instead of trying to reuse the full `whenToUse` text. * The details dialog preserves the ability to inspect the full prompt when needed without cluttering the main list. * Truncation based on terminal width keeps `/agents` readable across different environments and terminal sizes. ## Focus bug fix While implementing the details dialog, a focus bug surfaced: switching between dialogs (e.g., `/agents` ↔ agent details) caused the main input to lose focus. Root cause: * There was a race between keyboard handlers when dialogs were opened/closed in quick succession. * `replace()` could overwrite an existing valid saved focus reference. * `refocus()` was being called even when a new dialog was about to open immediately after. Fix: * Prevent `replace()` from clobbering a valid saved focus reference. * Skip `refocus()` when a new dialog is opened right after closing the previous one. ## How to test * [x] Have an agent that was created before the update (to verify backward compatibility). * [x] Create a new agent with `short_description` set. * [x] Open `/agents`. * [x] Confirm both agents show a visible description: * New agent shows `short_description`. * Old agent shows a truncated `description`. * [x] Verify that text is truncated correctly according to the dialog/terminal width. * [x] Focus a native agent and verify the footer is not shown. * [x] Focus a custom agent and check that the `Ctrl+E` hotkey is shown in the footer. * [x] Press `Ctrl+E` on a custom agent and confirm the agent details dialog opens. * [x] In the details dialog, verify that the scrollbar works with both keyboard and mouse. * [x] Close the details dialog and confirm the `/agents` dialog reappears with the same selection preserved. * [x] Open other dialogs (e.g., `/models`, `/sessions`) and confirm their behavior and focus handling are unchanged. ## Demo ![Demo](https://github.com/user-attachments/assets/81349ee4-0aa5-44cd-8aff-cb5c0f38960e)
yindo added the pull-request label 2026-02-16 18:16:03 -05:00
yindo closed this issue 2026-02-16 18:16:03 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#11249