Skip to content

feat(c-a2ui): Modify search prefills form with prior submit context#454

Merged
blove merged 1 commit into
mainfrom
claude/c-a2ui-modify-search-prefill
May 19, 2026
Merged

feat(c-a2ui): Modify search prefills form with prior submit context#454
blove merged 1 commit into
mainfrom
claude/c-a2ui-modify-search-prefill

Conversation

@blove
Copy link
Copy Markdown
Contributor

@blove blove commented May 19, 2026

Summary

Follow-up to PR #411 (confirmation surface). After Select → confirmation → Modify search, the booking form re-renders with the user's prior origin/dest/date/passengers/fare_class already populated as the field defaults — instead of starting blank and forcing re-entry.

Was listed as an explicit out-of-scope follow-up in PR #411's design doc; landing it now closes the loop.

How it works

  • build_form walks message history via the existing _extract_prior_submit_context helper (also used by confirm_booking)
  • New _form_defaults_from_prior(prior) projects the prior context onto the form's data_model schema (origin/dest/date/passengers/fare_class), filling missing keys from _BLANK_FORM_DEFAULTS and normalizing passengers to int
  • The _BUILD_FORM_SYSTEM prompt becomes _BUILD_FORM_SYSTEM_TMPL with a __DATA_MODEL_DEFAULTS__ sentinel substituted per-call via str.replace (avoided .format() because the prompt has many literal-brace JSON examples that would conflict with brace escaping)
  • The hardcoded _SENTINEL_BOOKING_FORM constant becomes _build_sentinel_booking_form(defaults) so the fallback path also respects prefill

Behavior matrix

Trigger data_model before data_model after
First turn (no prior submit) blank blank (unchanged)
Modify search after submit blank filled with prior values
Modify search with no prior in history (unusual) blank blank (graceful)

Files

  • cockpit/chat/a2ui/python/src/graph.py — single file, single capability change

Test plan

  • Standalone unit checks: template substitution, defaults helper (blank/partial/full prior), sentinel honors defaults
  • 3-turn programmatic real-LLM smoke: submit(LAX→JFK, 2 pax, Business) → flightSelect(UA123) → modifySearch → asserts dataModelUpdate.contents carries LAX/JFK/2026-06-15/2/Business
  • First-turn blank smoke (regression check) — still emits blank defaults
  • pnpm nx run cockpit-chat-a2ui-python:build — green
  • CI

🤖 Generated with Claude Code

After Select → confirmation surface → Modify search, the booking form
re-renders with the user's prior origin/dest/date/passengers/fare_class
already populated as the field defaults — instead of starting blank.

Today's flow: Modify search routes back through build_form which emits
the spec with hardcoded blank data_model. The render is correct but
forces the user to re-enter every field. Now build_form walks the
message history via the existing _extract_prior_submit_context helper
and seeds the form's data_model with whatever values the most recent
bookingSubmit carried.

Implementation:
- Convert _BUILD_FORM_SYSTEM (constant) to _BUILD_FORM_SYSTEM_TMPL with
  a non-brace sentinel __DATA_MODEL_DEFAULTS__ that build_form()
  substitutes per call via str.replace (.format() would conflict with
  the many literal-brace JSON examples in the prompt).
- Convert _SENTINEL_BOOKING_FORM (constant) to _build_sentinel_booking_form(defaults),
  so the sentinel honors prefilled values too — Modify search shouldn't
  blank the form if the LLM happens to retry-exhaust.
- New _form_defaults_from_prior helper projects the prior context dict
  onto the form's data_model schema, falling back to _BLANK_FORM_DEFAULTS
  for any missing keys and normalizing passengers to int.
- build_form now: extract prior → compute defaults → render prompt
  with those defaults → emit spec.

Verified via 3-turn programmatic real-LLM smoke:
  submit(LAX→JFK, 2 pax, Business) → flightSelect(UA123) → modifySearch
  → form data_model = {origin:LAX, dest:JFK, date:2026-06-15,
                       passengers:2, fare_class:Business}
First-turn blank case still emits blank defaults (regression check).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 19, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
threadplane Ready Ready Preview, Comment May 19, 2026 3:57am

Request Review

@blove blove merged commit 135a76d into main May 19, 2026
18 checks passed
@blove blove deleted the claude/c-a2ui-modify-search-prefill branch May 19, 2026 04:01
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