| 352 | // the stale-state trap: if you opened with 1 task (auto-skipped to detail), |
| 353 | // then a second task started, 'back' should show the list — not close. |
| 354 | const goBackToList = () => { |
| 355 | if (skippedListOnMount.current && allSelectableItems.length <= 1) { |
| 356 | onDone('Background tasks dialog dismissed', { |
| 357 | display: 'system' |
| 358 | }); |
| 359 | } else { |
| 360 | skippedListOnMount.current = false; |
| 361 | setViewState({ |
| 362 | mode: 'list' |
| 363 | }); |
| 364 | } |
| 365 | }; |
| 366 | |
| 367 | // If an item is selected, show the appropriate view |
| 368 | if (viewState.mode !== 'list' && typedTasks) { |