Skip to content

Commit 3dd8c56

Browse files
committed
docs: add clarifying comments addressing review feedback
- Expand comment for process nil check to explain: - Process is nil only for --print-openapi mode - Process is already running (termexec.StartProcess blocks) - Agent readiness is handled asynchronously via ReadyForInitialPrompt - Add comment for OnSnapshot callback explaining: - Callback pattern keeps screentracker decoupled from httpapi - Preserves clean package boundaries and avoids import cycles
1 parent 9a197fc commit 3dd8c56

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

lib/httpapi/server.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,9 @@ func NewServer(ctx context.Context, config ServerConfig) (*Server, error) {
263263
ReadyForInitialPrompt: isAgentReadyForInitialPrompt,
264264
FormatToolCall: formatToolCall,
265265
InitialPrompt: initialPrompt,
266+
// OnSnapshot uses a callback rather than passing the emitter directly
267+
// to keep the screentracker package decoupled from httpapi concerns.
268+
// This preserves clean package boundaries and avoids import cycles.
266269
OnSnapshot: func(status st.ConversationStatus, messages []st.ConversationMessage, screen string) {
267270
emitter.UpdateStatusAndEmitChanges(status, agentType)
268271
emitter.UpdateMessagesAndEmitChanges(messages)
@@ -295,7 +298,12 @@ func NewServer(ctx context.Context, config ServerConfig) (*Server, error) {
295298
// Register API routes
296299
s.registerRoutes()
297300

298-
// Start the conversation polling loop if we have a process
301+
// Start the conversation polling loop if we have a process.
302+
// Process is nil only when --print-openapi is used (no agent runs).
303+
// The process is already running at this point - termexec.StartProcess()
304+
// blocks until the PTY is created and the process is active. Agent
305+
// readiness (waiting for the prompt) is handled asynchronously inside
306+
// conversation.Start() via ReadyForInitialPrompt.
299307
if config.Process != nil {
300308
s.conversation.Start(ctx)
301309
}

0 commit comments

Comments
 (0)