feat(chat): view context — tell the assistant what you're looking at
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:
Daniele
2026-08-23 20:53:30 +01:00
parent 488c702517
commit 505f2e95c1
42 changed files with 2096 additions and 122 deletions
+18
View File
@@ -1,5 +1,6 @@
import { html, nothing } from 'lit';
import { LightElement } from '../../lib/base.js';
import { setSlice, clearSlice } from '../../lib/view-context.js';
import { RunningTasksSection } from './running.js';
import { CronJobsSection } from './cron.js';
import { ScheduledTasksSection } from './scheduled.js';
@@ -7,6 +8,9 @@ import { TaskHistorySection } from './history.js';
const SECTIONS = ['running', 'cron', 'scheduled', 'history'];
/// The view-context slice this page owns (see `lib/view-context.js`).
const VIEW_SLICE = 'entity@tasks';
export class TasksPage extends LightElement {
static properties = {
_open: { state: true },
@@ -29,9 +33,12 @@ export class TasksPage extends LightElement {
const sec = this._sectionFromHash();
this._section = sec;
this._loadSection(sec);
this._publishViewContext();
if (!location.hash.includes('/')) {
history.replaceState({ page: 'tasks', section: sec }, '', '#tasks/' + sec);
}
} else {
clearSlice(VIEW_SLICE);
}
});
window.addEventListener('tasks-section-change', (e) => {
@@ -39,9 +46,20 @@ export class TasksPage extends LightElement {
const sec = e.detail.section;
this._section = sec;
this._loadSection(sec);
this._publishViewContext();
});
}
disconnectedCallback() {
clearSlice(VIEW_SLICE);
super.disconnectedCallback();
}
// The entity slice: which of the four sections is showing.
_publishViewContext() {
setSlice(VIEW_SLICE, [{ label: 'Open section', value: this._section }]);
}
_sectionFromHash() {
const parts = location.hash.slice(1).split('/');
if (parts[0] === 'tasks' && parts[1]) {