Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

fix(ui): a Bot's replies and route read as the Bot (#3123)

Call White9d55abdef4cf
diff --git a/ui/e2e/workbench-general/bots.spec.ts b/ui/e2e/workbench-general/bots.spec.ts
index a175b7e84..695c4faa1 100644
--- a/ui/e2e/workbench-general/bots.spec.ts
+++ b/ui/e2e/workbench-general/bots.spec.ts
@@ -91,7 +91,14 @@ async function serveBots(page: Page, lang: Lang, bots: FixtureBot[]) {
};
await page.route(`**/api/sessions/${sessionId}/bootstrap`, (route) => route.fulfill({ json: {
session, capabilities: { can_chat: true }, agents: AGENTS, default_agent_name: 'vibey', config: { ui: {} },
- messages: [], queued: [], next_after_id: null, next_before_id: null,
+ // The main Bot's conversation has one reply; the others start empty.
+ messages: bot.handle === 'main' ? [{
+ id: 'msg-main-reply', scope_id: null, session_id: sessionId, platform: 'avibe', author: 'agent', type: 'result',
+ source: 'agent', author_id: null, author_name: null, native_message_id: null, parent_native_message_id: null,
+ text: 'The launch checklist is on track.', content: { text: 'The launch checklist is on track.' },
+ metadata: { author_agent_id: 'agt-main', author_backend: 'vibey' }, created_at: ago(5), updated_at: ago(5),
+ }] : [],
+ queued: [], next_after_id: null, next_before_id: null,
draft: { text: '', updated_at: null }, turn_state: turnState,
} }));
await page.route(`**/api/sessions/${sessionId}`, (route) => route.fulfill({ json: session }));
@@ -224,8 +231,8 @@ for (const theme of ['light', 'dark'] as const) {
// The empty conversation shows the Bot's role; the open Bot carries the ring.
await expect(page.locator('main')).toContainText('依赖与权限的安全审计,每周汇报');
await expect(page.getByRole('button', { name: '首席安全官, 2 unread', exact: true })).toHaveAttribute('aria-current', 'page');
- // The composer moves the model only: the Agent is the Bot's, named but not offered.
- await page.locator('main').getByRole('button', { name: /^cso/ }).click();
+ // The composer moves the model only: the Agent is the Bot's, named by the Bot but not offered.
+ await page.locator('main').getByRole('button', { name: /^首席安全官/ }).click();
await expect(page.getByText('Model', { exact: true })).toBeVisible();
await expect(page.getByRole('button', { name: /^Agent/ })).toHaveCount(0);
await expect(page.getByRole('button', { name: 'New agent' })).toHaveCount(0);
@@ -347,6 +354,20 @@ test('on a short window the dialog scrolls to its footer', async ({ page }) => {
expect(denied).toEqual([]);
});
+test("a Bot's replies and its route read as the Bot, not its Agent", async ({ page }) => {
+ const { denied } = await serveBots(page, 'en', [MAIN, CSO, PM]);
+ await page.setViewportSize(DESKTOP);
+ await open(page, '/chat/ses_main', { lang: 'en' });
+ const reply = page.locator('[data-message-id="msg-main-reply"]');
+ await expect(reply).toContainText('The launch checklist is on track.');
+ // D2: chat shows the display name (the main Bot's default, here) with its avatar.
+ await expect(reply).toContainText('Vibey');
+ await expect(reply).not.toContainText('main');
+ await expect(reply.locator('.bot-avatar-mascot')).toHaveCount(1);
+ await expect(page.locator('main').getByRole('button', { name: /^Vibey/ })).toBeVisible();
+ expect(denied).toEqual([]);
+});
+
test('with more Bots than fit, the strip scrolls and Add stays pinned at the right', async ({ page }) => {
const { denied } = await serveBots(page, 'en', [MAIN, CSO, PM, ...EXTRA]);
await page.setViewportSize(DESKTOP);
diff --git a/ui/src/components/workbench/ChatPage.tsx b/ui/src/components/workbench/ChatPage.tsx
index b29672ee7..3734df191 100644
--- a/ui/src/components/workbench/ChatPage.tsx
+++ b/ui/src/components/workbench/ChatPage.tsx
@@ -3738,7 +3738,14 @@ const ChatRoutePicker: React.FC<ChatRoutePickerProps> = ({ session, agents, defa
? concreteBackend
: pendingForkBackend ?? (backendLocked ? concreteBackend : null);
const canClearToDefault = !lockAgent && !backendLocked && !nativeBound;
- const pickableAgents = lockAgent ? agents.filter((agent) => agent.name === session.agent_name) : agents;
+ // A Bot's conversation names its Bot on the picker, as everywhere else in chat.
+ const { botForSession, displayName: botDisplayName } = useBots();
+ const routeBot = lockAgent ? botForSession(session.id) : undefined;
+ const pickableAgents = lockAgent
+ ? agents
+ .filter((agent) => agent.name === session.agent_name)
+ .map((agent) => (routeBot ? { ...agent, display_name: botDisplayName(routeBot) } : agent))
+ : agents;
const pickerDisabled = working && !concreteBackend && !pendingForkBackend;
const defaultRoute = defaultAgent
? {
@@ -4949,6 +4956,8 @@ export const ThinkingBubble: React.FC<{
statusLabel?: string | null;
}> = ({ session, agentDisplayName, agentBackend = null, onShowActivity, statusLabel }) => {
const { t } = useTranslation();
+ const { botForSession, displayName: botDisplayName } = useBots();
+ const replyBot = botForSession(session.id);
const dots = (
<div className="flex items-center gap-1 py-0.5">
<span className="vr-typing-dot size-1.5 rounded-full bg-mint" />
@@ -4960,9 +4969,13 @@ export const ThinkingBubble: React.FC<{
<div className="flex w-full justify-start">
<div className="group/message flex max-w-[min(92%,860px)] flex-col items-start gap-1">
<div className="flex items-center gap-2 px-0.5">
- <RoleAvatar tone="mint"><BackendAvatar backend={agentBackend ?? session.agent_backend ?? ''} /></RoleAvatar>
+ {replyBot ? (
+ <BotAvatar avatar={replyBot.avatar} name={botDisplayName(replyBot)} size={24} />
+ ) : (
+ <RoleAvatar tone="mint"><BackendAvatar backend={agentBackend ?? session.agent_backend ?? ''} /></RoleAvatar>
+ )}
<span className="text-[11px] font-medium text-muted">
- {statusLabel || agentDisplayName || session.agent_name || t('chat.thinking')}
+ {statusLabel || (replyBot ? botDisplayName(replyBot) : null) || agentDisplayName || session.agent_name || t('chat.thinking')}
</span>
</div>
{onShowActivity ? (
@@ -5046,6 +5059,11 @@ export const MessageRow = memo(function MessageRow({
// row's memo, so a personal↔organization change repaints the transcript
// without the page having to re-create every row's props.
const { instanceKind } = useInstanceAuthorization();
+ // In a Bot's conversation the replies are the Bot's own (docs/plans/bots.md D2:
+ // the display name is what chat shows), so its head carries the Bot's avatar
+ // and display name rather than the Agent's name.
+ const { botForSession, displayName: botDisplayName } = useBots();
+ const replyBot = botForSession(session.id);
// Harness rows are collapsed by default; the Transcript holds which are open.
const expanded = harnessOpen;
@@ -5367,13 +5385,17 @@ export const MessageRow = memo(function MessageRow({
// ----- Agent / boundary / system: left-aligned bubble with identity header -----
const agentIdentity = isAgent || isBoundary;
const name = agentIdentity
- ? agentDisplayName || session.agent_name || message.author_name
+ ? (replyBot ? botDisplayName(replyBot) : null) || agentDisplayName || session.agent_name || message.author_name
: message.author_name;
return (
<div data-message-id={message.id} className={rowClass('justify-start')}>
<div className="group/message flex max-w-[min(92%,860px)] flex-col items-start gap-1">
<div className="flex items-center gap-2 px-0.5">
- <RoleAvatar tone={isAgent ? 'mint' : 'muted'}>{agentIdentity ? <BackendAvatar backend={agentBackend ?? session.agent_backend ?? ''} /> : <Info />}</RoleAvatar>
+ {agentIdentity && replyBot ? (
+ <BotAvatar avatar={replyBot.avatar} name={botDisplayName(replyBot)} size={24} />
+ ) : (
+ <RoleAvatar tone={isAgent ? 'mint' : 'muted'}>{agentIdentity ? <BackendAvatar backend={agentBackend ?? session.agent_backend ?? ''} /> : <Info />}</RoleAvatar>
+ )}
{name && <span className="text-[11px] font-medium text-muted">{name}</span>}
</div>
{bodyNode || attachmentsNode ? (