Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ off — and where it doesn't.
| [save-engine.js](save-engine.js) | 3,263 | Done — the extracted save/sync seam module (Stages 1–7), 91 node tests. R21 (2026-09-26) folded its repeated blocks inside the file; do not split it. Large but modular and fully node-testable; no further action. |
| [pdf-tile-cache.js](pdf-tile-cache.js) | 867 | Done (stage 1, 2026-07-30) — the PDF raster-cache substrate extracted from app.js's "PDF render bitmap cache" section (`createPdfTileCache(ctx)`, the save-engine seam recipe): page-bitmap LRU, downsample pyramid, persisted zoom rungs, idle prefetch, full-document warm-up. Pinned by nine Playwright specs (page-switch-cache, pyramid, pyramid-persist, rung-prefetch, doc-warmup, zoom-ladder, commit-tile, crop-tile, tile-grid). Stage 2 (later): the Sharp crop tile / tile grid section. |
| [canvas-draw.js](canvas-draw.js) | 1,417 | Done — the unified annotation draw core (`createCanvasDraw(deps)` + `drawAnnotationsCore`), node-tested, guarded by [render-pixels.spec.js](render-pixels.spec.js). Both draw paths are thin env-builders over it. |
| [app/index.html](app/index.html) | 3,867 | The shell: HTML structure + every modal, no inline JS. Flat markup with no build step to split it; grows roughly linearly with modal count. Leave. |
| [styles.css](styles.css) | 2,857 | All CSS, token-organized. Leave. |
| [app/index.html](app/index.html) | 3,869 | The shell: HTML structure + every modal, no inline JS. Flat markup with no build step to split it; grows roughly linearly with modal count. Leave. |
| [styles.css](styles.css) | 2,862 | All CSS, token-organized. Leave. |
| [features/load-project.js](features/load-project.js) | 748 | Largest feature file (Load Project modal + filters), split 2026-07-30: the copy/fork domain moved to [features/copy-project.js](features/copy-project.js) at the file's documented domain boundary, and the row renderer was decomposed along its action boundaries (size / row HTML / actions / admin access / load click). Healthy — leave. |
| [annotation-model.js](annotation-model.js) | 1,225 | Done — extracted canvas/annotation data model + node tests. |
| [undo-stack.js](undo-stack.js) | 218 | Done (2026-07-30) — `createUndoStack(ctx)` split out of annotation-model.js: the model is pure-ish data transformation, the stack is a command-history controller with UI side-effect hooks in its ctx. Covered by the undo tests in [annotation-model.test.js](annotation-model.test.js) (interleaved with model tests, dual-require). |
| [icons.js](icons.js) | 531 | Bundled icon data, mostly literals. Leave. |
| [report.js](report.js) | 991 | Self-contained report builder with a frozen `window.*` contract. Leave. |
| `features/*.js` (108 files) | 37,327 total | Mostly single-feature files with their own specs. The largest are the teaching layer (tutorial 1,656; lessons 1,043, the three courses 609 to 725; tour-blank 794) and duct-tool (866); DECOMPOSITION_MAP.md has a verdict for every one. |
| `features/*.js` (108 files) | 37,380 total | Mostly single-feature files with their own specs. The largest are the teaching layer (tutorial 1,656; lessons 1,043, the three courses 609 to 725; tour-blank 794) and duct-tool (866); DECOMPOSITION_MAP.md has a verdict for every one. |

### What's left inside app.js (by `// SECTION:` size)

Expand Down Expand Up @@ -177,7 +177,7 @@ modules. Candidates in priority order:
| [user-admin.spec.js](user-admin.spec.js) | Playwright regression for pilot #20 — an always-run registry-contract test (asserts `window.App.openManageUserModal` + `openAllUsersModal` are functions and that calling them with no session is a safe no-op: the modals do not become visible and nothing throws), plus a cloud-gated test (`ensureSignedInWithProject`, `test.skip` when no cloud) that opens via `App.openManageUserModal()` and asserts `#manageUserModal.visible` + the list element gets content. Asserts no console / page errors; `npx playwright test user-admin.spec.js` |
| [features/load-project.js](features/load-project.js) | Twenty-first feature-file split (`window.App` registry pilot #21) and the **most dependency-heavy** so far — the cloud Load Project modal `openLoadProjectModal` (~585 lines: project browser list, ownership/role filters, per-row access panels + invite via `invite-to-project`, copy/download/delete row actions, and the project-load action). Its own IIFE loaded **after** [app.js](app.js); reads deps from `App` and re-reads `App.getSupabase()` in the outer fn + each nested async helper (client can be recycled); registers `App.openLoadProjectModal`. The save-before-load gate `openLoadProjectModalOrPromptSave` and the whole copy/fork domain live in [features/copy-project.js](features/copy-project.js) (split 2026-07-30 at this file's documented domain boundary); the `#loadProject*` bindings + Escape branch stay in app.js and reach both files through the registry at call time. The row renderer `renderLoadProjectListRows` is a thin loop over per-row helpers decomposed along its action boundaries (`computeLoadProjectRowSizeBytes` / `buildLoadProjectRowHtml` / `bindLoadProjectRowActions` / `bindLoadProjectAdminAccess` / `bindLoadProjectRowLoad`). Because the project-load action is fused with the boot/engine path, ~20 publish-only deps are exposed on `App` (`updateSaveStatusIndicator`, `canUseDevAuth`, `deleteProjectAsOwner`, `openCopyProjectModalOrPromptSave`, `hydrateProjectFromCloudRow`, `clearUndoStacks`, `subscribeToProjectCheckoutChanges`, `checkInCurrentProjectIfHeld`, `takeoffBackupGet`, `resolvePdfBufferForCloudProject`, `ensureGroupColors`, `openCanvasOnlyNeedsPdfModal`, `buildPagesFromPdfArrayBufferAndProjectData`, `backupDataToProjFormat`, `fitZoom`, `SUPABASE_URL`), incl. four **setters** (`setAutoSaveDirty`/`setLastModifiedAt`/`setLastLocalBackupAt`/`setLastSaveIncludedPdf`) for engine `let`-state the load resets (it cannot assign through the registry otherwise). The leftover grab-bag under the old `// SECTION: Load Project modal` marker was re-sectioned into 8 honest markers, and `// SECTION: Canvas Event Handlers` moved up to absorb the stray `showContextMenu`. The modal header has an admin-only **Advanced** toggle (`#loadProjectAdvancedToggle`, persisted via `loadProjectAdvanced`) that shows/hides every row's "Who has access" block by toggling a `hide-access` class on `#loadProjectList` (default OFF = hidden). The project-load action itself was extracted host-agnostic as `loadCloudProjectRow(proj, ui)` (registered `App.loadCloudProjectRow`; `ui` = `{hostModalId, showError}`) so [features/bid-board.js](features/bid-board.js) opens bids through the identical path; `bindLoadProjectRowLoad` is now the modal-specific wrapper (mutex + row busy UI). The owner-email filter is un-gated to `isAdmin \|\| isOverseer` **LOAD-DEVICE-PDF (2026-09-22)**: `devicePdfIfOnlyCopy(proj, idbBackup)` (the restore's rule: the backup's blob unless both hashes exist and disagree) is asked in both branches of `loadCloudProjectRow`, and `openOnDevicePdf` builds the sheets on it and hands the copy to the engine (`state.pdfBuffer`, `pdfStoragePath` null) for the autosave tick's upload; the canvas-only door opens only when the device has no copy. Spec: [load-device-pdf.spec.js](load-device-pdf.spec.js). R12 (2026-09-26): both canvas-only branches (the stored PDF missing, and no PDF stored) hydrate through `App.hydrateStateFromProjectData`, so a bid opened without its PDF no longer keeps the last project's rooms, zoom cap or duct knobs. |
| [features/copy-project.js](features/copy-project.js) | The **copy/fork domain + save-before-load gate**, split out of [features/load-project.js](features/load-project.js) 2026-07-30 at that file's documented domain boundary (the code itself arrived from app.js as registry split #35). Owns `pendingCopyProject` / `copyProjectModalTarget`; binds `#copyProjectModalConfirm` + the `#saveBeforeLoad*` modal buttons at load; registers `App.openCopyProjectModalOrPromptSave`, `App.openLoadProjectModalOrPromptSave`, `App.hydrateProjectFromCloudRow`, `App.resolvePdfBufferForCloudProject`, `App.buildPagesFromPdfArrayBufferAndProjectData`, `App.resetCopyProjectState`, `App.clearCopyProjectModalTarget`. Reads `App.openLoadProjectModal` (registered by load-project.js) at call time, so load order between the two files is irrelevant. Regression: [copy-project.spec.js](copy-project.spec.js). R12 (2026-09-26): `buildPagesFromPdfArrayBufferAndProjectData` builds its sheets with `App.buildBlankPagesFromPdf` and hydrates through `App.hydrateStateFromProjectData(d, { legacyScales: true })`. |
| [features/bid-board.js](features/bid-board.js) | The **overseer Bid Board** (`#bidBoardModal`) — the read-only "see every bid" surface for `profiles.is_overseer` users (server side: migrations `profiles_is_overseer` / `list_accessible_projects_overseer` / `overseer_admin`, see SUPABASE_SETUP.md). Renders `list_accessible_projects` rows as presentation-friendly cards (name, estimator = owner-email local part, counts, last-edited, `No PDF` badge) with a search box + estimator `<select>`; a card click funnels into `App.loadCloudProjectRow` (extracted from [features/load-project.js](features/load-project.js)) with `hostModalId: 'bidBoardModal'`, so a bid always opens in the existing viewer mode (`state.isViewer` — overseers have no checkout arm server-side). Registers `App.openBidBoard` (also bound to `#bidBoardBtnSidebar`, shown for overseers **and** admins by `updateUI`) and `App.maybeAutoOpenBidBoard` — called from app.js after the profile flags land at sign-in; auto-opens **once per page load** for pure overseers (never admins) with nothing on screen, deferring to a stored `clickcount-last-project` (the restore-last-session flow) and to view-link tabs. Regression: [bid-board.spec.js](bid-board.spec.js) (stubbed `App.getSupabase`; registry no-op, card render + filters, auto-open guards). Hides the two test-harness accounts' projects (`HIDDEN_TEST_OWNERS`, mirroring cleanup-test-accounts). Review handoff: `review_status === 'ready'` rows render in a pinned **Ready for review** lane (`.bid-board-lane-title`) with a gold badge and — for overseers/admins — a per-card **Mark reviewed** button that calls `App.setProjectReviewStatus(id, 'reviewed')` (registered by [features/review-flow.js](features/review-flow.js)) and re-renders; `'reviewed'` rows carry a quiet ✓ badge. |
| [features/bid-board.js](features/bid-board.js) | The **overseer Bid Board** (`#bidBoardModal`) — the read-only "see every bid" surface for `profiles.is_overseer` users (server side: migrations `profiles_is_overseer` / `list_accessible_projects_overseer` / `overseer_admin`, see SUPABASE_SETUP.md). Renders `list_accessible_projects` rows as presentation-friendly cards (name, estimator = owner-email local part, counts, last-edited, `No PDF` badge) with a search box + estimator `<select>`; a card click funnels into `App.loadCloudProjectRow` (extracted from [features/load-project.js](features/load-project.js)) with `hostModalId: 'bidBoardModal'`, so a bid always opens in the existing viewer mode (`state.isViewer` — overseers have no checkout arm server-side). Registers `App.openBidBoard` (also bound to `#bidBoardBtnSidebar`, shown for overseers **and** admins by `updateUI`) and `App.maybeAutoOpenBidBoard` — called from app.js after the profile flags land at sign-in; auto-opens **once per page load** for pure overseers (never admins) with nothing on screen, deferring to a stored `clickcount-last-project` (the restore-last-session flow) and to view-link tabs. Regression: [bid-board.spec.js](bid-board.spec.js) (stubbed `App.getSupabase`; registry no-op, card render + filters, auto-open guards). Hides the two test-harness accounts' projects (`HIDDEN_TEST_OWNERS`, mirroring cleanup-test-accounts). PEOPLE-TWINS (2026-10-13): a **People · Twins · All** switch (`#bidBoardKind`, a `.radio-seg` beside the search) opens on People for everyone but an admin, who opens on All; a twin is told by the owner's email against `TWIN_OWNER_RE`, the pattern twin-login enforces (the RPC carries no twin flag); `kindRows` feeds both the list and the estimator `<select>` (only the owners the segment shows); under People a `.bid-board-hidden-note` under the list says how many twin bids are off with a "show twins" link; the switch hides itself when no bid is twin-owned; the choice is per open, never stored. Review handoff: `review_status === 'ready'` rows render in a pinned **Ready for review** lane (`.bid-board-lane-title`) with a gold badge and — for overseers/admins — a per-card **Mark reviewed** button that calls `App.setProjectReviewStatus(id, 'reviewed')` (registered by [features/review-flow.js](features/review-flow.js)) and re-renders; `'reviewed'` rows carry a quiet ✓ badge. |
| [features/review-flow.js](features/review-flow.js) | The **bid review handoff** (estimator → overseer ops flow; server side: migrations `project_review_flow` / `list_accessible_projects_review`). Registers `App.setProjectReviewStatus(projectId, status)` — the single client entry to the guarded `set_project_review_status` RPC (`'ready'`/clear: owner, editor share, or admin; `'reviewed'`: overseer or admin) — and owns the Project Settings **Bid review** row (`#settingsReviewRow`: live status line + transition button "Mark ready for review" / "Withdraw" / "Mark ready again"). The row re-renders via a MutationObserver on `#settingsModal`'s class each time the modal becomes visible (no app.js hook), fetching `review_status/review_requested_at/reviewed_at` fresh from the projects row; it hides for signed-out/no-project/pure-viewer sessions but never gates harder than the server. Consumed by [features/bid-board.js](features/bid-board.js) (Mark reviewed) and badged in [features/load-project.js](features/load-project.js) rows. Regression: the review-handoff test in [bid-board.spec.js](bid-board.spec.js). |
| [features/bid-chip.js](features/bid-chip.js) | **The header bid switcher's chip** (BID-SWITCHER.md stage 2): `#headerBidChip` names the open bid ("No bid open" otherwise) and opens a menu of [recent-bids.js](recent-bids.js)' list, so moving between bids skips Load Project. Takes the wordmark's slot once a bid is open, and shows `#headerSidebarToggle` in its place (exactly one of the two is visible). Registers `App.renderBidChip` (called from app.js `updateUI`), `App.closeBidMenu` and `App.isBidMenuOpen` (the Esc ladder's popover rung), `App.loadRecentBidNow`. Spec: [bid-switcher.spec.js](bid-switcher.spec.js). |
| [copy-project.spec.js](copy-project.spec.js) | Always-run Playwright regression for the copy/fork split — registry contract (all seven registered names are functions), the not-dirty path (`openCopyProjectModalOrPromptSave` opens `#copyProjectModal` with the "(copy)" name prefilled), the dirty path (opens `#saveBeforeLoadModal` with the copy-specific message; Cancel clears `pendingCopyProject`), and Discard routing back to the copy modal. `npx playwright test copy-project.spec.js` |
Expand Down
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,32 @@ expired recovery UX" work occupies that slot).

---

## feat(bid-board): People · Twins · All, and an intro that says what the board does (PEOPLE-TWINS, 2026-10-13)

Wendi, a lead, opened All Bids on 41 cards, every one a digital twin's backtest, each wearing a
gold Ready badge and two gold buttons. The twins' bids are the fleet's work, not an estimator's,
and they outnumber the human bids many to one, so no restyling of the cards could quiet her
board. This is the first step of the "All Bids, quieter" mockups (the canvas of 2026-10-13); the
quiet list and the review bar in the bid are the follow-up, BOARD-QUIET in the punch list.

- **The switch.** A People · Twins · All `.radio-seg` beside the search (`#bidBoardKind`). The
board opens on People for everyone but an admin, who opens on All, the view they had. A twin
is told by the owner's email against the pattern twin-login enforces
(`twin-estimator-N@twins.counttooling.local`, `TWIN_OWNER_RE`): the RPC carries no twin flag,
and a twin account outside the pattern cannot sign in, so the pattern is the fleet. Under
People a line under the list says how many twin bids are off, with a "show twins" link; the
estimator filter lists only the owners the segment shows and keeps its pick when it survives
the flip; the switch hides itself for a company with no twin bids. The choice is per open,
not stored: the default is the role's.
- **The copy.** The intro said "Read-only, nothing can be changed by accident" above two buttons
that change a bid's review status (written for the overseer's board before the handoff
landed). Now: "Every bid in the company, newest first. Click one to open it read-only."
- features/bid-board.js, app/index.html, styles.css, the Overseer guide's board section (rebuilt),
sw.js restamped. bid-board.spec.js gains the fifth test: People and the note for a non-admin,
show twins, All with both ready bids in the lane and every owner listed, the admin's All, and
the switch hidden when no bid is twin-owned; the existing four pass unchanged under the
People default.

## docs(guides): the measuring article teaches Show Length and Move label (2026-10-13)

The measuring guide (content/guides/measuring-runs-lines-and-polylines.md) never taught the
Expand Down
4 changes: 3 additions & 1 deletion app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3048,12 +3048,14 @@ <h2 id="userActivityModalTitle">Activity log</h2>
<h2>All Bids</h2>
<div class="bid-board-filters">
<input type="search" id="bidBoardSearch" placeholder="Search bids…" autocomplete="off" aria-label="Search bids by name" class="bid-board-search" />
<!-- PEOPLE-TWINS: shown only when the company has twin-owned bids; features/bid-board.js picks the opening segment. -->
<div class="radio-seg bid-board-kind" role="radiogroup" aria-label="People, twins or all" id="bidBoardKind" style="display:none;"><label><input type="radio" name="bidBoardKind" value="people" checked><span>People</span></label><label><input type="radio" name="bidBoardKind" value="twins"><span>Twins</span></label><label><input type="radio" name="bidBoardKind" value="all"><span>All</span></label></div>
<span class="bid-board-owner-wrap"><label for="bidBoardOwnerFilter" class="bid-board-filter-label">Estimator</label>
<select id="bidBoardOwnerFilter" class="bid-board-owner-filter" aria-label="Filter by estimator"></select>
</span>
</div>
<button type="button" class="modal-close-btn" data-modal-close aria-label="Close">×</button></div>
<p class="form-group bid-board-intro">Every bid in the company, newest first. Click one to view it. Read-only, nothing can be changed by accident.</p>
<p class="form-group bid-board-intro">Every bid in the company, newest first. Click one to open it read-only.</p>
<div id="bidBoardError" class="form-group" style="display:none;"></div>
<div id="bidBoardList" class="bid-board-list form-group"></div>
<div class="actions">
Expand Down
Loading
Loading