Skip to content

perf(sessions): scope preview-tab refresh to items a chat tool touched#9999

Closed
Guilhem-lm wants to merge 1 commit into
mainfrom
glm/session-tab-smart-refresh
Closed

perf(sessions): scope preview-tab refresh to items a chat tool touched#9999
Guilhem-lm wants to merge 1 commit into
mainfrom
glm/session-tab-smart-refresh

Conversation

@Guilhem-lm

@Guilhem-lm Guilhem-lm commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Summary

After a chat round, the sessions page reloaded preview tabs based on a broad mutating-tool name regex (/^(write_|patch_|delete_|deploy_|discard_|set_|create_|update_|remove_)/) with a reload-all fallback: any matching tool without a resolvable args.path set pendingReloadAll, blank-rebooting every preview iframe in every warm session. The frequent offender was update_user_instructions (the AI's "remember this" tool — no path), so casually saving a preference rebooted every open preview. create_folder did the same.

This replaces the regex + fallback with an explicit allowlist that maps a completed tool call to the (kind, path) of the item it touched. Item editor iframes (script/flow/app) now reload only when that exact item changed — kind-aware, so a script edit never reboots a same-path flow/app tab. Non-item list pages (runs, schedules, …) still reload on any workspace mutation, so they stay fresh. A tool that changes no workspace state (update_user_instructions) reloads nothing.

The allowlist also picks up edit_script, init_app, and rebase_draft — real mutators whose names the old regex silently missed, so they never reloaded before.

No visible UI change — this only changes when preview iframes reload.

Changes

  • frontend/src/routes/(root)/(logged)/sessions/+page.svelte:
    • toolReloadEffect(name, args){ scopes, reloadPages }: the single source of truth for what a tool reloads. Item mutations yield a (kind, path) scope; non-item workspace mutations (write_schedule/write_resource/write_variable/write_trigger/create_folder) yield reloadPages: true only; everything else (incl. update_user_instructions) reloads nothing.
    • reloadTabs(scopes, reloadPages): item-route iframes reload only when their (kind, path) is in scope; non-item page tabs reload when reloadPages; live-editor slots still self-skip in PreviewTabHost.reload().
    • Dropped the pendingReloadAll "reload everything" fallback.

Test plan

Verified in a real browser (dev server, ai-meta-e2e workspace) by tagging a preview iframe's contentWindow with a sentinel and running real chat rounds:

  • update_user_instructions ("remember I prefer dark mode") → sentinel survives (no reload). Previously reloaded every tab.
  • write_script (draft script) → item/page reload fires (sentinel cleared).
  • write_variable (non-item workspace mutation) → page tab reloads (sentinel cleared) — list pages stay fresh.
  • npm run check:fast clean; sessions page + AI chat + preview panel mount with no console errors from the change.
  • Reviewer sanity: open a script and a raw-app in two preview tabs, edit each via chat, confirm only the touched tab's iframe reloads.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying windmill with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2161419
Status: ✅  Deploy successful!
Preview URL: https://97ca61fd.windmill.pages.dev
Branch Preview URL: https://glm-session-tab-smart-refres.windmill.pages.dev

View logs

@Guilhem-lm

Copy link
Copy Markdown
Contributor Author

Superseded by #10006, which now carries both the scoped preview-refresh change (this PR's commit is its base) and the multi-target live-editor work as a single PR.

@Guilhem-lm Guilhem-lm closed this Jul 8, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 8, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant