Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix cmd log

Lizie59d1f4e3579
diff --git a/scripts/__tests__/restart-desktop-remote.test.mjs b/scripts/__tests__/restart-desktop-remote.test.mjs
index 57af280141..06771220ca 100644
--- a/scripts/__tests__/restart-desktop-remote.test.mjs
+++ b/scripts/__tests__/restart-desktop-remote.test.mjs
@@ -6,6 +6,7 @@ import test from "node:test";
import { fileURLToPath } from "node:url";
import {
+ applyDesktopStartupConfigForPhase,
defaultIsolatedUserDataDir,
devEnvPrefix,
isRepositoryDesktopDevProcess,
@@ -125,6 +126,37 @@ test("desktop restart runner keeps the kill-before-deps order by default", () =>
]);
});
+test("desktop restart process-control phase does not initialize startup configuration", () => {
+ const processControlEnv = {};
+ assert.equal(
+ applyDesktopStartupConfigForPhase({
+ argv: ["--kill-only", "--region=global", "--endpoints-cdn"],
+ env: processControlEnv,
+ mode: "remote",
+ }),
+ null,
+ );
+ assert.deepEqual(processControlEnv, {});
+
+ const startupEnv = {};
+ assert.deepEqual(
+ applyDesktopStartupConfigForPhase({
+ argv: ["--region=global"],
+ env: startupEnv,
+ mode: "remote",
+ }),
+ {
+ region: "global",
+ endpointsCdn: false,
+ endpointManifestFile: "config/endpoint.global.json",
+ },
+ );
+ assert.deepEqual(startupEnv, {
+ CINDY_AUTH_REGION: "global",
+ XDT_ENDPOINT_MANIFEST_FILE: "config/endpoint.global.json",
+ });
+});
+
test("desktop restart blocks shared primary dev before the kill step", () => {
const calls = [];
assert.throws(
diff --git a/scripts/restart-desktop-remote.mjs b/scripts/restart-desktop-remote.mjs
index ee810a0e19..090cf21469 100644
--- a/scripts/restart-desktop-remote.mjs
+++ b/scripts/restart-desktop-remote.mjs
@@ -606,6 +606,16 @@ export async function waitForDesktopStartup(statusPath, timeoutMs = startupReady
);
}
+/**
+ * The kill-only phase controls existing processes but does not launch Desktop.
+ * Skipping startup initialization keeps that phase from printing default
+ * region/endpoint values that can contradict the following real startup.
+ */
+export function applyDesktopStartupConfigForPhase(options) {
+ if (options.argv.includes('--kill-only')) return null;
+ return applyDesktopDevStartupConfig(options);
+}
+
async function main() {
const argv = process.argv.slice(2);
const killOnly = argv.includes('--kill-only');
@@ -617,7 +627,7 @@ async function main() {
: null;
// --local 切换到本地模式(连 localhost:3333);缺省走 remote(连 xdt-api)。
const mode = argv.includes('--local') ? 'local' : 'remote';
- const startupConfig = applyDesktopDevStartupConfig({ argv, mode });
+ const startupConfig = applyDesktopStartupConfigForPhase({ argv, mode });
const isolatedArg = argv.find((a) => a === '--isolated' || a.startsWith('--isolated='));
if (preserveRunning && killOnly) {
throw new Error('--preserve-running cannot be combined with the internal --kill-only stage');
@@ -647,12 +657,14 @@ async function main() {
'--preserve-running reuses the current Cindy login via shared userData and cannot be combined with --isolated',
);
}
- console.log(`==> Desktop region: ${startupConfig.region}`);
+ if (startupConfig) {
+ console.log(`==> Desktop region: ${startupConfig.region}`);
+ }
// --passive: 定时任务被动模式 —— 本实例不参与自动触发(交给同机 primary,
// 典型场景多个 dev preview 与 release/primary 共享数据时 preview 让位)。
// 实现方式是置 XDT_SCHEDULER_PASSIVE=1,经 devEnvPrefix 白名单透传进新开的
// 系统终端 / 直接 spawn 的 dev 进程。
- if (argv.includes('--passive') || preserveRunning) {
+ if (startupConfig && (argv.includes('--passive') || preserveRunning)) {
process.env.XDT_SCHEDULER_PASSIVE = '1';
console.log(
preserveRunning
@@ -665,9 +677,9 @@ async function main() {
// 经 devEnvPrefix 白名单透传,主进程 devCliFlags/clientEndpointsService 消费。
// 注意 local 模式的 endpoint.local.json 生成不在本脚本——dev(local)脚本链里的
// apps/desktop/scripts/dev-local-env.mjs 统一负责(human 直跑与 restart 同路径)。
- if (startupConfig.endpointsCdn) {
+ if (startupConfig?.endpointsCdn) {
console.log(`==> Endpoints via CDN: dev will fetch the ${startupConfig.region} online endpoint manifest.`);
- } else if (mode === 'remote' && startupConfig.endpointManifestFile) {
+ } else if (startupConfig && mode === 'remote' && startupConfig.endpointManifestFile) {
console.log(`==> Endpoint manifest: ${startupConfig.endpointManifestFile}`);
}
// --isolated[=<名字>]: dev 使用独立的 userData 目录(数据库/登录态/会话全部与
@@ -681,7 +693,7 @@ async function main() {
// 主进程据此派生独立 deviceId(dev-[<名字>-]<机器指纹>,机器指纹只有主进程能取)
// ——服务端登录凭证按 (user, device) 一对一存,不派生的话沙箱登录会覆盖正式版
// 的续期凭证,同机互踢。
- if (isolatedArg) {
+ if (startupConfig && isolatedArg) {
let isolationName = '';
if (isolatedArg.includes('=')) {
isolationName = isolatedArg.slice('--isolated='.length);
@@ -700,7 +712,7 @@ async function main() {
fs.mkdirSync(process.env.XDT_USER_DATA_DIR, { recursive: true });
console.log(`==> Isolated dev user data${isolationName ? ` (sandbox "${isolationName}")` : ''}: ${process.env.XDT_USER_DATA_DIR}`);
}
- if (!killOnly) ensureDesktopEnv();
+ if (startupConfig) ensureDesktopEnv();
const devAncestor = findDevAncestor();
if (devAncestor && !preserveRunning) {