fix(viewer): bind dialog work to its input and opening
After sharing room A, leaving it, and reopening Share, a failed new mint or join could leave A’s URL and Copy control active beside a failure notice. Loaded CSV preview failures also scrolled away from the top error alert. A failed private-report DELETE invalidated a valid status refresh, while a late refresh could undo a confirmed deletion.
Reset the link and copied state alongside the notice whenever a new room attempt starts. Keep the room owner explicit because cleanup must stop only that opening’s pending join and preserve an established session. The mint effect alone resets minting. CSV errors stay at the top and no longer trigger the automatic bottom scroll; the alert indentation is fixed.
Use useAsyncRun for table suggestions keyed by the full draft identity, manual receipt refreshes, and resumed-draft cancellation. No changed viewer file imports or calls the helper deleted by #9590. Remove the suggestion’s custom controller/release cleanup and the report generation counter. A confirmed successful DELETE resets and aborts the receipt refresh; a failed request or unconfirmed deletion leaves that refresh valid.
Closing Share during “Creating room…” now abandons creation: an owned pending join is stopped with stopCollab, and its minted claim is released when the attempt unwinds. Creation no longer brings the room up in the background after the dialog closes. An established session survives closing the dialog.
The resumed-draft double-DELETE fix is a separate defect class retained here. Its small async-run cancellation wrapper also provides the owner check preventing a late cancellation from closing a replacement dialog. Keeping the wrapper and its mounted tests together avoids separate lifetime plumbing for that same cancellation operation. An explicitly requested private-data DELETE may finish after teardown; its owner check prevents a late close callback from affecting another dialog.
The mounted regressions were confirmed failing before the fixes: stale room-A URLs after both mint and join failures, discarded GETs after failed/unconfirmed DELETEs, duplicate same-tick GETs, and an actual scroll call away from a preview error. The prior migration preservation focus passed 64 tests with zero skips; the cancellation, suggestion, and shared-helper source are unchanged by this rebase. Prior mutation evidence below still applies; the original failing-first regressions remain in the full family gate. Assertions compare plain values, including viewport scroll calls and request signal state.
Rebased onto main 8011ae0486553f9cda0e605d3354b620ff887237. Full local validation at 7a6aef9ba069faeea789cbd2d9e8e01c55440364 on Pop!_OS (Node 24.22.0, pnpm 10.8.1). Every command below used an 8 GiB hard cap, zero swap, and a two-CPU quota.
| Command | Result |
|---|---|
systemd-run --user --scope -q -p MemoryMax=8G -p MemorySwapMax=0 -p CPUQuota=200% -- python3 /tmp/aee6-legacy-check.py | Passed; git grep -n useSingleFlight apps/viewer/src has zero matches in this PR’s changed viewer files |
systemd-run --user --scope -q -p MemoryMax=8G -p MemorySwapMax=0 -p CPUQuota=200% -- pnpm install --frozen-lockfile --ignore-scripts | Passed; refreshed workspace links without lifecycle builds |
systemd-run --user --scope -q -p MemoryMax=8G -p MemorySwapMax=0 -p CPUQuota=200% -- env TEST_PATTERN='EpsgLookupDialog|ShareDialog|ErrorReportDialog|DataConnector|EpsgLookupError|table-mapping-request|lib/collab/share-(link|scope)|components/error-report/|services/error-reports/|lib/error-reports/|useAsyncRun' pnpm test --filter=@ifc-lite/viewer --only | 192 passed; 1 skipped |
systemd-run --user --scope -q -p MemoryMax=8G -p MemorySwapMax=0 -p CPUQuota=200% -- env NODE_OPTIONS=--max-old-space-size=8192 TURBO_CONCURRENCY=1 pnpm typecheck:ci | Passed; viewer and viewer-embed plus test sources |
systemd-run --user --scope -q -p MemoryMax=8G -p MemorySwapMax=0 -p CPUQuota=200% -- env AEE3_LINT_TSC_LOCK=/tmp/aee8-tsc-dialog.lock NODE_OPTIONS=--import=file:///tmp/aee3-serialize-tsc.mjs pnpm lint | Passed, including unused locals; existing warnings outside touched files |
systemd-run --user --scope -q -p MemoryMax=8G -p MemorySwapMax=0 -p CPUQuota=200% -- node scripts/check-module-size.mjs | Passed |
systemd-run --user --scope -q -p MemoryMax=8G -p MemorySwapMax=0 -p CPUQuota=200% -- node scripts/check-source-text-assertions.mjs | Passed |
systemd-run --user --scope -q -p MemoryMax=8G -p MemorySwapMax=0 -p CPUQuota=200% -- node --test scripts/check-unused-locals-baseline.test.mjs | Passed |
systemd-run --user --scope -q -p MemoryMax=8G -p MemorySwapMax=0 -p CPUQuota=200% -- node scripts/pre-handoff.mjs | Passed |
The compatibility check executes the requested full viewer grep and compares its paths against git diff --name-only origin/main...HEAD; unchanged callers remain the responsibility of #9590.
Root typecheck:ci retains the test-program coverage tail and consumes prepared dependencies. Under the same scope, root pnpm build --filter=<package> --only refreshed @ifc-lite/{data,wasm-lifecycle,geometry,mutations,export,cache,clash,create,collab,rhino3dm,cli,renderer}. No Rust/WASM build was run.
Family skips: ﹣ #7495 mounted public opt-in transfers authentic IFC over real HTTP/PG/S3 and confirmed withdrawal preserves private bytes (11.152829ms) # SKIP.
Pre-handoff skipped coverage: SKIPPED retained-free viewer: apps/viewer/dist absent; build the default viewer first.
Lint’s compiler children are serialized to keep the entire existing command below 8 GiB; diagnostics, compiler arguments, and baselines are unchanged. The private preload was validated with a three-process fixture covering each child’s full lifetime.
Lint compiler serialization preload
import { openSync } from 'node:fs';
import { spawnSync } from 'node:child_process';
// Bound the existing lint worker pool's compiler overlap without changing diagnostics.
if (process.argv[1]?.endsWith('/typescript/bin/tsc')) {
const path = process.env.AEE3_LINT_TSC_LOCK;
if (!path) throw new Error('AEE3_LINT_TSC_LOCK is required for serialized lint');
const descriptor = openSync(path, 'a', 0o600);
const result = spawnSync('flock', ['--exclusive', '3'], {
stdio: ['ignore', 'ignore', 'pipe', descriptor],
});
if (result.error || result.status !== 0) {
throw new Error(`Cannot acquire TypeScript lint lock: ${result.error?.message ?? result.stderr}`);
}
// Keep this descriptor open: Linux flock follows the shared open description
// after the flock child exits, and the compiler's exit releases it.
}
Mutation command, one restored mutation at a time: systemd-run --user --scope -q -p MemoryMax=8G -p MemorySwapMax=0 -p CPUQuota=200% -- pnpm test --filter=@ifc-lite/viewer --only, with TEST_PATTERN set to DataConnector.lifetime, EpsgLookupDialog, ErrorReportDialog.test, ShareDialog.scope.
| Guard | Result / named failing test |
|---|---|
epsg-blank | Killed — C-7 clearing a search to "" keeps starters after debounce |
epsg-edit-abort | Killed — C-7 clearing input rejects a late local-index success |
epsg-catch-owner | Killed — C-7 clearing input rejects a late local-index failure |
epsg-starter-whitespace | Killed — C-7 clearing a search to " " keeps starters after debounce |
share-token | Killed — C-8 closing during mint skips the next seed preparation step |
share-seed | Killed — C-8 closing during serialization skips the next seed preparation step |
share-open-invalidate | Killed — C-8 unmount during admin mint prevents the later model upload |
share-join-abort | Killed — C-8 closing during a pending owner join retires that room |
share-join-pending | Killed — C-8 closing preserves a completed instead of stopping unrelated work |
share-join-room | Killed — C-8 closing preserves a other-room instead of stopping unrelated work |
share-join-committed | Killed — C-8 closing preserves a committed-session instead of stopping unrelated work |
share-outcome | Killed — C-8 a retired join returning without its room cannot report failure into the replacement |
share-error | Killed — C-8 retired room failure cannot clear the next attempt or show its notice |
share-finally | Killed — C-8 retired room failure cannot clear the next attempt or show its notice |
share-open-notice | Killed — C-8 reopening clears a failure notice before renewed consent |
share-minting | Killed — C-8 changing into a joiner during mint clears minting before the early return |
csv-reset | Killed — C-12 replacement "" clears the prior CSV import mapping |
csv-empty | Killed — C-12 replacement "" clears the prior CSV import mapping |
epsg-loading-reset | Killed — C-7 clearing input rejects a late local-index success |
report-cancel-owner | Killed — a draft cancellation settling after unmount cannot close a replacement dialog |
share-attempt-reset-delivery | Killed — #9576 a failed mint cannot reuse the previous room link or copied state |
share-attempt-reset-link | Killed — #9576 a failed mint cannot reuse the previous room link or copied state |
share-attempt-reset-copied | Killed — #9576 a failed mint cannot reuse the previous room link or copied state |
suggest-draft-key | Killed — C-12 replacing the CSV aborts an in-flight mapping suggestion |
suggest-rows-lifetime | Killed — C-12 accepting a pending file retires a suggestion for the previously displayed rows |
suggest-signal | Killed — C-12 replacing the CSV aborts an in-flight mapping suggestion |
suggest-flight-outcome | Killed — C-12 accepting a pending file retires a suggestion for the previously displayed rows |
suggest-draft-outcome | Survived — Immediate draft-generation defense. Mounted React updates flush the key cleanup before the response, so the independently killed flight-owner guard already rejects it. |
suggest-catch | Survived — Defensive ownership check for unexpected exceptions. Expected async provider failures are structured outcomes; the exercised unexpected context failures throw synchronously in the current owner. |
suggest-reentry | Killed — #9576 same-tick suggestion presses start one mapping request |
suggest-shared-settle | Killed — C-12 an older suggestion finally cannot lose the replacement suggestion controller |
suggest-shared-abort | Killed — C-12 replacing the CSV aborts an in-flight mapping suggestion |
receipt-outcome | Killed — late manual GET cannot restore submitted after private report deletion |
receipt-error | Killed — a retired manual refresh failure cannot show an error after confirmed deletion |
receipt-reset | Killed — late manual GET cannot restore submitted after private report deletion |
receipt-reset-after-success | Killed — #9576 a request DELETE failure preserves a valid in-flight receipt refresh |
receipt-reset-after-confirmation | Killed — #9576 a confirmation DELETE failure preserves a valid in-flight receipt refresh |
receipt-signal | Killed — late manual GET cannot restore submitted after private report deletion |
receipt-reentry | Killed — #9576 same-tick receipt refresh presses start one manual GET |
report-cancel | Killed — cancelling a resumed draft twice issues one DELETE |
report-private-delete-lock | Killed — private report deletion retains its synchronous double-click lock |
csv-error-scroll | Killed — #9576 a preview error keeps the viewport at its top alert |
report-shared-retire | Killed — a draft cancellation settling after unmount cannot close a replacement dialog |
Shared-helper mutations exercise its guarantees through real components; useAsyncRun itself has no production change in this PR.
Unverified / scope findings: EPSG APIs share a local-index import and expose no AbortSignal argument; stale consumers are invalidated without cancelling that shared import. The private-report DELETE already had a synchronous guard, so that alleged duplicate path was skipped and its existing protection retained. The distinct resumed-draft cancellation duplicate was reproduced and fixed as called out above. Hosted collaboration/report backends and GPU rendering were not exercised.
🤖 Generated with Claude Code