From b95f032090f74cdda5c94823c1188c5d917199de Mon Sep 17 00:00:00 2001 From: Robert Douglas <57234112+realrobertdouglas@users.noreply.github.com> Date: Tue, 13 Oct 2026 13:54:38 -0500 Subject: [PATCH] feat(review): the review bar in the bid, and the Ready lane oldest waiting first (REVIEW-BAR) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BOARD-QUIET step 1, Will's two calls of 2026-10-13: the Ready lane sorts oldest waiting first, and the decision moves to where the evidence is. - While a bid that is ready for review is open by someone who can oversee it (admin, overseer, lead), a slim bar sits under the header in the app's flex column: "Reviewing · waiting 11 days · twin-estimator-1 · 70 counts", then Request changes… (the confirm dialog's one-line note), one filled Mark reviewed, and Next ready, which opens the next bid in the board's lane. After a decision the bar says what happened and how many are left, and Next ready walks on. It hides when the open project is no longer the one it was shown for (updateUI calls App.refreshReviewBar). - features/load-project.js ends a cloud load by calling App.onCloudProjectRowLoaded(proj) with the RPC row; the board hands its Ready lane as rendered to App.setReviewQueue on every render, so Next ready walks the lane the reviewer sees. A decision writes the status onto the row the board holds, so its lane agrees without a refetch. - The lane sorts on review_requested_at (a row without a stamp last) and its title says so in a dim hint. The per-card buttons stay beside the bar; whether they go is still Will's call (BOARD-QUIET). - bid-board.spec.js: the review-bar test (the bar on the oldest ready card, Mark reviewed, Next ready walking to the twin's bid, Request changes through the dialog, the board agreeing, the bar gone with the project, no bar for a reviewed bid or a non-reviewer) and the lane's order pinned. The Overseer guide's handoff section, rebuilt. ARCHITECTURE rows for review-flow, bid-board and load-project; CHANGELOG; the plan file and the BOARD-QUIET row; sw.js and the TOC restamped. npm run check: all 14 steps pass. bid-board.spec.js 6/6; the loader specs that run without the cloud pass. Walked in the browser with a stubbed lead session: the oldest-waiting bid opened with the bar under the header, Mark reviewed read "Reviewed ✓ · 2 more ready", Next ready opened the next bid. Co-Authored-By: Claude Fable 5.1 --- ARCHITECTURE.md | 118 ++++++++++++------------ CHANGELOG.md | 32 +++++++ PUNCHLIST.md | 2 +- app.js | 1 + app/index.html | 11 +++ bid-board.spec.js | 72 ++++++++++++++- content/guides/reviewing-all-bids.md | 9 +- features/bid-board.js | 15 +++- features/load-project.js | 3 + features/review-flow.js | 130 +++++++++++++++++++++++++++ guides/reviewing-all-bids/index.html | 9 +- journeys/plans/BID-BOARD-QUIET.md | 21 +++-- styles.css | 17 ++++ sw.js | 16 ++-- 14 files changed, 366 insertions(+), 90 deletions(-) diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index bd58a1be..04844216 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -28,18 +28,18 @@ off — and where it doesn't. | File | Lines | Status / verdict | |------|------:|------------------| -| [app.js](app.js) | 7,158 | **The remaining monolith** — down from 16.2k (9.9k after save-engine Stage 6, 8.1k after the Tier-2 splits, then −987 from the canvas-draw extraction). The only file worth actively shrinking; the region table below says what's left and in what order. | +| [app.js](app.js) | 7,159 | **The remaining monolith** — down from 16.2k (9.9k after save-engine Stage 6, 8.1k after the Tier-2 splits, then −987 from the canvas-draw extraction). The only file worth actively shrinking; the region table below says what's left and in what order. | | [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,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. | +| [app/index.html](app/index.html) | 3,880 | 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,879 | All CSS, token-organized. Leave. | +| [features/load-project.js](features/load-project.js) | 751 | 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,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. | +| `features/*.js` (108 files) | 37,524 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) @@ -175,10 +175,10 @@ modules. Candidates in priority order: | [manage-projects.spec.js](manage-projects.spec.js) | Playwright regression for pilot #19 — an always-run registry-contract test (asserts `window.App.openManageProjectsModal` is a function and that calling it with no session is a safe no-op: `#manageProjectsModal` does not become visible and nothing throws), plus a cloud-gated test (`ensureSignedInWithProject` from `cloud-test-helpers.js` in `beforeAll`, `test.skip` when no cloud secrets) that opens Settings → Manage Projects and asserts the project list + a Delete button render. Asserts no console / page errors; `npx playwright test manage-projects.spec.js` R1-ADMIN (2026-09-27): an always-run case routes `list_projects_for_admin`, stubs `App.getSupabase()` and `App.tryTurnIn`, and pins Turn in on the open, held row (no force RPC, list redrawn), Force on another holder's row and on your own row held elsewhere, no button on a free row, and Force again once this tab is viewing only. | | [features/user-admin.js](features/user-admin.js) | Twentieth feature-file split (`window.App` registry pilot #20) — the admin user-management modals: `openManageUserModal` (user list + delete + activity, via `list_users_for_admin` RPC / `admin-list-users` Edge Fn), `openAllUsersModal` (read-only list), `deleteUser` (`admin-delete-user`), plus the `#manageUsersBtn` create-user opener + `#adminCreateForm` (`admin-create-user`) and the `#adminPanelClose`/`#manageUserModalClose`/`#allUsersModalClose`/`manageUserModalAllActivityBtn` handlers. Its own IIFE loaded **after** [app.js](app.js); registers `App.openManageUserModal` + `App.openAllUsersModal`. Three new publish-only deps: `App.formatLastSignIn` (a `format.js` global, lint-invisible to the features group so it must be published), `App.USER_ACTIVITY_ICON_SVG`, and `App.openUserActivityModal` (the User Activity modal **stays** in app.js; the moved lists + the all-activity button reach it via `App.*`); `state`/`showModal`/`hideModal`/`SUPABASE_URL`/`SUPABASE_ANON_KEY` were already on `App`. **My Settings** (`openMySettings`, which owns the airboard cloud-sync) deliberately stays in app.js under the renamed marker `// SECTION: My Settings modal`; its `#mySettingsManageUser`/`#mySettingsAllUsers` openers reach the feature via `App.*`. The moved handlers were interleaved with the User Activity + Canvas Repair handlers (which stay) in the Event Binding region. **Renamed** the `// SECTION: User Settings & Manage Users` marker → `// SECTION: My Settings modal` (rename, not removal, TOC stays 47). **Since extended** with the full Manage Users toolkit: an owned-`project_count` column (`list_users_for_admin` gained the count; clicking it opens `#userProjectsModal`, a per-user project list from `list_projects_for_admin`); a stacked last-sign-in/last-active cell; per-row **Set Password** (🔑 → `#setPasswordModal` → `admin-set-password`), **Transfer projects** (⇄ → `#transferProjectsModal` → `admin-reassign-projects`), and a **Delete** dialog (`#deleteUserConfirmModal`) that can **reassign** the user's projects to someone else before deleting (`admin-delete-user` with `reassignToUserId`); transfer/reassign share `supabase/functions/_shared/reassignProjects.ts`, which moves the project rows **and** their owner-scoped PDF storage objects, reassigns inherited view links, and clears redundant shares. Clicking the stacked dates cell or the heart icon opens the rich **Activity overview** `#userActivityOverviewModal` via `App.openUserActivityOverview` — the overview itself (and the `#mySettingsMyActivity` **My Activity** opener) **moved to [features/user-activity.js](features/user-activity.js)** so both activity surfaces live in one file. Manage Users rows also carry the **Overseer toggle** (👁, `.settings-user-overseer`, lit when `u.is_overseer`): POSTs the admin-guarded `admin_set_overseer` RPC then re-fetches; the Role column reads `Admin` > `Overseer` > `User` (from `list_users_for_admin` / the `admin-list-users` Edge Fn) | | [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/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. REVIEW-BAR (2026-10-13): `loadCloudProjectRow` ends by calling `App.onCloudProjectRowLoaded(proj)` (features/review-flow.js) with the row it opened, so the review bar can show for a ready bid. | | [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 `` (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-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 `` (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. The Ready lane runs oldest waiting first (`byOldestWaiting` on `review_requested_at`, Will 2026-10-13; the lane title says so in a `.bid-board-lane-hint`) and is handed to the review bar as its queue (`App.setReviewQueue`), so Next ready walks the lane as shown. 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. REVIEW-BAR (2026-10-13, BOARD-QUIET step 1): owns the **review bar** (`#reviewBar`, in the `.app` flex column under the header), shown by `App.onCloudProjectRowLoaded(proj)`, which features/load-project.js calls at the end of a cloud load with the RPC row, for a `review_status === 'ready'` row when `App.canOversee()`: how long it has waited, the owner, the counts, then Request changes… (the confirm dialog's note), Mark reviewed, and Next ready, which opens the next ready row of the queue the board hands over with `App.setReviewQueue(rows)` (its Ready lane as rendered, oldest waiting first) through `App.loadCloudProjectRow`; after a decision the bar says what happened and how many are left; `App.refreshReviewBar` (from `updateUI`) hides it once the open project is not the one it was shown for; `App.showReviewBar` is the spec seam. Regression: the review-handoff and review-bar tests 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` | | [load-project.spec.js](load-project.spec.js) | Playwright regression for pilot #21 — an always-run registry-contract test (`window.App.openLoadProjectModal` is a function; with Supabase unconfigured the modal shows "Cloud not configured" and becomes visible without throwing), plus a cloud-gated test (`ensureSignedInWithProject`, `test.skip` when no cloud) that opens via `App.openLoadProjectModal()` and asserts `#loadProjectModal.visible` + `#loadProjectList` (or `#loadProjectEmpty`) populated. Asserts no console / page errors; `npx playwright test load-project.spec.js` | @@ -671,57 +671,57 @@ live list with current `app.js` line numbers is generated by `npm run build:toc` - L1656 - PDF Rendering - L2531 - Recent bids - L2558 - UI Render Functions -- L2914 - Placing selection (setActiveCounterType / setActiveLineType) -- L3024 - Inline rename & polyline edit mode -- L3140 - Modal primitives (showModal / hideModal) -- L3306 - Toasts & line color picker -- L3375 - Airboard cloud sync -- L3420 - Supabase RPC & presence heartbeat -- L3460 - User activity / event telemetry -- L3519 - Supabase auth & dev auth -- L3710 - [sync] Checkout subscription & permission refresh -- L3720 - Modals & Handlers -- L3788 - PDF intake (upload, test PDF, hashing) -- L3796 - Toolbar tool buttons -- L3957 - Tool sidebar buttons & legend overlay -- L4043 - Add Line Type modal -- L4125 - Line color & sidebar handlers -- L4196 - Polyline modal & drawing -- L4253 - Zoom bar & page navigation -- L4279 - Export canvas JSON -- L4304 - PDF download helpers -- L4313 - View-link URL helpers & show-highlights/notes -- L4345 - Custom icon upload handler -- L4355 - Macros & custom-icon tips openers -- L4375 - Sidebar drawer toggles -- L4406 - Mobile actions burger menu pointer & header logo -- L4418 - User Activity pointer (format.js + features/user-activity.js) -- L4430 - My Settings pointer (features/my-settings.js) -- L4455 - Project Settings pointer (features/project-settings.js) -- L4461 - Auth & settings entry buttons - - L4506 - Project Settings checkout & Save Status bell - - L4619 - [sync] Checkout expired recovery - - L4675 - [sync] Turn In - - L4740 - Share modal pointer & copy-project openers - - L4771 - Settings menu actions - - L4783 - Auth sign-in form - - L4808 - Save Project modal - - L4819 - Checkout expired recovery modal wiring - - L4922 - Last-session restore prompt -- L4934 - Canvas Event Handlers -- L5318 - Event Binding -- L5328 - Aim loupe (mobile press-hold precise placement) -- L5481 - Zoom transform preview & commit -- L5560 - Canvas mouse, wheel & touch handlers -- L6249 - Global dropdown dismissal & keyboard hotkeys -- L6427 - [sync] Manual save to cloud -- L6437 - [sync] Auto-save -- L6444 - [sync] Local backup (IndexedDB takeoff state) -- L6453 - [sync] Visibility & timers -- L6470 - [sync] Checkout keep-alive -- L6484 - App feature registry -- L6877 - View-only mode -- L6883 - Init / boot +- L2915 - Placing selection (setActiveCounterType / setActiveLineType) +- L3025 - Inline rename & polyline edit mode +- L3141 - Modal primitives (showModal / hideModal) +- L3307 - Toasts & line color picker +- L3376 - Airboard cloud sync +- L3421 - Supabase RPC & presence heartbeat +- L3461 - User activity / event telemetry +- L3520 - Supabase auth & dev auth +- L3711 - [sync] Checkout subscription & permission refresh +- L3721 - Modals & Handlers +- L3789 - PDF intake (upload, test PDF, hashing) +- L3797 - Toolbar tool buttons +- L3958 - Tool sidebar buttons & legend overlay +- L4044 - Add Line Type modal +- L4126 - Line color & sidebar handlers +- L4197 - Polyline modal & drawing +- L4254 - Zoom bar & page navigation +- L4280 - Export canvas JSON +- L4305 - PDF download helpers +- L4314 - View-link URL helpers & show-highlights/notes +- L4346 - Custom icon upload handler +- L4356 - Macros & custom-icon tips openers +- L4376 - Sidebar drawer toggles +- L4407 - Mobile actions burger menu pointer & header logo +- L4419 - User Activity pointer (format.js + features/user-activity.js) +- L4431 - My Settings pointer (features/my-settings.js) +- L4456 - Project Settings pointer (features/project-settings.js) +- L4462 - Auth & settings entry buttons + - L4507 - Project Settings checkout & Save Status bell + - L4620 - [sync] Checkout expired recovery + - L4676 - [sync] Turn In + - L4741 - Share modal pointer & copy-project openers + - L4772 - Settings menu actions + - L4784 - Auth sign-in form + - L4809 - Save Project modal + - L4820 - Checkout expired recovery modal wiring + - L4923 - Last-session restore prompt +- L4935 - Canvas Event Handlers +- L5319 - Event Binding +- L5329 - Aim loupe (mobile press-hold precise placement) +- L5482 - Zoom transform preview & commit +- L5561 - Canvas mouse, wheel & touch handlers +- L6250 - Global dropdown dismissal & keyboard hotkeys +- L6428 - [sync] Manual save to cloud +- L6438 - [sync] Auto-save +- L6445 - [sync] Local backup (IndexedDB takeoff state) +- L6454 - [sync] Visibility & timers +- L6471 - [sync] Checkout keep-alive +- L6485 - App feature registry +- L6878 - View-only mode +- L6884 - Init / boot diff --git a/CHANGELOG.md b/CHANGELOG.md index b00b1de1..5e63f072 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,38 @@ expired recovery UX" work occupies that slot). --- +## feat(review): the review bar in the bid, and the Ready lane oldest waiting first (REVIEW-BAR, 2026-10-13) + +BOARD-QUIET step 1, Will's two calls of 2026-10-13: the Ready lane sorts oldest waiting first, +and the decision moves to where the evidence is. A reviewer judged a bid from a card she had +not opened; now the board is for triage and the bid carries its own decision. + +- **The bar.** While a bid that is ready for review is open by someone who can oversee it + (admin, overseer, lead), a slim bar sits under the header in the app's flex column, so the + sheet gives up its height rather than being covered: "Reviewing · waiting 11 days · + twin-estimator-1 · 70 counts", then Request changes… (the confirm dialog's one-line note, the + server still refusing a blank one), one filled Mark reviewed, and Next ready, which opens the + next bid in the board's lane. After a decision the bar says what happened and how many are + left ("Reviewed ✓ · 40 more ready"), and Next ready walks on, so a morning of reviews is one + loop instead of forty trips to the board. It hides when the open project is no longer the one + it was shown for. +- **How it knows.** features/load-project.js ends a cloud load by calling + `App.onCloudProjectRowLoaded(proj)` with the RPC row, which carries `review_status`; the + board hands its Ready lane as rendered to `App.setReviewQueue` on every render, so Next + ready walks the lane the reviewer sees, filters included. A decision writes the status onto + the row the board holds, so its lane agrees without a refetch. +- **Oldest waiting first.** The lane sorts on `review_requested_at`, a row without a stamp + last; the lane title says so in a dim hint. +- The board's per-card Mark reviewed and Request changes… stay beside the bar for a bid the + reviewer does not need to open; whether they go is still Will's call (BOARD-QUIET). +- features/review-flow.js (the bar), features/bid-board.js (the sort, the queue), + features/load-project.js (the hook), app.js (`updateUI` calls `App.refreshReviewBar`), + app/index.html, styles.css, the Overseer guide's handoff section (rebuilt), sw.js restamped. + bid-board.spec.js gains the review-bar test (the bar on the oldest ready card, Mark reviewed, + Next ready walking to the twin's bid, Request changes through the dialog, the board agreeing, + the bar gone with the project, no bar for a reviewed bid or a non-reviewer) and pins the + lane's order. + ## 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 diff --git a/PUNCHLIST.md b/PUNCHLIST.md index bcebf440..8b5e85a8 100644 --- a/PUNCHLIST.md +++ b/PUNCHLIST.md @@ -38,4 +38,4 @@ How agents add to this list: AGENTS.md, "Recording a to-do". | TRADE-DEFAULT | A project that never named a trade: does the device's default trade count as the project's? The app answers three ways today, so Bid Check on such a project shows water rows and the IPC edition but no hanger, fitting or plumbing rows. Decide, then one resolver | decision | ⚑ call | — | [DECOMPOSITION_MAP.md](DECOMPOSITION_MAP.md#t06-one-trade-resolver) | | ICON-STORE | Opening a project REPLACES the user's own icon store with its `customIconPaths` (annotation-model.js:509 and 444 into app.js:209, wholesale; a project with an empty list empties the store), and they ride the user's later saves. Since #268 they are inert, but should a project be able to add icons to a user's store at all? Decide, then build | decision | ⚑ call | — | | | DEMO-TRACK | The demo track behind the test drive's "Try it" is built for all three trades (phases 1 to 3 landed 2026-10-02). Left: a tester's real tablet and phone walk with a stopwatch against the 60 s target | test | tester | — | [DEMO-TRACK.md](journeys/plans/DEMO-TRACK.md#open-after-phase-2) | -| BOARD-QUIET | All Bids for a lead: the review moves into the opened bid (a review bar with Next ready) and the board becomes a quiet list, actions on the hovered row, exceptions only, oldest waiting first; PEOPLE-TWINS shipped the first step, the twin fleet off by default | build | agent | — | [BID-BOARD-QUIET.md](journeys/plans/BID-BOARD-QUIET.md#what-is-left) | +| BOARD-QUIET | All Bids for a lead: the board becomes a quiet list, actions on the hovered row, exceptions only, grouped by estimator once there are enough; PEOPLE-TWINS and REVIEW-BAR shipped the first two steps (the twin fleet off by default, the decision in the opened bid, oldest waiting first); whether the per-card buttons go is Will's call | build | agent | — | [BID-BOARD-QUIET.md](journeys/plans/BID-BOARD-QUIET.md#what-is-left) | diff --git a/app.js b/app.js index 5eb16099..e7397ee9 100644 --- a/app.js +++ b/app.js @@ -2571,6 +2571,7 @@ // Same seam: the Notes ledger (features/notes-ledger.js) re-syncs its // header badge and, when open, its drawer rows. App.onNotesLedgerSync && App.onNotesLedgerSync(); + App.refreshReviewBar && App.refreshReviewBar(); // REVIEW-BAR (features/review-flow.js): hides once the project it was shown for is gone notePerfSample('updateUIMs', performance.now() - t0); } // N3: rapid mark placement must never rebuild the sidebar per click — the diff --git a/app/index.html b/app/index.html index f610f1c3..f8c129fa 100644 --- a/app/index.html +++ b/app/index.html @@ -270,6 +270,17 @@ Drag Counters and Lines by their left colors to re-order. + +
diff --git a/bid-board.spec.js b/bid-board.spec.js index 954421d1..7064f1cf 100644 --- a/bid-board.spec.js +++ b/bid-board.spec.js @@ -142,7 +142,7 @@ test.describe('Bid Board - overseer all-bids browser', () => { // The ready bid gets its own pinned lane; the rest fall under "All bids". const laneTitles = await page.locator('.bid-board-lane-title').allTextContents(); - expect(laneTitles).toEqual(['Ready for review (1)', 'All bids']); + expect(laneTitles).toEqual(['Ready for review (1) · oldest waiting first', 'All bids']); await expect(page.locator('#bidBoardList .bid-card-badge-ready')).toHaveText('Ready for review'); await expect(page.locator('#bidBoardList .bid-card-badge-reviewed')).toHaveText('Reviewed ✓'); @@ -171,7 +171,7 @@ test.describe('Bid Board - overseer all-bids browser', () => { await expect(page.locator('#bidBoardList .bid-card')).toHaveCount(3); await expect(page.locator('#bidBoardList')).not.toContainText('ZZ Twin'); await expect(page.locator('.bid-board-hidden-note')).toHaveText('1 twin bid is off · show twins'); - expect(await page.locator('.bid-board-lane-title').allTextContents()).toEqual(['Ready for review (1)', 'All bids']); + expect(await page.locator('.bid-board-lane-title').allTextContents()).toEqual(['Ready for review (1) · oldest waiting first', 'All bids']); // "show twins" flips the segment: only the fleet, and only its owner in the estimator list. await page.click('.bid-board-show-twins'); @@ -184,7 +184,9 @@ test.describe('Bid Board - overseer all-bids browser', () => { // All: everyone, both ready bids in the lane, every owner in the list. await page.locator('#bidBoardKind label', { hasText: 'All' }).click(); await expect(page.locator('#bidBoardList .bid-card')).toHaveCount(4); - expect(await page.locator('.bid-board-lane-title').allTextContents()).toEqual(['Ready for review (2)', 'All bids']); + expect(await page.locator('.bid-board-lane-title').allTextContents()).toEqual(['Ready for review (2) · oldest waiting first', 'All bids']); + // Oldest waiting first: p1 asked on the 27th, the twin on the 28th. + expect(await page.locator('#bidBoardList .bid-card-name').allTextContents()).toEqual(['Riverside Apartments', 'ZZ Twin Oak Hill (backtest)', 'Oak Hill Elementary', 'Lakeway Medical Office']); expect(await page.locator('#bidBoardOwnerFilter option').allTextContents()).toEqual(['All estimators', 'jake', 'twin-estimator-1', 'wendi']); // An admin opens on All, the view they always had. @@ -206,6 +208,70 @@ test.describe('Bid Board - overseer all-bids browser', () => { expect(errors).toEqual([]); }); + test('review bar: shows on an open ready bid, takes the decision, walks Next ready', async ({ page }) => { + const errors = await bootApp(page); + await stubOverseerSession(page, STUB_ROWS); + // A cloud load needs the real backend; stand in for it the way the real one ends: the + // project is open and the hook fires with the row. + await page.evaluate(() => { + window.__loaded = []; + window.App.loadCloudProjectRow = async (proj, ui) => { + window.__loaded.push(proj.id); + window.state.currentProjectId = proj.id; + if (ui && ui.hostModalId) window.App.hideModal(ui.hostModalId); + window.App.onCloudProjectRowLoaded(proj); + }; + }); + await page.evaluate(() => window.App.openBidBoard()); + await expect(page.locator('#bidBoardModal')).toBeVisible(); + await expect(page.locator('#reviewBar')).toBeHidden(); + await page.locator('#bidBoardKind label', { hasText: 'All' }).click(); + + // Open the first ready card (the oldest waiting): the bar shows under the header. + await page.locator('#bidBoardList .bid-card').first().click(); + await expect(page.locator('#reviewBar')).toBeVisible(); + await expect(page.locator('#reviewBarText')).toHaveText(/^waiting \d+ days · wendi · 214 counts · 38 lines$/); + await expect(page.locator('#reviewBarReviewed')).toBeVisible(); + await expect(page.locator('#reviewBarChanges')).toBeVisible(); + await expect(page.locator('#reviewBarNext')).toBeVisible(); + + // Mark reviewed: the decision buttons go, the text says what happened and what is left. + await page.click('#reviewBarReviewed'); + await expect(page.locator('#reviewBarText')).toHaveText('Reviewed ✓ · 1 more ready'); + await expect(page.locator('#reviewBarReviewed')).toBeHidden(); + await expect(page.locator('#reviewBarChanges')).toBeHidden(); + + // Next ready opens the next bid in the lane; nothing is left after it, so Next goes. + await page.click('#reviewBarNext'); + await expect(page.locator('#reviewBarText')).toHaveText(/^waiting \d+ days · twin-estimator-1 · 90 counts · 10 lines$/); + expect(await page.evaluate(() => window.__loaded)).toEqual(['p1', 'p5']); + await expect(page.locator('#reviewBarNext')).toBeHidden(); + + // Request changes goes through the confirm dialog; a note is required; the text quotes it. + await page.click('#reviewBarChanges'); + await expect(page.locator('#confirmInput')).toBeVisible(); + await page.fill('#confirmInput', 'tighten the vent sizes'); + await page.click('#confirmOk'); + await expect(page.locator('#reviewBarText')).toHaveText('Sent back: “tighten the vent sizes” · none left ready'); + + // Reopening the board shows the lane as the decisions left it; closing the project hides the bar. + await page.evaluate(() => window.App.openBidBoard()); + await expect(page.locator('#bidBoardModal')).toBeVisible(); + await page.locator('#bidBoardKind label', { hasText: 'All' }).click(); + await expect(page.locator('.bid-board-lane-title')).toHaveCount(0); + await expect(page.locator('#bidBoardList .bid-card-badge-warn', { hasText: 'Changes requested' })).toHaveCount(1); + await page.click('#bidBoardClose'); + await page.evaluate(() => { window.state.currentProjectId = null; window.App.updateUI(); }); + await expect(page.locator('#reviewBar')).toBeHidden(); + + // A bid that is not ready, or a user who cannot oversee, gets no bar. + await page.evaluate(() => { window.state.currentProjectId = 'p2'; window.App.showReviewBar(Object.assign({}, window.__p2 || { id: 'p2', review_status: 'reviewed' })); }); + await expect(page.locator('#reviewBar')).toBeHidden(); + await page.evaluate(() => { window.state.isOverseer = false; window.state.currentProjectId = 'p9'; window.App.showReviewBar({ id: 'p9', review_status: 'ready', owner_email: 'x@example.com' }); }); + await expect(page.locator('#reviewBar')).toBeHidden(); + expect(errors).toEqual([]); + }); + test('auto-open: opens once for a pure overseer, never for admins', async ({ page }) => { await bootApp(page); await stubOverseerSession(page, STUB_ROWS); diff --git a/content/guides/reviewing-all-bids.md b/content/guides/reviewing-all-bids.md index 903122bc..e9cefdad 100644 --- a/content/guides/reviewing-all-bids.md +++ b/content/guides/reviewing-all-bids.md @@ -111,9 +111,12 @@ sign in, CountTooling brings you back to the bid you last had open; the board is - On the overseer's board, that bid jumps into a pinned **Ready for review** lane at the top, wearing a gold badge, no searching, no asking who finished what. -- After looking it over, the overseer clicks **Mark reviewed** right on the card. The bid - drops out of the lane and keeps a quiet **Reviewed ✓** badge, so both sides can see it's - been seen. +- The lane runs oldest waiting first, so the bid that has waited longest is the first card. +- Open a ready bid and a **Reviewing** bar sits under the header: how long it has waited, who + made it, its counts, then **Request changes…**, **Mark reviewed** and **Next ready**, which + opens the next bid in the lane, so a morning of reviews is one loop. The same two decisions + are on the card for a bid you do not need to open. Either way the bid drops out of the lane + and keeps a quiet **Reviewed ✓** badge, so both sides can see it's been seen. - If the estimator changes the bid afterward, they can **Mark ready again** from the same Project Settings row (or **Withdraw** a request that went up too early). diff --git a/features/bid-board.js b/features/bid-board.js index 0b6c1d9e..7cfcc4c7 100644 --- a/features/bid-board.js +++ b/features/bid-board.js @@ -144,6 +144,15 @@ return rows; } + // Oldest waiting first (Will, 2026-10-13): the Ready lane runs oldest request first, so the + // bid that has waited longest is the first card and the review bar's first Next ready. A + // row with no stamp sorts last. + function byOldestWaiting(a, b) { + const ta = a.review_requested_at ? new Date(a.review_requested_at).getTime() : Infinity; + const tb = b.review_requested_at ? new Date(b.review_requested_at).getTime() : Infinity; + return ta - tb; + } + function renderBidBoardList() { const listEl = document.getElementById('bidBoardList'); if (!listEl) return; @@ -159,10 +168,12 @@ } // "Ready for review" bids get their own lane pinned above the rest — the // estimator's handoff signal is the first thing an overseer sees. - const ready = rows.filter(function (p) { return p.review_status === 'ready'; }); + const ready = rows.filter(function (p) { return p.review_status === 'ready'; }).sort(byOldestWaiting); const rest = rows.filter(function (p) { return p.review_status !== 'ready'; }); + // REVIEW-BAR: the lane as shown is the bar's Next ready queue (features/review-flow.js). + App.setReviewQueue && App.setReviewQueue(ready); listEl.innerHTML = ready.length - ? '
Ready for review (' + ready.length + ')
' + + ? '
Ready for review (' + ready.length + ') · oldest waiting first
' + ready.map(bidCardHtml).join('') + (rest.length ? '
All bids
' + rest.map(bidCardHtml).join('') : '') : rows.map(bidCardHtml).join(''); diff --git a/features/load-project.js b/features/load-project.js index 73013ff3..a6a57b6a 100644 --- a/features/load-project.js +++ b/features/load-project.js @@ -558,6 +558,9 @@ // dedicated modal so the user has a clear next action. openCanvasOnlyNeedsPdfModal({ reason: 'no_pdf_stored' }); } + // REVIEW-BAR (features/review-flow.js): the row carries review_status, so the bar + // can show for a ready bid opened by a reviewer, from the board or Load Project. + App.onCloudProjectRowLoaded && App.onCloudProjectRowLoaded(proj); fitZoom(); updateUI(); } diff --git a/features/review-flow.js b/features/review-flow.js index 6e4cb87b..f1ba61e8 100644 --- a/features/review-flow.js +++ b/features/review-flow.js @@ -10,6 +10,17 @@ // app.js hook needed) and reads the live status from the projects row. // * features/bid-board.js calls App.setProjectReviewStatus for the // overseer's per-card "Mark reviewed" action. + // * The review bar (#reviewBar, REVIEW-BAR 2026-10-13, BOARD-QUIET step 1): the + // decision happens where the evidence is. While a bid that is ready for + // review is open by someone who can oversee it (App.canOversee: admin, + // overseer, lead), a slim bar under the header says how long it has waited + // and carries the two decisions, Request changes… and Mark reviewed, plus + // Next ready, which opens the next bid in the board's Ready lane (oldest + // waiting first; the board hands the lane over with App.setReviewQueue each + // time it renders). It shows from App.onCloudProjectRowLoaded, which + // features/load-project.js calls at the end of a cloud load with the RPC + // row (review_status rides it), and hides when the open project is no + // longer the one it was shown for (App.refreshReviewBar, from updateUI). // All transitions go through the set_project_review_status RPC, which // enforces who can do what server-side ('ready'/clear: owner, editor share, // or admin; 'reviewed': overseer or admin) — this file never gates harder @@ -75,6 +86,115 @@ } } + // --- The review bar --- + let reviewBar = null; // { proj, decided: null | 'reviewed' | 'changes', note } + let reviewQueue = []; // the board's Ready lane as rendered, oldest waiting first + + function waitedLabel(iso) { + if (!iso) return ''; + const days = Math.max(0, Math.round((Date.now() - new Date(iso).getTime()) / 864e5)); + if (days === 0) return 'ready today'; + if (days === 1) return 'waiting a day'; + return 'waiting ' + days + ' days'; + } + function countsLabel(p) { + return [ + p.counter_count > 0 ? p.counter_count + (p.counter_count === 1 ? ' count' : ' counts') : null, + p.line_count > 0 ? p.line_count + (p.line_count === 1 ? ' line' : ' lines') : null, + ].filter(Boolean).join(' · '); + } + function readyLeft() { + const id = reviewBar ? reviewBar.proj.id : null; + return reviewQueue.filter(function (q) { return q.review_status === 'ready' && q.id !== id; }).length; + } + // The next ready bid after the open one in lane order (the lane's head when the open bid + // is not in it, e.g. opened from Load Project). + function nextReadyRow() { + if (!reviewBar) return null; + const id = reviewBar.proj.id; + const idx = reviewQueue.findIndex(function (q) { return q.id === id; }); + const after = idx === -1 ? reviewQueue : reviewQueue.slice(idx + 1); + return after.find(function (q) { return q.id !== id && q.review_status === 'ready'; }) || null; + } + function renderReviewBar() { + const bar = document.getElementById('reviewBar'); + if (!bar) return; + const state = App.state; + const show = !!(reviewBar && state.currentProjectId && state.currentProjectId === reviewBar.proj.id); + bar.style.display = show ? '' : 'none'; + if (!show) return; + const p = reviewBar.proj; + const text = document.getElementById('reviewBarText'); + const changesBtn = document.getElementById('reviewBarChanges'); + const reviewedBtn = document.getElementById('reviewBarReviewed'); + const nextBtn = document.getElementById('reviewBarNext'); + const left = readyLeft(); + const tail = left ? ' · ' + left + ' more ready' : ' · none left ready'; + if (reviewBar.decided === 'reviewed') text.textContent = 'Reviewed ✓' + tail; + else if (reviewBar.decided === 'changes') text.textContent = 'Sent back: “' + reviewBar.note + '”' + tail; + else { + const who = p.owner_email ? p.owner_email.split('@')[0] : ''; + text.textContent = [waitedLabel(p.review_requested_at), who, countsLabel(p)].filter(Boolean).join(' · '); + } + bar.classList.toggle('done', !!reviewBar.decided); + changesBtn.style.display = reviewBar.decided ? 'none' : ''; + reviewedBtn.style.display = reviewBar.decided ? 'none' : ''; + changesBtn.disabled = false; + reviewedBtn.disabled = false; + const next = nextReadyRow(); + nextBtn.style.display = next ? '' : 'none'; + nextBtn.disabled = false; + nextBtn.textContent = 'Next ready ▸'; + } + function showReviewBar(proj) { + const ok = !!(proj && proj.review_status === 'ready' && App.canOversee && App.canOversee()); + reviewBar = ok ? { proj: proj, decided: null, note: null } : null; + renderReviewBar(); + } + async function decideReviewBar(status) { + if (!reviewBar || reviewBar.decided) return; + const p = reviewBar.proj; + let note = null; + if (status === 'changes') { + // The server refuses a blank note ('changes' without guidance is noise); cancel aborts. + note = await App.confirmDialog({ title: 'What should change before this bid comes back?', input: { placeholder: 'One line the estimator will read' }, confirmLabel: 'Send back' }); + if (note == null || !note.trim()) return; + note = note.trim(); + } + document.getElementById('reviewBarChanges').disabled = true; + document.getElementById('reviewBarReviewed').disabled = true; + const res = await setProjectReviewStatus(p.id, status, note); + if (!res || !res.ok) { + App.showToast((res && res.error) || 'Could not update review status.', 4000); + renderReviewBar(); + return; + } + p.review_status = status; // the board holds this same row, so its lane agrees without a refetch + p.reviewed_at = new Date().toISOString(); + if (note) p.review_note = note; + reviewBar.decided = status; + reviewBar.note = note; + App.showToast(status === 'reviewed' ? 'Marked "' + (p.name || 'Untitled') + '" reviewed.' : 'Changes requested on "' + (p.name || 'Untitled') + '".', 3000); + renderReviewBar(); + } + async function openNextReady() { + const next = nextReadyRow(); + if (!next) return; + const nextBtn = document.getElementById('reviewBarNext'); + nextBtn.disabled = true; + nextBtn.textContent = 'Opening…'; + try { + await App.loadCloudProjectRow(next, { + hostModalId: 'bidBoardModal', + showError: function (html) { App.showToast(String(html).replace(/<[^>]+>/g, ''), 4000); }, + }); + showReviewBar(next); // the load's own hook does this too; a load a spec stubs does not + } catch (e) { + App.showToast((e && e.message) || 'Failed to open bid.', 4000); + renderReviewBar(); + } + } + function wireReviewFlow() { const modal = document.getElementById('settingsModal'); const btn = document.getElementById('settingsReviewToggleBtn'); @@ -93,6 +213,12 @@ void refreshSettingsReviewRow(); }; } + const barChanges = document.getElementById('reviewBarChanges'); + if (barChanges) barChanges.onclick = function () { void decideReviewBar('changes'); }; + const barReviewed = document.getElementById('reviewBarReviewed'); + if (barReviewed) barReviewed.onclick = function () { void decideReviewBar('reviewed'); }; + const barNext = document.getElementById('reviewBarNext'); + if (barNext) barNext.onclick = function () { void openNextReady(); }; if (modal && typeof MutationObserver !== 'undefined') { let wasVisible = modal.classList.contains('visible'); new MutationObserver(function () { @@ -105,4 +231,8 @@ wireReviewFlow(); App.setProjectReviewStatus = setProjectReviewStatus; + App.onCloudProjectRowLoaded = showReviewBar; // features/load-project.js, at the end of a cloud load + App.showReviewBar = showReviewBar; // the spec seam + App.setReviewQueue = function (rows) { reviewQueue = Array.isArray(rows) ? rows.slice() : []; renderReviewBar(); }; // features/bid-board.js, the Ready lane as rendered + App.refreshReviewBar = renderReviewBar; // app.js updateUI })(); diff --git a/guides/reviewing-all-bids/index.html b/guides/reviewing-all-bids/index.html index 867a9b53..0f89ef50 100644 --- a/guides/reviewing-all-bids/index.html +++ b/guides/reviewing-all-bids/index.html @@ -180,9 +180,12 @@

The review handoff

diff --git a/journeys/plans/BID-BOARD-QUIET.md b/journeys/plans/BID-BOARD-QUIET.md index 2aea36ec..65e67b92 100644 --- a/journeys/plans/BID-BOARD-QUIET.md +++ b/journeys/plans/BID-BOARD-QUIET.md @@ -24,20 +24,19 @@ D the cards kept and quieted). for everyone but an admin, a "N twin bids are off · show twins" line, the estimator filter narrowed to the segment, the switch hidden when no bid is twin-owned; the intro rewritten. Detail in CHANGELOG.md. +- REVIEW-BAR (2026-10-13, Will's two calls: oldest waiting first, the bar next): the Ready + lane sorts on `review_requested_at`; a ready bid opened by a reviewer carries a bar under the + header with how long it has waited, Request changes…, Mark reviewed and Next ready, which walks + the lane as the board shows it. features/review-flow.js owns it. Detail in CHANGELOG.md. ## What is left -1. **C, the review bar in the bid.** On a ready bid opened by someone who `App.canOversee()`, a - slim bar under the header: how long it has waited, its counts, Request changes…, one filled - Mark reviewed, and Next ready (the next bid in the lane, so 41 reviews are a loop, not 41 - trips to the board). features/review-flow.js owns it. The board's per-card buttons go once - it lands; the Overseer guide ("clicks Mark reviewed right on the card") and bid-board.spec.js - change with it. -2. **A, the board as a list.** One row per bid, 42px: name with the stamp in dim mono, estimator, +1. **A, the board as a list.** One row per bid, 42px: name with the stamp in dim mono, estimator, counts, days waiting; actions on the hovered row only; badges for exceptions only (canvas - only, changes requested); the Ready lane oldest-waiting first. Forty rows to a screen. -3. **B, grouped by estimator**, only once the company has more than two or three human + only, changes requested). Forty rows to a screen. +2. **B, grouped by estimator**, only once the company has more than two or three human estimators; with one or two it is A with a caret. -Decisions still Will's: the Ready lane's sort (oldest waiting first is the assumption), and -whether the board's per-card buttons go when C lands or stay beside it. +Decision still Will's: whether the board's per-card Mark reviewed and Request changes… go now +that the bar carries them, or stay for a bid the reviewer does not need to open (they stay +today). diff --git a/styles.css b/styles.css index afbbaff3..310a08bb 100644 --- a/styles.css +++ b/styles.css @@ -2531,6 +2531,23 @@ body:has(.modal-overlay.visible) .chain-panel { display: none !important; } .settings-review-row .settings-review-status { flex: 1; min-width: 0; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } #settingsModal .settings-review-row .settings-review-btn { padding: 6px 2px; white-space: nowrap; } .settings-review-row .settings-review-btn:disabled { opacity: 0.6; cursor: wait; text-decoration: none; } +#bidBoardModal .bid-board-lane-hint { color: var(--border2); } +/* REVIEW-BAR (features/review-flow.js): under the header while a ready bid is open by a reviewer. + In the .app flex column like the header, so the sheet below gives up its height. */ +.review-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; flex-shrink: 0; min-height: 40px; padding: 4px 14px; background: var(--surface); border-bottom: 1px solid var(--border); font-size: 0.85rem; } +.review-bar-kicker { font-family: 'DM Mono', monospace; font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); } +.review-bar-text { color: var(--text2); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } +.review-bar.done .review-bar-text { color: var(--green); } +.review-bar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; } +.review-bar button { font: inherit; font-size: 0.85rem; padding: 6px 12px; border-radius: 6px; cursor: pointer; } +.review-bar-changes { background: transparent; border: 1px solid var(--border2); color: var(--text2); } +.review-bar-changes:hover { color: var(--text); border-color: var(--accent2); } +.review-bar-reviewed { background: var(--accent); border: 1px solid var(--accent); color: var(--bg); font-weight: 600; } +.review-bar-reviewed:hover { background: var(--accent2); border-color: var(--accent2); } +.review-bar-next { background: none; border: none; color: var(--accent); padding: 6px 4px; } +.review-bar-next:hover { text-decoration: underline; } +.review-bar button:disabled { opacity: 0.6; cursor: wait; } +@media (max-width: 768px) { .review-bar { padding: 4px 10px; gap: 8px; } .review-bar-text { white-space: normal; } .review-bar-actions { margin-left: 0; } } /* Notes ledger (features/notes-ledger.js) — header badge, right drawer, and the note hover chip. Pins themselves are canvas-drawn. */ diff --git a/sw.js b/sw.js index 64c40a8e..58736e72 100644 --- a/sw.js +++ b/sw.js @@ -23,7 +23,7 @@ * visit once the CDN has settled. The app's admin "global force reload" clears caches * as a backstop. */ -const CACHE_VERSION = '710039353267'; +const CACHE_VERSION = 'b49ec427c7ce'; const CACHE_NAME = `counttooling-shell-${CACHE_VERSION}`; // The full same-origin app shell. GENERATED by `npm run build:sw`, do not edit by hand: @@ -239,7 +239,7 @@ const PRECACHE_SHA256 = { '/vendor/jspdf.umd-2.5.1.min.js': '98ccf17aa10c20bb1301762618fcc9b6ab3a4e7f26b6071d64d0b41154df3875', '/vendor/supabase-js-2.108.0.min.js': '005a6b7d396160fbe924316baa98adf198dc6f99a63412e27edec9675c225270', '/vendor/tus-js-client-4.3.1.min.js': '8cbb1b63fccc3bba0ae73ad1deb160ce046c3750851d0c3e94921ae3ef070eb8', - '/styles.css': '81991e5a6b20f1e75bd4020913993755d38eec7679184b9eae50fce9806b3b37', + '/styles.css': '9e6ff65967d1e0ca25b4c8bab00fc8d0a5671a0a7aa9d8f3497fb69fd36b557e', '/icons.js': 'bb3c3506a859d25685287d0c1d3afb3231601754555aea403505e7ca8d68779b', '/icons-custom.js': 'efe6b960301031a5fb40abc2f54de18798e19f4b7b04e0eccb81b47f1e9cacad', '/icon-render.js': '41b09b835c3898be95b013b27a6c11e1453c629cb811326d49fdcbfec19439d8', @@ -273,7 +273,7 @@ const PRECACHE_SHA256 = { '/undo-stack.js': '34180b25071008b6f29c8b3c2529faa29e21c2957e9ee26b5510e5ef5750f69c', '/save-engine.js': 'd620a2ade982357362d0e7dd9c701df90a3cffe47e66f780dcd1d24b81fda918', '/pdf-tile-cache.js': 'd9d520d6399480191df2b97038ce0b453803666d79f1b804a995484e98fc5772', - '/app.js': '7c74492df27d7324f1184946b55b36c5d7e426f83e0a3431391d899499b38bc1', + '/app.js': '4bcfbfb8613cb827d5d0b94095bedac90fdcea5ab954f7c9d13a663a6a725442', '/features/canvas-repair.js': 'b2dca5c86174ed9589d0c44091d9265c2e3af039c08cf4422eb151fa5fd8ec02', '/features/view-only.js': 'f4e6c4f5601c089aa1001a9583c409e61d9090a639acd6a69994bccd6ca0dbcc', '/features/save-project.js': '6f01819d040f4a05ee9805ccabdc5170973429a39d5d0c3e54381a0d43866ad2', @@ -304,9 +304,9 @@ const PRECACHE_SHA256 = { '/features/manage-projects.js': 'e462989f4621db4375471bb3deb05fe9c707345d1e4bda9394d302f1f8bb02fe', '/features/hand-off.js': 'e996c7300432489bcb8e1c9a02539278a7ac3ffbf2daaabce4922b4875e10c23', '/features/user-admin.js': '2abd3029bdf2950310af9c19fb302b416976922bad3f4142db55626e3a229128', - '/features/load-project.js': 'c0d46b903bf80f5b033a2bfe03f91871c687c20ee5d538d25ef523c1e87fb878', - '/features/bid-board.js': '1937ccb419fa583f1bd9e8de4a80cdcffea6225e839e409cbc9b2dc4f19d7628', - '/features/review-flow.js': '7dd1ac948e0031abab788666622873a143eeefd3315ed0b1cadb1a8083400bc5', + '/features/load-project.js': 'f01367d24dc62824ca474b5f7f707fc7e739bfcd936b85d3cafe6d6813c98ad8', + '/features/bid-board.js': 'eee65ebbadf86c3198d5eeac19371fa55cc9c5146aed582b3161105490f4fad2', + '/features/review-flow.js': '8e0139b0861a45b147f2dee31d416a3c2188fde6fb7ab16644a0f2d14475bb6b', '/features/copy-project.js': '7668abd5e8121edc27c3155882da4c252791455a5a7bdd4a6accbe36ef0bea09', '/features/prepare-pdf.js': '7468cb401fc5a29c1e3e6f3188c1e99396c6b7b5d5374d2cb7de0367a80e4c24', '/features/quick-modals.js': '052927460e00406495fea8cdb36c0e3cf816d455eb94cb764437bd40016ed527', @@ -405,8 +405,8 @@ const PRECACHE_SHA256 = { '/icons/icon-192.png': 'c807a7a2fda05dc5a74c60f16d7199bc1c617aa36948acc20e3712a412f943c2', '/icons/icon-512.png': '386919ae854bc73fd0c8fa39bcb8f16d2496ce0b487792ca17b0924d7a8eb137', '/icons/maskable-512.png': 'a5c54fa0ab699678992c5e5473721804d24257762a859f8c2183fb4049bfa164', - '/app/': 'ffce11a51a4b7e14245147cd2ceb6fa876173ab282f86a495a37454a7ec0a991', - '/app/index.html': 'ffce11a51a4b7e14245147cd2ceb6fa876173ab282f86a495a37454a7ec0a991', + '/app/': '452f968fd1c1e2931521e62e84d319dfafb7453ee92c8c8e13dc11d6544034b9', + '/app/index.html': '452f968fd1c1e2931521e62e84d319dfafb7453ee92c8c8e13dc11d6544034b9', '/render-worker.js': '97409f02a7150a5f9b5e456769083b49dca0c7baaae0263a34e2fc7a1d23a54d', '/vendor/pdf.worker.min-3.11.174.js': 'feabdf309770ed24bba31a5467836cdc8cf639c705af27d52b585b041bb8527b', '/rules/rules.json': 'bf4f68f9b25bd2bbc13e382bd204fce243c23945c8cf7bcb57da828f652e122b',