feat(chat): view context — tell the assistant what you're looking at
Nightly Build / build (push) Successful in 7m51s
Nightly Build / build (push) Successful in 7m51s
An eye next to the paperclip shares what the user has open with their next
message: the page, the folder being browsed, the file open in the viewer and
any highlighted passage (line numbers where a source view exists), plus which
entity a detail page is about. The bag is client-authored {label, value} pairs
in English — the backend only clamps (chars, never bytes), neutralizes the
harness tag and renders one <system-extra> block per message, deduped
consecutively so it appears exactly when the view changed. On by default,
per-device toggle, hover/tap to preview, a chip on every sent message;
docs/view-context.md for users, an updated harness.md clause for the model.
This commit is contained in:
@@ -630,6 +630,9 @@ fn build_debug_items<'a>(
|
||||
let attachments = msg.metadata.as_ref()
|
||||
.map(|m| m.attachments.clone())
|
||||
.unwrap_or_default();
|
||||
let view_context = msg.metadata.as_ref()
|
||||
.map(|m| m.view_context.clone())
|
||||
.unwrap_or_default();
|
||||
// Custom slash commands render the typed command, not the
|
||||
// expanded template persisted for LLM replay.
|
||||
let content = msg.metadata.as_ref()
|
||||
@@ -640,6 +643,7 @@ fn build_debug_items<'a>(
|
||||
"kind": "user",
|
||||
"content": content,
|
||||
"attachments": attachments,
|
||||
"view_context": view_context,
|
||||
"failed": failed,
|
||||
"is_synthetic": msg.is_synthetic,
|
||||
"created_at": msg.created_at,
|
||||
@@ -759,18 +763,22 @@ fn build_items<'a>(
|
||||
if msg.is_synthetic {
|
||||
continue;
|
||||
}
|
||||
// `content` stays clean (typed text); attachments are surfaced
|
||||
// structurally so the UI renders chips, not the LLM-facing block.
|
||||
// `content` stays clean (typed text); attachments and view
|
||||
// context are surfaced structurally so the UI renders chips,
|
||||
// not the LLM-facing block.
|
||||
let attachments = msg.metadata.as_ref()
|
||||
.map(|m| m.attachments.clone())
|
||||
.unwrap_or_default();
|
||||
let view_context = msg.metadata.as_ref()
|
||||
.map(|m| m.view_context.clone())
|
||||
.unwrap_or_default();
|
||||
// Custom slash commands render the typed command, not the
|
||||
// expanded template persisted for LLM replay.
|
||||
let content = msg.metadata.as_ref()
|
||||
.and_then(|m| m.command.as_ref())
|
||||
.map(|c| c.display.clone())
|
||||
.unwrap_or_else(|| msg.content.clone());
|
||||
items.push(json!({ "kind": "user", "content": content, "attachments": attachments, "failed": failed }));
|
||||
items.push(json!({ "kind": "user", "content": content, "attachments": attachments, "view_context": view_context, "failed": failed }));
|
||||
}
|
||||
chat_history::Role::Agent => {}
|
||||
chat_history::Role::Assistant => {
|
||||
|
||||
Reference in New Issue
Block a user