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,11 +1,15 @@
|
||||
import { html, nothing } from 'lit';
|
||||
import { LightElement } from '../lib/base.js';
|
||||
import { t } from '../lib/i18n.js';
|
||||
import { setSlice, clearSlice } from '../lib/view-context.js';
|
||||
import { ConfigFormController, maybeT, propKeyId } from './shared/config-form.js';
|
||||
|
||||
const PAGE_ID = 'system-agents';
|
||||
const PER_PAGE = 20;
|
||||
|
||||
/// The view-context slice this page owns (see `lib/view-context.js`).
|
||||
const VIEW_SLICE = 'entity@system-agents';
|
||||
|
||||
/** The overview tab: every agent's runs, interleaved. */
|
||||
const ALL_TAB = '__all__';
|
||||
|
||||
@@ -98,19 +102,28 @@ export class SystemAgentsPage extends LightElement {
|
||||
window.addEventListener('llm-page-change', (e) => {
|
||||
this._open = e.detail.page === PAGE_ID;
|
||||
this.style.display = this._open ? 'flex' : 'none';
|
||||
if (this._open) this._loadAll();
|
||||
if (this._open) { this._loadAll(); this._publishViewContext(); }
|
||||
// Navigating away stops the polling; the pass keeps running server-side
|
||||
// and its row is waiting on the next visit.
|
||||
else this._stopPolling();
|
||||
else { this._stopPolling(); clearSlice(VIEW_SLICE); }
|
||||
});
|
||||
}
|
||||
|
||||
disconnectedCallback() {
|
||||
window.removeEventListener('locale-changed', this.__onLocaleChanged);
|
||||
this._stopPolling();
|
||||
clearSlice(VIEW_SLICE);
|
||||
super.disconnectedCallback();
|
||||
}
|
||||
|
||||
// The entity slice: which agent's tab is open. The "All" tab is no one agent,
|
||||
// so it publishes nothing — the route slice already describes the page.
|
||||
_publishViewContext() {
|
||||
setSlice(VIEW_SLICE, this._tab === ALL_TAB
|
||||
? null
|
||||
: [{ label: 'Open tab', value: this._tab }]);
|
||||
}
|
||||
|
||||
async _loadAll() {
|
||||
await this._fetchAgents();
|
||||
await this._fetch(this._page);
|
||||
@@ -158,6 +171,7 @@ export class SystemAgentsPage extends LightElement {
|
||||
this._tab = id;
|
||||
this._page = 1;
|
||||
this._runMsg = null;
|
||||
this._publishViewContext();
|
||||
this._fetch(1);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user