Skip to content

Fix/scenarios list refresh - #8

Open
92Infinitus92 wants to merge 4 commits into
feat/studio-override-outcomes-uifrom
fix/scenarios-list-refresh
Open

Fix/scenarios list refresh#8
92Infinitus92 wants to merge 4 commits into
feat/studio-override-outcomes-uifrom
fix/scenarios-list-refresh

Conversation

@92Infinitus92

@92Infinitus92 92Infinitus92 commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator
  • Refresh scenarios without showing a full-page loading state.
  • Remove deleted scenarios immediately.
  • Preserve concurrent list changes when an optimistic delete or update fails.
  • Surface background refresh failures with retry and dismiss actions.

Greptile Summary

The PR adds background scenario-list refreshes, immediate optimistic deletion, concurrency-aware list operations, and visible retryable refresh errors.

  • Defers editor-triggered refreshes while the detail pane is open.
  • Preserves the displayed list when a background fetch fails.
  • Adds optimistic delete rollback and refresh-state tests.

Confidence Score: 4/5

The PR is not yet safe to merge because failed deletion can still replace a concurrently updated scenario with its stale pre-delete snapshot.

The rollback helper preserves a newer scenario only if that ID is already present locally; while the detail pane is open, update-triggered refreshes are deferred, so a failed DELETE can reinsert the captured stale object before the newer server state reaches the list.

Files Needing Attention: apps/studio/src/components/svm/scenarios-bento.tsx, apps/studio/src/lib/scenarios-list-ops.ts

Important Files Changed

Filename Overview
apps/studio/src/components/svm/scenarios-bento.tsx Adds functional state updates and optimistic deletion, but the failed-delete rollback still restores a stale captured scenario when a same-scenario update has not entered the local list.
apps/studio/src/lib/scenarios-list-ops.ts Preserves unrelated concurrent list changes, but its duplicate-ID guard cannot preserve a newer scenario version that exists only on the server.
apps/studio/src/app/scenarios/page.tsx Implements non-blocking refreshes, deferred editor refreshes, and retryable background-refresh errors.
apps/studio/src/components/svm/scenario-editor.tsx Moves the update event after successful PATCH completion so refreshes read persisted state.
apps/studio/src/lib/scenarios-list-ops.test.ts Covers list-level insertion behavior, including the case where a newer same-ID object is already present.
apps/studio/src/app/scenarios/page.test.tsx Exercises initial loading, background refresh, deferred refresh, and retry behavior.

Sequence Diagram

sequenceDiagram
    participant Editor
    participant Page
    participant List
    participant API
    Editor->>API: PATCH scenario
    List->>List: Optimistically remove scenario
    List->>API: DELETE scenario
    API-->>Editor: PATCH succeeds
    Editor->>Page: scenarioUpdated
    Page->>Page: Defer refresh while pane is open
    API-->>List: DELETE fails
    List->>List: Reinsert captured pre-delete snapshot
    Note over List: Newer server fields remain absent until a successful refresh
Loading

Reviews (2): Last reviewed commit: "test(studio): preserve refreshed scenari..." | Re-trigger Greptile

@92Infinitus92 92Infinitus92 self-assigned this Aug 14, 2026
Comment thread apps/studio/src/components/svm/scenarios-bento.tsx
Dispatch scenarioUpdated only after the PATCH resolves, defer the list refresh
while the editor pane is open, and flush it once on close. Show the full-screen
loader only on the first load so create and post-edit refreshes update the list
in the background instead of blanking the page.
Optimistically remove a scenario card on delete and restore it on failure, and surface a small notice when a background refresh fails so the list is not silently stale. Adds tests for the refresh state machine.
…olls back

Roll back optimistic delete and update against the current list via functional state updates, so a create or delete that lands mid-request survives the rollback instead of being clobbered by a stale snapshot. Adds unit tests for the reinsert helper.
@92Infinitus92
92Infinitus92 force-pushed the fix/scenarios-list-refresh branch from 13546c4 to 9f11e5f Compare August 14, 2026 21:52
@92Infinitus92

Copy link
Copy Markdown
Collaborator Author

@greptileai

@greptile-apps greptile-apps 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.

92Infinitus92 has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

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