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:
@@ -1,7 +1,8 @@
|
||||
import { html, nothing } from 'lit';
|
||||
import { ChatSession } from '../lib/chat-session.js';
|
||||
import { t, I18nMixin } from '../lib/i18n.js';
|
||||
import { renderMsg, renderAttachmentChips } from './copilot-render.js';
|
||||
import { pageFromHash } from '../lib/routes.js';
|
||||
import { renderMsg, renderAttachmentChips, renderViewContextPill } from './copilot-render.js';
|
||||
import { renderTaskStrip } from './shared/agent-tasks.js';
|
||||
|
||||
// Built-in (server-handled) slash commands shown at the top of the composer
|
||||
@@ -138,11 +139,13 @@ export class AppCopilot extends I18nMixin(ChatSession) {
|
||||
window.addEventListener('llm-page-change', this._onPageChange);
|
||||
}
|
||||
|
||||
// Shared with the sidebar and the view-context store (`lib/routes.js`). It used
|
||||
// to be a third copy of the same list, and had already drifted: `files`,
|
||||
// `plugins`, `shared-folders` and the plugin routes were missing, so a deep
|
||||
// link to one of those opened the chat full-screen over the page it should
|
||||
// have docked beside.
|
||||
_pageFromHash() {
|
||||
const m = location.hash.slice(1).match(/^([^/?]+)/);
|
||||
const seg = m ? m[1] : '';
|
||||
const known = ['inbox', 'dashboard', 'tasks', 'projects', 'models', 'providers', 'approval', 'agents', 'users', 'roles', 'connectors', 'connector', 'marketplace', 'profile', 'config', 'llm-requests', 'session', 'system-agents', 'file_viewer', 'tool_detail'];
|
||||
return known.includes(seg) ? seg : 'home';
|
||||
return pageFromHash();
|
||||
}
|
||||
|
||||
_onPageChange(e) {
|
||||
@@ -738,6 +741,7 @@ export class AppCopilot extends I18nMixin(ChatSession) {
|
||||
title=${t('chat.attach')}
|
||||
@click=${() => this.querySelector('.copilot-file-input')?.click()}
|
||||
><i class="bi bi-paperclip"></i></button>
|
||||
${renderViewContextPill(this)}
|
||||
${this._providers.length > 1 ? html`
|
||||
<div class="copilot-model-wrap">
|
||||
${this._modelOpen ? html`
|
||||
|
||||
Reference in New Issue
Block a user