on main help sign in
chore: fix cancellation
31a3c05Kujtim Hoxha
internal/app/app.go+3−3
@@ -279,6 +279,9 @@ func (app *App) Subscribe(program *tea.Program) {
279
279
280// Shutdown performs a clean shutdown of the application
280// Shutdown performs a clean shutdown of the application
281func (app *App) Shutdown() {
281func (app *App) Shutdown() {
282+ if app.CoderAgent != nil {
283+ app.CoderAgent.CancelAll()
284+ }
282 app.cancelFuncsMutex.Lock()
285 app.cancelFuncsMutex.Lock()
283 for _, cancel := range app.watcherCancelFuncs {
286 for _, cancel := range app.watcherCancelFuncs {
284 cancel()
287 cancel()
@@ -298,9 +301,6 @@ func (app *App) Shutdown() {
298 }
301 }
299 cancel()
302 cancel()
300 }
303 }
301− if app.CoderAgent != nil {
302− app.CoderAgent.CancelAll()
303− }
304
304
305 for _, cleanup := range app.cleanupFuncs {
305 for _, cleanup := range app.cleanupFuncs {
306 if cleanup != nil {
306 if cleanup != nil {
internal/llm/agent/agent.go+7
@@ -801,6 +801,13 @@ func (a *agent) CancelAll() {
801 a.Cancel(key.(string)) // key is sessionID
801 a.Cancel(key.(string)) // key is sessionID
802 return true
802 return true
803 })
803 })
804+ for {
805+ if a.IsBusy() {
806+ time.Sleep(200 * time.Millisecond)
807+ } else {
808+ break
809+ }
810+ }
804}
811}
805
812
806func (a *agent) UpdateModel() error {
813func (a *agent) UpdateModel() error {