






















@@ -1,12 +1,13 @@
11import { html, nothing } from "lit";
22import { t } from "../../i18n/index.ts";
3-import { formatRelativeTimestamp } from "../format.ts";
3+import { formatRelativeTimestamp, parseSessionKeyParts } from "../format.ts";
44import { icons } from "../icons.ts";
55import { pathForTab } from "../navigation.ts";
66import { formatSessionTokens } from "../presenter.ts";
77import { normalizeLowercaseStringOrEmpty, normalizeOptionalString } from "../string-coerce.ts";
88import { normalizeThinkLevel } from "../thinking.ts";
99import type {
10+AgentIdentityResult,
1011GatewaySessionRow,
1112GatewayThinkingLevelOption,
1213SessionCompactionCheckpoint,
@@ -23,6 +24,7 @@ export type SessionsProps = {
2324includeUnknown: boolean;
2425basePath: string;
2526searchQuery: string;
27+agentIdentityById: Record<string, AgentIdentityResult>;
2628sortColumn: "key" | "kind" | "updated" | "tokens";
2729sortDir: "asc" | "desc";
2830page: number;
@@ -80,6 +82,15 @@ const FAST_LEVELS = [
8082const REASONING_LEVELS = ["", "off", "on", "stream"] as const;
8183const PAGE_SIZES = [10, 25, 50, 100] as const;
828485+function getAgentIdentity(
86+agentIdentityById: Record<string, AgentIdentityResult>,
87+agentId: string,
88+): AgentIdentityResult | null {
89+return Object.prototype.hasOwnProperty.call(agentIdentityById, agentId)
90+ ? (agentIdentityById[agentId] ?? null)
91+ : null;
92+}
93+8394function normalizeThinkingOptionValue(raw: string): string {
8495return normalizeThinkLevel(raw) ?? normalizeLowercaseStringOrEmpty(raw);
8596}
@@ -133,7 +144,11 @@ function resolveThinkLevelPatchValue(value: string): string | null {
133144return value;
134145}
135146136-function filterRows(rows: GatewaySessionRow[], query: string): GatewaySessionRow[] {
147+function filterRows(
148+rows: GatewaySessionRow[],
149+query: string,
150+agentIdentityById: Record<string, AgentIdentityResult>,
151+): GatewaySessionRow[] {
137152const q = normalizeLowercaseStringOrEmpty(query);
138153if (!q) {
139154return rows;
@@ -143,7 +158,14 @@ function filterRows(rows: GatewaySessionRow[], query: string): GatewaySessionRow
143158const label = normalizeLowercaseStringOrEmpty(row.label);
144159const kind = normalizeLowercaseStringOrEmpty(row.kind);
145160const displayName = normalizeLowercaseStringOrEmpty(row.displayName);
146-return key.includes(q) || label.includes(q) || kind.includes(q) || displayName.includes(q);
161+if (key.includes(q) || label.includes(q) || kind.includes(q) || displayName.includes(q)) {
162+return true;
163+}
164+const keyParts = parseSessionKeyParts(row.key);
165+const identityName = keyParts
166+ ? normalizeLowercaseStringOrEmpty(getAgentIdentity(agentIdentityById, keyParts.agentId)?.name)
167+ : "";
168+return identityName.includes(q);
147169});
148170}
149171@@ -216,7 +238,7 @@ function formatCheckpointDelta(checkpoint: SessionCompactionCheckpoint): string
216238217239export function renderSessions(props: SessionsProps) {
218240const rawRows = props.result?.sessions ?? [];
219-const filtered = filterRows(rawRows, props.searchQuery);
241+const filtered = filterRows(rawRows, props.searchQuery, props.agentIdentityById);
220242const sorted = sortRows(filtered, props.sortColumn, props.sortDir);
221243const totalRows = sorted.length;
222244const totalPages = Math.max(1, Math.ceil(totalRows / props.pageSize));
@@ -328,7 +350,7 @@ export function renderSessions(props: SessionsProps) {
328350 <div class="data-table-search">
329351 <input
330352 type="text"
331- placeholder="Filter by key, label, kind…"
353+ placeholder="Filter by key, agent, label, kind…"
332354 .value=${props.searchQuery}
333355 @input=${(e: Event) => props.onSearchChange((e.target as HTMLInputElement).value)}
334356 />
@@ -460,6 +482,17 @@ function renderRows(row: GatewaySessionRow, props: SessionsProps) {
460482const showDisplayName = Boolean(
461483displayName && displayName !== row.key && displayName !== trimmedLabel,
462484);
485+const keyParts = parseSessionKeyParts(row.key);
486+const agentIdentity = keyParts
487+ ? getAgentIdentity(props.agentIdentityById, keyParts.agentId)
488+ : null;
489+const identityEmoji = normalizeOptionalString(agentIdentity?.emoji) ?? "";
490+const identityName = normalizeOptionalString(agentIdentity?.name) ?? "";
491+const friendlyKeyLabel =
492+identityName && keyParts
493+ ? `${identityEmoji ? `${identityEmoji} ` : ""}${identityName} (${keyParts.channel})`
494+ : null;
495+const keyCellTitle = friendlyKeyLabel ?? row.key;
463496const canLink = row.kind !== "global";
464497const chatUrl = canLink
465498 ? `${pathForTab("chat", props.basePath)}?session=${encodeURIComponent(row.key)}`
@@ -484,7 +517,10 @@ function renderRows(row: GatewaySessionRow, props: SessionsProps) {
484517 />
485518 </td>
486519 <td class="data-table-key-col">
487- <div class="mono session-key-cell">
520+ <div
521+ class=${friendlyKeyLabel ? "session-key-cell" : "mono session-key-cell"}
522+ title=${keyCellTitle}
523+ >
488524 ${canLink
489525 ? html`<a
490526 href=${chatUrl}
@@ -505,9 +541,9 @@ function renderRows(row: GatewaySessionRow, props: SessionsProps) {
505541 props.onNavigateToChat(row.key);
506542 }
507543 }}
508- >${row.key}</a
544+ >${friendlyKeyLabel ?? row.key}</a
509545 >`
510- : row.key}
546+ : (friendlyKeyLabel ?? row.key)}
511547 ${showDisplayName
512548 ? html`<span class="muted session-key-display-name">${displayName}</span>`
513549 : nothing}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。