Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions frontend/src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,9 @@
"nameHint": "Lower-case letters, digits, and dashes. This is the identity your agent posts as.",
"podLabel": "Install into pod",
"podHint": "Your agent will be installed here. You can install it into more pods later.",
"loadingPods": "Loading pods…"
"loadingPods": "Loading pods…",
"machineLabel": "Computer",
"machineHint": "The daemon on this computer will adopt and start the agent."
},
"actions": {
"install": "Install + generate token",
Expand All @@ -1168,7 +1170,9 @@
"goToPod": "Go to your pod",
"installAnother": "Install another",
"runHere": "Run it here",
"starting": "Starting…"
"starting": "Starting…",
"assign": "Add to this computer",
"assigning": "Assigning…"
},
"footnote": {
"preferCli": "Prefer the CLI?",
Expand Down Expand Up @@ -1208,7 +1212,8 @@
"fileTooLarge": "That file is over the 256KB import ceiling — trim it or paste the relevant part.",
"importFailed": "Import failed.",
"hostedCap": "You already have a hosted agent (beta allows {{cap}}). Connect your own runtime for more.",
"hostedUnavailable": "Hosting isn't available on this instance yet. Connect your own runtime instead."
"hostedUnavailable": "Hosting isn't available on this instance yet. Connect your own runtime instead.",
"machineRequired": "Pick a computer first."
},
"listen": {
"title": "One more step, or it can't answer you",
Expand All @@ -1228,7 +1233,10 @@
"recommended": "RECOMMENDED",
"yours": "YOUR MACHINE",
"hostedMeta": "Live in ~10 seconds — no terminal, no keys",
"byoMeta": "MCP token + snippets for your editor"
"byoMeta": "MCP token + snippets for your editor",
"machine": "On my computer",
"machineHint": "Runs on a computer you've added — your files, your CLIs",
"machineMeta": "Needs the Commonly daemon running there"
},
"hosted": {
"heading": "Running:",
Expand All @@ -1253,6 +1261,15 @@
"persona": {
"hiring": "Hiring",
"none": "No colleague selected — this is the blank-agent path."
},
"machine": {
"online": "online",
"offline": "offline",
"heading": "Now starting:",
"running": "Running on {{machine}} — say hi in the pod.",
"waiting": "Waiting for the daemon on {{machine}} to pick it up…",
"slow": "Still waiting — check that commonly daemon run is active on {{machine}}. The agent starts the moment it's back.",
"openPod": "Open the pod"
}
},
"compare": {
Expand Down
25 changes: 21 additions & 4 deletions frontend/src/i18n/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -1218,7 +1218,9 @@
"nameHint": "小写字母、数字和连字符。这是你的智能体发帖时使用的身份。",
"podLabel": "安装到 Pod",
"podHint": "你的智能体会安装在这里。之后可以把它安装到更多 Pod。",
"loadingPods": "正在加载 Pod…"
"loadingPods": "正在加载 Pod…",
"machineLabel": "电脑",
"machineHint": "这台电脑上的守护进程会接管并启动该智能体。"
},
"actions": {
"install": "安装并生成令牌",
Expand All @@ -1228,7 +1230,9 @@
"goToPod": "前往你的 Pod",
"installAnother": "再安装一个",
"runHere": "在这里运行",
"starting": "正在启动…"
"starting": "正在启动…",
"assign": "添加到这台电脑",
"assigning": "分配中…"
},
"footnote": {
"preferCli": "更喜欢用 CLI?",
Expand Down Expand Up @@ -1268,7 +1272,8 @@
"fileTooLarge": "该文件超过 256KB 的导入上限——请精简,或只粘贴相关部分。",
"importFailed": "导入失败。",
"hostedCap": "你已有一个托管智能体(测试期允许 {{cap}} 个)。如需更多,请自带运行时。",
"hostedUnavailable": "此实例暂未开放托管。请改用自带运行时。"
"hostedUnavailable": "此实例暂未开放托管。请改用自带运行时。",
"machineRequired": "请先选择一台电脑。"
},
"listen": {
"title": "还差一步,否则它无法回复你",
Expand All @@ -1288,7 +1293,10 @@
"recommended": "推荐",
"yours": "你的电脑",
"hostedMeta": "约 10 秒上线——无需终端与密钥",
"byoMeta": "MCP 令牌 + 编辑器代码片段"
"byoMeta": "MCP 令牌 + 编辑器代码片段",
"machine": "在我的电脑上",
"machineHint": "在你已添加的电脑上运行——你的文件、你的 CLI",
"machineMeta": "需要那台电脑运行 Commonly 守护进程"
},
"hosted": {
"heading": "运行中:",
Expand All @@ -1313,6 +1321,15 @@
"persona": {
"hiring": "正在雇佣",
"none": "还没有选择同事——这是空白智能体路径。"
},
"machine": {
"online": "在线",
"offline": "离线",
"heading": "正在启动:",
"running": "已在 {{machine}} 上运行——去 pod 里打个招呼吧。",
"waiting": "正在等待 {{machine}} 上的守护进程接管…",
"slow": "仍在等待——请确认 {{machine}} 上正在运行 commonly daemon run,恢复后会立即启动该智能体。",
"openPod": "打开 pod"
}
},
"agentProfile": {
Expand Down
107 changes: 107 additions & 0 deletions frontend/src/v2/__tests__/V2AgentBYOMachine.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
// @ts-nocheck
// ADR-026 Phase 2 slice 3: the "on my computer" path. Pinned: the mode card
// appears only when the user has daemon machines; submit installs with
// runtimeType 'wrapper' and files a placement request (never a binding); the
// result panel watches the daemon's per-agent heartbeat state.
import React from 'react';
import { render, screen, waitFor, fireEvent } from '@testing-library/react';
import { MemoryRouter } from 'react-router-dom';
import V2AgentBYO from '../components/V2AgentBYO';
import { AuthContext } from '../../context/AuthContext';

jest.mock('axios', () => {
const mock = {
get: jest.fn(),
post: jest.fn(),
patch: jest.fn(),
delete: jest.fn(),
defaults: { baseURL: '', headers: { common: {} } },
interceptors: {
request: { use: jest.fn(), eject: jest.fn() },
response: { use: jest.fn(), eject: jest.fn() },
},
};
return { __esModule: true, default: mock, ...mock };
});

const axios = jest.requireMock('axios').default;

const authValue = {
currentUser: { _id: 'u1', username: 'sam' },
user: { _id: 'u1', username: 'sam' },
token: 'user-jwt',
loading: false,
error: null,
isAuthenticated: true,
register: jest.fn(),
login: jest.fn(),
logout: jest.fn(),
updateProfile: jest.fn(),
};

const machineRow = {
id: 'm1', machineId: 'mach-a', name: 'Sam’s MacBook', status: 'online', agentStates: [],
};

const mockGet = ({ machines = [machineRow] } = {}) => {
axios.get.mockImplementation((url) => {
if (url.startsWith('/api/hosted/availability')) {
return Promise.resolve({ data: { configured: false, caps: { agentsPerUser: 1, turnsPerDay: 200 } } });
}
if (url === '/api/pods') return Promise.resolve({ data: [{ _id: 'p1', name: 'Workspace', type: 'chat', createdBy: { _id: 'u1' } }] });
if (url === '/api/machines') return Promise.resolve({ data: { machines, offlineAfterMs: 90000 } });
return Promise.resolve({ data: {} });
});
};

const renderPage = () => render(
<AuthContext.Provider value={authValue}>
<MemoryRouter>
<V2AgentBYO />
</MemoryRouter>
</AuthContext.Provider>,
);

afterEach(() => {
jest.clearAllMocks();
window.history.pushState({}, '', '/v2/agents/byo');
});

describe('BYO on-my-computer mode', () => {
test('a registered machine surfaces the mode card and picker', async () => {
mockGet();
renderPage();
await waitFor(() => expect(screen.getByTestId('byo-mode-machine')).toBeInTheDocument());
fireEvent.click(screen.getByTestId('byo-mode-machine'));
expect(screen.getByTestId('byo-machine-select')).toBeInTheDocument();
expect(screen.getByTestId('byo-machine-select')).toHaveTextContent('Sam’s MacBook');
});

test('no machines — no card, page untouched', async () => {
mockGet({ machines: [] });
renderPage();
await waitFor(() => expect(axios.get).toHaveBeenCalledWith('/api/machines', expect.anything()));
expect(screen.queryByTestId('byo-mode-machine')).toBeNull();
});

test('submit installs a wrapper runtime and files the placement request', async () => {
mockGet();
axios.post.mockResolvedValue({ data: {} });
renderPage();
await waitFor(() => expect(screen.getByTestId('byo-mode-machine')).toBeInTheDocument());
fireEvent.click(screen.getByTestId('byo-mode-machine'));
fireEvent.click(screen.getByText('Add to this computer'));

await waitFor(() => expect(screen.getByTestId('byo-machine-result')).toBeInTheDocument());
expect(axios.post).toHaveBeenCalledWith('/api/registry/install', expect.objectContaining({
agentName: 'sam-agent',
podId: 'p1',
config: expect.objectContaining({ runtime: { runtimeType: 'wrapper' } }),
}), expect.anything());
expect(axios.post).toHaveBeenCalledWith('/api/agent-binding/request', {
agentName: 'sam-agent', instanceId: 'default', machineId: 'mach-a',
}, expect.anything());
// Honest until the daemon reports it: waiting, not live.
expect(screen.getByTestId('byo-machine-waiting')).toBeInTheDocument();
});
});
Loading
Loading