| 1 | package main |
| 2 | |
| 3 | // Bound to the persisted tab state, not the end-of-turn notice card: that card |
| 4 | // renders once per finished turn, so a session reopened while still awaiting |
| 5 | // delivery would otherwise have no exit (#9036). |
| 6 | |
| 7 | // AcceptDelivery accepts the active tab's pending delivery checks. |
| 8 | func (a *App) AcceptDelivery() error { |
| 9 | return a.AcceptDeliveryToTab("") |
| 10 | } |
| 11 | |
| 12 | // AcceptDeliveryToTab clears one tab's awaiting-delivery state. It touches no |
| 13 | // other status, starts no turn, and is idempotent: accepting a tab that is not |
| 14 | // awaiting delivery succeeds and changes nothing. |
| 15 | func (a *App) AcceptDeliveryToTab(tabID string) error { |
| 16 | tab := a.tabByID(tabID) |
| 17 | if tab == nil { |
| 18 | return a.workspaceNotReadyErr(nil) |
| 19 | } |
| 20 | a.mu.Lock() |
| 21 | cleared := a.tabs[tab.ID] == tab && awaitingDelivery(tab) |
| 22 | if cleared { |
| 23 | tab.ActivityStatus = "" |
| 24 | } |
| 25 | a.mu.Unlock() |
| 26 | if cleared { |
| 27 | a.emitProjectTreeChanged() |
| 28 | } |
| 29 | return nil |
| 30 | } |
| 31 | |
| 32 | // awaitingDelivery reports the state the accept action is bound to. |
| 33 | func awaitingDelivery(tab *WorkspaceTab) bool { |
| 34 | return tab != nil && tab.ActivityStatus == topicStatusAwaitingDelivery |
| 35 | } |
| 36 |