Skip to content

Commit 2b64027

Browse files
committed
simplify initialPromptReady: channel -> bool
1 parent 7f72f23 commit 2b64027

1 file changed

Lines changed: 5 additions & 13 deletions

File tree

lib/screentracker/pty_conversation.go

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ type PTYConversation struct {
104104
stableSignal chan struct{}
105105
// toolCallMessageSet keeps track of the tool calls that have been detected & logged in the current agent message
106106
toolCallMessageSet map[string]bool
107-
// initialPromptReady is closed when ReadyForInitialPrompt returns true.
107+
// initialPromptReady is set to true when ReadyForInitialPrompt returns true.
108108
// Checked inline in the snapshot loop on each tick.
109-
initialPromptReady chan struct{}
109+
initialPromptReady bool
110110
}
111111

112112
var _ Conversation = &PTYConversation{}
@@ -130,7 +130,6 @@ func NewPTY(ctx context.Context, cfg PTYConversationConfig) *PTYConversation {
130130
outboundQueue: make(chan outboundMessage, 1),
131131
stableSignal: make(chan struct{}, 1),
132132
toolCallMessageSet: make(map[string]bool),
133-
initialPromptReady: make(chan struct{}),
134133
}
135134
// If we have an initial prompt, enqueue it
136135
if len(cfg.InitialPrompt) > 0 {
@@ -157,17 +156,10 @@ func (c *PTYConversation) Start(ctx context.Context) {
157156
// Signal send loop if agent is ready and queue has items.
158157
// We check readiness independently of statusLocked() because
159158
// statusLocked() returns "changing" when queue has items.
160-
isReady := false
161-
select {
162-
case <-c.initialPromptReady:
163-
isReady = true
164-
default:
165-
if c.cfg.ReadyForInitialPrompt(screen) {
166-
close(c.initialPromptReady)
167-
isReady = true
168-
}
159+
if !c.initialPromptReady && c.cfg.ReadyForInitialPrompt(screen) {
160+
c.initialPromptReady = true
169161
}
170-
if isReady && len(c.outboundQueue) > 0 && c.isScreenStableLocked() {
162+
if c.initialPromptReady && len(c.outboundQueue) > 0 && c.isScreenStableLocked() {
171163
select {
172164
case c.stableSignal <- struct{}{}:
173165
default:

0 commit comments

Comments
 (0)