Skip to content

fix(studio): refresh schedule history after actions and tidy the detail page - #2315

Merged
kantord merged 2 commits into
mainfrom
studio-followups/05-schedules-refresh
Oct 15, 2026
Merged

kantord merged 2 commits into
mainfrom
studio-followups/05-schedules-refresh

Conversation

@kantord

@kantord kantord commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Summary

Run now left the run history stale, deleting from the detail page waited for the list refetch before leaving, and a few schedule details were inconsistent or duplicated.

Part of #2303 ("Tiny follow-up fixes"); it does not close it. This is PR 5 of 14 in a stack of draft PRs, reviewed and merged in order.

What changed

  • Run now (list and detail) refreshes in finally, and invalidates the schedule's fires query for fire, even when the fire fails (a failed fire still records a row).
  • Detail delete awaits the mutation, drops the item from the list cache, removes its fires query, navigates, then invalidates the list without awaiting. (The review described a "not found" flash; in a browser the visible effect was the page staying on the deleted schedule's detail until the list refetch finished.)
  • describeRuns shows "None yet · up to N" when a run limit exists.
  • describeNextRun and describeLastRun reuse formatUntilTime and formatRelativeTime; formatSpan and the now parameters are removed. The shared formatters are unchanged ("<1m ago" matches the design).
  • filterScheduleInventory is exported; the workspace filters once and derives both layouts from the result.

Behavior changes

Reopening the detail after Run now shows the new fire. Deleting from the detail page navigates immediately instead of waiting for the list refetch. The run limit is visible before the first fire.

Screenshots

Before is the parent branch (#2314), after is this PR, with the same scenario code and offline mock data.

Scenario Before After
Run limit before the first fire
Runs reads "None yet" with no hint that a limit exists.

Runs reads "None yet · up to 5".
Delete from the detail page, list refetch slowed to 2 s (captured 400 ms after confirming)
Still on the deleted schedule's detail page, waiting for the list refetch.

Already back on the list, with no alert.
Run now from the list, then reopen the detail
Run history lacks the new run (the cached history is stale).

The new failed run is on top.

Note on the delete case: the "not found" alert described in the review did not reproduce in a browser (checked with a DOM mutation observer and 20x CPU throttling). The visible difference is the wait: before, the page stays on the detail until the list refetch finishes; after, it navigates immediately.

Verification

Biome, typecheck, the full Studio test suite and pnpm generated:check pass on this branch, run on the assembled stack. The full Playwright suite passes on the stack tip (122 passed, 30 skipped, 0 failed, including chat-approval against a real mecated build). The Run now, failed-fire, delete-flash and run-limit tests fail without the fix. The pause, rejected-delete, fake-timer and filter-both-layouts tests also pass on the old code, so they are regression guards. The detail page's own Run now try/finally has no test of its own.

Not included

Focus and shortcut fixes (next PR) and the BFF outcome (after that).

Fully or partially written by an AI agent.

🤖 Generated with Claude Code

@peppescg peppescg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks Daniel. The Run now invalidation, the run-limit hint and the formatter dedup look right, and the filter-once refactor makes the two layouts much easier to follow.

Before merge

  1. Delete can still flash "not found" (apps/web/src/features/schedules/schedule-detail.tsx:159-170). setQueryData removes the schedule from the list query while the detail page is still mounted and subscribed to it, so its next render hits !schedule and shows the "Scheduled task not found" role="alert" state, which is what the comment says this prevents. It usually doesn't show only because the router tends to commit before Query's batched notify. removeQueries on the fires key has a related problem: the key still has a mounted observer, so the next render can rebuild it and fire a GET /fires for the schedule you just deleted. await navigate({ to: "/workspace/schedules" }) first, then do the cache cleanup.
  2. The test can't see the flash (apps/web/src/features/schedules/schedules-workspace.test.tsx:324). queryByRole("alert") runs after the path has changed, when the detail page is already unmounted, so it passes either way. Watch for the alert while navigation is still pending (a MutationObserver attached before confirming, or a router stub whose navigation never resolves) and assert it never appears.

Nits:

  • The detail page's Run now try/finally (schedule-detail.tsx:136) has no test. A rejected fire that still refetches the detail page's fires would cover it, like the workspace test does.

@kantord
kantord force-pushed the studio-followups/05-schedules-refresh branch 3 times, most recently from 777b2b8 to f27f09d Compare October 15, 2026 09:26
Base automatically changed from studio-followups/04-escape-docs to main October 15, 2026 09:29
…il page

Run now (list and detail) invalidates the fires query even when the fire
fails, since a failed fire still records a row. Deleting from the detail
page drops the item from the cache and navigates before the list refetch,
so "not found" no longer flashes. The run limit shows before the first
fire, relative times reuse the shared formatters, and the inventory
filters once for both layouts.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@kantord
kantord force-pushed the studio-followups/05-schedules-refresh branch from f27f09d to 49c68dc Compare October 15, 2026 09:29
Addresses the review on #2315:
- Delete now awaits the navigation first, then drops the item from the
  list cache and removes its fires query, so no mounted observer
  re-renders into "not found" or refires GET /fires for the deleted task.
- The delete test holds the navigation and watches for the alert with a
  MutationObserver, and asserts no fires request follows the delete.
- Add a detail-page test that a rejected Run now still refetches fires.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@kantord

kantord commented Oct 15, 2026

Copy link
Copy Markdown
Member Author

Thanks Giuseppe. Addressed in 3712413.

  1. deleteItem now awaits navigate({ to: "/workspace/schedules" }) first (still outside the catch), and only then drops the item from the list cache, removes the fires query and invalidates the list without awaiting. The comment now gives the actual reason: the cleanup runs after the page has left, so no mounted observer re-renders into the not-found state or refires GET /fires for the deleted schedule.
  2. The test now holds navigation open with a promise the test controls and watches for any role="alert" with a MutationObserver attached before confirming. It also asserts the list cache still holds the schedule while navigation is pending, and that no GET .../fires is issued after the DELETE. Against the previous deleteItem it fails: first on the cache assertion (the old code emptied the list cache before navigating), and with that assertion removed, on the observer's flash assertion. I did not separately show the no-refire assertion failing on the old code.
  3. Added the detail-page test: a rejected fire still refetches that schedule's fires.

Checked on top of the current head: Biome, typecheck, the full Studio test suite and generated:check pass. Not run: e2e.

Fully or partially written by an AI agent.

@kantord
kantord merged commit ce0f816 into main Oct 15, 2026
31 checks passed
@kantord
kantord deleted the studio-followups/05-schedules-refresh branch October 15, 2026 12:25
@toolhive-release-app toolhive-release-app Bot mentioned this pull request Oct 20, 2026
2 tasks
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.

2 participants