Skip to content

feat: Allow to extend and customize TUI with additional commands#2346

Open
shaj13 wants to merge 1 commit intodocker:mainfrom
shaj13:shaj13/tuicmd
Open

feat: Allow to extend and customize TUI with additional commands#2346
shaj13 wants to merge 1 commit intodocker:mainfrom
shaj13:shaj13/tuicmd

Conversation

@shaj13
Copy link
Copy Markdown
Contributor

@shaj13 shaj13 commented Apr 7, 2026

Problem

Customizing the TUI currently requires forking the repository or building a UI from scratch. This limits docker-agent's potential to serve as an end-to-end framework where consumers can reuse the TUI while adding their own commands.

What was done

  • Added Immediate flag to commands.Item to control whether a command interrupts an ongoing stream
  • Refactored ParseSlashCommand to a Parser struct with NewParser constructor, allowing consumers to build parsers with custom command categories
  • Added WithCommandBuilder option to allow consumers to provide custom command categories to the TUI

Dependency Resolution

At first, I started with an interface that appModel implements which returns internal objects like *app.App, *service.SessionState, chat.Page, and editor.Editor. However, that interface can't be set in the main package as it may not serve future changes, unless it's set in a dedicated package with a guarantee there will be no circular imports.

So I added a dynamic dependency resolution pattern via core.Resolve[T] - a type-safe generic function that retrieves dependencies from any tea.Model implementing Resolve(any) any. This pattern:

  • Avoids circular dependencies between internal packages
  • Allows command handlers to access dependencies without tight coupling
  • Enables future refactoring of handlers into separate packages

Usage:

app := core.Resolve[*app.App](model)
sessionState := core.Resolve[*service.SessionState](model)
chatPage := core.Resolve[chat.Page](model)

This may not be the final implementation as I am looking for feedback. I'm not sure if you're willing to allow TUI customization, but I think it would be very useful.

image image

@shaj13 shaj13 requested a review from a team as a code owner April 7, 2026 22:38
@shaj13 shaj13 force-pushed the shaj13/tuicmd branch 2 times, most recently from 2b4a12c to 1144cac Compare April 7, 2026 22:41
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.

1 participant