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,6 +1,9 @@
|
||||
import { html, nothing } from 'lit';
|
||||
import { LightElement } from '../lib/base.js';
|
||||
import { t, I18nMixin } from '../lib/i18n.js';
|
||||
// Shared with the view-context store: one reading of the hash, so the page the
|
||||
// assistant is told about is always the page the menu highlights.
|
||||
import { pageFromHash } from '../lib/routes.js';
|
||||
|
||||
|
||||
// ── Navigation model ──────────────────────────────────────────────────────────
|
||||
@@ -237,22 +240,7 @@ export class AppSidebar extends I18nMixin(LightElement) {
|
||||
}
|
||||
|
||||
_pageFromHash() {
|
||||
const hash = location.hash.slice(1);
|
||||
if (!hash) return 'home';
|
||||
// Segment ends at the first `/` (e.g. `#session/123`) or `?` (e.g. `#file_viewer?path=...`).
|
||||
const match = hash.match(/^([^/?]+)/);
|
||||
const segment = match ? match[1] : '';
|
||||
// Plugin pages: `#plugin/<plugin_id>/<page_id>` — the route is accepted by
|
||||
// shape (deep links must survive the async `/api/plugins/pages` load); the
|
||||
// host reports an error if the page turns out not to exist for this user.
|
||||
if (segment === 'plugin') {
|
||||
const m = hash.match(/^plugin\/([^/?]+)\/([^/?]+)/);
|
||||
return m ? `plugin/${m[1]}/${m[2]}` : 'home';
|
||||
}
|
||||
// `connector` (singular) is the per-connector detail page, `connectors` the list.
|
||||
// `plugin-catalog` is the pre-merge hash of what is now `#plugins`.
|
||||
const page = segment === 'plugin-catalog' ? 'plugins' : segment;
|
||||
return ['inbox', 'dashboard', 'tasks', 'projects', 'files', 'models', 'providers', 'approval', 'agents', 'users', 'roles', 'shared-folders', 'connectors', 'connector', 'plugins', 'plugin-detail', 'marketplace', 'profile', 'config', 'llm-requests', 'session', 'system-agents', 'file_viewer', 'tool_detail'].includes(page) ? page : 'home';
|
||||
return pageFromHash();
|
||||
}
|
||||
|
||||
_tasksSectionFromHash() {
|
||||
|
||||
Reference in New Issue
Block a user