Skip to content

Commit ad4f99b

Browse files
authored
Merge pull request #2207 from dgageot/fix-clear
Fix /clear
2 parents 6878e0b + b879a94 commit ad4f99b

1 file changed

Lines changed: 26 additions & 30 deletions

File tree

pkg/app/app.go

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,30 @@ func (a *App) NewSession() {
577577
// Clear first message so it won't be re-sent on re-init
578578
a.firstMessage = nil
579579
a.firstMessageAttach = ""
580+
581+
// Re-emit startup info so the sidebar shows agent/tools info in the new session
582+
a.reEmitStartupInfo(context.Background())
583+
}
584+
585+
// reEmitStartupInfo resets and re-emits startup info (agent, team, tools)
586+
// through the events channel so the sidebar updates.
587+
func (a *App) reEmitStartupInfo(ctx context.Context) {
588+
a.runtime.ResetStartupInfo()
589+
go func() {
590+
startupEvents := make(chan runtime.Event, 10)
591+
go func() {
592+
defer close(startupEvents)
593+
a.runtime.EmitStartupInfo(ctx, a.session, startupEvents)
594+
}()
595+
for event := range startupEvents {
596+
select {
597+
case a.events <- event:
598+
case <-ctx.Done():
599+
return
600+
default:
601+
}
602+
}
603+
}()
580604
}
581605

582606
func (a *App) Session() *session.Session {
@@ -677,21 +701,7 @@ func (a *App) SetCurrentAgentModel(ctx context.Context, modelRef string) error {
677701
}
678702

679703
// Re-emit startup info so the sidebar updates with the new model
680-
a.runtime.ResetStartupInfo()
681-
go func() {
682-
startupEvents := make(chan runtime.Event, 10)
683-
go func() {
684-
defer close(startupEvents)
685-
a.runtime.EmitStartupInfo(ctx, a.session, startupEvents)
686-
}()
687-
for event := range startupEvents {
688-
select {
689-
case a.events <- event:
690-
case <-ctx.Done():
691-
return
692-
}
693-
}
694-
}()
704+
a.reEmitStartupInfo(ctx)
695705

696706
return nil
697707
}
@@ -851,21 +861,7 @@ func (a *App) ReplaceSession(ctx context.Context, sess *session.Session) {
851861
a.applySessionModelOverrides(ctx, sess)
852862

853863
// Reset and re-emit startup info so the sidebar shows agent/tools info
854-
a.runtime.ResetStartupInfo()
855-
go func() {
856-
startupEvents := make(chan runtime.Event, 10)
857-
go func() {
858-
defer close(startupEvents)
859-
a.runtime.EmitStartupInfo(ctx, a.session, startupEvents)
860-
}()
861-
for event := range startupEvents {
862-
select {
863-
case a.events <- event:
864-
case <-ctx.Done():
865-
return
866-
}
867-
}
868-
}()
864+
a.reEmitStartupInfo(ctx)
869865
}
870866

871867
// applySessionModelOverrides applies any stored model overrides from a loaded session.

0 commit comments

Comments
 (0)