Skip to content

Harden plan editor resource lifecycle - #337

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

Harden plan editor resource lifecycle#337
TraderSamwise merged 3 commits into
masterfrom
chore/core-sidecar-next-62

Conversation

@TraderSamwise

@TraderSamwise TraderSamwise commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • move the app plan editor onto the project resource lifecycle store
  • preserve draft-vs-saved plan content across transient refresh failures and stale responses
  • update north-star/app guidance for selected-project resource state

Verification

  • yarn --cwd app typecheck
  • yarn --cwd app lint (existing cli-auth warning only)
  • yarn --cwd app test
  • yarn typecheck
  • yarn lint
  • yarn build
  • yarn vitest
  • git diff --check

Summary by CodeRabbit

  • New Features

    • Plan editing now keeps draft changes in sync with saved content, making edits more reliable across refreshes and saves.
    • Project plan data now persists more consistently while loading and updating.
  • Bug Fixes

    • Fixed cases where a late refresh could overwrite unsaved plan edits.
    • Improved handling when a plan is missing or a refresh fails, reducing stale or inconsistent screen state.
  • Documentation

    • Updated guidance for managing shared project state and plan editing 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 11:15am

@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: 40 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: 5889e13d-fab2-4238-98ca-5eb1e485f948

📥 Commits

Reviewing files that changed from the base of the PR and between f1b644d and 728c710.

📒 Files selected for processing (3)
  • app/app/(main)/(tabs)/(dashboard)/plans/[sessionId].tsx
  • app/stores/project.test.ts
  • app/stores/project.ts
📝 Walkthrough

Walkthrough

Adds a project plan resource lifecycle to the Jotai project store (types, atoms for begin/apply success/failure/edit/save/clear/settle), migrates the plan editor screen from local React state to these atoms with a request tracker, adds corresponding test coverage, and updates documentation/guidelines to reflect the shared resource pattern.

Changes

Project plan resource migration

Layer / File(s) Summary
Plan resource contract and atoms
app/stores/project.ts
Adds ProjectPlanValue type, plan input interfaces, projectPlanResourceFamily/projectPlanFamily atom families, and lifecycle atoms for begin/apply-success/apply-failure/action-failure/edit/save-success/clear/settle.
Plan editor screen wiring
app/app/(main)/(tabs)/(dashboard)/plans/[sessionId].tsx
Replaces local content/loading/saving/error state with atom-driven refresh (refreshPlan), save (handleSave), and edit flows using a request tracker; updates derived UI state and input bindings.
Tests and documentation
app/stores/project.test.ts, AGENTS.md, docs/core-sidecar-north-star.md
Adds test helpers (plan(), putPlan()) and cases covering plan resource lifecycle semantics; updates AGENTS.md guideline on shared project state and revises north-star doc describing draft preservation.

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

Sequence Diagram(s)

sequenceDiagram
  participant PlanEditorScreen
  participant ProjectStoreAtoms
  participant PlanAPI

  PlanEditorScreen->>ProjectStoreAtoms: beginProjectPlanRefreshAtom(planKey)
  PlanEditorScreen->>PlanAPI: getPlan(planKey)
  PlanAPI-->>PlanEditorScreen: plan data or 404
  PlanEditorScreen->>ProjectStoreAtoms: applyProjectPlanSuccessAtom / applyProjectPlanFailureAtom
  PlanEditorScreen->>ProjectStoreAtoms: editProjectPlanDraftAtom(content)
  PlanEditorScreen->>PlanAPI: putPlan(content)
  PlanAPI-->>PlanEditorScreen: save result
  PlanEditorScreen->>ProjectStoreAtoms: applyProjectPlanSaveSuccessAtom / applyProjectPlanActionFailureAtom
  PlanEditorScreen->>ProjectStoreAtoms: refreshPlan()
Loading
🚥 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 the plan editor onto the project resource lifecycle and hardening draft/save behavior.
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-62

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.

Actionable comments posted: 2

🤖 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.

Inline comments:
In `@app/app/`(main)/(tabs)/(dashboard)/plans/[sessionId].tsx:
- Around line 72-75: The refreshPlan logic in the useCallback should not clear
draft data just because serviceEndpoint is temporarily missing. Update the guard
in refreshPlan so clearPlanResource(planKey) only runs when there is no valid
session or the plan is the NO_PROJECT_PLAN_KEY case; if projectPath/sessionId
still identify a real plan, keep the existing resource and simply skip the fetch
until the endpoint returns.

In `@app/stores/project.ts`:
- Around line 505-531: applyProjectPlanSaveSuccessAtom is overwriting the live
draft in projectPlanResourceFamily when a save resolves, which can clobber user
edits made after clicking save. Update the atom so it preserves the current
draft content from the existing projectPlanResourceFamily state when it has
diverged from the saved payload, and only refresh savedContent, sessionId,
fetchedAt, error, stale, and updatedAt in the success path. Use
applyProjectPlanSaveSuccessAtom and projectPlanResourceFamily to locate the
logic and keep the editor value stable while a putPlan request is in flight.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 792ffde5-e67e-4a07-a4db-6e56db7a2e42

📥 Commits

Reviewing files that changed from the base of the PR and between 3fba7e8 and f1b644d.

📒 Files selected for processing (5)
  • AGENTS.md
  • app/app/(main)/(tabs)/(dashboard)/plans/[sessionId].tsx
  • app/stores/project.test.ts
  • app/stores/project.ts
  • docs/core-sidecar-north-star.md

Comment thread app/app/(main)/(tabs)/(dashboard)/plans/[sessionId].tsx
Comment thread app/stores/project.ts
@TraderSamwise
TraderSamwise merged commit 618f8f6 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