Skip to content

NL query: AI chat panel on the preview page - #52

Open
Ayobamiu wants to merge 2 commits into
mainfrom
feat/nl-query
Open

NL query: AI chat panel on the preview page#52
Ayobamiu wants to merge 2 commits into
mainfrom
feat/nl-query

Conversation

@Ayobamiu

@Ayobamiu Ayobamiu commented Jul 1, 2026

Copy link
Copy Markdown
Owner

The web UI for natural-language chat over extracted data. Pairs with the backend PR in the ai repo (POST/GET /nlquery/chat).

What's here

  • AiChatPanel (src/components/nlquery/AiChatPanel.tsx): reusable chat panel — message list, scope-aware starter-question chips, composer, render_view detail table with CSV export, and markdown-rendered assistant replies (react-markdown + remark-gfm, since the agent emits tables/headers). Loads conversation history on open.
  • api client (src/lib/api.ts): NlChatScope/View/Message/History/Turn types + nlChatHistory() / nlChat().
  • preview page (src/app/preview/[id]/page.tsx): two entry points —
    • footer button with dynamic copy per left-rail view: Ask about all records / Ask about {document type} / Ask about all files / Ask about {filename}.
    • Ask AI button in the record drawer, next to Compare.
    • Panel is resizable via antd Splitter. When both Compare and AI are open, the drawer goes full-width and squeezes into a 3-way [PDF · record · AI] split rather than making them mutually exclusive.
  • Entry points are gated on auth — the preview page is public, but chat is authed + org-scoped.

Also includes

The lean standalone /query page + apiClient.nlQuery() (one-shot NL query → table), from earlier in the effort.

Verification

Driven live in the browser (logged-in, prod data) across all four preview contexts and the record-drawer Compare+AI squeeze: dynamic button copy, data-aware starters, grounded replies, render_view table + CSV, history persist/reload. tsc clean apart from a pre-existing unrelated Button.tsx error.

🤖 Generated with Claude Code

Ayobamiu and others added 2 commits July 1, 2026 11:10
- apiClient.nlQuery() -> POST /nlquery
- /query workspace page: text box -> results table + interpreted-filter
  echo + CSV export

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Reusable conversational chat UI over the /nlquery/chat backend.

- AiChatPanel: message list, scope-aware starter chips, composer, render_view
  detail table + CSV export, markdown-rendered assistant replies (react-markdown
  + remark-gfm). Loads history on open.
- api client: NlChat* types + nlChatHistory()/nlChat().
- preview page: two entry points — footer button with dynamic copy per view
  (all records / a document type / all files / one file), and a "Ask AI" button
  in the record drawer next to Compare. Resizable via antd Splitter; when both
  Compare + AI are open the drawer squeezes into a 3-way [pdf · record · ai]
  split rather than excluding either. Gated on auth (the preview page is public;
  chat is authed + org-scoped).

Verified live in the browser against prod data across all four contexts + the
drawer squeeze. tsc clean (pre-existing Button.tsx error unrelated).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
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