Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .changeset/39507-cited-passage-reader.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
'@object-ui/plugin-chatbot': patch
'@object-ui/app-shell': patch
'@object-ui/i18n': patch
---

feat(console): a cited passage opens where the answer quotes it, in a body reader beside the conversation

Clause-②: yes (widening)
Metadata-protocol: none

Who sees it: anyone reading an AI answer that cites records (ADR-0160 D9, as amended for objectstack-ai/objectstack#39505). What is drawn as a citation is the turn's verified list, no more and no fewer: a passage the answer quotes that the turn did not cite stays plain text.

- **The passages the answer quotes are the links** (`@object-ui/plugin-chatbot`, inside `ChatbotEnhanced`). Once the answer has finished, each passage of the answer that quotes a verified citation, whole or as an excerpt inside quotation marks, is underlined; a click opens that citation's record at the passage through the host's `onOpenRecord`, which now also receives `quote`, `context` and `siblingQuotes` (the answer's other cited passages of the same record). An ellipsis, or the `|` of a quoted table row, splits an excerpt into pieces that each must be in the passage; the block quoting the most of a passage is the one marked. A record link in a cited answer opens its record with every passage of it the answer cites. A citation the answer does not quote is listed as a chip under it, as before. A turn's citations are drawn once, under its answer.
- **Citations survive a reload.** The chat (`@object-ui/plugin-chatbot`, internally) reads a stored message's verified list back off its last `cite_records` result when the message carries no citation part. The exported `hydratedMessagesToChatMessages` (`@object-ui/app-shell`) now moves a turn's `recordCitations` to the turn's last assistant message and removes them from the turn's earlier rows.
- **The body reader** (`@object-ui/app-shell`, internal to the console's chat). A cited open shows the record's body alone, beside the conversation: the field its context pack declares as `body` (else a long-text field that holds the passage), scrolled to the passage and marked, with the answer's other cited passages of that record marked lightly. Its inner edge resizes it (remembered per browser), and it closes when the page changes. The `ai:chat` page opens it on the right, the assistant drawer's rail on the left (the right in its full window); on a phone there is no reader. Only a cited open goes to the reader; every other record link and the `open_record` card open as before.
- `@object-ui/i18n`: `chatbot.recordReader.*` and `chatbot.toolCalls.cite_records` in every pack.
4 changes: 4 additions & 0 deletions ui/packages/app-shell/src/console/ai/AppAskPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,10 @@ export function AppAskPage() {
// objectstack#38463 — an answer's links open in a new tab, so the
// question asked here stays on the page (ruling 7302940124).
openLinksInNewTab
// A cited or linked record opens beside the conversation, its body alone
// (RecordReaderDrawer.tsx); on a phone there is no reader, and a record
// opens as it always has.
recordReaderSide={phone ? undefined : 'right'}
presentation={presentation}
historyOpen={phone && historyOver}
onHistoryOpenChange={phone ? setHistoryOver : undefined}
Expand Down
28 changes: 26 additions & 2 deletions ui/packages/app-shell/src/console/ai/ChatPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ import {
useComposerDraftHandoff,
type PendingFirstMessage,
} from './useDeferredFirstSend.js';
import { useRecordReader } from './recordReader.js';

interface ChatPaneProps {
/**
Expand Down Expand Up @@ -262,8 +263,31 @@ export function ChatPane({
},
[routerRootHref],
);
// The `ai:chat` page's body reader (`RecordReaderDrawer.tsx`): where the
// host offers one, a record an answer cites or links opens in it, the body
// alone at the cited passage, and the conversation stays where it is.
const recordReader = useRecordReader();
const openRecord = useCallback(
async (handoff: { objectName: string; recordId: string; anchor?: string }) => {
async (handoff: { objectName: string; recordId: string; anchor?: string; quote?: string; siblingQuotes?: string[]; context?: string }) => {
// Only a record opened FOR a passage (a cited quote, or a 出处 link whose
// answer cites passages of it) goes to the body reader; any other
// record link or `open_record` card opens the record as before.
if (recordReader && (handoff.quote || handoff.siblingQuotes?.length)) {
recordReader.open(
{
objectName: handoff.objectName,
recordId: handoff.recordId,
...(handoff.anchor ? { anchor: handoff.anchor } : {}),
...(handoff.quote ? { quote: handoff.quote } : {}),
...(handoff.siblingQuotes?.length ? { siblingQuotes: handoff.siblingQuotes } : {}),
...(handoff.context ? { context: handoff.context } : {}),
},
() => {
void appOfObject(handoff.objectName).then((app) => openInNewTab(recordOpenTarget(app, handoff)));
},
);
return;
}
const app = await appOfObject(handoff.objectName);
const to = recordOpenTarget(app, handoff);
if (openLinksInNewTab) {
Expand All @@ -272,7 +296,7 @@ export function ChatPane({
}
navigate(to, handoff.anchor ? { state: { [RECORD_SECTION_OPENED_STATE]: nextSectionOpening() } } : undefined);
},
[navigate, openLinksInNewTab, openInNewTab],
[navigate, openLinksInNewTab, openInNewTab, recordReader],
);

// objectstack#31869 — a `/list/OBJECT` link in an answer opens that list.
Expand Down
Loading
Loading