Skip to content

Move project tab refreshes into resource actions - #339

Merged
TraderSamwise merged 4 commits into
masterfrom
chore/core-sidecar-next-64
Jul 6, 2026
Merged

Move project tab refreshes into resource actions#339
TraderSamwise merged 4 commits into
masterfrom
chore/core-sidecar-next-64

Conversation

@TraderSamwise

@TraderSamwise TraderSamwise commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • move Project tab observability/tasks refresh orchestration out of the screen into API-backed resource actions
  • keep the pure project resource store separate from HTTP-backed refresh actions
  • add stale/failure/last-request-wins coverage for Project tab resource refreshes
  • update the core sidecar north-star progress doc

Verification

  • yarn --cwd app typecheck
  • yarn --cwd app lint
  • yarn --cwd app test
  • yarn typecheck
  • yarn lint
  • yarn build
  • yarn vitest run
  • git diff --check
  • pre-push: yarn typecheck && yarn lint && yarn test

Summary by CodeRabbit

  • New Features
    • Project data refreshes now run through a shared refresh flow, improving consistency when updating project details and task lists.
  • Bug Fixes
    • Improved refresh reliability so the latest request wins, reducing stale or out-of-order project information.
    • Better error handling during refreshes helps keep previously loaded data visible when a request fails.
  • Documentation
    • Updated project progress notes to reflect the new refresh behavior.

@vercel

vercel Bot commented Jul 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
app Ready Ready Preview, Comment Jul 6, 2026 12:49pm

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 21 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fd1c4cec-797f-4d63-9899-b32d933174c9

📥 Commits

Reviewing files that changed from the base of the PR and between 8205950 and 8b2ff30.

📒 Files selected for processing (4)
  • app/app/(main)/(tabs)/project/index.tsx
  • app/lib/project-api-refresh.ts
  • app/stores/project.test.ts
  • app/stores/projectRefresh.ts
📝 Walkthrough

Walkthrough

Adds a new projectRefresh.ts module exposing refreshProjectObservabilityResourceAtom and refreshProjectTasksResourceAtom for fetching project observability and task data. Replaces the project screen's manual ref-based refresh counters and begin/apply/settle dispatch logic with calls to these atoms. Adds corresponding tests and a documentation update.

Changes

Refresh resource atoms migration

Layer / File(s) Summary
Refresh atom implementation
app/stores/projectRefresh.ts
New module defines RefreshProjectApiResourceInput, helper functions for endpoint keys and error normalization, and two exported atoms that fetch observability/tasks data and write begin/success/failure state with fetchedAt timestamps.
Screen refresh callback simplification
app/app/(main)/(tabs)/project/index.tsx
Removes useRef-based sequence counters, request scopes/keys, and manual begin/apply/settle dispatches; replaces them with a single refreshProjectView callback invoking both resource atoms concurrently via Promise.all.
Refresh atom tests
app/stores/project.test.ts
Adds mocks for getProjectObservability/listTasks, test helpers (endpoint, getToken, deferred()), and async tests covering success, failure with stale-data preservation, and concurrency ordering.
Documentation update
docs/core-sidecar-north-star.md
States that Project tab refreshes now use project-store resource actions instead of screen-owned request bookkeeping.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ProjectScreen
  participant refreshProjectObservabilityResourceAtom
  participant refreshProjectTasksResourceAtom
  participant API

  ProjectScreen->>refreshProjectObservabilityResourceAtom: set({projectPath, endpoint, getToken})
  ProjectScreen->>refreshProjectTasksResourceAtom: set({projectPath, endpoint, getToken})
  refreshProjectObservabilityResourceAtom->>API: getProjectObservability(endpoint, token)
  refreshProjectTasksResourceAtom->>API: listTasks(endpoint, token)
  API-->>refreshProjectObservabilityResourceAtom: observability data
  API-->>refreshProjectTasksResourceAtom: tasks data
  refreshProjectObservabilityResourceAtom-->>ProjectScreen: apply success/failure
  refreshProjectTasksResourceAtom-->>ProjectScreen: apply success/failure
Loading

Possibly related PRs

  • TraderSamwise/aimux#180: The new refreshProjectObservabilityResourceAtom consumes getProjectObservability(), the API this PR added, tying both to the same observability-fetch contract.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: moving Project tab refresh orchestration into resource actions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/core-sidecar-next-64

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
app/stores/projectRefresh.ts (1)

30-96: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicate fetch/begin/apply orchestration between the two atoms.

refreshProjectObservabilityResourceAtom and refreshProjectTasksResourceAtom are structurally identical (requestKey build → begin → try/fetch/success → catch/failure). Consider extracting a shared helper parameterized by the begin/success/failure atoms and the fetch call, to avoid drift as more resources are added.

♻️ Possible consolidation
+async function runResourceRefresh<TSuccessPayload>(
+  set: <A extends unknown[], R>(atom: WritableAtom<unknown, A, R>, ...args: A) => R,
+  { projectPath, endpoint, getToken }: RefreshProjectApiResourceInput,
+  clearAtom: WritableAtom<unknown, [string], void>,
+  beginAtom: WritableAtom<unknown, [{ projectPath: string; requestKey: string }], void>,
+  fetchFn: (endpoint: ServiceEndpoint, token: string | null) => Promise<TSuccessPayload>,
+  successAtom: WritableAtom<unknown, [{ projectPath: string; requestKey: string; payload: TSuccessPayload }], void>,
+  failureAtom: WritableAtom<unknown, [{ projectPath: string; requestKey: string; error: string }], void>,
+) {
+  if (!endpoint) {
+    set(clearAtom, projectPath);
+    return;
+  }
+  const requestKey = projectResourceRequestKey({ projectPath, endpointKey: endpointKey(endpoint), generation: 0 });
+  set(beginAtom, { projectPath, requestKey });
+  try {
+    const token = await getToken();
+    const payload = await fetchFn(endpoint, token);
+    set(successAtom, { projectPath, requestKey, payload });
+  } catch (err) {
+    set(failureAtom, { projectPath, requestKey, error: errorMessage(err) });
+  }
+}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/stores/projectRefresh.ts` around lines 30 - 96, The two refresh atoms
duplicate the same requestKey/begin/try-fetch/success/catch-failure flow, so
extract the shared orchestration into a helper that takes the
begin/success/failure atoms plus the fetch function. Use the existing
refreshProjectObservabilityResourceAtom and refreshProjectTasksResourceAtom as
callers, and keep their resource-specific response mapping inside the helper
parameters to prevent future drift when adding more project resources.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@app/stores/projectRefresh.ts`:
- Around line 30-96: The two refresh atoms duplicate the same
requestKey/begin/try-fetch/success/catch-failure flow, so extract the shared
orchestration into a helper that takes the begin/success/failure atoms plus the
fetch function. Use the existing refreshProjectObservabilityResourceAtom and
refreshProjectTasksResourceAtom as callers, and keep their resource-specific
response mapping inside the helper parameters to prevent future drift when
adding more project resources.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1be371e6-45de-4860-9f40-b6e5a3039824

📥 Commits

Reviewing files that changed from the base of the PR and between dd3a5ff and 8205950.

📒 Files selected for processing (4)
  • app/app/(main)/(tabs)/project/index.tsx
  • app/stores/project.test.ts
  • app/stores/projectRefresh.ts
  • docs/core-sidecar-north-star.md

@TraderSamwise
TraderSamwise merged commit 9ca159b into master Jul 6, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant