cicy-desktop 2.1.113 → 2.1.114
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/backends/homepage-preload.js +2 -0
- package/src/backends/homepage-react/assets/{index-CgqXmbpX.js → index-CmVf11CZ.js} +11 -11
- package/src/backends/homepage-react/index.html +1 -1
- package/src/backends/sidecar-ipc.js +24 -4
- package/src/sidecar/wsl-docker.js +19 -10
- package/workers/render/src/App.jsx +9 -1
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<link rel="icon" type="image/svg+xml" href="./favicon.svg" />
|
|
7
7
|
<link rel="icon" type="image/png" sizes="256x256" href="./favicon-256.png" />
|
|
8
8
|
<title>CiCy Desktop</title>
|
|
9
|
-
<script type="module" crossorigin src="./assets/index-
|
|
9
|
+
<script type="module" crossorigin src="./assets/index-CmVf11CZ.js"></script>
|
|
10
10
|
<link rel="stylesheet" crossorigin href="./assets/index-BcVFakIC.css">
|
|
11
11
|
</head>
|
|
12
12
|
<body>
|
|
@@ -130,13 +130,33 @@ function register({ sidecarLogPath } = {}) {
|
|
|
130
130
|
};
|
|
131
131
|
// Register the running :8009 instance as a (custom) team so the card's "打开"
|
|
132
132
|
// reuses the token-injected open/reload flow. addTeam dedups by host:port.
|
|
133
|
+
// Upsert the :8009 team with the CONTAINER's OWN live token. Critical: never
|
|
134
|
+
// fall back to the host 8008 token (addTeam auto-fills global.json on an empty
|
|
135
|
+
// api_token — that's the host credential, which 8009 rejects → login screen).
|
|
136
|
+
// Returns the team id, or {ok:false} when the container token can't be read.
|
|
133
137
|
const registerAppTeam = async () => {
|
|
138
|
+
const lt = require("./local-teams");
|
|
139
|
+
const tok = await wslDocker.readContainerToken(APP_PORT); // retried inside
|
|
140
|
+
if (!tok) return { ok: false, error: "no_token", id: null };
|
|
141
|
+
const r = await lt.addTeam({ base_url: `http://127.0.0.1:${APP_PORT}`, name: "Docker cicy-code", api_token: tok });
|
|
142
|
+
return { ok: true, id: r && r.id };
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
// Card「打开」→ ALWAYS re-read the live container token and upsert the team
|
|
146
|
+
// before opening, so the URL carries the current ?token= (a token captured at
|
|
147
|
+
// install time goes stale after the container is recreated/reset). If the
|
|
148
|
+
// token can't be read we refuse to open — opening tokenless / with the host
|
|
149
|
+
// token just strands the user at a login screen (主人: 必须拿到 token 才能打开).
|
|
150
|
+
ipcMain.handle("docker:app-open", async () => {
|
|
151
|
+
if (process.platform !== "win32") return { ok: false, error: "windows_only" };
|
|
134
152
|
try {
|
|
153
|
+
const reg = await registerAppTeam();
|
|
154
|
+
if (!reg.ok || !reg.id) return { ok: false, error: reg.error || "no_token" };
|
|
135
155
|
const lt = require("./local-teams");
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
} catch {
|
|
139
|
-
};
|
|
156
|
+
const r = await lt.openTeam(reg.id);
|
|
157
|
+
return r && r.ok ? { ok: true } : { ok: false, error: (r && r.error) || "open_failed" };
|
|
158
|
+
} catch (e) { return { ok: false, error: e.message }; }
|
|
159
|
+
});
|
|
140
160
|
|
|
141
161
|
// One-click bootstrap (方案 A): ensure WSL2 → Ubuntu → Docker Engine → load
|
|
142
162
|
// image → start :8009 container → health. Streams phase/progress on
|
|
@@ -262,17 +262,26 @@ async function runContainer({ port = 8009, container = "cicy-code-docker", volum
|
|
|
262
262
|
return { started: true };
|
|
263
263
|
}
|
|
264
264
|
|
|
265
|
-
// Read the container's
|
|
266
|
-
//
|
|
265
|
+
// Read the container's OWN api_token (its volume-persisted global.json). This is
|
|
266
|
+
// the ONLY correct credential for :8009 — the host's 8008 token is different and
|
|
267
|
+
// 8009 rejects it. Retries because right after start the entrypoint may not have
|
|
268
|
+
// written global.json yet; returns "" only if it truly can't be read (callers
|
|
269
|
+
// must then NOT open with a wrong/host token — that strands the user at login).
|
|
267
270
|
async function readContainerToken(port = 8009, container = "cicy-code-docker") {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
271
|
+
for (let attempt = 1; attempt <= 5; attempt++) {
|
|
272
|
+
try {
|
|
273
|
+
// Look the container up by name and read the token from inside it.
|
|
274
|
+
const { stdout } = await wslRun(`docker ps --filter "name=${container}" --format '{{.Names}}'`, { timeout: 10000 });
|
|
275
|
+
const name = stdout.trim().split("\n")[0];
|
|
276
|
+
if (name) {
|
|
277
|
+
const r = await wslRun(`docker exec ${name} cat /home/cicy/cicy-ai/global.json`, { timeout: 10000 });
|
|
278
|
+
const tok = JSON.parse(r.stdout).api_token || "";
|
|
279
|
+
if (tok) return tok;
|
|
280
|
+
}
|
|
281
|
+
} catch { /* container/global.json not ready yet — retry */ }
|
|
282
|
+
await new Promise((r) => setTimeout(r, 2000));
|
|
283
|
+
}
|
|
284
|
+
return "";
|
|
276
285
|
}
|
|
277
286
|
|
|
278
287
|
// Register a Windows logon task that starts dockerd in our distro on every
|
|
@@ -740,7 +740,15 @@ export default function App() {
|
|
|
740
740
|
{showLocal && (
|
|
741
741
|
<DockerCard
|
|
742
742
|
dockerTeam={dockerTeam}
|
|
743
|
-
onOpen={(
|
|
743
|
+
onOpen={async () => {
|
|
744
|
+
// Always open via the live-token path: re-reads the container's
|
|
745
|
+
// own api_token and refuses to open a tokenless/host-token page
|
|
746
|
+
// (主人: 必须拿到 token 才能打开,否则被卡在登录页).
|
|
747
|
+
try {
|
|
748
|
+
const r = await window.cicy?.docker?.appOpen?.();
|
|
749
|
+
if (!r?.ok) window.alert("拿不到容器 token,无法打开 :8009。请确认服务已就绪(或用卡片菜单「重启」)后再试。");
|
|
750
|
+
} catch (e) { console.warn("[DockerCard] open", e); }
|
|
751
|
+
}}
|
|
744
752
|
onRefresh={fetchLocalTeams}
|
|
745
753
|
/>
|
|
746
754
|
)}
|