From e539860530a74c4fd190f2a10105feb6ee9670d1 Mon Sep 17 00:00:00 2001 From: Maurice Date: Tue, 1 Dec 2026 21:06:05 +0100 Subject: [PATCH] fix(quality): resolve reliability findings on dev The Sonar quality gate rated new code D. Preserve focus and keyboard interaction through native controls and shared dialog behavior. Replace ambiguous regex scans with bounded parsing and make numeric coercion and initialization explicit. --- .../Admin/PackingTemplateManager.tsx | 11 +- .../components/Admin/SchoolHolidayCatalog.tsx | 2 +- .../Admin/SchoolHolidayRegionEditor.tsx | 2 +- .../components/AtlasGlobe/AtlasGlobe.test.tsx | 4 + .../src/components/AtlasGlobe/AtlasGlobe.tsx | 2 +- .../components/AtlasGlobe/GlobeEngine.test.ts | 12 +- .../src/components/AtlasGlobe/GlobeEngine.ts | 9 +- .../src/components/AtlasGlobe/globeTheme.ts | 2 +- client/src/components/Budget/CostsTable.tsx | 3 +- client/src/components/Budget/CostsToolbar.tsx | 2 +- client/src/components/Collab/CollabLinks.tsx | 3 +- client/src/components/Collab/CollabPolls.tsx | 2 +- .../Collections/AddPlaceToCollectionModal.tsx | 1 - .../Collections/CollectionExportMenu.tsx | 1 + .../Collections/CollectionPlaceDetail.tsx | 3 +- .../Collections/CopyToTripModal.tsx | 2 +- .../Collections/MoveToListModal.tsx | 2 +- .../Collections/OriginNotesSection.tsx | 10 +- .../components/Collections/PlaceEditForm.tsx | 3 +- .../components/Collections/PlaceTagsCard.tsx | 3 +- .../Collections/SaveTripPlacesToListModal.tsx | 2 +- .../Collections/usePlaceDuplicates.ts | 4 +- client/src/components/Demo/DemoWelcome.tsx | 3 +- .../Files/docsync/DocSyncConnectModal.tsx | 8 +- .../Journey/ContributorInviteDialog.tsx | 2 +- .../JourneyDetailPageAddTripDialog.tsx | 2 +- client/src/components/Map/valhallaRoute.ts | 3 +- .../Packing/PackingListPanelBagCard.tsx | 5 +- .../Packing/PackingListPanelBagModal.tsx | 3 +- .../Packing/PackingListPanelBagSidebar.tsx | 3 +- .../Packing/PackingListPanelCategoryGroup.tsx | 7 +- .../Packing/packingListPanel.helpers.ts | 5 +- .../DayPlanSidebarMobileAddPlaceButton.tsx | 3 +- .../Planner/PlaceFormHeaderPills.tsx | 3 +- .../src/components/Planner/PlaceFormModal.tsx | 2 +- .../Planner/PlacesSidebarListImportModal.tsx | 2 +- .../Planner/ReservationsPanel.test.tsx | 2 +- .../Planner/ReservationsPanel.views.test.tsx | 6 +- .../Planner/bookings/BookingCard.tsx | 180 +++++++++--------- .../Planner/bookings/BookingsHeader.tsx | 2 +- .../Planner/bookings/BookingsList.tsx | 16 +- client/src/components/Planner/placeRefresh.ts | 5 +- .../src/components/Roadtrip/SettingsHint.tsx | 2 +- .../components/Settings/ApiKeysSection.tsx | 2 +- .../components/Settings/IntegrationsTab.tsx | 14 +- .../components/Settings/PasskeysSection.tsx | 3 +- .../components/Settings/WandererWatchRow.tsx | 13 +- client/src/components/Studio/StudioCanvas.tsx | 3 +- .../components/Studio/StudioFontPicker.tsx | 17 +- .../components/Studio/StudioLayersPanel.tsx | 4 +- .../components/Studio/StudioPaintPicker.tsx | 13 +- client/src/components/Todo/TodoListPanel.tsx | 3 +- .../src/components/Tours/TourDetailDialog.tsx | 3 +- .../Tours/horse/RecordedRideFacts.tsx | 7 +- .../Tours/library/TourLibraryDialog.tsx | 2 +- .../Tours/planner/TripPlacePicker.tsx | 33 +++- .../Tours/planner/tripPlaces.test.tsx | 2 +- .../Tours/wanderer/WandererBrowserRail.tsx | 1 - .../src/components/Trips/TripShareDialog.tsx | 3 +- .../shared/CustomDateTimePicker.tsx | 3 +- client/src/components/shared/DialogShell.tsx | 2 +- client/src/components/shared/dialogFocus.ts | 5 + client/src/mobile/components/MDayPager.tsx | 2 +- client/src/mobile/components/MRail.tsx | 2 +- .../mobile/components/trek3d/MascotClip.tsx | 6 +- .../screens/admin/MAdminCategoryManager.tsx | 1 - .../collections/MOriginNotesSection.tsx | 3 +- .../mobile/screens/journey/MJourneyDetail.tsx | 2 +- .../screens/journey/mobileJourneyMeta.ts | 6 +- .../screens/trip/plan/MPlanTimeline.tsx | 3 +- .../trip/sheets/MTripSettingsSheet.tsx | 3 +- .../screens/trip/sheets/PlCategoryPicker.tsx | 3 +- .../mobile/screens/trip/tabs/MBagsSheet.tsx | 7 +- .../mobile/screens/trip/tabs/MCollabNotes.tsx | 3 +- .../screens/trip/tabs/MDocSyncSheet.tsx | 2 +- .../screens/trip/tabs/MPackingListTab.tsx | 9 +- .../mobile/screens/trip/tabs/MTaskSheet.tsx | 3 +- .../mobile/screens/trip/tabs/tabChrome.tsx | 2 +- client/src/native/serverAddress.ts | 3 +- client/src/pages/ResetPasswordPage.tsx | 1 - client/src/pages/atlas/AtlasGlobeWishAdd.tsx | 3 +- client/src/pages/atlas/atlasGlobePaint.ts | 2 +- client/src/pages/atlas/useAtlasGlobe.ts | 2 +- client/src/repo/mapMatchRepo.ts | 4 +- client/src/utils/colorSpace.ts | 2 +- server/src/app-config/parsers.ts | 11 +- server/src/db/engine/postgres/pg-tools.ts | 13 +- .../postgres/sqlite-move/plugin-data.ts | 2 +- .../db/engine/postgres/sqlite-move/values.ts | 2 +- server/src/nest/assistant/assistant-home.ts | 3 +- server/src/nest/atlas/city-from-address.ts | 4 +- .../nest/doc-sync/doc-sync-config.service.ts | 9 +- .../providers/synology-drive.client.ts | 4 +- .../nest/doc-sync/providers/webdav.client.ts | 13 +- .../doc-sync/providers/webdav.provider.ts | 7 +- .../nest/flight-live/flight-live.derive.ts | 12 +- server/src/nest/help/wiki.ts | 40 ++-- .../src/nest/integrations/dawarich.helpers.ts | 4 +- .../nest/journey/book-design-draft.store.ts | 11 +- server/src/nest/llm-parse/mime-walker.ts | 17 +- .../mail-ingest-address.service.ts | 5 +- .../mail-ingest-inbound.controller.ts | 7 +- server/src/nest/maps/trek-places.client.ts | 3 +- server/src/nest/maps/trek-places.fetch.ts | 2 +- .../notifications/transports/ntfy.service.ts | 3 +- .../place-contrib/place-contrib-settings.ts | 3 +- server/src/nest/platform/platform.routes.ts | 18 +- .../src/nest/plugins/install/safe-extract.ts | 2 +- server/src/nest/plugins/mcp-tool-schema.ts | 9 +- .../nest/roadtrip/roadtrip-router.service.ts | 5 +- .../routing-relay/routing-relay.service.ts | 9 +- .../service-identity/registration-dialect.ts | 2 +- .../service-identity.helpers.ts | 4 +- server/src/nest/sessions/sessions.service.ts | 2 +- .../nest/ski-routing/ski-graph.contract.ts | 8 +- .../nest/storage/storage-reclaim.ledger.ts | 3 +- .../src/nest/tours/tours-import.controller.ts | 10 +- .../nest/wallet-pass/wallet-pass.service.ts | 2 +- server/src/nest/wanderer/wanderer.client.ts | 11 +- shared/src/book/design/design-framing.ts | 7 +- shared/src/book/design/design-random.ts | 2 +- shared/src/common/strip-markdown.spec.ts | 16 +- shared/src/common/strip-markdown.ts | 34 +++- shared/src/common/strip-trailing-slashes.ts | 6 + shared/src/index.ts | 1 + shared/src/trip/day-grid.ts | 2 +- shared/src/trip/trip.schema.ts | 2 +- 127 files changed, 548 insertions(+), 338 deletions(-) create mode 100644 shared/src/common/strip-trailing-slashes.ts diff --git a/client/src/components/Admin/PackingTemplateManager.tsx b/client/src/components/Admin/PackingTemplateManager.tsx index be06e6e98..da62d7487 100644 --- a/client/src/components/Admin/PackingTemplateManager.tsx +++ b/client/src/components/Admin/PackingTemplateManager.tsx @@ -1,3 +1,4 @@ +import { focusRevealedEditor } from '../shared/dialogFocus' import { useTranslation } from '../../i18n' import { Plus, Trash2, Pencil, Package, X, Check, ChevronRight, FolderPlus, Loader2 } from 'lucide-react' import { fs } from '../shared/DialogShell' @@ -57,7 +58,7 @@ export default function PackingTemplateManager() { {showCreate && (
- setCreateName(e.target.value)} + setCreateName(e.target.value)} onKeyDown={e => { if (e.key === 'Enter') void handleCreateTemplate(); if (e.key === 'Escape') setShowCreate(false) }} placeholder={t('admin.packingTemplates.namePlaceholder')} className={COMPOSER_INPUT} style={fs(13, 'body')} /> @@ -101,7 +102,7 @@ export default function PackingTemplateManager() { {editingTemplate === tmpl.id ? ( - setEditTemplateName(e.target.value)} + setEditTemplateName(e.target.value)} onBlur={() => handleRenameTemplate(tmpl.id)} onKeyDown={e => { if (e.key === 'Enter') void handleRenameTemplate(tmpl.id); if (e.key === 'Escape') setEditingTemplate(null) }} aria-label={t('common.rename')} @@ -132,7 +133,7 @@ export default function PackingTemplateManager() { {/* Category header */}
{editingCatId === cat.id ? ( - setEditCatName(e.target.value)} + setEditCatName(e.target.value)} onBlur={() => handleRenameCategory(cat.id)} onKeyDown={e => { if (e.key === 'Enter') void handleRenameCategory(cat.id); if (e.key === 'Escape') setEditingCatId(null) }} aria-label={t('common.rename')} @@ -162,7 +163,7 @@ export default function PackingTemplateManager() {
{editingItemId === item.id ? ( <> - setEditItemName(e.target.value)} + setEditItemName(e.target.value)} onKeyDown={e => { if (e.key === 'Enter') void handleRenameItem(item.id); if (e.key === 'Escape') setEditingItemId(null) }} aria-label={t('common.rename')} className={`${ROW_INPUT} flex-1`} style={fs(12.5, 'body')} /> @@ -219,7 +220,7 @@ export default function PackingTemplateManager() { {/* Add category */} {addingCategory ? (
- setNewCatName(e.target.value)} + setNewCatName(e.target.value)} onKeyDown={e => { if (e.key === 'Enter') void handleAddCategory(); if (e.key === 'Escape') { setAddingCategory(false); setNewCatName('') } }} placeholder={t('admin.packingTemplates.categoryName')} className={COMPOSER_INPUT} style={fs(13, 'body')} /> diff --git a/client/src/components/Admin/SchoolHolidayCatalog.tsx b/client/src/components/Admin/SchoolHolidayCatalog.tsx index 849316232..39954895d 100644 --- a/client/src/components/Admin/SchoolHolidayCatalog.tsx +++ b/client/src/components/Admin/SchoolHolidayCatalog.tsx @@ -67,7 +67,7 @@ function Catalog() { }}>
- setName(event.target.value)} /> + setName(event.target.value)} /> setCode(event.target.value.toUpperCase())} placeholder="US" /> diff --git a/client/src/components/Admin/SchoolHolidayRegionEditor.tsx b/client/src/components/Admin/SchoolHolidayRegionEditor.tsx index 273ead59f..3c2001055 100644 --- a/client/src/components/Admin/SchoolHolidayRegionEditor.tsx +++ b/client/src/components/Admin/SchoolHolidayRegionEditor.tsx @@ -62,7 +62,7 @@ export default function SchoolHolidayRegionEditor({ region, busy, offline = fals
- setName(event.target.value)} /> + setName(event.target.value)} /> {t('schoolCatalog.periodHint')} {holidays.map((holiday, index) => { diff --git a/client/src/components/AtlasGlobe/AtlasGlobe.test.tsx b/client/src/components/AtlasGlobe/AtlasGlobe.test.tsx index bbf11c0a7..7f165fa84 100644 --- a/client/src/components/AtlasGlobe/AtlasGlobe.test.tsx +++ b/client/src/components/AtlasGlobe/AtlasGlobe.test.tsx @@ -17,6 +17,10 @@ const h = vi.hoisted(() => { insets: number[] = []; kicks = 0; disposed = false; + static create(opts: GlobeEngineOptions): FakeEngine { + return new FakeEngine(opts); + } + constructor(opts: GlobeEngineOptions) { if (state.failNext !== null) { const err = state.failNext; diff --git a/client/src/components/AtlasGlobe/AtlasGlobe.tsx b/client/src/components/AtlasGlobe/AtlasGlobe.tsx index 271d57ef9..2fddc88a4 100644 --- a/client/src/components/AtlasGlobe/AtlasGlobe.tsx +++ b/client/src/components/AtlasGlobe/AtlasGlobe.tsx @@ -54,7 +54,7 @@ const AtlasGlobe = forwardRef(function AtlasG if (!canvas) return; let engine: GlobeEngine; try { - engine = new GlobeEngine({ + engine = GlobeEngine.create({ canvas, fetchJson: (p) => propsRef.current.fetchJson(p), theme: globeTheme(propsRef.current.dark), diff --git a/client/src/components/AtlasGlobe/GlobeEngine.test.ts b/client/src/components/AtlasGlobe/GlobeEngine.test.ts index 81755681f..06bb56ed3 100644 --- a/client/src/components/AtlasGlobe/GlobeEngine.test.ts +++ b/client/src/components/AtlasGlobe/GlobeEngine.test.ts @@ -210,7 +210,7 @@ async function start(o: StartOptions = {}) { onSelect: vi.fn(), onFrame: vi.fn(), }; - const engine = new mod.GlobeEngine({ canvas, fetchJson, theme: o.theme ?? LIGHT, initial: o.initial, ...cb }); + const engine = mod.GlobeEngine.create({ canvas, fetchJson, theme: o.theme ?? LIGHT, initial: o.initial, ...cb }); engines.push(engine); return { mod, @@ -310,7 +310,7 @@ describe('GlobeEngine boot', () => { const otherFetch = vi.fn(async (): Promise => null); const canvas = document.createElement('canvas'); const onReady = vi.fn(); - const second = new first.mod.GlobeEngine({ canvas, fetchJson: otherFetch, theme: LIGHT, onReady }); + const second = first.mod.GlobeEngine.create({ canvas, fetchJson: otherFetch, theme: LIGHT, onReady }); engines.push(second); await flush(); expect(otherFetch).not.toHaveBeenCalled(); @@ -345,7 +345,7 @@ describe('GlobeEngine boot retries', () => { }); const onError = vi.fn(); engines.push( - new mod.GlobeEngine({ canvas: document.createElement('canvas'), fetchJson: fail, theme: LIGHT, onError }) + mod.GlobeEngine.create({ canvas: document.createElement('canvas'), fetchJson: fail, theme: LIGHT, onError }) ); const delays: number[] = []; for (let i = 0; i < 4; i++) { @@ -364,7 +364,7 @@ describe('GlobeEngine boot retries', () => { const ok = vi.fn(async (p: string): Promise => files[p]); const onReady = vi.fn(); engines.push( - new mod.GlobeEngine({ canvas: document.createElement('canvas'), fetchJson: ok, theme: LIGHT, onReady }) + mod.GlobeEngine.create({ canvas: document.createElement('canvas'), fetchJson: ok, theme: LIGHT, onReady }) ); await flush(); expect(ok).toHaveBeenCalledWith('manifest'); @@ -381,7 +381,9 @@ describe('GlobeEngine boot retries', () => { return files[p]; }); const onReady = vi.fn(); - engines.push(new mod.GlobeEngine({ canvas: document.createElement('canvas'), fetchJson, theme: LIGHT, onReady })); + engines.push( + mod.GlobeEngine.create({ canvas: document.createElement('canvas'), fetchJson, theme: LIGHT, onReady }) + ); await flush(); expect(pending.map((t) => t.ms)).toEqual([1000]); pending[0].cb(); diff --git a/client/src/components/AtlasGlobe/GlobeEngine.ts b/client/src/components/AtlasGlobe/GlobeEngine.ts index 5f9b205b9..7bed1952f 100644 --- a/client/src/components/AtlasGlobe/GlobeEngine.ts +++ b/client/src/components/AtlasGlobe/GlobeEngine.ts @@ -164,7 +164,13 @@ export class GlobeEngine { private sun: [number, number, number] = sunVector(new Date()); private sunAt = 0; - constructor(opts: GlobeEngineOptions) { + static create(opts: GlobeEngineOptions): GlobeEngine { + const engine = new GlobeEngine(opts); + void engine.boot(); + return engine; + } + + private constructor(opts: GlobeEngineOptions) { this.opts = opts; this.theme = opts.theme; Object.assign(this.cam, opts.initial ?? {}); @@ -187,7 +193,6 @@ export class GlobeEngine { this.resizeObs.observe(opts.canvas); opts.canvas.addEventListener('webglcontextlost', this.onContextLost); this.resize(); - void this.boot(); } // ---------------------------------------------------------------- loading diff --git a/client/src/components/AtlasGlobe/globeTheme.ts b/client/src/components/AtlasGlobe/globeTheme.ts index 496d37859..437faf4d7 100644 --- a/client/src/components/AtlasGlobe/globeTheme.ts +++ b/client/src/components/AtlasGlobe/globeTheme.ts @@ -14,7 +14,7 @@ export function hexToRgb(hex: string): Rgb { .map((c) => c + c) .join('') : h.slice(0, 6); - const n = parseInt(full, 16); + const n = Number.parseInt(full, 16); if (Number.isNaN(n)) return [0.5, 0.5, 0.5]; return [((n >> 16) & 255) / 255, ((n >> 8) & 255) / 255, (n & 255) / 255]; } diff --git a/client/src/components/Budget/CostsTable.tsx b/client/src/components/Budget/CostsTable.tsx index 574d01275..6c9bf5b2d 100644 --- a/client/src/components/Budget/CostsTable.tsx +++ b/client/src/components/Budget/CostsTable.tsx @@ -1,3 +1,4 @@ +import { focusRevealedEditor } from '../shared/dialogFocus' import { useMemo, useRef, useState, type KeyboardEvent, type ReactNode } from 'react' import { ChevronDown, Lock, Pencil, Plus, Trash2 } from 'lucide-react' import { useTranslation } from '../../i18n' @@ -307,7 +308,7 @@ function TextInput({ value, onSave, onCancel, label, numeric = false }: { if (ev.key === 'Escape') { ev.preventDefault(); ev.stopPropagation(); finish(onCancel) } } return ( - setDraft(ev.target.value)} onKeyDown={onKey} onBlur={() => finish(() => onSave(draft))} className={`${INPUT} ${numeric ? 'text-center tabular-nums' : ''}`} /> ) diff --git a/client/src/components/Budget/CostsToolbar.tsx b/client/src/components/Budget/CostsToolbar.tsx index 03cbe88ae..6af0e15fa 100644 --- a/client/src/components/Budget/CostsToolbar.tsx +++ b/client/src/components/Budget/CostsToolbar.tsx @@ -197,7 +197,7 @@ function FilterMenu(f: CostsFilterProps & { splitting: boolean }) { {open && ( -
{ if (e.key === 'Escape') close() }} className="absolute end-0 top-11 z-30" style={{ ...POPOVER, width: 310 }}> +
{ if (e.key === 'Escape') close() }} className="absolute end-0 top-11 z-30" style={{ ...POPOVER, width: 310 }}> {f.splitting && <>
{owners.map(([o, label]) => ( diff --git a/client/src/components/Collab/CollabLinks.tsx b/client/src/components/Collab/CollabLinks.tsx index 327aa5b60..2addf3b7b 100644 --- a/client/src/components/Collab/CollabLinks.tsx +++ b/client/src/components/Collab/CollabLinks.tsx @@ -1,3 +1,4 @@ +import { focusRevealedEditor } from '../shared/dialogFocus' import { cloneElement, CSSProperties, FormEvent, ReactElement, useEffect, useId, useRef, useState } from 'react' import { createPortal } from 'react-dom' import { ExternalLink, Link2, Pencil, Pin, Plus, Trash2, X } from 'lucide-react' @@ -147,7 +148,7 @@ function LinkModal({ link, onClose, onSave }: { link?: CollabLink; onClose: () =
- setTitle(e.target.value)} placeholder={t('collab.links.titlePlaceholder')} autoFocus style={field} /> + setTitle(e.target.value)} placeholder={t('collab.links.titlePlaceholder')} ref={focusRevealedEditor} style={field} />
diff --git a/client/src/components/Collab/CollabPolls.tsx b/client/src/components/Collab/CollabPolls.tsx index f42d84349..c7cd8163c 100644 --- a/client/src/components/Collab/CollabPolls.tsx +++ b/client/src/components/Collab/CollabPolls.tsx @@ -118,7 +118,7 @@ function CreatePollModal({ onClose, onCreate, t }: CreatePollModalProps) { )} > -