Improve search result metadata display (#394, #321)#584
Conversation
|
Wot Claude Opus 4.6 thinks... Performance AssessmentPerformance impact: negligible. Backend changes (search response construction)
Frontend changes (rendering)
Summary
There are no new network requests, no additional ES queries, no new database calls, and no algorithmic complexity changes. This branch should have no measurable performance impact. |
|
Phil's asked me to make the new js utils as tsx |
Backend: - Add collections (dataset names) to SearchResult model - Add human-friendly display MIME types to DocumentResultDetails, mapped via MimeDetails - Add sentAt timestamp to EmailResultDetails Frontend: - Show human-friendly file types instead of raw MIME strings - Show dataset as a clickable link to the collection page - File-type-specific icons with colour coding: video (purple), audio (orange), image (green), spreadsheet (gold), presentation (pink), PDF (pink), archive (orange), web (purple) - Email results now show From and Sent date instead of Attachments - Compact date formatting using date-fns (e.g. "Sep 4, 2008 at 2:27pm") - Restyled detail box with inline label/value rows New files: - frontend/src/js/util/fileTypeIcon.js — MIME-to-icon mapping - frontend/src/js/util/formatDate.js — date-fns formatting helper
- Backend: replace sentAt with recipients (List[Recipient]) in EmailResultDetails, read from ES metadata.recipients - Frontend: display To field (displayName or email, truncated with ellipsis after 80/60 chars), restore Attachments count, remove Sent - Update TypeScript types accordingly
748f673 to
8584e0a
Compare
Convert fileTypeIcon.js and formatDate.js to .ts with proper type annotations. Imports use extensionless paths so no consumer changes needed.
- Extract duplicated collection-link rendering into a shared CollectionLinks component used by both SearchResult and CompactResultsTable - Extract recipient formatting/truncation into a reusable formatRecipients utility with consistent interface - Replace inline IIFE in CompactResultsTable with a clean expression using the new utility
Cover edge cases: empty inputs, truncation behaviour, mime type mapping for all supported categories, and date formatting.
Most audio files in practice are recordings of interviews, speeches etc, so a microphone icon is more representative.
date-fns format() only accepts Date | number. All call sites already pass new Date(...) so string was never needed.
|
I ummed and erred about whether to consolidate the backend categorisation of mime types into overall file types with those used in the search results (and sidebar). But it would make this change far more complicated. Possibly something to revisit later. And naturally I asked for reassurance from a robot. The robot said: Context:
This PR introduces Decision: Rationale:
Future considerations: |
|
I think it's perhaps time to inflict this on you folks for review... sorry |
Work towards #394, #321 (excluding the workspaces bit). See also the epic #320.
This makes it easier for users to pick out relevant files in long search results lists.
This is quite an ambitious change. Some considerations to note:
Potential for performance impact: claude says it will be negligible - see comment below
Somewhat duplicated logic for categorising file types: consolidating these into one would have been a deeply involved change at backend and frontend. I chickened out. See another comment below
Changes
Backend:
collections(dataset names) toSearchResultmodel — reads existing ES fielddisplayMimeTypestoDocumentResultDetails, mapped viaMimeDetailsrecipientstoEmailResultDetailsFrontend:
human-datewithdate-fnsfor date formatting.New files:
frontend/src/js/util/fileTypeIcon.ts— MIME-to-icon mappingfrontend/src/js/util/formatDate.ts— date-fns formatting helperfrontend/src/js/util/formatRecipients.ts— recipient list formatting with truncationfrontend/src/js/components/SearchResults/CollectionLinks.tsx— shared component for rendering dataset linksTests (20 tests, 3 suites):
fileTypeIcon.spec.ts— all icon categories, edge cases (empty/undefined input, unknown MIME, first-mime-wins)formatDate.spec.ts— Date object and timestamp formattingformatRecipients.spec.ts— empty input, displayName/email fallback, truncation boundaryTesting:
Looks good on local and playground. Unit tests all pass.