mock: drop a real flight booking → LLM re-anchors the trip

The user drags a flight ticket (PDF/text/ics/html) onto the chat panel,
or uses the new 📎 button. The doc is text-extracted server-side
(pdftotext for PDFs; images rejected with a clear "no OCR" message),
then the LLM reads it, extracts the confirmed arrival + departure
(date, local time, airport, city) and calls a new deterministic tool,
apply_flight_anchors, which reconfigures the trip:

- re-dates the day window across the booked [arrival, departure] span
  (contiguous when the day counts match, evenly spread when they don't)
- records the flights as hard-anchor bookings, replacing placeholders
- shortens the arrival day (start after landing + a real airport→hotel
  taxi time) and the departure day (ends exactly at the booked time)
- trims stops that no longer fit and updates the trip title's range

Undo/redo and reload persistence now version the trip's bookings + title
alongside days/stays, so a re-configuration reverts and reloads cleanly.
Server gains POST /parse-doc. Verified E2E (LLM extraction + reconfigure),
idempotency, drag-and-drop, and undo; non-flight agent unaffected.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
gmp
2026-09-09 13:20:47 -04:00
co-authored by Claude
parent c7b5ecb8da
commit 88dc0c5323
4 changed files with 298 additions and 7 deletions
+3 -1
View File
@@ -112,7 +112,9 @@
<aside id="chat">
<div id="chat-body"></div>
<div id="chat-input-row">
<input id="chat-input" type="text" placeholder="Ask, direct — or “find a lunch spot”…" />
<input id="doc-file" type="file" accept=".pdf,.txt,.ics,.html,.htm,.csv,.json" hidden />
<button class="btn small" id="doc-attach" title="Drop or attach your flight booking (PDF or text) to reconfigure the trip around it">📎</button>
<input id="chat-input" type="text" placeholder="Ask, direct — or drop a booking…" />
<button class="btn primary small" id="chat-send">→</button>
</div>
</aside>