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:
@@ -119,12 +119,18 @@ impl EventTranslator {
|
||||
.as_ref()
|
||||
.and_then(|v| serde_json::from_value(v.clone()).ok());
|
||||
let attachments = meta.as_ref().map(|m| m.attachments.clone()).unwrap_or_default();
|
||||
let view_context = meta.as_ref().map(|m| m.view_context.clone()).unwrap_or_default();
|
||||
// A custom slash command persists its expanded template (for
|
||||
// LLM replay) but the bubble shows the typed command.
|
||||
let echo = meta
|
||||
.and_then(|m| m.command.map(|c| c.display))
|
||||
.unwrap_or(content);
|
||||
self.emit(ServerEvent::UserMessage { message_id: message_id.get(), content: echo, attachments }).await;
|
||||
self.emit(ServerEvent::UserMessage {
|
||||
message_id: message_id.get(),
|
||||
content: echo,
|
||||
attachments,
|
||||
view_context,
|
||||
}).await;
|
||||
}
|
||||
|
||||
LoopEvent::TokenDelta { kind, text } => {
|
||||
|
||||
Reference in New Issue
Block a user