Coordinated fix across 31 bugs found in a parallel QA pass. Findings docs at /tmp/wrongmove-bugs/qa-round-3/qa{1,2,3,4}-*.md.
## Backend / scrape (Fix-1) — 8 bugs
- B1 [P0] Scrape totally broken on prod: pod UID 100 vs NFS dir 1000:1000 mode 775 → PermissionError on every never-seen listing. Switched Dockerfile to explicit `useradd --uid 1000 --gid 1000`; added securityContext + chown initContainer to k8s/{api,celery-beat}-deployment.yaml. Celery worker manifest lives outside this repo — Dockerfile UID change is the load-bearing fix.
- B4 [P1] Celery broker reaped every ~30s by Redis HAProxy idle timeout. Added `broker_transport_options` / `result_backend_transport_options` with `socket_keepalive=True, health_check_interval=25` in celery_app.py + same kwargs on every redis.from_url/Redis call across services/, utils/redis_lock.py, redis_repository.py.
- B5 [P1] dump_listings_task never published terminal FAILURE to the task_progress pub/sub channel — UI polled forever. Wrap body in try/except that publishes FAILURE before re-raising.
- B6 [P1] _process_worker had no per-listing exception handler — one bad listing killed the whole scrape via asyncio.gather. Wrap loop body in try/except Exception (re-raises CancelledError).
- B20 [P2] dump_listings_task gained time_limit=3600, soft_time_limit=3500, acks_late=True.
- B21 [P2] RedisRepository moved off shared db0 (was alongside paperless-ngx) to db3 via REDIS_USER_DB env var; keys prefixed `wrongmove:user:`.
- B32 [P3] redis_lock now uses uuid4() owner token + Lua compare-and-delete.
- B33 [P3] Slack notify in refresh_listings → asyncio.create_task (fire-and-forget).
## Frontend filter system (Fix-2) — 7 bugs
- B2 [P0] BUY tab click triggered "Maximum update depth exceeded" → ErrorBoundary. Replaced the three mutually-triggering useEffects in FilterBar with a single one-way controlled-value flow (URL → parent state → form), guarded by previousListingTypeRef so price-defaults fires once per real transition.
- B3 [P0] Filter values never reached the URL. Wired useFilterParams.setFilterValues into FilterBar/FilterPanel onSubmit + handleRemoveChip + new handleResetAllFilters; fed parsed filterValues into both forms' defaultValues; added URL→form sync via form.reset on browser back/forward.
- B8 [P1] Chip removal now resets form state via new FilterBar onFormReady callback — More badge no longer sticks.
- B12 [P2] Desktop swipe-review FAB added next to header (mobile FAB unchanged).
- B17 [P2] "Reset all" affordance on chip strip.
- B22 [P2] formatPrice precision: 1500 → £1.5k, 2500 → £2.5k (no longer collides with £2k/£3k defaults).
- B30 [P3] last_seen_days input gained min={0}.
## Frontend render hygiene + data integrity (Fix-3) — 8 bugs
- B7 [P1] streamingService bails on first non-NDJSON chunk (HTML response = backend down) and throws StreamParseError so the existing AlertError dialog surfaces a single user-visible error instead of 18× console.error spam.
- B9 [P1] formatDuration widened to (null|undefined|number): returns "—" for non-finite or negative, caps implausibly large values.
- B10 [P1] PropertyCard / PropertyCardCompact / SwipeCard JSX leaves render "—" for null total_price/qm/qmprice (was "£0/0 m²/£0/m²" — looked like free listings).
- B13 [P2] hexgrid worker reduceAverage uses Number.isFinite filter instead of !isNaN (which incorrectly accepted null → 0, biasing per-hex averages low).
- B14 [P2] ListingDetail Overview wraps agency in "Listed by" labelled block so it can't collapse to a bare agency name.
- B15 [P2] Compact POIDistanceBadges iterates all three travel modes with "—" for missing, matching the detail-sheet Travel table.
- B24 [P3] Drawer.Description (sr-only) added to ListingDetailSheet + MobileBottomSheet to silence Radix a11y warning.
- B25 [P3] lastSeenDays clamped to ≥0 so future timestamps don't render as "-7d ago".
## Frontend map / carousel / tasks polish (Fix-4) — 8 bugs
- B11 [P2] HexgridHeatmapClient destroy race: Map.tsx adds .catch() + ref guard so post-destroy promise rejections are silent no-ops. Verified by browser smoke (24 rapid Map↔List toggles → 0 pageErrors).
- B16 [P2] PhotoCarousel + inner CardCarousel gained keyboard nav (Arrow keys).
- B18 [P2] Default map center moved from Czech Republic to London (zoom 10).
- B19+B29 [P2/P3] Mapbox token: no longer hard-coded fallback; reads env-only and shows a clear "Map unavailable — set VITE_MAPBOX_TOKEN" banner when missing.
- B23 [P3] PhotoCarousel suppresses "1/1" counter for single-photo listings; added onError fallback for broken URLs.
- B26 [P3] PhotoCarousel only enables loop when photos.length > 1.
- B27 [P3] TaskIndicator cancel/clear-all buttons gained aria-label + data-testid.
- B28 [P3] useTaskProgress strips terminal-local task IDs from the polling union — no more forever-poll on completed tasks.
## Tests
74 new vitest tests + 18 new pytest tests. Local: tsc clean, 201 vitest tests pass, 633 pytest tests pass.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
286 lines
12 KiB
TypeScript
286 lines
12 KiB
TypeScript
import { ExternalLink, Heart, X, Bed, Maximize2, PoundSterling, Building, Clock, MapPin, Footprints, Bike, Train } from 'lucide-react';
|
|
import { Button } from './ui/button';
|
|
import { Tabs, TabsList, TabsTrigger, TabsContent } from './ui/tabs';
|
|
import { PhotoCarousel } from './PhotoCarousel';
|
|
import type { ListingDetailData, DecisionType, POIDistanceInfo } from '@/types';
|
|
import { formatDate, formatDuration } from '@/utils/format';
|
|
|
|
interface ListingDetailProps {
|
|
detail: ListingDetailData;
|
|
onDecide: (decision: DecisionType) => void;
|
|
onClearDecision: () => void;
|
|
}
|
|
|
|
function TravelModeLabel({ mode }: { mode: string }) {
|
|
switch (mode) {
|
|
case 'WALK': return 'Walk';
|
|
case 'BICYCLE': return 'Cycle';
|
|
case 'TRANSIT': return 'Transit';
|
|
default: return mode;
|
|
}
|
|
}
|
|
|
|
export function ListingDetail({ detail, onDecide, onClearDecision }: ListingDetailProps) {
|
|
const allPhotos = [
|
|
...detail.photos,
|
|
...detail.floorplans.map(fp => ({ url: fp.url, caption: fp.caption || 'Floorplan', type: 'FLOORPLAN' as string | null })),
|
|
];
|
|
|
|
const pricePerSqm = detail.square_meters ? Math.round(detail.price / detail.square_meters) : null;
|
|
|
|
// Group POI distances by POI name for the travel table
|
|
const poiGroups = new Map<string, Map<string, POIDistanceInfo>>();
|
|
for (const d of detail.poi_distances) {
|
|
if (!poiGroups.has(d.poi_name)) {
|
|
poiGroups.set(d.poi_name, new Map());
|
|
}
|
|
poiGroups.get(d.poi_name)!.set(d.travel_mode, d);
|
|
}
|
|
|
|
// Check which tabs have content
|
|
const hasOverview = detail.key_features.length > 0 || !!detail.description;
|
|
const hasTravel = detail.poi_distances.length > 0;
|
|
const hasPriceHistory = detail.price_history.length > 1;
|
|
const hasDetails = !!(detail.property_sub_type || detail.furnish_type || detail.council_tax_band || detail.available_from || detail.service_charge != null || detail.lease_left != null);
|
|
|
|
return (
|
|
<div className="pb-8">
|
|
{/* Photo carousel - always visible above tabs */}
|
|
<PhotoCarousel photos={allPhotos} />
|
|
|
|
<div className="px-4 pt-4 space-y-4">
|
|
{/* Price header */}
|
|
<div>
|
|
<div className="flex items-start justify-between">
|
|
<div>
|
|
<div className="text-2xl font-bold tracking-tight">
|
|
£{detail.price.toLocaleString()}
|
|
{detail.listing_type !== 'BUY' && (
|
|
<span className="text-muted-foreground font-normal text-base">/mo</span>
|
|
)}
|
|
</div>
|
|
{/* Key metrics */}
|
|
<div className="flex items-center gap-1.5 text-sm text-muted-foreground mt-1">
|
|
<span className="flex items-center gap-1">
|
|
<Bed className="h-3.5 w-3.5" />
|
|
{detail.number_of_bedrooms} bed
|
|
</span>
|
|
<span>·</span>
|
|
<span className="flex items-center gap-1">
|
|
<Maximize2 className="h-3.5 w-3.5" />
|
|
{detail.square_meters ?? '\u2014'} m²
|
|
</span>
|
|
{pricePerSqm && (
|
|
<>
|
|
<span>·</span>
|
|
<span className="flex items-center gap-1">
|
|
<PoundSterling className="h-3.5 w-3.5" />
|
|
£{pricePerSqm}/m²
|
|
</span>
|
|
</>
|
|
)}
|
|
</div>
|
|
{detail.display_address && (
|
|
<div className="flex items-center gap-1 text-sm text-muted-foreground mt-1">
|
|
<MapPin className="h-3.5 w-3.5" />
|
|
{detail.display_address}
|
|
</div>
|
|
)}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{/* Action buttons */}
|
|
<div className="flex gap-2">
|
|
<Button
|
|
variant={detail.decision === 'disliked' ? 'destructive' : 'outline'}
|
|
className="flex-1"
|
|
onClick={() => detail.decision === 'disliked' ? onClearDecision() : onDecide('disliked')}
|
|
>
|
|
<X className="h-4 w-4 mr-2" />
|
|
{detail.decision === 'disliked' ? 'Disliked' : 'Dislike'}
|
|
</Button>
|
|
<Button
|
|
variant={detail.decision === 'liked' ? 'default' : 'outline'}
|
|
className={`flex-1 ${detail.decision === 'liked' ? 'bg-green-600 hover:bg-green-700' : ''}`}
|
|
onClick={() => detail.decision === 'liked' ? onClearDecision() : onDecide('liked')}
|
|
>
|
|
<Heart className={`h-4 w-4 mr-2 ${detail.decision === 'liked' ? 'fill-current' : ''}`} />
|
|
{detail.decision === 'liked' ? 'Liked' : 'Like'}
|
|
</Button>
|
|
<Button asChild variant="outline" size="icon" className="shrink-0">
|
|
<a href={detail.url} target="_blank" rel="noopener noreferrer" title="View on Rightmove">
|
|
<ExternalLink className="h-4 w-4" />
|
|
</a>
|
|
</Button>
|
|
</div>
|
|
|
|
{/* Tabbed sections */}
|
|
<Tabs defaultValue="overview">
|
|
<TabsList>
|
|
<TabsTrigger value="overview">Overview</TabsTrigger>
|
|
{hasTravel && <TabsTrigger value="travel">Travel</TabsTrigger>}
|
|
{hasPriceHistory && <TabsTrigger value="price-history">Price</TabsTrigger>}
|
|
{hasDetails && <TabsTrigger value="details">Details</TabsTrigger>}
|
|
</TabsList>
|
|
|
|
{/* Overview tab */}
|
|
<TabsContent value="overview" className="space-y-4">
|
|
{detail.key_features.length > 0 && (
|
|
<div>
|
|
<h3 className="text-sm font-semibold mb-2">Key Features</h3>
|
|
<ul className="list-disc list-inside text-sm text-muted-foreground space-y-1">
|
|
{detail.key_features.map((f, i) => (
|
|
<li key={i}>{f}</li>
|
|
))}
|
|
</ul>
|
|
</div>
|
|
)}
|
|
|
|
{detail.description && (
|
|
<div>
|
|
<h3 className="text-sm font-semibold mb-2">Description</h3>
|
|
<p className="text-sm text-muted-foreground whitespace-pre-line">{detail.description}</p>
|
|
</div>
|
|
)}
|
|
|
|
{/* Floorplans */}
|
|
{detail.floorplans.length > 0 && (
|
|
<div>
|
|
<h3 className="text-sm font-semibold mb-2">Floorplans</h3>
|
|
<div className="space-y-2">
|
|
{detail.floorplans.map((fp, i) => (
|
|
<img key={i} src={fp.url} alt={fp.caption || 'Floorplan'} className="w-full rounded-md border" />
|
|
))}
|
|
</div>
|
|
</div>
|
|
)}
|
|
|
|
{/* Agency — wrapped in a labelled block so the Overview tab doesn't
|
|
collapse to just "Foxtons" when description/key_features/floorplans are empty. */}
|
|
{detail.agency && (
|
|
<div>
|
|
<h3 className="text-sm font-semibold mb-2">Listed by</h3>
|
|
<div className="flex items-center gap-2 text-sm text-muted-foreground">
|
|
<Building className="h-4 w-4" />
|
|
<span>{detail.agency}</span>
|
|
</div>
|
|
</div>
|
|
)}
|
|
|
|
{!hasOverview && !detail.floorplans.length && !detail.agency && (
|
|
<p className="text-sm text-muted-foreground">No overview information available.</p>
|
|
)}
|
|
</TabsContent>
|
|
|
|
{/* Travel tab */}
|
|
{hasTravel && (
|
|
<TabsContent value="travel">
|
|
<div className="overflow-x-auto">
|
|
<table className="w-full text-sm">
|
|
<thead>
|
|
<tr className="border-b">
|
|
<th className="text-left py-2 pr-4 font-medium text-muted-foreground">Destination</th>
|
|
<th className="text-center py-2 px-2 font-medium text-muted-foreground">
|
|
<span className="inline-flex items-center gap-1"><Footprints className="h-3 w-3" /> <TravelModeLabel mode="WALK" /></span>
|
|
</th>
|
|
<th className="text-center py-2 px-2 font-medium text-muted-foreground">
|
|
<span className="inline-flex items-center gap-1"><Bike className="h-3 w-3" /> <TravelModeLabel mode="BICYCLE" /></span>
|
|
</th>
|
|
<th className="text-center py-2 px-2 font-medium text-muted-foreground">
|
|
<span className="inline-flex items-center gap-1"><Train className="h-3 w-3" /> <TravelModeLabel mode="TRANSIT" /></span>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{Array.from(poiGroups.entries()).map(([poiName, modes]) => (
|
|
<tr key={poiName} className="border-b last:border-0">
|
|
<td className="py-2 pr-4 font-medium">{poiName}</td>
|
|
{(['WALK', 'BICYCLE', 'TRANSIT'] as const).map(mode => {
|
|
const d = modes.get(mode);
|
|
return (
|
|
<td key={mode} className="py-2 px-2 text-center text-muted-foreground">
|
|
{d ? formatDuration(d.duration_seconds) : '\u2014'}
|
|
</td>
|
|
);
|
|
})}
|
|
</tr>
|
|
))}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</TabsContent>
|
|
)}
|
|
|
|
{/* Price History tab */}
|
|
{hasPriceHistory && (
|
|
<TabsContent value="price-history">
|
|
<div className="space-y-2">
|
|
{detail.price_history.map((entry) => (
|
|
<div key={entry.id} className="flex justify-between items-center text-sm py-1.5 border-b last:border-0">
|
|
<span className="text-muted-foreground">
|
|
{typeof entry.last_seen === 'string' ? entry.last_seen.split('T')[0] : '—'}
|
|
</span>
|
|
<span className="font-medium">
|
|
£{typeof entry.price === 'number' && Number.isFinite(entry.price) ? entry.price.toLocaleString() : '—'}
|
|
</span>
|
|
</div>
|
|
))}
|
|
</div>
|
|
</TabsContent>
|
|
)}
|
|
|
|
{/* Details tab */}
|
|
{hasDetails && (
|
|
<TabsContent value="details">
|
|
<div className="grid grid-cols-2 gap-3 text-sm">
|
|
{detail.property_sub_type && (
|
|
<div className="space-y-0.5">
|
|
<div className="text-xs text-muted-foreground">Property Type</div>
|
|
<div className="font-medium flex items-center gap-1.5">
|
|
<Building className="h-3.5 w-3.5 text-muted-foreground" />
|
|
{detail.property_sub_type}
|
|
</div>
|
|
</div>
|
|
)}
|
|
{detail.furnish_type && (
|
|
<div className="space-y-0.5">
|
|
<div className="text-xs text-muted-foreground">Furnishing</div>
|
|
<div className="font-medium">{detail.furnish_type}</div>
|
|
</div>
|
|
)}
|
|
{detail.council_tax_band && (
|
|
<div className="space-y-0.5">
|
|
<div className="text-xs text-muted-foreground">Council Tax</div>
|
|
<div className="font-medium">Band {detail.council_tax_band}</div>
|
|
</div>
|
|
)}
|
|
{detail.lease_left != null && (
|
|
<div className="space-y-0.5">
|
|
<div className="text-xs text-muted-foreground">Lease Remaining</div>
|
|
<div className="font-medium">{detail.lease_left} years</div>
|
|
</div>
|
|
)}
|
|
{detail.service_charge != null && (
|
|
<div className="space-y-0.5">
|
|
<div className="text-xs text-muted-foreground">Service Charge</div>
|
|
<div className="font-medium">£{detail.service_charge.toLocaleString()}</div>
|
|
</div>
|
|
)}
|
|
{detail.available_from && (
|
|
<div className="space-y-0.5">
|
|
<div className="text-xs text-muted-foreground">Available From</div>
|
|
<div className="font-medium flex items-center gap-1.5">
|
|
<Clock className="h-3.5 w-3.5 text-muted-foreground" />
|
|
{formatDate(detail.available_from)}
|
|
</div>
|
|
</div>
|
|
)}
|
|
</div>
|
|
</TabsContent>
|
|
)}
|
|
</Tabs>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|