Skip to content

The open source AI video agent: turns any coding agent into a video agent, with an editor to change anything it makes.

Chat: `@` is the one menu, with moments, files and skills; `/` opens nothing (#299)

riverisbuilding3a54152cccf7
diff --git a/.changeset/at-is-the-one-menu.md b/.changeset/at-is-the-one-menu.md
new file mode 100644
index 0000000..9060173
--- /dev/null
+++ b/.changeset/at-is-the-one-menu.md
@@ -0,0 +1,5 @@
+---
+"@openfilm/desktop": patch
+---
+
+Chat: `@` is the one menu: moments, files and skills. Every skill is there with what each does, and picking one names it in the message, as the Skills button does. Typing `/` opens nothing: the agent's own commands (`/review`, `/mcp`…) are no longer listed, and one typed by hand still goes to the agent as typed. With many files, the skills after them keep their rows, and the arrow keys keep the row they are on in view.
diff --git a/apps/desktop/chat/src/App.tsx b/apps/desktop/chat/src/App.tsx
index 814523a..2f47a72 100644
--- a/apps/desktop/chat/src/App.tsx
+++ b/apps/desktop/chat/src/App.tsx
@@ -6,7 +6,7 @@
* (lib/local-agent-run's saved turns).
*/
import React from 'react';
-import { ArrowDown, Blocks, Coins, CornerDownLeft, LibraryBig, Loader2, Plus, ShieldQuestion, Square, SquareSlash, X } from 'lucide-react';
+import { ArrowDown, Blocks, Coins, CornerDownLeft, LibraryBig, Loader2, Plus, ShieldQuestion, Square, X } from 'lucide-react';
import { buildPromptDisplay, type Turn } from '@openfilm/shared';
import { useT, useUiLocale } from '@/i18n';
import { ConversationSessionBar } from '@/components/ConversationSessionBar';
@@ -48,7 +48,6 @@ import {
restingItems,
saveLocalAgentTurn,
steerLocalAgentTurn,
- useAgentCommands,
useAgentContext,
useLocalAgentTurn,
type LocalAgentTurn,
@@ -347,7 +346,7 @@ function ChatPane({ project, banners, selection, assetsOpen }: { project: Projec
const [contextNoticeOff, setContextNoticeOff] = React.useState<string | null>(null);
const contextFull = Boolean(agentContext && agentContext.size > 0 && agentContext.used / agentContext.size >= CONTEXT_NOTICE_SHARE) && contextNoticeOff !== sessionId;
- /* the skills this message can name (the Skills button, and `/`) */
+ /* the skills this message can name (the Skills button, and `@`) */
const [skillListing, setSkillListing] = React.useState<SkillListing | null>(null);
const reloadSkills = React.useCallback(async () => {
const next = await app.skills?.list(project.path, agent).catch(() => null);
@@ -397,42 +396,6 @@ function ChatPane({ project, banners, selection, assetsOpen }: { project: Projec
window.addEventListener(MAKE_SKILL, make);
return () => { window.removeEventListener(SKILLS_CHANGED, changed); window.removeEventListener(MAKE_SKILL, make); };
}, [reloadSkills, skillListing, t]);
- /* the agent's own skills hidden in OpenFilm: not offered among its commands either */
- const hiddenSkills = React.useMemo(() => new Set((skillListing?.own.filtered ? skillListing.own.skills.filter((s) => !s.allowed) : []).map((s) => s.name)), [skillListing]);
-
- /* the agent's own commands, a `/` at the start of the message, as in its own chat: they go as typed; above them, the
- skills, each a pill */
- const agentCommands = useAgentCommands(agent);
- const commandMenu = React.useMemo(() => (agentCommands.length || nameableSkills.length ? {
- label: t('composer.commands'),
- providers: [...(nameableSkills.length ? [{
- id: 'skills',
- groupLabel: t('skills.button'),
- items: nameableSkills.map((skill) => ({
- id: skillReferenceId(skill.name),
- kind: 'skill' as const,
- icon: Blocks,
- label: skillWords(skill.name).title,
- ...(skillWords(skill.name, skill.description).summary ? { detail: skillWords(skill.name, skill.description).summary, describes: true } : {}),
- keywords: [skill.name, skillWords(skill.name).title],
- select: () => skillPill(skill),
- })),
- }] : []), ...(agentCommands.length ? [{
- id: 'commands',
- groupLabel: t('composer.commands'),
- items: agentCommands.filter((c) => !hiddenSkills.has(c.name)).map((c) => ({
- id: `command:${c.name}`,
- kind: 'file' as const,
- icon: SquareSlash,
- label: `/${c.name}`,
- /* what it does, cut to the row */
- ...(c.description ? { detail: c.description, describes: true } : {}),
- /* found by its name, as in the agent's own chat (its description would put a word in it first) */
- keywords: [c.name],
- select: () => ({ text: `/${c.name}` }),
- })),
- }] : [])],
- } : undefined), [agentCommands, nameableSkills, hiddenSkills, skillPill, skillWords, t]);
const mentionProviders = React.useMemo<MentionProvider[]>(() => {
const picked = selection?.refs ?? [];
const range = selection ? selectionRange(selection) : null;
@@ -479,8 +442,27 @@ function ChatPane({ project, banners, selection, assetsOpen }: { project: Projec
};
}),
},
+ /* the skills, each the pill the Skills button makes: after the files, which people reach for most and which stop
+ at 20. Every one, uncut: an agent's own can be a hundred or more, and a person may not remember the name to type */
+ {
+ id: 'skills',
+ groupLabel: t('skills.button'),
+ limit: Infinity,
+ items: nameableSkills.map((skill) => {
+ const words = skillWords(skill.name, skill.description);
+ return {
+ id: skillReferenceId(skill.name),
+ kind: 'skill' as const,
+ label: words.title,
+ /* what it does, cut to the row */
+ ...(words.summary ? { detail: words.summary, describes: true } : {}),
+ keywords: [skill.name],
+ select: () => skillPill(skill),
+ };
+ }),
+ },
];
- }, [selection, mentionFiles, t, takeStudioRefs]);
+ }, [selection, mentionFiles, nameableSkills, skillWords, skillPill, t, takeStudioRefs]);
const onComposerChange = React.useCallback((state: PromptEditorState) => {
setFollowUp(state.text);
setFollowUpRefs(state.references);
@@ -939,7 +921,6 @@ function ChatPane({ project, banners, selection, assetsOpen }: { project: Projec
contentClassName="text-[14px] leading-[22px] text-[var(--chat-text)]"
onPasteFiles={(files) => composerFiles.add(files)}
mentions={{ providers: mentionProviders, label: t('mention.menu'), onOpen: loadMentionFiles }}
- commands={commandMenu}
/>
</div>
{/* while it works: Stop, or Send once something is written (it goes into the turn, or after it); Esc stops */}
diff --git a/apps/desktop/chat/src/components/prompt-editor/MentionMenuPlugin.tsx b/apps/desktop/chat/src/components/prompt-editor/MentionMenuPlugin.tsx
index b30a479..c955860 100644
--- a/apps/desktop/chat/src/components/prompt-editor/MentionMenuPlugin.tsx
+++ b/apps/desktop/chat/src/components/prompt-editor/MentionMenuPlugin.tsx
@@ -37,7 +37,6 @@ import {
matchMentionTrigger,
type MentionEntry,
type MentionProvider,
- type MentionTrigger,
} from './mention-menu';
import { chatLayer } from '@/lib/chat-layer';
@@ -52,8 +51,6 @@ export interface MentionMenuConfig {
* The file list is fetched only then: most sessions never mention a file.
*/
onOpen?: () => void;
- /** When typing opens it: an `@` (the default), or a `/` at the start (the agent's commands, matchSlashTrigger). */
- trigger?: (textBeforeCursor: string) => MentionTrigger | null;
}
/** Lexical requires options to subclass MenuOption (it attaches a ref for scrolling). */
@@ -66,7 +63,7 @@ class MentionMenuOption extends MenuOption {
}
}
-export function MentionMenuPlugin({ providers, label, onOpen, trigger: match = matchMentionTrigger }: MentionMenuConfig) {
+export function MentionMenuPlugin({ providers, label, onOpen }: MentionMenuConfig) {
const [editor] = useLexicalComposerContext();
const [query, setQuery] = React.useState('');
@@ -86,10 +83,8 @@ export function MentionMenuPlugin({ providers, label, onOpen, trigger: match = m
const handleOpen = React.useCallback(() => onOpenRef.current?.(), []);
const handleQueryChange = React.useCallback((value: string | null) => setQuery(value ?? ''), []);
- const matchRef = React.useRef(match);
- matchRef.current = match;
const triggerFn = React.useCallback((text: string): MenuTextMatch | null => {
- const trigger = matchRef.current(text);
+ const trigger = matchMentionTrigger(text);
if (!trigger) return null;
/* No matches, no menu: an open menu takes the arrow keys, so an empty one would lock
them while the user probably wants to move the caret. */
@@ -105,18 +100,6 @@ export function MentionMenuPlugin({ providers, label, onOpen, trigger: match = m
(option: MentionMenuOption, nodeToReplace: TextNode | null, closeMenu: () => void) => {
const { item } = option.entry;
const picked = item.disabled ? null : item.select();
- /* a command goes in as its words, with a space for what follows */
- if (picked && 'text' in picked) {
- editor.update(() => {
- const node = $createTextNode(`${picked.text} `);
- if (nodeToReplace) nodeToReplace.replace(node);
- else $insertNodes([node]);
- node.select();
- closeMenu();
- });
- keepCaretInComposer(editor);
- return;
- }
const references = picked ? [picked].flat() : [];
/* A disabled item yields nothing, but the menu still closes: an open menu takes
Enter, so the next Enter would not send. Same when select() returns nothing
@@ -287,6 +270,20 @@ function MentionMenu({
};
}, [editorRoot]);
+ /* The arrow keys' row kept in view. Lexical scrolls only a menu inside its own anchor (`#typeahead-menu`), and this
+ one is in the chat layer, so past the rows that fit, the selection went on below the menu's edge. */
+ React.useEffect(() => {
+ if (selectedIndex == null) return;
+ const row = options[selectedIndex]?.ref?.current;
+ /* back at the first row: its group's title too */
+ if (selectedIndex === 0) row?.parentElement?.scrollTo({ top: 0 });
+ else {
+ /* the first row of a later group: its title too, above it */
+ if (options[selectedIndex]!.entry.firstOfGroup) row?.previousElementSibling?.scrollIntoView({ block: 'nearest' });
+ row?.scrollIntoView({ block: 'nearest' });
+ }
+ }, [selectedIndex, options]);
+
if (!style) return null;
return (
<div
@@ -301,7 +298,7 @@ function MentionMenu({
<div className="min-h-0 flex-1 overflow-y-auto overflow-x-hidden p-1.5">
{options.map((option, index) => {
const { item, groupLabel, firstOfGroup } = option.entry;
- const Icon = item.icon ?? (item.kind === 'file' ? fileIcon(item.label) : PILL_ICON[item.kind]);
+ const Icon = item.kind === 'file' ? fileIcon(item.label) : PILL_ICON[item.kind];
const selected = index === selectedIndex;
return (
<React.Fragment key={option.key}>
diff --git a/apps/desktop/chat/src/components/prompt-editor/PromptEditor.tsx b/apps/desktop/chat/src/components/prompt-editor/PromptEditor.tsx
index 61b9e5f..60b9891 100644
--- a/apps/desktop/chat/src/components/prompt-editor/PromptEditor.tsx
+++ b/apps/desktop/chat/src/components/prompt-editor/PromptEditor.tsx
@@ -34,7 +34,6 @@ import {
PromptReferenceNode,
} from './PromptReferenceNode';
import { MentionMenuPlugin, type MentionMenuConfig } from './MentionMenuPlugin';
-import { matchSlashTrigger } from './mention-menu';
import type { PromptPillCard } from './PromptPill';
import {
collectPromptReferences,
@@ -108,8 +107,6 @@ export interface PromptEditorProps {
disabled?: boolean;
/** What `@` can pick; without it there is no `@` menu. */
mentions?: MentionMenuConfig;
- /** The agent's commands, a `/` at the start of the message; without it there is no `/` menu. */
- commands?: MentionMenuConfig;
}
/**
@@ -142,7 +139,6 @@ export const PromptEditor = React.forwardRef<PromptEditorHandle, PromptEditorPro
autoFocus,
disabled,
mentions,
- commands,
} = props;
const lookup = React.useMemo(() => {
@@ -214,7 +210,6 @@ export const PromptEditor = React.forwardRef<PromptEditorHandle, PromptEditorPro
<ChangePlugin onChange={onChange} lookup={lookup} />
<HandlePlugin ref={ref} lookupRef={lookupRef} autoFocus={autoFocus} />
{mentions ? <MentionMenuPlugin {...mentions} /> : null}
- {commands ? <MentionMenuPlugin {...commands} trigger={matchSlashTrigger} /> : null}
</PromptReferenceContext.Provider>
</LexicalComposer>
);
diff --git a/apps/desktop/chat/src/components/prompt-editor/mention-menu.ts b/apps/desktop/chat/src/components/prompt-editor/mention-menu.ts
index 1e41240..672191e 100644
--- a/apps/desktop/chat/src/components/prompt-editor/mention-menu.ts
+++ b/apps/desktop/chat/src/components/prompt-editor/mention-menu.ts
@@ -1,19 +1,17 @@
/**
- * The `@` menu (and the `/` menu of the agent's commands): when typing counts as an `@` or a `/`, which items show,
- * and in what order.
+ * The `@` menu: when typing counts as an `@`, which items show, and in what order.
*
* Pure logic; the Lexical half is in MentionMenuPlugin. Kept apart so these rules can be
* tested on plain strings: an email address opening the menu, or the best match ranked
* eighth, raises no error.
*/
-import type React from 'react';
import type { PromptReference, PromptReferenceKind } from './prompt-text';
/**
* One menu item.
*
- * It does not know whether it stands for a moment or a file; the provider does. Here it
- * is only an icon, a label, what typing finds it, and the reference it yields.
+ * It does not know whether it stands for a moment, a file or a skill; the provider does.
+ * Here it is only an icon, a label, what typing finds it, and the reference it yields.
*/
export interface MentionItem {
/** Unique in the menu. The id of the reference it will become is simplest. */
@@ -29,17 +27,14 @@ export interface MentionItem {
disabled?: boolean;
/** Why it is not usable; a gray item without a reason looks broken. */
disabledHint?: string;
- /** The detail is a description (an agent's command): the label keeps its width, the detail is cut. */
+ /** The detail is a description (a skill's): the label keeps its width, the detail is cut. */
describes?: boolean;
- /** Its own icon, instead of its kind's (an agent's command). */
- icon?: React.ComponentType<{ size?: number; className?: string }>;
/**
* Picks it: records what it needs and returns how it appears in the sentence, possibly
- * several references (the current selection is every selected thing), or plain text
- * (`{ text }`: an agent's command). Null or empty means it failed (too many references,
- * or the thing is gone).
+ * several references (the current selection is every selected thing). Null or empty
+ * means it failed (too many references, or the thing is gone).
*/
- select: () => PromptReference | PromptReference[] | { text: string } | null;
+ select: () => PromptReference | PromptReference[] | null;
}
/**
@@ -53,6 +48,8 @@ export interface MentionProvider {
id: string;
/** The group title, already localized; this layer has no i18n. */
groupLabel: string;
+ /** The most rows it shows (MENTION_MENU_LIMIT); Infinity for a group a person scrolls through whole. */
+ limit?: number;
items: MentionItem[];
}
@@ -99,17 +96,6 @@ export function matchMentionTrigger(textBeforeCursor: string): MentionTrigger |
return { leadOffset: at, query, replaceableString: textBeforeCursor.slice(at) };
}
-/**
- * Whether the message so far is a `/` being typed at its very start: an agent's command, as in its own chat (`/` in
- * the middle of a sentence is a path or a fraction). The query is what follows, up to the first space.
- */
-export function matchSlashTrigger(textBeforeCursor: string): MentionTrigger | null {
- const m = /^\s*\/([^\s/]{0,40})$/.exec(textBeforeCursor);
- if (!m) return null;
- const at = textBeforeCursor.indexOf('/');
- return { leadOffset: at, query: m[1]!, replaceableString: textBeforeCursor.slice(at) };
-}
-
/* Ranking: prefix < word start < substring < subsequence (other characters in between).
Within a tier, an earlier match ranks higher: "video" at position 3 of my-video.mp4
beats position 20 of a-really-long-name-video.mp4.
@@ -166,19 +152,16 @@ export function scoreMentionItem(item: MentionItem, query: string): number | nul
return best;
}
-/** The most rows the menu shows; with hundreds of files, typing a little more beats scrolling. */
+/** The most rows a group shows unless it says; with hundreds of files, typing a little more beats scrolling. */
export const MENTION_MENU_LIMIT = 20;
/**
* Flattens the providers into the menu's rows.
*
- * Groups stay together, each one kind of thing; sorting happens only within a group.
+ * Groups stay together, each one kind of thing; sorting happens only within a group. Each
+ * group is cut on its own, so a long one (files) never pushes a later one out of the menu.
*/
-export function buildMentionMenu(
- providers: MentionProvider[],
- query: string,
- limit: number = MENTION_MENU_LIMIT,
-): MentionEntry[] {
+export function buildMentionMenu(providers: MentionProvider[], query: string): MentionEntry[] {
const entries: MentionEntry[] = [];
for (const provider of providers) {
provider.items
@@ -192,6 +175,7 @@ export function buildMentionMenu(
// Ties keep the provider's order (files come newest first).
return a.order - b.order;
})
+ .slice(0, provider.limit ?? MENTION_MENU_LIMIT)
.forEach((row, index) => {
entries.push({
item: row.item,
@@ -201,6 +185,5 @@ export function buildMentionMenu(
});
});
}
- /* Cut from the end, so every remaining group keeps its first row and title. */
- return entries.slice(0, limit);
+ return entries;
}
diff --git a/apps/desktop/chat/src/i18n/locales/en-US.ts b/apps/desktop/chat/src/i18n/locales/en-US.ts
index cc17257..bf0ca80 100644
--- a/apps/desktop/chat/src/i18n/locales/en-US.ts
+++ b/apps/desktop/chat/src/i18n/locales/en-US.ts
@@ -131,7 +131,6 @@ export const enUS = {
composer: {
contextFull: 'This conversation is getting long. A new one will work better.',
contextFullNew: 'New conversation',
- commands: 'Commands',
agentLoading: 'Loading…',
agentNone: 'Agent',
agentNoneShown: 'No agent is switched on for the chat.',
@@ -222,8 +221,8 @@ export const enUS = {
assets: 'Assets',
addAttachment: 'Add files',
close: 'Close',
- composerPlaceholder: 'Say what to change. Type @ to point at a file, a moment or what you selected',
- composerPlaceholderBlank: 'Describe your film. Type @ to use a file from this project',
+ composerPlaceholder: 'Say what to change. Type @ for a file, a skill, a moment or what you selected',
+ composerPlaceholderBlank: 'Describe your film. Type @ to add a file or a skill',
dismiss: 'Dismiss',
jumpToLatest: 'Jump to latest',
loadingMessages: 'Loading conversation…',
diff --git a/apps/desktop/chat/src/i18n/locales/es.ts b/apps/desktop/chat/src/i18n/locales/es.ts
index cdb8436..6606228 100644
--- a/apps/desktop/chat/src/i18n/locales/es.ts
+++ b/apps/desktop/chat/src/i18n/locales/es.ts
@@ -131,7 +131,6 @@ export const es: Words = {
composer: {
contextFull: 'Esta conversación ya es larga. Una nueva funcionará mejor.',
contextFullNew: 'Nueva conversación',
- commands: 'Comandos',
agentLoading: 'Cargando…',
agentNone: 'Agente',
agentNoneShown: 'No hay ningún agente activado para el chat.',
@@ -221,8 +220,8 @@ export const es: Words = {
assets: 'Recursos',
addAttachment: 'Añadir archivos',
close: 'Cerrar',
- composerPlaceholder: 'Di qué cambiar. Escribe @ para señalar un archivo, un momento o lo que seleccionaste',
- composerPlaceholderBlank: 'Describe tu película. Escribe @ para usar un archivo de este proyecto',
+ composerPlaceholder: 'Di qué cambiar. Escribe @ para un archivo, una skill, un momento o lo que seleccionaste',
+ composerPlaceholderBlank: 'Describe tu película. Escribe @ para añadir un archivo o una skill',
dismiss: 'Descartar',
jumpToLatest: 'Ir a lo más reciente',
loadingMessages: 'Cargando la conversación…',
diff --git a/apps/desktop/chat/src/i18n/locales/ja.ts b/apps/desktop/chat/src/i18n/locales/ja.ts
index 9b74b7f..0689410 100644
--- a/apps/desktop/chat/src/i18n/locales/ja.ts
+++ b/apps/desktop/chat/src/i18n/locales/ja.ts
@@ -131,7 +131,6 @@ export const ja: Words = {
composer: {
contextFull: 'この会話は長くなっています。新しい会話のほうがうまくいきます。',
contextFullNew: '新しい会話',
- commands: 'コマンド',
agentLoading: '読み込み中…',
agentNone: 'エージェント',
agentNoneShown: 'チャットで使えるエージェントがオンになっていません。',
@@ -221,8 +220,8 @@ export const ja: Words = {
assets: '素材',
addAttachment: 'ファイルを追加',
close: '閉じる',
- composerPlaceholder: '変更したい内容を入力。@ でファイル、タイミング、選択中のものを指定できます',
- composerPlaceholderBlank: '作りたい映像を説明してください。@ でこのプロジェクトのファイルを使えます',
+ composerPlaceholder: '変更したい内容を入力。@ でファイル、スキル、タイミング、選択中のものを指定できます',
+ composerPlaceholderBlank: '作りたい映像を説明してください。@ でファイルやスキルを追加できます',
dismiss: '閉じる',
jumpToLatest: '最新へ移動',
loadingMessages: '会話を読み込み中…',
diff --git a/apps/desktop/chat/src/i18n/locales/ko.ts b/apps/desktop/chat/src/i18n/locales/ko.ts
index 42eeb56..54ad50a 100644
--- a/apps/desktop/chat/src/i18n/locales/ko.ts
+++ b/apps/desktop/chat/src/i18n/locales/ko.ts
@@ -127,7 +127,6 @@ export const ko: Words = {
composer: {
contextFull: '대화가 길어졌습니다. 새 대화를 시작하면 더 잘 됩니다.',
contextFullNew: '새 대화',
- commands: '명령',
agentLoading: '불러오는 중…',
agentNone: '에이전트',
agentNoneShown: '채팅에 켜 둔 에이전트가 없습니다.',
@@ -217,8 +216,8 @@ export const ko: Words = {
assets: '에셋',
addAttachment: '파일 추가',
close: '닫기',
- composerPlaceholder: '무엇을 바꿀지 말해 주세요. @를 입력하면 파일, 순간, 선택한 항목을 가리킬 수 있습니다',
- composerPlaceholderBlank: '만들고 싶은 영상을 설명해 주세요. @를 입력하면 이 프로젝트의 파일을 쓸 수 있습니다',
+ composerPlaceholder: '무엇을 바꿀지 말해 주세요. @를 입력하면 파일, 스킬, 순간, 선택한 항목을 가리킬 수 있습니다',
+ composerPlaceholderBlank: '만들고 싶은 영상을 설명해 주세요. @를 입력하면 파일이나 스킬을 넣을 수 있습니다',
dismiss: '닫기',
jumpToLatest: '최신 메시지로 이동',
loadingMessages: '대화를 불러오는 중…',
diff --git a/apps/desktop/chat/src/i18n/locales/zh-CN.ts b/apps/desktop/chat/src/i18n/locales/zh-CN.ts
index da60ff8..fbd7a10 100644
--- a/apps/desktop/chat/src/i18n/locales/zh-CN.ts
+++ b/apps/desktop/chat/src/i18n/locales/zh-CN.ts
@@ -131,7 +131,6 @@ export const zhCN: Words = {
composer: {
contextFull: '这段对话已经很长了,开个新对话效果更好。',
contextFullNew: '新对话',
- commands: '命令',
agentLoading: '正在加载…',
agentNone: '智能体',
agentNoneShown: '对话中尚未开启任何智能体。',
@@ -221,8 +220,8 @@ export const zhCN: Words = {
assets: '素材',
addAttachment: '添加文件',
close: '关闭',
- composerPlaceholder: '说说要改什么。输入 @ 可指向文件、某个时刻或当前选中的内容',
- composerPlaceholderBlank: '描述你的影片。输入 @ 可使用此项目中的文件',
+ composerPlaceholder: '说说要改什么。输入 @ 可指向文件、skill、某个时刻或当前选中的内容',
+ composerPlaceholderBlank: '描述你的影片。输入 @ 可加入文件或 skill',
dismiss: '关闭',
jumpToLatest: '跳到最新',
loadingMessages: '正在加载对话…',
diff --git a/apps/desktop/chat/src/lib/desktop-bridge.ts b/apps/desktop/chat/src/lib/desktop-bridge.ts
index caa5419..0f4b88d 100644
--- a/apps/desktop/chat/src/lib/desktop-bridge.ts
+++ b/apps/desktop/chat/src/lib/desktop-bridge.ts
@@ -53,8 +53,6 @@ export interface LocalAgentSessionInfo {
resumed?: boolean;
/** a message sent while it works can join the running turn (`steer`) */
steering?: boolean;
- /** its commands, as a session opened only to ask said them (`probe`): ACP's availableCommands */
- commands?: unknown[];
agentInfo: { name: string; title?: string; version?: string } | null;
authMethods: Array<{ id: string; name: string; description?: string }>;
/** Whether our MCP tools were handed over (not when the agent does not take HTTP). */
diff --git a/apps/desktop/chat/src/lib/local-agent-run.ts b/apps/desktop/chat/src/lib/local-agent-run.ts
index 8c2c5d9..4642655 100644
--- a/apps/desktop/chat/src/lib/local-agent-run.ts
+++ b/apps/desktop/chat/src/lib/local-agent-run.ts
@@ -553,47 +553,6 @@ const sessions = new Map<string, LiveSession>();
export function forgetLocalAgentSessions(agent: LocalAgentId): void {
for (const [k, s] of sessions) if (s.agent === agent) sessions.delete(k);
}
-/* ── the agent's own commands (its `/` menu: built-in ones, the person's skills and custom commands), as its sessions
- say them (ACP available_commands_update). Kept by agent: the last list any of its sessions gave, so a new
- conversation has them before its first message. A list that comes before its session is known here waits for it. */
-
-export interface AgentCommand { name: string; description: string; hint: string | null }
-
-/* kept between launches (this page's storage), so the menu has them before the agent's first session */
-const COMMANDS_KEY = 'openfilm.agent-commands.v1';
-const commandsByAgent = new Map<LocalAgentId, AgentCommand[]>((() => {
- try { return Object.entries(JSON.parse(localStorage.getItem(COMMANDS_KEY) ?? '{}')) as Array<[LocalAgentId, AgentCommand[]]>; } catch { return []; }
-})());
-const unclaimedCommands = new Map<string, AgentCommand[]>();
-const commandListeners = new Set<() => void>();
-const NO_COMMANDS: AgentCommand[] = [];
-
-/** The commands as ACP lists them (`availableCommands`: { name, description, input?.hint }). */
-export function readCommands(update: Record<string, unknown>): AgentCommand[] {
- const list = Array.isArray(update.availableCommands) ? update.availableCommands as Array<Record<string, unknown>> : [];
- return list.flatMap((c) => (typeof c?.name === 'string' && c.name ? [{
- name: c.name.replace(/^\//, ''),
- description: typeof c.description === 'string' ? c.description : '',
- hint: typeof (c.input as { hint?: unknown } | null)?.hint === 'string' ? (c.input as { hint: string }).hint : null,
- }] : []));
-}
-
-/** The agent's commands as one of its sessions said them (the menu's probe too). */
-export function keepCommands(agent: LocalAgentId, list: AgentCommand[]): void {
- commandsByAgent.set(agent, list);
- try { localStorage.setItem(COMMANDS_KEY, JSON.stringify(Object.fromEntries(commandsByAgent))); } catch { /* kept for this launch */ }
- for (const listener of commandListeners) listener();
-}
-
-/** The agent's commands, for the composer's `/` menu (empty until one of its sessions has said them). */
-export function useAgentCommands(agent: LocalAgentId): AgentCommand[] {
- return React.useSyncExternalStore(
- (listener) => { commandListeners.add(listener); return () => { commandListeners.delete(listener); }; },
- () => commandsByAgent.get(agent) ?? NO_COMMANDS,
- () => NO_COMMANDS,
- );
-}
-
/* ── how full the agent's context is (ACP usage_update): tokens in the conversation now, of its context window, as
the agent's own chat shows it. By session: each conversation has its own. ── */
@@ -726,13 +685,6 @@ function listen(): void {
if (origin && origin.kind !== 'human' && unprompted.has(event.key)) endUnprompted(event.key);
return;
}
- if (event.kind === 'update' && event.update.sessionUpdate === 'available_commands_update') {
- const list = readCommands(event.update);
- const agent = [...sessions.values()].find((s) => s.key === event.key)?.agent;
- if (agent) keepCommands(agent, list);
- else unclaimedCommands.set(event.key, list);
- return;
- }
const turn = turnByKey.get(event.key);
if (event.kind === 'done') {
const waiter = doneWaiters.get(event.key);
@@ -855,8 +807,6 @@ export async function runLocalAgentTurn({
session = { key: started.key, agent, cwd, info: started.info, projectId, conversation };
sessions.set(sessionKey, session);
tellContext();
- const said = unclaimedCommands.get(started.key);
- if (said) { unclaimedCommands.delete(started.key); keepCommands(agent, said); }
onSessionInfo?.(started.info);
}
/* a turn the agent was working on by itself ends as the person writes */
diff --git a/apps/desktop/chat/src/state/local-agent-store.ts b/apps/desktop/chat/src/state/local-agent-store.ts
index 9950249..daad629 100644
--- a/apps/desktop/chat/src/state/local-agent-store.ts
+++ b/apps/desktop/chat/src/state/local-agent-store.ts
@@ -17,7 +17,7 @@ import {
type LocalAgentSessionInfo,
type RosterAgent,
} from '@/lib/desktop-bridge';
-import { forgetLocalAgentSessions, keepCommands, readCommands } from '@/lib/local-agent-run';
+import { forgetLocalAgentSessions } from '@/lib/local-agent-run';
export type AgentPick = LocalAgentId;
@@ -259,7 +259,6 @@ export const useLocalAgents = create<LocalAgentStore>((set, get) => ({
const r = await api.probe(agent, model).catch((e: unknown) => ({ ok: false as const, error: e instanceof Error ? e.message : String(e), code: undefined }));
// A newer model pick wins; an older response must not replace its effort list.
if (currentKey() !== key || !get().roster?.some((a) => a.id === agent && a.shown && a.status === 'ready')) return;
- if (r.ok && r.info.commands?.length) keepCommands(agent, readCommands({ availableCommands: r.info.commands }));
if (r.ok && r.info.configOptions?.length) get().noteOptions(agent, r.info.configOptions);
/* the ones kept from before stay when this launch's ask fails */
else if (!kept || model != null) set({ optionsError: { ...get().optionsError, [agent]: r.ok ? { text: 'no options' } : { text: r.error, ...(r.code ? { code: r.code } : {}) } } });
diff --git a/apps/desktop/src/local-agents-ipc.mjs b/apps/desktop/src/local-agents-ipc.mjs
index c2b551e..4220a5b 100644
--- a/apps/desktop/src/local-agents-ipc.mjs
+++ b/apps/desktop/src/local-agents-ipc.mjs
@@ -5,8 +5,7 @@
* desktop:local-agents:list → [{ id, label, cli: { path, source } | null, signedIn, install, setupRequired }]
* desktop:local-agents:sign-in { agent } → Terminal runs its own sign-in, which opens its own page
* desktop:local-agents:probe { agent } → { ok, info }: a session opened and closed, only for its options
- * (model, reasoning effort) and its commands (info.commands), so the menu and the
- * composer's / show them before the first message
+ * (model, reasoning effort), so the menu shows them before the first message
* desktop:local-agents:start { agent, cwd, resume? } → { ok, key, info } | { ok: false, error, code? }
* resume: the agent's own id of a conversation it had (info.sessionId of an earlier
* start), taken up where it stopped: the session still open here (a reloaded
@@ -61,8 +60,6 @@ const BETWEEN_TURNS_MAX = 500;
/** a session nobody has spoken in for this long closes; how often that is looked at */
const IDLE_MS = 20 * 60_000;
const IDLE_CHECK_MS = 60_000;
-/** how long a session opened for its options waits for the agent to say its commands */
-const PROBE_COMMANDS_MS = 1500;
/** how long after its turn a session whose skills changed closes: the page has settled the turn by then */
const STALE_CLOSE_MS = 3000;
/** the pictures one message may carry (the page's PROMPT_PICTURES_MAX), and how big each (base64, at most 2000 px a side) */
@@ -222,23 +219,15 @@ export function registerLocalAgentIpc(ipcMain, { trusted, binDir = null, fallbac
if (!isChatAgent(agent)) return { ok: false, error: `Unknown agent: ${String(agent)}` };
let session;
try {
- /* its commands too (the composer's / menu), which it says just after the session opens: waited for a moment */
- let commands = null;
let options = null;
- let said = () => {};
- const heard = new Promise((done) => { said = done; });
session = new AgentSession({ agent, cwd: probeFolder(), binDir, fallbackDir, env, harness: await harnessFor(agent),
- onUpdate: (update) => {
- if (update?.sessionUpdate === 'available_commands_update') { commands = update.availableCommands ?? null; said(); }
- if (update?.sessionUpdate === 'config_option_update') options = update.configOptions ?? null;
- } });
+ onUpdate: (update) => { if (update?.sessionUpdate === 'config_option_update') options = update.configOptions ?? null; } });
let info = await session.start();
if (options) info = { ...info, configOptions: options };
options = null;
info = await optionsForModel(session, info, typeof opts?.model === 'string' ? opts.model : undefined);
- await Promise.race([heard, new Promise((done) => setTimeout(done, PROBE_COMMANDS_MS))]);
if (options) info = { ...info, configOptions: options };
- return { ok: true, info: { ...info, ...(commands ? { commands } : {}) } };
+ return { ok: true, info };
} catch (e) {
const error = e instanceof Error ? e.message : String(e);
/* the model menu says only that it could not start: what went wrong is kept here (logs/studio.log) */
diff --git a/apps/desktop/src/mention-menu.test.mjs b/apps/desktop/src/mention-menu.test.mjs
index 87cced7..f7acd9d 100644
--- a/apps/desktop/src/mention-menu.test.mjs
+++ b/apps/desktop/src/mention-menu.test.mjs
@@ -1,12 +1,22 @@
import { test } from 'node:test';
import assert from 'node:assert/strict';
-import { matchSlashTrigger } from '../chat/src/components/prompt-editor/mention-menu.ts';
+import { MENTION_MENU_LIMIT, buildMentionMenu, matchMentionTrigger } from '../chat/src/components/prompt-editor/mention-menu.ts';
-test("a `/` at the start of the message opens the agent's commands; anywhere else it is only a slash", () => {
- assert.deepEqual(matchSlashTrigger('/'), { leadOffset: 0, query: '', replaceableString: '/' });
- assert.deepEqual(matchSlashTrigger(' /comp'), { leadOffset: 2, query: 'comp', replaceableString: '/comp' });
- assert.equal(matchSlashTrigger('/compact now'), null, 'a space ends the command');
- assert.equal(matchSlashTrigger('make it 1/2'), null);
- assert.equal(matchSlashTrigger('assets/'), null);
- assert.equal(matchSlashTrigger('//'), null);
+test('`@` is the one menu: a `/` at the start of the message is only a slash', () => {
+ assert.deepEqual(matchMentionTrigger('@'), { leadOffset: 0, query: '', replaceableString: '@' });
+ assert.equal(matchMentionTrigger('/'), null);
+ assert.equal(matchMentionTrigger('/compact'), null);
+});
+
+test('each group is cut on its own: many files keep the skills after them, each group with its title', () => {
+ const items = (kind, n) => Array.from({ length: n }, (_, i) => ({ id: `${kind}:${i}`, kind, label: `${kind} ${i}`, select: () => null }));
+ const menu = buildMentionMenu([
+ { id: 'moment', groupLabel: 'Moments', items: items('time', 2) },
+ { id: 'asset', groupLabel: 'Files', items: items('file', 50) },
+ { id: 'skills', groupLabel: 'Skills', items: items('skill', 146), limit: Infinity },
+ ], '');
+ assert.equal(menu.filter((e) => e.providerId === 'moment').length, 2);
+ assert.equal(menu.filter((e) => e.providerId === 'asset').length, MENTION_MENU_LIMIT);
+ assert.equal(menu.filter((e) => e.providerId === 'skills').length, 146, 'a group with no cap shows every row');
+ assert.deepEqual(menu.filter((e) => e.firstOfGroup).map((e) => e.groupLabel), ['Moments', 'Files', 'Skills']);
});