Skip to content

Commit

Permalink
fix missing file handling, closes #195
Browse files Browse the repository at this point in the history
  • Loading branch information
danenania committed Oct 2, 2024
1 parent 14bef0d commit 225010c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
1 change: 1 addition & 0 deletions app/cli/stream_tui/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ func (m *streamUIModel) streamUpdate(msg *shared.StreamMessage, deferUIUpdate bo
}

// log.Println("streamUI received message:", msg.Type)
// log.Println(spew.Sdump(msg))

switch msg.Type {

Expand Down
23 changes: 15 additions & 8 deletions app/server/types/active_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,16 +164,22 @@ func (ap *ActivePlan) FlushStreamBuffer() {

// log.Printf("ActivePlan: flushing %d messages from stream buffer\n", len(ap.streamMessageBuffer))

// construct a multi message from the buffer
multiMsg := shared.StreamMessage{
Type: shared.StreamMessageMulti,
StreamMessages: ap.streamMessageBuffer,
var msg shared.StreamMessage
if len(ap.streamMessageBuffer) == 1 {
log.Println("ActivePlan: flushing 1 message from stream buffer")
msg = ap.streamMessageBuffer[0]
} else {
msg = shared.StreamMessage{
Type: shared.StreamMessageMulti,
StreamMessages: ap.streamMessageBuffer,
}
}

ap.streamMessageBuffer = []shared.StreamMessage{}

ap.streamMu.Unlock()

ap.Stream(multiMsg)
ap.Stream(msg)
}

func (ap *ActivePlan) Stream(msg shared.StreamMessage) {
Expand All @@ -182,7 +188,8 @@ func (ap *ActivePlan) Stream(msg shared.StreamMessage) {
ap.streamMu.Lock()
defer ap.streamMu.Unlock()

if msg.Type != shared.StreamMessageFinished {
if msg.Type != shared.StreamMessageFinished &&
msg.Type != shared.StreamMessagePromptMissingFile {
if time.Since(ap.lastStreamMessageSent) < MaxStreamRate {
// log.Println("ActivePlan: stream rate limiting -- buffering message")
ap.streamMessageBuffer = append(ap.streamMessageBuffer, msg)
Expand Down Expand Up @@ -226,11 +233,11 @@ func (ap *ActivePlan) Stream(msg shared.StreamMessage) {
}
}

// log.Println("ActivePlan: sending stream message")
// log.Println("ActivePlan: sending stream message:", msg.Type)

ap.streamCh <- string(msgJson)

// log.Println("ActivePlan: sent stream message")
// log.Println("ActivePlan: sent stream message:", msg.Type)

now := time.Now()
if now.After(ap.lastStreamMessageSent) {
Expand Down

0 comments on commit 225010c

Please sign in to comment.