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
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ jobs:
push: true
build-args: |
LOOPFORGE_COMMIT=${{ steps.release.outputs.commit }}
LOOPFORGE_RELEASE_VERSION=${{ steps.release.outputs.tag }}
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
cache-from: type=gha
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ ENV PATH="/app/bin:${PATH}"
# An explicit LOOPFORGE_COMMIT wins. Otherwise read HEAD from the build context
# so `docker build` stamps the same corner label as the release workflow.
ARG LOOPFORGE_COMMIT=
ARG LOOPFORGE_RELEASE_VERSION=
ENV LOOPFORGE_RELEASE_VERSION=${LOOPFORGE_RELEASE_VERSION}
RUN --mount=type=bind,source=.,target=/ctx,ro \
sh /ctx/scripts/image-commit.sh /ctx /app/loopforge-commit
EXPOSE 8080
Expand Down
14 changes: 14 additions & 0 deletions chatbot/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1897,6 +1897,19 @@ export default function App() {
</IconButton>
</div>
) : null}
{chat.missingServerCLI && !chat.busy && !chat.error && !chat.readOnly ? (
<div className="runtime-cli-notice" role="status">
<HarnessIcon name="terminal" size={16} aria-hidden="true" />
<span>{chat.missingServerCLI.name} 未安装在平台服务器上。{chat.missingServerCLI.serverInstallable ? "" : "请联系管理员安装。"}</span>
{chat.missingServerCLI.serverInstallable ? (
<CLIInstallAction
key={chat.missingServerCLI.id}
executor={{ engine: chat.missingServerCLI.id, label: chat.missingServerCLI.name }}
onResult={() => chat.refreshCredentials()}
/>
) : null}
</div>
) : null}
{needsExecutor ? (
<div className="credential-notice" role="status">
<HarnessIcon name="terminal" size={16} aria-hidden="true" />
Expand Down Expand Up @@ -2292,6 +2305,7 @@ export default function App() {
disabled={
!chat.ready ||
!hasComposerExecutor ||
!!chat.missingServerCLI ||
chat.submitting ||
chat.machineSaving ||
composerLoading ||
Expand Down
2 changes: 1 addition & 1 deletion chatbot/src/SopDesigner.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ export default function SopDesigner({ search = location.search, canvas = window.
{!messages.length && !running ? (
<div className="sop-designer-intro">
<h3>您好,我是 <em>AI 编排助手</em></h3>
<p>画布是空的,就描述要搭的流程。画布上已经有流程时,直接说改哪一步,我只改你说的地方。</p>
<p>描述要创建的流程,或指出现有流程中需要调整的步骤。</p>
<div className="sop-designer-suggest-head">
<span>可以试试这些场景:</span>
<button type="button" onClick={() => setPage((n) => n + 1)}>换一批</button>
Expand Down
4 changes: 2 additions & 2 deletions chatbot/src/cli-install.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export function cliFailureSettles(text) {
// CLIInstallAction installs the CLI named by a conversation failure.
// The server keeps the download after a reload, so the button asks for the
// current status instead of trusting a click that only this page remembers.
export function CLIInstallAction({ text, onResult }) {
const hint = cliInstallHint(text);
export function CLIInstallAction({ text, executor, onResult }) {
const hint = executor || cliInstallHint(text);
const onResultRef = useRef(onResult);
onResultRef.current = onResult;
const pending = useRef(hint ? rememberedInstall(hint.engine) : false);
Expand Down
12 changes: 6 additions & 6 deletions chatbot/src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -1626,7 +1626,7 @@ small {
color: var(--muted);
font-size: 11px;
}
.credential-notice {
:is(.credential-notice, .runtime-cli-notice) {
display: flex;
align-items: center;
gap: 10px;
Expand All @@ -1639,18 +1639,18 @@ small {
font-size: 13px;
line-height: 1.5;
}
[data-theme="dark"] .credential-notice {
[data-theme="dark"] :is(.credential-notice, .runtime-cli-notice) {
border-color: #5a4a22;
background: #2b2513;
color: #e8cf8c;
}
.credential-notice > svg {
:is(.credential-notice, .runtime-cli-notice) > svg {
flex: none;
}
.credential-notice > span {
:is(.credential-notice, .runtime-cli-notice) > span {
flex: 1;
}
.credential-notice button {
:is(.credential-notice, .runtime-cli-notice) button {
flex: none;
height: 30px;
padding: 0 10px;
Expand All @@ -1662,7 +1662,7 @@ small {
font-weight: 500;
cursor: pointer;
}
.credential-notice button:hover {
:is(.credential-notice, .runtime-cli-notice) button:hover {
background: var(--hover);
}
.info-card {
Expand Down
17 changes: 13 additions & 4 deletions chatbot/src/useChat.js
Original file line number Diff line number Diff line change
Expand Up @@ -650,13 +650,18 @@ export function useChat() {
}
const runnerId = composerRunnerId(session);
const runner = executionMachines.machines.find(machine => machine.id === runnerId && machine.ownerUserId === user?.id);
const checkServerCLI = executionMachines.machinesReady && !runnerId &&
!session?.executionTarget?.runnerId && !session?.runId && session?.runtimeMode !== "workspace";
const availableExecutors = EXECUTORS.flatMap(item => {
const local = ["codex", "claude-code", "agy"].includes(item.id) &&
runner?.runtimes?.some(runtime => runtime.provider === item.id && runtime.authMode !== "personal");
if (local) return [{ ...item, detail: "使用执行机器上的本机登录态。" }];
const configured = catalogEngines.find(engine => engine.id === item.id)?.configured ??
personalEngineConfigured(user, item.id);
return configured || (item.id === "codebuddy" && sponsoredModel) ? [item] : [];
const option = catalogEngines.find(engine => engine.id === item.id);
const configured = option?.configured ?? personalEngineConfigured(user, item.id);
if (!configured && !(item.id === "codebuddy" && sponsoredModel)) return [];
return [checkServerCLI && option?.serverMissing
? { ...item, detail: "平台服务器未安装 CLI" }
: item];
});
// Drafts can use any available executor. A recorded conversation keeps its
// executor even if its authentication changes.
Expand All @@ -667,6 +672,9 @@ export function useChat() {
(session?.executionTarget?.pool === "runner" && !executionMachines.machinesReady));
const executor = keepSessionExecutor || !user || user.isGuest ? selection.executor :
(preferred || availableExecutor(selection.executor) || availableExecutors[0])?.id || "";
const missingServerCLI = checkServerCLI
? catalogEngines.find(item => item.id === executor && item.serverMissing)
: undefined;
const { model, effort } = executor === selection.executor ? selection : { model: null, effort: null };
function resolveComposerModel(
{ executor, model, effort }, conversation, draft,
Expand Down Expand Up @@ -1060,7 +1068,7 @@ export function useChat() {
setError("会话仍在加载,请稍候再发送。");
return false;
}
if (!executor) return false;
if (!executor || missingServerCLI) return false;
const currentProjectId = sessionRef.current?.projectId || "";
const approval = fromQueue
? queuedApproval({ approvalMode, approvalUserId, approvalProjectId }, user?.id, currentProjectId)
Expand Down Expand Up @@ -1617,6 +1625,7 @@ export function useChat() {
models: executorModels,
executor,
executors: user ? availableExecutors : [],
missingServerCLI,
setExecutor: chooseExecutor,
sessions,
session,
Expand Down
6 changes: 5 additions & 1 deletion e2e/public/executors.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,14 @@ test('executor selection has independent models, credentials and a persistent ch
await options.filter({hasText:label}).click();
await expect(executor).toContainText(label);
};
for(const label of ['Codex','Claude Code','CodeBuddy']){
const {engines}=await page.request.get('/api/assistant/models').then(r=>r.json());
for(const [id,label] of [['codex','Codex'],['claude-code','Claude Code'],['codebuddy','CodeBuddy']]){
await choose(label);
await expect(input).toHaveValue(draft);
await expect(frame.locator('.credential-notice')).toHaveCount(0);
const missing=engines.find(engine=>engine.id===id)?.serverMissing;
await expect(frame.locator('.runtime-cli-notice')).toHaveCount(missing?1:0);
if(missing)await expect(frame.locator('.send-button')).toBeDisabled();
}
await choose('Codex');
await page.reload();
Expand Down
93 changes: 90 additions & 3 deletions e2e/ui/02-interactions.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ test.afterAll(cleanup);
test('requirement composer: create, find and dispatch a requirement from its drawer', async ({ page }) => {
const errors = watchErrors(page);
const title = `E2E UI 需求 ${cfg.runTag}-${Date.now() % 100000}`;
const description = '自动化 UI 测试创建,会被关闭。'.repeat(10);
// A requirement needs a runnable SOP; a fresh database has none in the e2e project.
const wf = await createWorkflow('ui-requirement', [script('only', 'echo UI_REQUIREMENT')]);
await page.goto('/#/issues');
await expect(page.locator('#issuesView')).toBeVisible();
await page.locator('#newIssue').click();
await expect(page.locator('#requirementModal')).toHaveClass(/open/);
await page.locator('#chatInput').fill(`${title}\n\n自动化 UI 测试创建,会被关闭。`);
await page.locator('#chatInput').fill(`${title}\n\n${description}`);
await expect(page.locator('#reqCreate')).toBeEnabled();
await page.getByRole('button', { name: 'SOP 流程', exact: true }).click();
await page.getByRole('listbox', { name: 'SOP 流程', exact: true })
Expand Down Expand Up @@ -65,6 +66,12 @@ test('requirement composer: create, find and dispatch a requirement from its dra
const run = await waitRun(runId, r => r.status === 'succeeded', { label: 'requirement SOP succeeds' });
expect(run.workflowId).toBe(wf);
expect(run.nodes.only.status).toBe('succeeded');
await page.goto(`/?projectId=${encodeURIComponent(cfg.projectId)}#/runs/${encodeURIComponent(runId)}`);
const runHeader = page.locator('.run-header-main');
await expect(runHeader.getByRole('heading', { level: 2 })).toHaveText(title);
await expect(runHeader.locator('.run-header-copy')).toHaveText(description);
await runHeader.getByText('展开全文', { exact: true }).click();
await expect(runHeader.getByText('收起全文', { exact: true })).toBeVisible();
expect(errors).toEqual([]);
});

Expand Down Expand Up @@ -110,8 +117,28 @@ test('run detail: tabs render and a waiting approval is approved from the UI', a
const errors = watchErrors(page);
await page.goto(`/#/runs/${encodeURIComponent(id)}`);
const approve = page.locator('[data-approve="gate"]').first();
await page.locator('[data-run-node="gate"]').click();
const gate = page.locator('[data-run-node="gate"]');
await gate.click();
await expect(approve).toBeVisible();
await expect(page.locator('.graph-legend')).toContainText('待确认');
await expect(gate).toContainText('待确认');
await expect(page.locator('.node-inspector-status')).toContainText('待确认');
const preview = page.locator('.approval-callout').getByRole('button', { name: 'result', exact: true });
await preview.click();
const dialog = page.getByRole('dialog', { name: 'result' });
await expect(dialog.getByRole('button', { name: '关闭', exact: true })).toBeFocused();
await expect(page.locator('#artifactPreview')).toContainText('UI E2E');
await page.context().grantPermissions(['clipboard-write']);
await dialog.getByRole('button', { name: /复制内容/ }).click();
const feedback = dialog.getByRole('status').filter({ hasText: '产物内容已复制到剪贴板' });
await expect(feedback).toBeVisible();
await expect.poll(() => feedback.evaluate(el => {
const rect = el.getBoundingClientRect();
return el.contains(document.elementFromPoint(rect.left + rect.width / 2, rect.top + rect.height / 2));
})).toBe(true);
await page.keyboard.press('Escape');
await expect(dialog).toBeHidden();
await expect(preview).toBeFocused();

for (const tab of ['trace', 'logs', 'workspace', 'eval', 'overview']) {
await page.locator(`[data-run-tab="${tab}"]`).click();
Expand All @@ -135,7 +162,9 @@ test('run detail: tabs render and a waiting approval is approved from the UI', a

test('approvals queue: approve a waiting run with context from the sidebar', async ({ page }) => {
const wf = await createWorkflow('ui-approval-queue', [
script('prep', 'echo QUEUE_PREP'),
script('prep', 'mkdir -p out && echo "# Review fixture" > out/review.md', {
artifactOutputs: [{ name: 'review', path: 'out/review.md', mediaType: 'text/markdown', required: true }],
}),
approval('gate', 'prep'),
script('finish', 'echo QUEUE_FINISH'),
]);
Expand All @@ -154,6 +183,29 @@ test('approvals queue: approve a waiting run with context from the sidebar', asy
});
await expect(card).toBeVisible();
await expect(card).toContainText('E2E ui-approval-queue');
const preview = card.getByRole('button', { name: 'review', exact: true });
await preview.click();
const dialog = page.getByRole('dialog', { name: 'review' });
const close = dialog.getByRole('button', { name: '关闭', exact: true });
const newWindow = dialog.getByRole('link', { name: /在新窗口打开/ });
await expect(close).toBeFocused();
await expect(page.locator('#artifactPreview')).toContainText('Review fixture');
const [linkBox, closeBox] = await Promise.all([newWindow.boundingBox(), close.boundingBox()]);
expect(linkBox.x + linkBox.width).toBeLessThanOrEqual(closeBox.x);
await newWindow.click({ trial: true });
await page.keyboard.press('Shift+Tab');
await expect(newWindow).toBeFocused();
await page.keyboard.press('Shift+Tab');
await expect(dialog.getByRole('button', { name: /下载文件/ })).toBeFocused();
await page.keyboard.press('Tab');
await expect(newWindow).toBeFocused();
await page.keyboard.press('Escape');
await expect(dialog).toBeHidden();
await expect(preview).toBeFocused();
await preview.click();
await close.click();
await expect(dialog).toBeHidden();
await expect(preview).toBeFocused();
const context = `Queue approval ${cfg.runTag}`;
await card.locator('[data-human-context]').fill(context);
const [response] = await Promise.all([
Expand Down Expand Up @@ -188,6 +240,41 @@ test('SOP designer: rename a node and save a new revision', async ({ page }) =>
expect(errors).toEqual([]);
});

test('SOP designer: all nodes stay in view when the AI assistant closes', async ({ page }) => {
const wf = await createWorkflow('ui-designer-fit', [90, 425, 780].map((x, i) =>
script(`step-${i+1}`, 'echo E2E', { position: { x, y: 200 } })));
await page.setViewportSize({ width: 1440, height: 900 });
await page.goto(`/#/flow/${encodeURIComponent(wf)}`);
const palette = page.locator('#flowPalette');
const assistant = page.locator('#aiOrchestrator');
const nodes = page.locator('#nodes .flow-node');
await expect(nodes).toHaveCount(3);
const paletteWidth = () => palette.evaluate(el => Math.round(el.getBoundingClientRect().width));
const nodesFit = () => nodes.evaluateAll(items => {
const canvas = document.getElementById('canvas').getBoundingClientRect();
const drawer = document.getElementById('aiOrchestrator');
const right = drawer.hidden ? canvas.right : drawer.getBoundingClientRect().left;
return items.every(node => {
const rect = node.getBoundingClientRect();
return rect.left >= canvas.left && rect.right <= right &&
rect.top >= canvas.top && rect.bottom <= canvas.bottom;
});
});
for (const reducedMotion of ['no-preference', 'reduce']) {
await page.emulateMedia({ reducedMotion });
await expect.poll(paletteWidth).toBe(256);
await expect.poll(nodesFit).toBe(true);
await page.locator('#openAIOrchestrator').click();
await expect(assistant).toBeVisible();
await expect.poll(paletteWidth).toBe(48);
await expect.poll(nodesFit).toBe(true);
await page.locator('#closeAIOrchestrator').click();
await expect(assistant).toBeHidden();
await expect.poll(paletteWidth).toBe(256);
await expect.poll(nodesFit).toBe(true);
}
});

test('SOP designer: drag the failure outlet onto an upstream step to route rework', async ({ page }) => {
const wf = await createWorkflow('ui-reject', [script('first', 'echo 1'), script('second', 'echo 2')]);
const before = await get(`/api/workflows/${wf}`);
Expand Down
16 changes: 16 additions & 0 deletions e2e/ui/03-workbench-settings.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,22 @@ test('AI workbench: a saved conversation is listed, opened, searched, renamed, a
expect(errors).toEqual([]);
});

test('desktop settings navigation reopens on the current page', async ({ page }) => {
await openView(page, 'settings');
const collapse = page.locator('#settingsSidebarToggle');
const expand = page.getByRole('button', { name: '展开设置导航', exact: true });
for (const reducedMotion of ['reduce', 'no-preference']) {
await page.emulateMedia({ reducedMotion });
await collapse.click();
await expect(page.locator('#settingsSidebar')).toHaveAttribute('aria-hidden', 'true');
await expect(expand).toBeFocused();
await expand.press('Enter');
await expect(collapse).toBeVisible();
await expect(collapse).toBeFocused();
await expect(page).toHaveURL(/#\/settings$/);
}
});

test('personal credentials: the add wizard validates, saves write-only, and the row clears it', async ({ page, identity }) => {
const me = identity.user;
test.skip(!!(await userById(me.id))?.codexApiKeyConfigured, 'the token owner already has a Codex API Key; not overwriting a real credential');
Expand Down
3 changes: 3 additions & 0 deletions internal/httpapi/assistant_engines.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ type assistantEngineOption struct {
Configured bool `json:"configured"`
Personal bool `json:"personal"`
Credential string `json:"credential"`
// Missing and installable are reported only for a cloud chat hosted by this platform.
ServerMissing bool `json:"serverMissing,omitempty"`
ServerInstallable bool `json:"serverInstallable,omitempty"`
}

// assistantEngineCredentialField is the 个人配置 field that enables a CLI.
Expand Down
5 changes: 4 additions & 1 deletion internal/httpapi/assistant_failure.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ func classifyAssistantFailure(ctx context.Context, err error) domain.AssistantFa
}
var missing assistantCLIMissingError
if errors.As(err, &missing) {
f.Code, f.Phase, f.Message, f.Suggestion = "CLI_NOT_INSTALLED", "setup", missing.Error(), "请管理员检查执行器的安装与配置。"
f.Code, f.Phase, f.Message = "CLI_NOT_INSTALLED", "setup", missing.Error()
if runtime.OnDemandInstallable(missing.engine) {
f.Suggestion = "可在对话中安装此执行器,安装后重新发送。"
}
return f
}
// The process error usually carries the CLI's stderr tail. Classify the
Expand Down
14 changes: 14 additions & 0 deletions internal/httpapi/assistant_models.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"crypto/sha256"
"encoding/hex"
"errors"
"os"
"os/exec"
"regexp"
Expand Down Expand Up @@ -256,6 +257,19 @@ func (h *assistantHandlers) models(c *gin.Context) {
catalog.Preferences = &user.AssistantDefaults
}
catalog.Engines = assistantEngineOptions(user, usingSharedKey)
cloudPool := false
if h.engine != nil {
cloudPool, _ = h.engine.CloudPoolStatus()
}
if !cloudPool {
for i := range catalog.Engines {
option := &catalog.Engines[i]
if _, err := resolveAssistantEngineBin(option.ID); errors.Is(err, errAssistantCLIMissing) {
option.ServerMissing = true
option.ServerInstallable = runtime.OnDemandInstallable(option.ID)
}
}
}
var runnerLogin map[string]bool
if c.Query("schedule") == "1" {
runnerLogin = make(map[string]bool)
Expand Down
Loading
Loading