opencode icon indicating copy to clipboard operation
opencode copied to clipboard

feat: add dynamic window titles based on user messages

Open aryasaatvik opened this issue 6 months ago • 2 comments

Summary

  • Adds dynamic window title generation that shows the user's message in the terminal title bar while AI is processing
  • Implements AI-powered title generation using fast models (Haiku for Anthropic, GPT-4o-mini for OpenAI)
  • Window title reverts to "opencode" when AI finishes processing or when session is interrupted

Implementation Details

  • Added /session_generate_title endpoint in TypeScript server
  • Created title-window.txt prompt file for concise title generation
  • Integrated window title updates in Go TUI client
  • Title generation happens asynchronously without blocking message submission
  • Handles edge cases like session interruption, session switching, and model selection

Test Plan

  • [x] Test window title updates when submitting messages
  • [x] Verify title reverts to "opencode" when AI completes
  • [x] Test title reset on session interrupt (Ctrl+C)
  • [x] Verify title resets when switching sessions
  • [x] Test fallback to truncated message if API fails
  • [x] Ensure title generation works with different providers (Anthropic, OpenAI)

https://github.com/user-attachments/assets/32d3f521-70db-42f4-b129-71dab67be3fe

aryasaatvik avatar Jun 20 '25 20:06 aryasaatvik

this is very cool

i want to clean up our system for doing conditional stuff per provider so let me play with that first before i merge this

thdxr avatar Jun 20 '25 21:06 thdxr

this is very cool

i want to clean up our system for doing conditional stuff per provider so let me play with that first before i merge this

thank you! for smaller tasks like generating verbs and window title i think it would be better to store 2 models (lightweight and main) in the config. i will finish https://github.com/sst/opencode/pull/279 tomorrow

aryasaatvik avatar Jun 20 '25 22:06 aryasaatvik