Documentation Index
Fetch the complete documentation index at: https://mintlify.com/jaypopat/cf_ai_duet/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Theui package implements the Bubble Tea model for Duet’s terminal user interface, managing screens, room interactions, terminal display, and AI sidebar.
Types
Model
Main UI model managing all application state.Screen
Enumeration of UI screens:ScreenLaunch: Main menuScreenCreate: Create room formScreenJoin: Join room formScreenRoomCreated: Room created confirmationScreenRoom: Active room with terminal
InputMode
Terminal input modes:ModeNormal: Direct terminal inputModeAI: AI prompt input (Ctrl+G)ModeSandbox: Sandbox command input (Ctrl+R)
Functions
New
Creates a new UI model instance.Lipgloss renderer for styled output
Room manager instance
SSH username (defaults to “guest” if empty)
*Model ready for Bubble Tea
Example:
Init
Bubble Tea initialization command.Update
Bubble Tea update function handling messages.tea.WindowSizeMsg: Resize terminal and viewportstea.KeyMsg: Keyboard input routingterminalUpdateMsg: Terminal content changedroomEventMsg: Room events (join/leave/typing/ai_sync)AIResponseMsg: AI response receivedSandboxResultMsg: Sandbox command completed
View
Bubble Tea view function rendering the UI.Message Types
GotoScreenMsg
Navigate to a different screen.RoomCreatedMsg
Room successfully created.RoomJoinedMsg
Successfully joined a room.AIResponseMsg
AI response received.SandboxResultMsg
Sandbox command output.ToastMsg
Display a toast notification.ErrorMsg
Error occurred.Key Bindings
Launch Screen
c/C: Create roomJ: Join room↑/k: Move selection up↓/j: Move selection downEnter: Confirm selectionq/Esc: Quit
Room Screen (Normal Mode)
Ctrl+G: Open AI promptCtrl+R: Open sandbox commandCtrl+A: Toggle AI sidebarCtrl+J: Scroll AI sidebar downCtrl+K: Scroll AI sidebar upCtrl+L: Leave room- All other keys: Sent to terminal
AI/Sandbox Input Mode
Enter: Submit prompt/commandEsc: Cancel and return to normal mode
Layout Configuration
Internal Methods
roomLayout
Calculates layout dimensions.sidebarW: User list width (1/6 of screen)terminalW: Terminal width (remaining space)aiSidebarW: AI sidebar width (1/4 if visible, 0 otherwise)mainH: Main content height
startTerminal
Initializes or connects to room terminal.- Reuses existing room terminal if available
- Creates new terminal with room workspace directory
- Subscribes to terminal updates
- Stores terminal reference in room for other clients
sendAIMessage
Sends AI prompt to worker.User prompt
AIResponseMsg or ErrorMsg
execSandboxCmd
Executes command in isolated sandbox.Shell command to execute
SandboxResultMsg or ErrorMsg
syncAIViewportContent
Rebuild AI viewport from room’s message history.- Late joiners syncing chat history
- Refreshing after another client sends AI message
- Responding to “ai_sync” room events
addToast
Displays a temporary notification.Toast message (visible for 1 second)
cleanup
Cleans up resources when leaving room.- Unsubscribes from terminal updates
- Leaves room via manager
- Clears terminal reference
- Resets room state