Settings: Resolve scrape activity shipment names across active and archived records #45

Closed
opened 2026-06-27 15:41:16 +02:00 by bullitt · 1 comment
Owner

Problem

The Recent Scrape Activity table in Settings shows #4, #16, #23 etc. as shipment links when the shipment name hasn't been loaded or resolved via shipmentMap. The shipmentMap is populated from fetchShipments() but archived shipments are not included — so archived shipment scrape log entries always show as #N.

Root cause

File: frontend/src/pages/Settings.tsx — around line 355:

const ship = shipmentMap[entry.shipment_id]
// ship is undefined for archived shipments → falls back to `#${entry.shipment_id}`

fetchShipments() without args returns only active+delivered. Archived shipments are not in the map.

Implementation

Option A — Fetch all shipments including archived

Promise.all([
  fetch(`${BASE}/api/settings`).then(r => r.json()),
  fetch(`${BASE}/api/scrapers`).then(r => r.json()),
  fetchScrapeLog({ limit: 30 }),
  fetchShipments(),
  fetchShipments("archived"),  // add this
]).then(([settingsData, scrapersData, logData, shipmentsData, archivedData]) => {
  // ...
  const map: Record<number, Shipment> = {}
  for (const s of [...shipmentsData, ...archivedData]) map[s.id] = s
  setShipmentMap(map)
})

Option B — Include shipment title in scrape log API response

In db.py, modify the scrape log query to JOIN with the shipments table and include title. This is cleaner long-term.

In main.py, the /api/scrape-log route would return title alongside shipment_id. Update the ScrapeLogEntry type in frontend/src/lib/api.ts to include title?: string.

Then in the table: ship?.title || entry.title || \#${entry.shipment_id}``

Acceptance criteria

  • Shipment names appear in the Recent Activity table for all shipments including archived
  • Fallback #N only shows if the shipment genuinely doesn't exist

Brand identity alignment

Recent activity is an audit surface. Raw IDs are acceptable fallback data, but Trackbox should prefer human-readable shipment names and source context wherever possible.

Brand-compliant implementation notes

  • Display shipment title first, tracking ID second in monospace when useful.
  • Include archived shipments in the lookup so historical activity remains understandable.
  • Fallback #N should be visually secondary and only appear when the shipment record is missing.
  • Keep the activity table scan-friendly with subtle dividers and neutral surfaces.

Additional acceptance criteria

  • Activity rows can be understood without cross-referencing numeric IDs.
  • Technical identifiers remain available but secondary.
  • Archived records retain audit readability.

Migrated from GitHub issue #24: https://github.com/bullitt186/trackbox/issues/24
Original author: @bullitt186
Original created: 2026-06-27T13:25:55Z
Original labels: ux

## Problem The Recent Scrape Activity table in Settings shows `#4`, `#16`, `#23` etc. as shipment links when the shipment name hasn't been loaded or resolved via `shipmentMap`. The `shipmentMap` is populated from `fetchShipments()` but archived shipments are not included — so archived shipment scrape log entries always show as `#N`. ## Root cause File: `frontend/src/pages/Settings.tsx` — around line 355: ```tsx const ship = shipmentMap[entry.shipment_id] // ship is undefined for archived shipments → falls back to `#${entry.shipment_id}` ``` `fetchShipments()` without args returns only active+delivered. Archived shipments are not in the map. ## Implementation ### Option A — Fetch all shipments including archived ```ts Promise.all([ fetch(`${BASE}/api/settings`).then(r => r.json()), fetch(`${BASE}/api/scrapers`).then(r => r.json()), fetchScrapeLog({ limit: 30 }), fetchShipments(), fetchShipments("archived"), // add this ]).then(([settingsData, scrapersData, logData, shipmentsData, archivedData]) => { // ... const map: Record<number, Shipment> = {} for (const s of [...shipmentsData, ...archivedData]) map[s.id] = s setShipmentMap(map) }) ``` ### Option B — Include shipment title in scrape log API response In `db.py`, modify the scrape log query to JOIN with the shipments table and include `title`. This is cleaner long-term. In `main.py`, the `/api/scrape-log` route would return `title` alongside `shipment_id`. Update the `ScrapeLogEntry` type in `frontend/src/lib/api.ts` to include `title?: string`. Then in the table: `ship?.title || entry.title || \`#${entry.shipment_id}\`` ### Recommended: Option A (immediate fix), Option B (proper fix) ## Acceptance criteria - Shipment names appear in the Recent Activity table for all shipments including archived - Fallback `#N` only shows if the shipment genuinely doesn't exist ## Brand identity alignment Recent activity is an audit surface. Raw IDs are acceptable fallback data, but Trackbox should prefer human-readable shipment names and source context wherever possible. ## Brand-compliant implementation notes - Display shipment title first, tracking ID second in monospace when useful. - Include archived shipments in the lookup so historical activity remains understandable. - Fallback `#N` should be visually secondary and only appear when the shipment record is missing. - Keep the activity table scan-friendly with subtle dividers and neutral surfaces. ## Additional acceptance criteria - Activity rows can be understood without cross-referencing numeric IDs. - Technical identifiers remain available but secondary. - Archived records retain audit readability. --- Migrated from GitHub issue #24: https://github.com/bullitt186/trackbox/issues/24 Original author: @bullitt186 Original created: 2026-06-27T13:25:55Z Original labels: ux
bullitt changed title from Settings: Recent Scrape Activity table shows raw #IDs instead of shipment names to Settings: Resolve scrape activity shipment names across active and archived records 2026-06-27 15:46:22 +02:00
Author
Owner

Implemented in commit bd6b0e7. Settings now fetches both active/delivered shipments and archived shipments at load time, merging both into shipmentMap. Shipment names now resolve correctly for all scrape activity rows including archived records. The numeric #N fallback only appears when the shipment record genuinely doesn't exist.

Implemented in commit bd6b0e7. Settings now fetches both active/delivered shipments and archived shipments at load time, merging both into `shipmentMap`. Shipment names now resolve correctly for all scrape activity rows including archived records. The numeric `#N` fallback only appears when the shipment record genuinely doesn't exist.
Sign in to join this conversation.
No labels
arch
harness
security
ux
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
bullitt/trackbox#45
No description provided.