Skip to content

UX quick wins: example prompts, prototype disclaimer, honest empty state#6

Open
joaquinOEF wants to merge 4 commits into
mainfrom
feat/ux-quick-wins
Open

UX quick wins: example prompts, prototype disclaimer, honest empty state#6
joaquinOEF wants to merge 4 commits into
mainfrom
feat/ux-quick-wins

Conversation

@joaquinOEF

Copy link
Copy Markdown
Owner

Small, client-only UX improvements (the bigger UX items — PT-BR i18n, mobile, color-blind-safe risk encoding — were deferred to their own passes).

  • Example-prompt chips in the chat (auto-send on click) so users discover the assistant's capabilities without typing. Also fixed the Send button passing the click event object as the query, and refactored handleSendMessage to take an explicit prompt.
  • Prototype disclaimer in the footer: "⚠ Prototype — for exploration only, not for emergency or critical decisions." — important honesty for a risk tool.
  • Honest empty-assets state: when zero assets actually loaded (OSM down → proxy returns []), show "No critical assets loaded — data service may be unavailable" + Retry, instead of the misleading "no assets match your filters."

npm run build passes.

⚠️ Stacked on #3#4#5merge those first, then this.

🤖 Generated with Claude Code

Joaquin van Peborgh and others added 4 commits June 8, 2026 17:13
… OpenAI timeout

The /api/chat/* and /api/osm/* endpoints called OpenAI / Overpass with no auth, no rate
limit, no input validation, and no body-size cap — anyone could run up the OpenAI bill, use
us as a free proxy, or OOM the server with a huge payload.

- express-rate-limit (40/min/IP) on /api/chat and /api/osm
- zod-validate /api/chat/query (string ≤500 chars + optional bbox tuple); cap index-assets
  (≤5000), index-geojson features (≤20000), overpass query length (≤10k)
- express.json/urlencoded limit 1mb
- OpenAI client timeout 15s + maxRetries 2 (a hung call can't block the server)
- health check no longer leaks OPENAI_API_KEY presence
- .gitignore .env*

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…, bigger embed batch

- generateSummary: gpt-4o → gpt-4o-mini (~50× cheaper, fast; summary is short prose)
- compression() middleware → the ~1.9MB GeoJSON ships gzipped (~200-300KB)
- express.static maxAge 1d → repeat visits don't re-download the static assets/GeoJSON
- osmService: load the 6 risk-zone files in parallel (Promise.all) instead of sequentially
- embedding batch 50 → 500 (far fewer OpenAI round-trips → faster startup indexing)

Deferred (needs a persistent vector store to be reliable on Replit cold starts, so not a
low-risk one-liner): persisting embeddings so the server doesn't re-embed on every boot.
Mitigated here by the larger batch size. Tracked as a follow-up.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- cosineSimilarity: guard against zero-magnitude vectors (return 0, not NaN)
- bboxToH3Cells: reject inverted/degenerate bbox (was silently returning an empty filter
  that behaves like "no spatial filter")
- delete dead code left after the chat refactor: mapActionSchema,
  enhanceMapActionWithCoordinates, enhanceResponseWithGeography
- strip 45 standalone console.log statements across aiChat.ts, MapView.tsx, osmService.ts
  (kept console.error / console.warn)
- remove unused deps: overpass-ts, h3-js (never imported)

No behavior change beyond the two guards. Deferred shared/config.ts (centralizing the
duplicated PoA bbox/center) — it touches many files, so it belongs in its own pass, not this
low-risk batch.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…sets state

- AIChatBox: clickable example-prompt chips below the welcome message (auto-send) so users
  discover what the assistant can do without typing. Refactored handleSendMessage to accept
  an explicit prompt (and fixed the Send button passing the click event as the query).
- Footer: "⚠ Prototype — for exploration only, not for emergency or critical decisions."
  disclaimer (important framing for a risk tool).
- AssetsTab: when zero assets actually loaded (OSM service down → proxy returns []), show
  "No critical assets loaded — data service may be unavailable" + Retry, instead of the
  misleading "no assets match your filters".

Client-only, low-risk; npm run build passes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant