Skip to content

perf(viewer): expose history and selection on the ?perf probe - #924

Open
Aymericr wants to merge 1 commit into
mainfrom
fidelity/a-08-perf-history-hook
Open

Aymericr wants to merge 1 commit into
mainfrom
fidelity/a-08-perf-history-hook

Conversation

@Aymericr

@Aymericr Aymericr commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

This adds two read-only methods to the ?perf scripted probe, window.__pascalPerf. The probe is mounted only when ?perf is in the URL.

  • history() returns { past, future, tracking, pauseDepth }: undo and redo entry counts, whether scene history is recording, and the number of refcounted pause owners (pauseSceneHistory and leases). A direct temporal.pause() shows as tracking: false with pauseDepth: 0. That is the signature of the unbalanced item-move pause that building-fidelity A-12 fixes.
  • selection() returns { buildingId, levelId, zoneId, selectedIds }.

Why: the private gesture receipts measure undo entries per gesture and whether history stays paused while an item is carried. Today they can only read those through dev-only store handles, so they cannot run against next start. This hook lets them. The logic is in lib/perf-probe-state.ts, with unit tests.

Nothing changes for the house: this is measurement only.

How to test

  1. bun run --cwd packages/viewer test: 368 pass, 0 fail (3 new in perf-probe-state.test.ts).
  2. Open any project with ?perf and run __pascalPerf.history() in the console. Move a wall, then run it again: past increases.

Checklist

  • bun check: 2479 files, no fixes.
  • check-types for @pascal-app/viewer passes. The workspace-wide run fails only in apps/editor on the missing optional @webxr/plugin module in this local checkout. That failure also happens without this change.
  • This PR targets the main branch.

🤖 Generated with Claude Code


Note

Low Risk
Read-only instrumentation behind the existing ?perf gate; no changes to scene history, selection, or viewer behavior.

Overview
Adds history() and selection() to the URL-gated window.__pascalPerf probe so scripted gesture receipts can read undo/redo counts, history tracking/pause state, and the current selection on production builds without dev-only store handles.

The logic lives in new perf-probe-state.ts: history() reports past, future, tracking, and refcounted pauseDepth (via getSceneHistoryPauseDepth), distinguishing direct temporal.pause() from pauseSceneHistory; selection() returns building/level/zone IDs and a copied selectedIds array. perf-monitor.tsx wires both into the existing probe object; unit tests cover pause semantics and selection immutability.

Normal sessions are unchanged—the probe still mounts only with ?perf.

Reviewed by Cursor Bugbot for commit 3314d8f. Bugbot is set up for automated code reviews on this repo. Configure here.

`window.__pascalPerf.history()` returns undo/redo entry counts, whether history is
tracking and the refcounted pause depth; `selection()` returns the selection path.
Scripted gesture receipts (private bench/next-house, scripts/perf) need both on
production builds, where the only store handles are dev-only. Mounted with ?perf only.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@pascal

pascal Bot commented Sep 24, 2026

Copy link
Copy Markdown

I hit an error while handling your request (Model unavailable on AI Gateway free tier: Free tier users do not have access to this model. Upgrade to paid credits at https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai%3Fmodal%3Dtop-up for unrestricted…).

Please try again, rephrase, or reach out if it keeps failing.

Error id: 2f95f0f7-5d34-41de-919a-b46af5edda24

This branch has not been deployed

No deployments
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