feat(webui): add lightweight session messaging via mentions

This commit is contained in:
chengyongru authored and chengyongru committed 2026-08-19 01:15:56 +08:00
1 parent 2bdb11eeba
commit 0e184965e8
76 files changed
+8297 -658

No files matched your search

+46 -4
View File
@@ -5,6 +5,7 @@ import { useTranslation } from "react-i18next";
import { FilePreviewAvailabilityProvider } from "@/components/FilePreviewAvailabilityContext";
import { FilePreviewPanel } from "@/components/FilePreviewPanel";
import { SessionHandleHighlight } from "@/components/CliAppMentionText";
import { PromptNavigator } from "@/components/thread/PromptNavigator";
import { SessionInfoPopover } from "@/components/thread/SessionInfoPopover";
import { ThreadComposer } from "@/components/thread/ThreadComposer";
@@ -36,6 +37,7 @@ import type { CanonicalRunSnapshot, StreamError } from "@/lib/nanobot-client";
import { inferProviderFromModelName, providerDisplayLabel } from "@/lib/provider-brand";
import type {
ChatSummary,
SessionHandle,
SettingsPayload,
SlashCommand,
SkillSummary,
@@ -637,7 +639,7 @@ export function ThreadShell({
const { t } = useTranslation();
const chatId = session?.chatId ?? null;
const historyKey = temporary ? null : session?.key ?? null;
const mentionSessions = useMemo(
const referenceSessions = useMemo(
() => sessions.filter((candidate) => (
candidate.key !== historyKey
&& (
@@ -647,6 +649,18 @@ export function ThreadShell({
)),
[historyKey, sessions, workspaceScope],
);
const handleSessions = useMemo(() => {
if (temporary) return [];
return sessions;
}, [sessions, temporary]);
const sessionDirectory = useMemo<SessionHandle[]>(() => {
const handles = new Map<string, SessionHandle>();
if (session?.handle) handles.set(session.handle.id, session.handle);
for (const candidate of handleSessions) {
if (candidate.handle) handles.set(candidate.handle.id, candidate.handle);
}
return [...handles.values()];
}, [handleSessions, session?.handle]);
const {
messages: historical,
loading,
@@ -1316,7 +1330,14 @@ export function ThreadShell({
setPendingFirstTargetChatId(newId);
return true;
},
[booting, client, localModelPreset, onCreateChat, withWorkspaceScope, workspaceScope],
[
booting,
client,
localModelPreset,
onCreateChat,
withWorkspaceScope,
workspaceScope,
],
);
const handleThreadSend = useCallback(
@@ -1469,7 +1490,8 @@ export function ThreadShell({
slashCommands={availableSlashCommands}
cliApps={cliApps}
mcpPresets={mcpPresets}
sessions={mentionSessions}
sessions={referenceSessions}
handleSessions={handleSessions}
skills={skills}
onStop={stop}
onTranscribeAudio={transcribeAudio}
@@ -1516,7 +1538,8 @@ export function ThreadShell({
slashCommands={availableSlashCommands}
cliApps={cliApps}
mcpPresets={mcpPresets}
sessions={mentionSessions}
sessions={referenceSessions}
handleSessions={handleSessions}
skills={skills}
surfaceRef={composerSurfaceRef}
onTranscribeAudio={transcribeAudio}
@@ -1560,6 +1583,7 @@ export function ThreadShell({
const threadHeader = !hideHeader ? (
<ThreadHeader
title={title}
handle={temporary || hideHeaderTitle ? null : session?.handle}
onToggleSidebar={onToggleSidebar}
theme={theme}
onToggleTheme={onToggleTheme}
@@ -1583,6 +1607,23 @@ export function ThreadShell({
return (
<section ref={shellRef} className="relative flex min-h-0 flex-1 overflow-hidden">
<div className="relative flex min-w-0 flex-1 flex-col overflow-hidden">
{hideHeaderTitle && !temporary && session?.handle ? (
<div
data-testid="pane-handle-identity"
data-active={headerActive ? "true" : "false"}
aria-label={`Session @${session.handle.name}`}
className="flex h-8 shrink-0 items-center px-3 text-[12px]"
>
<span
data-pane-handle-handle
className="shrink-0"
>
<SessionHandleHighlight handle={session.handle}>
@{session.handle.name}
</SessionHandleHighlight>
</span>
</div>
) : null}
{headerPortalTarget === undefined ? threadHeader : null}
<FilePreviewAvailabilityProvider
resolve={historyKey ? resolveFilePreviewAvailability : undefined}
@@ -1602,6 +1643,7 @@ export function ThreadShell({
showScrollToBottomButton={!!session}
cliApps={cliApps}
mcpPresets={mcpPresets}
sessionDirectory={sessionDirectory}
slashCommands={availableSlashCommands}
forkBoundaryMessageCount={forkBoundaryMessageCount}
hasMoreBefore={hasMoreBefore}