Scope TUI app directory state to the active context (#38743)

## Why

App directory data and in-flight requests can outlive the account, workspace, or thread that produced them, allowing stale apps to appear in the current TUI context.

## What changed

- Invalidate cached app data, dismiss the app picker, and start a fresh fetch when the account, workspace, or thread changes.
- Tag app directory fetches with their originating thread, workspace, and scope generation, and ignore queued requests or results that no longer match.
- Treat `AppListUpdated` notifications as revalidation signals instead of directly adopting their unscoped contents, with deduplication and a bounded error retry.

## Testing

Added coverage for stale request and result rejection, context invalidation, picker dismissal, and notification revalidation.

GitOrigin-RevId: f20930a0598a6abbdfb3c7826ec955346fe2da7a
This commit is contained in:
Charlie Marsh authored and copyberry committed 2026-08-15 10:57:15 +00:00
1 parent 85fc4def35
commit 3c7ae4a812
13 files changed
+505 -28

No files matched your search

@@ -0,0 +1,18 @@
---
source: tui/src/chatwidget/tests/popups_and_settings.rs
expression: "format!(\"Before account change:\\n{before}\\n\\nAfter account change:\\n{after}\")"
---
Before account change:
Apps
Use $ to insert an installed app into your prompt.
Installed 1 of 1 available apps.
Type to search apps
› Previous Account App Installed. App link unavailable.
Press enter to confirm or esc to go back
After account change:
› Ask Codex to do anything
gpt-5.6-sol default · /tmp/project