Skip to content

Commit b879a94

Browse files
committed
Fix /clear
Signed-off-by: David Gageot <david.gageot@docker.com>
1 parent 12ade90 commit b879a94

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
@@ -572,6 +572,30 @@ func (a *App) NewSession() {
572572
// Clear first message so it won't be re-sent on re-init
573573
a.firstMessage = nil
574574
a.firstMessageAttach = ""
575+
576+
// Re-emit startup info so the sidebar shows agent/tools info in the new session
577+
a.reEmitStartupInfo(context.Background())
578+
}
579+
580+
// reEmitStartupInfo resets and re-emits startup info (agent, team, tools)
581+
// through the events channel so the sidebar updates.
582+
func (a *App) reEmitStartupInfo(ctx context.Context) {
583+
a.runtime.ResetStartupInfo()
584+
go func() {
585+
startupEvents := make(chan runtime.Event, 10)
586+
go func() {
587+
defer close(startupEvents)
588+
a.runtime.EmitStartupInfo(ctx, a.session, startupEvents)
589+
}()
590+
for event := range startupEvents {
591+
select {
592+
case a.events <- event:
593+
case <-ctx.Done():
594+
return
595+
default:
596+
}
597+
}
598+
}()
575599
}
576600

577601
func (a *App) Session() *session.Session {
@@ -672,21 +696,7 @@ func (a *App) SetCurrentAgentModel(ctx context.Context, modelRef string) error {
672696
}
673697

674698
// Re-emit startup info so the sidebar updates with the new model
675-
a.runtime.ResetStartupInfo()
676-
go func() {
677-
startupEvents := make(chan runtime.Event, 10)
678-
go func() {
679-
defer close(startupEvents)
680-
a.runtime.EmitStartupInfo(ctx, a.session, startupEvents)
681-
}()
682-
for event := range startupEvents {
683-
select {
684-
case a.events <- event:
685-
case <-ctx.Done():
686-
return
687-
}
688-
}
689-
}()
699+
a.reEmitStartupInfo(ctx)
690700

691701
return nil
692702
}
@@ -846,21 +856,7 @@ func (a *App) ReplaceSession(ctx context.Context, sess *session.Session) {
846856
a.applySessionModelOverrides(ctx, sess)
847857

848858
// Reset and re-emit startup info so the sidebar shows agent/tools info
849-
a.runtime.ResetStartupInfo()
850-
go func() {
851-
startupEvents := make(chan runtime.Event, 10)
852-
go func() {
853-
defer close(startupEvents)
854-
a.runtime.EmitStartupInfo(ctx, a.session, startupEvents)
855-
}()
856-
for event := range startupEvents {
857-
select {
858-
case a.events <- event:
859-
case <-ctx.Done():
860-
return
861-
}
862-
}
863-
}()
859+
a.reEmitStartupInfo(ctx)
864860
}
865861

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

0 commit comments

Comments
 (0)