From a4c49f5e5a9059063bff26afdc2ed8ef121c23bf Mon Sep 17 00:00:00 2001 From: Matt Date: Mon, 11 May 2026 12:44:48 +0200 Subject: [PATCH] fix(documents): surface signedFromDocumentId + hub cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three follow-ups from Task 15 code review: 1. (Important) The aggregated files API now LEFT JOINs against documents to surface signedFromDocumentId per file row. The "view signing details" button on EntityFolderView's Files section now passes the workflow id to SigningDetailsDialog instead of the file id. Previously the button always 404'd and the dialog hung in the loading state. Drops the v1 filename-prefix heuristic. 2. (Minor) Drop dead initialTab prop + DocumentsHubTab import — leftover from the pre-refactor tab strip. 3. (Minor) FlatFolderListing remounts on folder switch via a key prop, restoring the pre-refactor typeFilter reset behaviour. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/components/documents/documents-hub.tsx | 4 +- .../documents/entity-folder-view.tsx | 14 +++--- src/hooks/use-aggregated-listing.ts | 1 + src/lib/services/files.ts | 41 ++++++++++++---- tests/unit/aggregated-projection.test.ts | 49 +++++++++++++++++++ 5 files changed, 91 insertions(+), 18 deletions(-) diff --git a/src/components/documents/documents-hub.tsx b/src/components/documents/documents-hub.tsx index f25adeb0..85cbe49f 100644 --- a/src/components/documents/documents-hub.tsx +++ b/src/components/documents/documents-hub.tsx @@ -14,7 +14,6 @@ import { PermissionGate } from '@/components/shared/permission-gate'; import { usePaginatedQuery } from '@/hooks/use-paginated-query'; import { useRealtimeInvalidation } from '@/hooks/use-realtime-invalidation'; import { useDocumentFolders, type FolderNode } from '@/hooks/use-document-folders'; -import type { DocumentsHubTab } from '@/lib/validators/documents'; import { FolderActionsMenu } from './folder-actions-menu'; import { FolderBreadcrumb } from './folder-breadcrumb'; import { FolderTreeSidebar } from './folder-tree-sidebar'; @@ -64,7 +63,6 @@ const SIGNER_STATUS_LABELS: Record = { interface DocumentsHubProps { portSlug: string; - initialTab?: DocumentsHubTab; } function findInTree(nodes: FolderNode[], id: string): FolderNode | null { @@ -137,7 +135,7 @@ export function DocumentsHub({ portSlug }: DocumentsHubProps) { entityId={selectedFolder!.entityId!} /> ) : ( - + )} diff --git a/src/components/documents/entity-folder-view.tsx b/src/components/documents/entity-folder-view.tsx index 9c1ab004..cfc716f8 100644 --- a/src/components/documents/entity-folder-view.tsx +++ b/src/components/documents/entity-folder-view.tsx @@ -8,7 +8,11 @@ import { AggregatedSection } from './aggregated-section'; import { SigningDetailsDialog } from './signing-details-dialog'; import { useAggregatedFiles, useAggregatedWorkflows } from '@/hooks/use-aggregated-listing'; import { StatusPill, type StatusPillStatus } from '@/components/ui/status-pill'; -import type { AggregatedWorkflow, AggregatedFile, AggregatedGroup } from '@/hooks/use-aggregated-listing'; +import type { + AggregatedWorkflow, + AggregatedFile, + AggregatedGroup, +} from '@/hooks/use-aggregated-listing'; interface Props { portSlug: string; @@ -68,19 +72,17 @@ export function EntityFolderView({ portSlug, entityType, entityId }: Props) { loading={filesLoading} emptyMessage="No files for this entity yet." renderRow={(f: AggregatedFile, _group: AggregatedGroup) => { - // Heuristic v1: auto-deposit handler (Task 7) names signed files with "signed-" prefix. - // Follow-up: surface signedFromDocumentId from the aggregated API for a principled check. - const isSigned = f.filename?.startsWith('signed-'); + const signedFromDocumentId = f.signedFromDocumentId; return (
{f.filename}
{new Date(f.createdAt).toLocaleDateString('en-GB')} - {isSigned ? ( + {signedFromDocumentId ? (