Repository navigation
fix: preserve account context across task run views - #2355
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Resolve task-run scope hooks/useTaskRunScope.ts, hooks/__tests__/taskRunScope.fixture.tsx |
The new scope hook resolves account selection and read readiness, tracks scope identity, and checks context during reads. The shared test fixture mocks authentication, account selection, and API origin. |
Fetch runs within scope hooks/useTaskRuns.ts, hooks/useTaskRunStatus.ts, hooks/useChatRunStatus.ts, lib/tasks/getTaskRuns.ts, lib/tasks/getTaskRunStatus.ts, lib/tasks/getChatRunStatus.ts |
Task-run and chat-status hooks use scoped query keys, readiness, tokens, API URLs, and abort signals. Request functions accept API URL and cancellation options; task-status requests can include an account override. |
Carry account context through task pages lib/tasks/getAccountScopedHref.ts, lib/tasks/getRunHref.ts, components/Home/*, components/TasksPage/*, components/TasksPage/Run/*, hooks/useHomeTasksModuleState.ts |
Task links and breadcrumbs include account context. The Recents view and run page show scope notices and gate content on readiness. Run details check account matching before displaying the chat link. Home-task state returns the account ID and limits the existing-report lookup to the specified conditions. |
Priority:
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Bug fix
Sequence Diagram(s)
sequenceDiagram
participant TasksTabs
participant useTaskRuns
participant useTaskRunScope
participant getTaskRuns
participant TasksAPI
TasksTabs->>useTaskRuns: Request task runs
useTaskRuns->>useTaskRunScope: Resolve scope and readiness
useTaskRunScope-->>useTaskRuns: Provide scoped read context
useTaskRuns->>getTaskRuns: Read runs with scope and abort signal
getTaskRuns->>TasksAPI: GET task runs
Possibly related PRs
- recoupable/app#2343: It changes account-override resolution consumed by the task-run scope hook.
Merge Risk: 
Minimal · up to a3a79
-
The selected-account empty state does not fall back to the signed-in account. No identified issue needs to be resolved before merging.
Pre-merge checks: 
2 · 
1
-
Failed checks: 1 warning Passed checks: 2 passedFull details: Solid & Clean Code
-
Explanation
The pull request adds a 64-line
useTaskRunScopefunction (hooks/useTaskRunScope.ts:18-81), which exceeds the check's 20-line guideline. It also combines scope resolution, session generation, cache-key construction, lifecycle invalidation, token acquisition, API-origin validation, and request execution. Its nestedreadcallback spans lines 55-78. The change introduces a clear SRP and maintainability violation. The other changed components mainly pass the account context through and remain focused.Resolution
Split
useTaskRunScopeinto focused units. Extract pure scope resolution and scope-key creation, move login-generation and mounted-scope invalidation into a dedicated hook or helper, and move token acquisition plus stale-request checks into a reusable scoped-read helper. KeepuseTaskRunScopeas a small composition layer with one responsibility.
-
Finishing Touches
-
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Account paths follow the run
Scope checks start before reads begin
Requests carry their context through
Notices name the account in view
Breadcrumbs keep the path in tune
Comment @coderabbitai help to get the list of available commands.
Summary
Preserve the selected account across Recents/Home → run detail → Recents, using the existing authorized task-run API contract. Current-main successor for the account-override intent in #1735; that historical PR remains untouched.
account_idon task list/detail requests. Preserve polling, terminal states, kickoff metadata and timings.Verification
Boundaries
No API, dependency, auth-provider or schedule mutation changes. Existing server task-run access checks remain authoritative. Linked workflow status cache isolation does not add backend ownership checks to that separate endpoint. Per-mounted-reader cache identity deliberately trades duplicate concurrent list reads for preventing cross-session cache reuse. Authenticated hosted behavior has not been exercised.
Preview: https://app-git-cosmo-task-run-account-scope-recoup.vercel.app