Skip to content
10 changes: 10 additions & 0 deletions lib/httpapi/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,16 @@ func (s *Server) StartSnapshotLoop(ctx context.Context) {

// Send initial prompt when agent becomes stable for the first time
if !s.conversation.InitialPromptSent && convertStatus(currentStatus) == AgentStatusStable {

// If agent type is opencode
if s.agentType == mf.AgentTypeOpencode {
time.Sleep(5 * time.Second)
// If we still have it as stable, go ahead.
if convertStatus(s.conversation.Status()) != AgentStatusStable {
continue
}
}

if err := s.conversation.SendMessage(FormatMessage(s.agentType, s.conversation.InitialPrompt)...); err != nil {
s.logger.Error("Failed to send initial prompt", "error", err)
} else {
Expand Down
4 changes: 2 additions & 2 deletions lib/msgfmt/message_box.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ func removeOpencodeMessageBox(msg string) string {
// ┃ ┃
// We only check for the first ┃ and then an empty line above it - as sometimes the full input block does not load within a snapshot,
// this leads to displaying a bunch of newlines.
for i := len(lines) - 1; i >= 1; i-- {
if strings.TrimSpace(lines[i-1]) == "" &&
for i := len(lines) - 1; i >= 2; i-- {
if strings.ReplaceAll(lines[i-2], " ", "") != "┃┃" &&
strings.ReplaceAll(lines[i], " ", "") == "┃┃" {
lines = lines[:i-1]
break
Expand Down
1 change: 1 addition & 0 deletions lib/msgfmt/msgfmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ func formatCodexMessage(message string, userInput string) string {
}

func formatOpencodeMessage(message string, userInput string) string {

message = RemoveUserInput(message, userInput, AgentTypeOpencode)
message = removeOpencodeMessageBox(message)
message = trimEmptyLines(message)
Expand Down