From 9c2dbdf5910f065411994231df5631a63c3561ab Mon Sep 17 00:00:00 2001 From: JasonFraser Date: Tue, 13 Oct 2026 09:46:20 -0400 Subject: [PATCH] Add per-project document hierarchy to the sidebar; fix dropdown hover gap ProjectSidebar: each project now expands (chevron toggle) into its own lazy-loaded document list - click a document to open it in the main view, or delete it via the same two-step ConfirmModal pattern already used elsewhere (Move to project, DocumentNavBar's own delete). Deleting from here keeps both the sidebar's cached list and the main workspace (extractionStore) in sync. Also fixes a real reported bug: the Results dropdown closed when the mouse moved slowly from the toggle down to the checks list, but stayed open on a fast drag. Root cause: the panel's 8px gap was a `top` positioning offset, which doesn't extend its relatively-positioned parent's own hoverable box - that gap sat outside the hover zone entirely, so crossing it slowly let a genuine mouseleave fire first. Fixed by moving the gap into padding on an invisible wrapper instead of a positioning offset, so the whole hover path - button, gap, and panel - is one continuous box with no dead zone. Verified: npm run build passes; the served bundle contains the new class names. The two new Vue reactivity patterns (a reactive Set via ref(new Set()), and dynamic keys on a reactive({}) object) were each executed directly against real Vue reactivity, not assumed - both correct. measure.py unaffected. Not machine-verified: the actual interactive behavior - Claude-in-Chrome did not connect this session. Co-Authored-By: Claude Sonnet 5 --- CLAUDE.md | 71 ++++++- frontend/src/assets/main.css | 64 +++++- frontend/src/components/ProjectSidebar.vue | 200 +++++++++++++++--- frontend/src/components/TransactionsTable.vue | 20 +- 4 files changed, 310 insertions(+), 45 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index a8ee1fc..877f6b2 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -409,7 +409,9 @@ security only, not the full SaaS-shaped doc — and the judgment call on what co (the app's primary left nav as of 2026-10-13 — project list/select/create/rename/delete, a client-side project search box, filters the document list, collapses to an - icon-only rail), LoginView + icon-only rail; each project also expands into its own + lazy-loaded document hierarchy, open or delete a document + straight from here), LoginView (Sign In/Sign Up toggle + "Continue with Google"), ConfirmModal (generic confirm/cancel dialog over a dimmed backdrop; `danger`/`busy` props added 2026-10-13 for the @@ -1213,6 +1215,73 @@ behavior - the hover-sticky dropdown's timing, the delete/rename modals' click-t whether the 3-column header truly centers the nav at various widths - Claude-in-Chrome still did not connect this session; this is the user's own check before calling it done. +**Sidebar document hierarchy + a real hover-dropdown bug fix, 2026-10-13.** Two more +fixes from direct user feedback on the work above: + +1. **`ProjectSidebar.vue`'s projects now expand into their own document hierarchy** - a + chevron toggle per project (`toggleExpand`), lazy-loaded on first expand via + `documentsService.listDocuments({project})` and cached in a `projectDocuments` + reactive object keyed by project id (re-fetched only if this same component deletes + a document out from under it, not on every expand/collapse). Each listed document + can be opened (click the name - loads its project's documents into the main view if + they aren't already loaded, then `extractionStore.setActiveIndex`s to it) or deleted + straight from the sidebar, via the exact same two-step ConfirmModal pattern + (`danger`/`busy` props) `DocumentNavBar`'s own delete flow already established - no + new pattern invented, same one reused a third time now (Move to project, document + delete, project-sidebar document delete). + + Required restructuring `
  • ` in the project list: the clickable row (expand chevron + + folder icon/name + rename/delete) moved into its own `.project-row` div, since the + `
  • ` itself now also holds a second, block-level child - the nested + `.project-doc-list` - which can't share a flex line with the row above it. The + active-project highlight background moved from `.project-list li.active` to + `.project-list li.active > .project-row` for the same reason - so only the row + itself highlights, not the whole block including its nested documents. + + **Deleting a document from here keeps BOTH places in sync**: the sidebar's own + cached `projectDocuments[project]` array (spliced locally, not re-fetched) AND + `extractionStore.removeDocument(doc.id)` (a harmless no-op if that document wasn't + also loaded in the main view) - so deleting a document from the sidebar while it's + the one currently being reviewed in TransactionsTable removes it from both places in + one action, not just the list it was clicked from. + +2. **The Results dropdown's hover-sticky behavior had a real, reported bug**: it + collapsed if the user moved the mouse down SLOWLY from the toggle button toward the + checks list, but stayed open when dragged down quickly - "it seems like the little + gap... is causing it to detect as if the user navigated away, when all they are + doing is navigating down." Diagnosed and confirmed exactly that: the panel was + positioned via `top:calc(100% + 8px)`, an absolutely-positioned child, which does + NOT extend its relatively-positioned parent's (`.results-trigger-wrap`) own + hoverable bounding box - that box stays only as tall as the in-flow toggle button. + The 8px visual gap therefore sat OUTSIDE the wrap's hover zone entirely; crossing it + slowly gave the browser time to fire a genuine `mouseleave` before the pointer ever + reached the panel, while a fast drag could skip past that dead strip within one + pointer-event tick without one ever firing - exactly the "works fast, breaks slow" + symptom reported, not a flaky timing issue. + + **Fixed by moving the gap from a positioning offset into padding**: `.results-dropdown` + now sits flush against the toggle (`top:100%`, no offset) and is itself just an + invisible hit-box with `padding-top:8px` - padding is still part of the element's + own box, so hovering through it counts as hovering a descendant of + `.results-trigger-wrap`, the same as hovering the toggle button itself. The actual + visible card moved into a new inner element, `.results-dropdown-inner` (still + `.card`-styled), offset down by that padding alone - same 8px visual gap as before, + now with zero dead zone in the hover path. Confirmed by reasoning through the box + model precisely rather than guessing at a timing fix (e.g. a debounce/delay on + mouseleave, which would have "fixed" the symptom without addressing why it happened, + and would have made the dropdown feel laggy to close on a deliberate mouse-away). + +**Verified:** `npm run build` passes; the served JS bundle confirmed to contain the new +sidebar class names (`project-doc-list`, `project-doc-delete`, `results-dropdown-inner`). +**The two new Vue reactivity patterns this introduced - a reactive `Set` via +`ref(new Set())` and dynamically-keyed property access on a `reactive({})` object - +were executed directly against real Vue reactivity** (an `effect()` watching each, +not assumed from documentation): both triggered re-runs correctly on `.add`/`.delete` +and on a brand-new key being assigned. `measure.py` re-run, unaffected (no backend +touched). **Not machine-verified:** whether the hover fix actually feels right in a +real browser, and the sidebar hierarchy's own click-through (expand/collapse, opening a +document, deleting one) - Claude-in-Chrome still did not connect this session. + **Governing rule: never silently correct or exclude data.** This shows up in several concrete places, not just as an abstract principle: - A row with an unusual status (e.g. HSBC's "Cancelled" wires) stays in the output and is diff --git a/frontend/src/assets/main.css b/frontend/src/assets/main.css index 3d3015e..11bdb29 100644 --- a/frontend/src/assets/main.css +++ b/frontend/src/assets/main.css @@ -285,10 +285,27 @@ tr.editing td{ background:rgba(37,99,235,.03); } instant the pointer leaves the trigger+panel zone entirely (mouseleave doesn't fire when moving between a parent's own children, only when truly exiting it - no separate "is the panel itself hovered" tracking - needed). */ + needed). + + .results-dropdown itself sits FLUSH against the toggle (top:100%, no + gap) and is just an invisible hit-box - the visible gap is its own + padding-top, not a positioning offset. This split matters: moving the + gap into `top:calc(100% + 8px)` instead (as a first pass did) put + that 8px strip OUTSIDE .results-trigger-wrap's hoverable area + entirely, since an absolutely-positioned child doesn't extend its + relatively-positioned ancestor's own box - crossing that strip SLOWLY + fired mouseleave before the pointer ever reached the panel (confirmed + as the actual reported bug: worked when dragged quickly, since a fast + pointer can skip the dead strip in one event tick, broke when moved + slowly through it). Padding is a child of .results-dropdown itself, + so hovering through it is still "inside a descendant of the wrap" - + mouseleave only fires once the pointer leaves the padding too, not + partway through it. .results-dropdown-inner is the actual visible + card, offset down by that padding alone. */ .results-dropdown{ - position:absolute; top:calc(100% + 8px); left:0; z-index:15; width:340px; max-width:90vw; margin-bottom:0; + position:absolute; top:100%; left:0; z-index:15; width:340px; max-width:90vw; padding-top:8px; } +.results-dropdown-inner{ margin-bottom:0; } /* Sits across the top of the transactions card, above the Hide Source Doc row (TransactionsTable.vue renders it first) - no border/ @@ -597,10 +614,20 @@ tr.editing td{ background:rgba(37,99,235,.03); } .app-sidebar-toggle:hover{ border-color:var(--blue); color:var(--blue); } .project-list{ list-style:none; margin:0 0 10px; padding:0; display:flex; flex-direction:column; gap:2px; width:100%; } -.project-list li{ - display:flex; align-items:center; gap:2px; border-radius:7px; padding:2px; +/* .project-row (the clickable row - expand chevron, folder icon+name, + rename/delete) is its own flex row INSIDE the
  • , not the
  • + itself, so the
  • can also hold the nested .project-doc-list + underneath it as a second, block-level child instead of competing for + space in the same flex line. */ +.project-row{ display:flex; align-items:center; gap:2px; border-radius:7px; padding:2px; } +.project-list li.active > .project-row{ background:rgba(37,99,235,.08); } +.project-expand-btn{ + flex-shrink:0; width:18px; height:18px; display:flex; align-items:center; justify-content:center; + background:transparent; border:none; cursor:pointer; color:var(--t4); font-size:9px; border-radius:4px; + transition:transform .15s, color .15s; } -.project-list li.active{ background:rgba(37,99,235,.08); } +.project-expand-btn:hover{ color:var(--blue); } +.project-expand-btn.expanded{ transform:rotate(90deg); } .project-name{ flex:1 1 auto; min-width:0; display:flex; align-items:center; gap:9px; text-align:left; background:transparent; border:none; cursor:pointer; @@ -621,9 +648,36 @@ tr.editing td{ background:rgba(37,99,235,.03); } border:1px solid var(--blue); border-radius:6px; font-size:13px; color:var(--t1); font-family:var(--fb); outline:none; } + +/* Each project's own document hierarchy - a lazy-loaded nested list + under its row, indented with a thin rule so it reads as nested rather + than a sibling project. */ +.project-doc-list{ + list-style:none; margin:2px 0 4px 20px; padding:0 0 0 10px; display:flex; flex-direction:column; gap:1px; + border-left:1px solid var(--border); +} +.project-doc-loading, .project-doc-empty{ font-size:11.5px; color:var(--t4); padding:5px 8px; } +.project-doc-item{ display:flex; align-items:center; gap:2px; } +.project-doc-name{ + flex:1 1 auto; min-width:0; display:flex; align-items:center; gap:7px; text-align:left; + background:transparent; border:none; cursor:pointer; padding:5px 7px; border-radius:6px; + font-size:12px; color:var(--t3); font-family:var(--fb); +} +.project-doc-name i{ flex-shrink:0; font-size:10px; color:var(--t4); } +.project-doc-name span{ white-space:nowrap; overflow:hidden; text-overflow:ellipsis; } +.project-doc-name:hover{ color:var(--blue); } +.project-doc-delete{ + flex-shrink:0; background:transparent; border:none; cursor:pointer; color:var(--t4); + font-size:10px; padding:5px; border-radius:5px; line-height:1; +} +.project-doc-delete:hover:not(:disabled){ color:var(--red); background:rgba(16,24,40,.06); } +.project-doc-delete:disabled{ opacity:.5; cursor:not-allowed; } + .app-sidebar.collapsed .project-name{ justify-content:center; padding:9px 0; } .app-sidebar.collapsed .project-name-text, .app-sidebar.collapsed .project-row-btn, +.app-sidebar.collapsed .project-expand-btn, +.app-sidebar.collapsed .project-doc-list, .app-sidebar.collapsed .project-new, .app-sidebar.collapsed .app-sidebar-toggle span{ display:none; } diff --git a/frontend/src/components/ProjectSidebar.vue b/frontend/src/components/ProjectSidebar.vue index 41cdad0..12811c3 100644 --- a/frontend/src/components/ProjectSidebar.vue +++ b/frontend/src/components/ProjectSidebar.vue @@ -10,18 +10,30 @@ * anything - "All Documents" (the default) shows every document, same * as before projects existed at all. * + * Each project also expands into its own document hierarchy (a chevron + * toggle, lazy-loaded on first expand) - lets a document be opened or + * deleted straight from the sidebar, without first selecting the + * project as the active filter. Reuses the same delete-confirm pattern + * TransactionsTable/DocumentNavBar already established (a destructive + * action always goes through a ConfirmModal, never a single click). + * * Collapsed state shrinks to a narrow icon-only rail (same pattern as * Slack/most enterprise dashboards) rather than nearly vanishing - the - * search box, section label, and inline rename/delete controls hide; - * icons + the expand toggle stay reachable via their own title tooltips. + * search box, section label, expand chevrons, nested document lists, and + * inline rename/delete controls hide; icons + the expand toggle stay + * reachable via their own title tooltips. */ -import { ref, computed } from 'vue' +import { reactive, ref, computed } from 'vue' import { useProjectsStore } from '../stores/projectsStore' import { useUiStore } from '../stores/uiStore' +import { useExtractionStore } from '../stores/extractionStore' import { useDocuments } from '../composables/useDocuments' +import * as documentsService from '../services/documentsService' +import ConfirmModal from './ConfirmModal.vue' const projectsStore = useProjectsStore() const uiStore = useUiStore() +const extractionStore = useExtractionStore() const { loadDocuments } = useDocuments() const searchQuery = ref('') @@ -90,6 +102,85 @@ async function confirmRename(project) { errorMessage.value = 'Could not rename the project: ' + e.message } } + +// ── Per-project document hierarchy ────────────────────────────────── +// expandedProjects is a reactive Set (Vue 3 proxies Set/Map natively - +// .add/.delete trigger reactivity directly, no need to reassign a new +// Set each time). projectDocuments is lazy-loaded per project id on +// first expand and cached for the rest of the session - re-fetched only +// if a document is added/removed through this same component. +const expandedProjects = ref(new Set()) +const projectDocuments = reactive({}) +const loadingProjectId = ref(null) + +async function toggleExpand(project) { + if (expandedProjects.value.has(project.id)) { + expandedProjects.value.delete(project.id) + return + } + expandedProjects.value.add(project.id) + if (projectDocuments[project.id]) return + loadingProjectId.value = project.id + errorMessage.value = '' + try { + projectDocuments[project.id] = await documentsService.listDocuments({ project: project.id }) + } catch (e) { + errorMessage.value = `Could not load "${project.name}"'s documents: ` + e.message + expandedProjects.value.delete(project.id) + } + loadingProjectId.value = null +} + +/** + * Opens a document from the sidebar in the main view - if it's already + * loaded there (whatever the current project filter is), just switches + * to it; otherwise loads its own project's documents first, the same + * fetch selecting that project in the sidebar would make. + */ +async function openDocument(doc) { + errorMessage.value = '' + try { + let idx = extractionStore.documents.findIndex((d) => d.pbId === doc.id) + if (idx === -1) { + projectsStore.setActiveProject(doc.project) + await loadDocuments({ project: doc.project }) + idx = extractionStore.documents.findIndex((d) => d.pbId === doc.id) + } + if (idx !== -1) extractionStore.setActiveIndex(idx) + } catch (e) { + errorMessage.value = 'Could not open this document: ' + e.message + } +} + +const deletingDocId = ref(null) +const showDeleteDocConfirm = ref(false) +const pendingDeleteDoc = ref(null) + +function requestDeleteDoc(doc) { + pendingDeleteDoc.value = doc + showDeleteDocConfirm.value = true +} + +async function confirmDeleteDoc() { + const doc = pendingDeleteDoc.value + if (!doc) return + deletingDocId.value = doc.id + errorMessage.value = '' + try { + await documentsService.deleteDocument(doc.id) + if (projectDocuments[doc.project]) { + projectDocuments[doc.project] = projectDocuments[doc.project].filter((d) => d.id !== doc.id) + } + // Keeps the main workspace in sync too, if this document happened to + // be loaded there (removeDocument is a harmless no-op otherwise). + extractionStore.removeDocument(doc.id) + showDeleteDocConfirm.value = false + } catch (e) { + errorMessage.value = 'Could not delete this document: ' + e.message + showDeleteDocConfirm.value = false + } + deletingDocId.value = null +} diff --git a/frontend/src/components/TransactionsTable.vue b/frontend/src/components/TransactionsTable.vue index 33e7a35..eca75d3 100644 --- a/frontend/src/components/TransactionsTable.vue +++ b/frontend/src/components/TransactionsTable.vue @@ -345,15 +345,17 @@ async function handleRecheck() { Results -
    -
    {{ result.status }}
    -
    {{ periodText }}
    -
      -
    • - {{ check.outcome.replace('_', ' ') }} - {{ check.name.replace(/_/g, ' ') }} — {{ check.detail }} -
    • -
    +
    +
    +
    {{ result.status }}
    +
    {{ periodText }}
    +
      +
    • + {{ check.outcome.replace('_', ' ') }} + {{ check.name.replace(/_/g, ' ') }} — {{ check.detail }} +
    • +
    +