sessions: Relocate project in zh-TW, ja and de, with a GUI test; Export Markdown reached past the taller folder row (#1131)
#1131 shipped its eight Relocate strings in English and Simplified
Chinese only, so the dialog came up half in English for zh-TW, ja and de
readers. They are added here; zh-TW says 會話, as its Sessions nav does.
sessions-relocate.test.cjs drives the dialog in en, zh, zh-TW, ja and de,
Chromium and WebKit, at 900 and 420px: Relocate is on a writable Claude
Code folder only and fits its row, the click holds the page still and
doesn't unfold the folder, the dialog is magpie's own (no browser
dialog), the preview posts no token, editing the path after a preview
asks for a new one, the confirm carries the preview's token, and the
folder is listed at its new path afterwards. With the path field's
oninput neutered it goes red.
The Relocate button makes a Claude Code folder row 58px rather than 48px
in the web view, which put Export Markdown under the window's foot in
WebKit: sessions-export.test.cjs now wheels to it, and to the OpenCode
tab, with reach() as main's other tests do.
Run on this tree (base 7df0a5bf3): gofmt, go vet (darwin, GOOS=linux
-tags nogui, GOOS=windows), the three builds, go test -tags nogui
-count=1 ./... under a sandbox HOME, all green. GUI: every sessions-*
test, i18n-*, checkbox-look, gateway-conversations and old-webkit in
Chromium and WebKit, 285/285. text-size failed once in WebKit under a
concurrent run ("element is not stable" on the agents nav, zh dark 150%)
and passes alone on this tree and on main.
This commit is contained in:
@@ -4623,6 +4623,14 @@ const I18N = {
|
||||
"{n} agents hidden": "已隱藏 {n} 個 Agent",
|
||||
"{n} agent unhidden": "已取消隱藏 {n} 個 Agent",
|
||||
"{n} agents unhidden": "已取消隱藏 {n} 個 Agent",
|
||||
"Relocate project": "遷移專案會話",
|
||||
"Relocate Claude Code project": "遷移 Claude Code 專案會話",
|
||||
"New absolute project path": "新的專案絕對路徑",
|
||||
"Preview relocation": "預覽遷移",
|
||||
"Confirm relocation": "確認遷移",
|
||||
"Close Claude Code and its editor sessions first. This moves the entire project's sessions, not just filtered or selected rows. Existing target storage is never overwritten. Desktop-only sessions are not changed.": "請先關閉 Claude Code 及編輯器內的會話。此操作遷移整個專案的會話,不只是篩選或勾選的部分。不會覆寫目標已有的會話儲存,也不修改桌面版獨立儲存的會話。",
|
||||
"Relocation complete. Original files and recovery manifest: {dir}": "遷移完成。原始檔案及復原清單保存在:{dir}",
|
||||
"Move {n} sessions ({size}) from {from} to {to}. Originals are retained outside Claude's project list. Historical message text is unchanged.": "將 {n} 個會話({size})從 {from} 遷移至 {to}。原始檔案保留在 Claude 專案列表之外,歷史訊息內文不變。",
|
||||
"Get started": "快速上手",
|
||||
"{n} of {m} done": "已完成 {n}/{m}",
|
||||
"Hide Get started": "隱藏快速上手",
|
||||
@@ -9195,6 +9203,14 @@ const I18N = {
|
||||
"{n} agents hidden": "{n} 個のエージェントを非表示にしました",
|
||||
"{n} agent unhidden": "{n} 個のエージェントの非表示を解除しました",
|
||||
"{n} agents unhidden": "{n} 個のエージェントの非表示を解除しました",
|
||||
"Relocate project": "プロジェクトを移動",
|
||||
"Relocate Claude Code project": "Claude Code プロジェクトのセッションを移動",
|
||||
"New absolute project path": "新しいプロジェクトの絶対パス",
|
||||
"Preview relocation": "移動をプレビュー",
|
||||
"Confirm relocation": "移動を確定",
|
||||
"Close Claude Code and its editor sessions first. This moves the entire project's sessions, not just filtered or selected rows. Existing target storage is never overwritten. Desktop-only sessions are not changed.": "先に Claude Code とエディター内のセッションを閉じてください。絞り込みや選択した行だけでなく、プロジェクトのセッションすべてを移動します。移動先に既にあるセッションの保存場所は上書きしません。デスクトップ版だけのセッションは変更しません。",
|
||||
"Relocation complete. Original files and recovery manifest: {dir}": "移動しました。元のファイルと復元用マニフェスト:{dir}",
|
||||
"Move {n} sessions ({size}) from {from} to {to}. Originals are retained outside Claude's project list. Historical message text is unchanged.": "{n} 件のセッション({size})を {from} から {to} へ移動します。元のファイルは Claude のプロジェクト一覧の外に残します。過去のメッセージ本文は変わりません。",
|
||||
"Get started": "はじめに",
|
||||
"{n} of {m} done": "{m} 件中 {n} 件完了",
|
||||
"Hide Get started": "「はじめに」を隠す",
|
||||
@@ -13771,6 +13787,14 @@ const I18N = {
|
||||
"{n} agents hidden": "{n} Agents ausgeblendet",
|
||||
"{n} agent unhidden": "{n} Agent eingeblendet",
|
||||
"{n} agents unhidden": "{n} Agents eingeblendet",
|
||||
"Relocate project": "Projekt verschieben",
|
||||
"Relocate Claude Code project": "Claude-Code-Projekt verschieben",
|
||||
"New absolute project path": "Neuer absoluter Projektpfad",
|
||||
"Preview relocation": "Verschieben prüfen",
|
||||
"Confirm relocation": "Verschieben bestätigen",
|
||||
"Close Claude Code and its editor sessions first. This moves the entire project's sessions, not just filtered or selected rows. Existing target storage is never overwritten. Desktop-only sessions are not changed.": "Schließe zuerst Claude Code und seine Sitzungen im Editor. Verschoben werden alle Sitzungen des Projekts, nicht nur gefilterte oder ausgewählte Zeilen. Ein bestehender Zielspeicher wird nie überschrieben. Sitzungen, die nur in der Desktop-App liegen, bleiben unverändert.",
|
||||
"Relocation complete. Original files and recovery manifest: {dir}": "Verschoben. Originaldateien und Wiederherstellungsmanifest: {dir}",
|
||||
"Move {n} sessions ({size}) from {from} to {to}. Originals are retained outside Claude's project list. Historical message text is unchanged.": "{n} Sitzungen ({size}) von {from} nach {to} verschieben. Die Originale bleiben außerhalb von Claudes Projektliste erhalten. Der Text früherer Nachrichten bleibt unverändert.",
|
||||
"Get started": "Erste Schritte",
|
||||
"{n} of {m} done": "{n} von {m} erledigt",
|
||||
"Hide Get started": "Erste Schritte ausblenden",
|
||||
|
||||
@@ -12,6 +12,7 @@ const fs = require("node:fs/promises");
|
||||
const path = require("node:path");
|
||||
const { test } = require("node:test");
|
||||
const { chromium, webkit } = require("playwright");
|
||||
const { reach } = require("./reader.cjs");
|
||||
|
||||
const assets = path.resolve(__dirname, "../assets");
|
||||
const at = (min) => new Date(Date.now() - min * 60e3).toISOString();
|
||||
@@ -94,6 +95,10 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert(await exp.isVisible(), "the button is in sight at 560px");
|
||||
const box = await exp.boundingBox();
|
||||
assert(box.x + box.width <= 560, `the button fits the window: ${JSON.stringify(box)}`);
|
||||
// under a Claude Code folder's Relocate project (#1131) the web
|
||||
// layout's taller folder row puts the button at the window's foot:
|
||||
// the reader wheels down to it, then the click must hold the page
|
||||
await reach(page, exp);
|
||||
const top = await row.evaluate((e) => e.getBoundingClientRect().top);
|
||||
if (web) {
|
||||
// the browser's own download of sessions/markdown, its name the
|
||||
@@ -115,7 +120,9 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert.equal(calls.filter((c) => c.path === "transcript").length, 0, "the conversation wasn't shown");
|
||||
|
||||
// an agent whose sessions can't be read has nothing to export
|
||||
await view.locator(".sm-agents .opt", { hasText: "OpenCode" }).click();
|
||||
const oc = view.locator(".sm-agents .opt", { hasText: "OpenCode" });
|
||||
await reach(page, oc); // back up, past the export the reader wheeled to
|
||||
await oc.click();
|
||||
const o = view.locator('.row.sm-sess[data-id="o-1"]');
|
||||
await o.waitFor();
|
||||
await o.locator(".who").click();
|
||||
|
||||
@@ -0,0 +1,145 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// A Claude Code project folder renamed or moved (#1131): its row on the
|
||||
// Sessions page has Relocate project, which opens magpie's own dialog (never
|
||||
// prompt()) with the old path and a field for the new one. Preview posts
|
||||
// sessions/relocate-claude with no token and says what would move; the same
|
||||
// button then confirms with the preview's token, and editing the path first
|
||||
// asks for a new preview. A folder with a session magpie can't write, or a
|
||||
// gateway folder, has no Relocate. In every language, Chromium and WebKit,
|
||||
// at a narrow width; no backend, the API is faked here.
|
||||
const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs/promises");
|
||||
const path = require("node:path");
|
||||
const { test } = require("node:test");
|
||||
const { chromium, webkit } = require("playwright");
|
||||
|
||||
const assets = path.resolve(__dirname, "../assets");
|
||||
const at = (min) => new Date(Date.now() - min * 60e3).toISOString();
|
||||
const sess = (id, cwd, title, min, extra = {}) => ({
|
||||
agent: "claude", id, cwd, title, start: at(min + 5), last: at(min), models: [],
|
||||
resume: `cd ${cwd} && claude --resume ${id}`, path: `~/.claude/projects/x/${id}.jsonl`, size: 1024, messages: 4, files: 1, deletable: true, ...extra,
|
||||
});
|
||||
|
||||
function serve(lang, calls) {
|
||||
let moved = false;
|
||||
const list = () => moved
|
||||
? [sess("a-1", "/work/new-app", "fix the login", 30), sess("a-2", "/work/new-app", "add tests", 90), sess("d-1", "/work/desk", "desktop chat", 120, { read_only: true, deletable: false })]
|
||||
: [sess("a-1", "/work/old-app", "fix the login", 30), sess("a-2", "/work/old-app", "add tests", 90), sess("d-1", "/work/desk", "desktop chat", 120, { read_only: true, deletable: false })];
|
||||
return async (route) => {
|
||||
const req = route.request(), url = new URL(req.url());
|
||||
const json = (data, status = 200) => route.fulfill({ status, json: data });
|
||||
if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:true};` });
|
||||
if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
|
||||
if (url.pathname === "/api/state") return json({ agents: [], profiles: [], settings: { lang, theme: "light" } });
|
||||
if (url.pathname === "/api/plugins") return json({ plugins: [] });
|
||||
if (url.pathname === "/api/groups") return json({ groups: [] });
|
||||
if (url.pathname === "/api/providers") return json({ providers: [], presets: [], excluded: [], gateway: { running: true, window: true } });
|
||||
if (url.pathname === "/api/sessions/manage") {
|
||||
return json({
|
||||
agents: [{ agent: "claude", count: 3, deletable: true, name: "Claude Code", icon: "claude" }],
|
||||
agent: "claude", sessions: list(), terminal: false, trash: [], trashDir: "~/Library/Application Support/magpie/trash/sessions",
|
||||
});
|
||||
}
|
||||
if (url.pathname === "/api/sessions/relocate-claude") {
|
||||
const body = req.postDataJSON();
|
||||
calls.push(body);
|
||||
const out = { from: body.from, to: body.to, sessions: 2, files: 3, bytes: 2048, token: "tk-" + body.to };
|
||||
if (!body.token) return json(out);
|
||||
if (body.token !== out.token) return json({ error: "project files changed; preview the relocation again" }, 400);
|
||||
moved = true;
|
||||
return json({ ...out, backup: "/home/me/.claude/magpie-relocations/project-1" });
|
||||
}
|
||||
if (url.pathname.startsWith("/api/")) return json({});
|
||||
const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname);
|
||||
const contentType = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)];
|
||||
try { await route.fulfill({ body: await fs.readFile(file), contentType }); } catch { await route.fulfill({ status: 404, body: "" }); }
|
||||
};
|
||||
}
|
||||
|
||||
const navs = { en: "Sessions", zh: "会话", "zh-TW": "會話", ja: "セッション", de: "Sitzungen" };
|
||||
const keys = ["Relocate project", "Relocate Claude Code project", "New absolute project path", "Preview relocation", "Confirm relocation",
|
||||
"Close Claude Code and its editor sessions first. This moves the entire project's sessions, not just filtered or selected rows. Existing target storage is never overwritten. Desktop-only sessions are not changed.",
|
||||
"Relocation complete. Original files and recovery manifest: {dir}",
|
||||
"Move {n} sessions ({size}) from {from} to {to}. Originals are retained outside Claude's project list. Historical message text is unchanged."];
|
||||
|
||||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
||||
for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) {
|
||||
for (const width of [900, 420]) {
|
||||
test(`${engine} ${lang} ${width}px: a Claude Code folder is relocated after a preview, in magpie's own dialog`, async (t) => {
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
||||
const page = await (await browser.newContext({ viewport: { width, height: 640 }, reducedMotion: "reduce" })).newPage();
|
||||
t.after(async () => {
|
||||
if (process.env.ARTIFACT_DIR) {
|
||||
await fs.mkdir(process.env.ARTIFACT_DIR, { recursive: true });
|
||||
await page.screenshot({ path: path.join(process.env.ARTIFACT_DIR, `${engine}-${lang}-${width}-sessions-relocate.png`) });
|
||||
}
|
||||
await browser.close();
|
||||
});
|
||||
page.setDefaultTimeout(5000);
|
||||
const errors = [];
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
page.on("dialog", (d) => { errors.push("a browser dialog: " + d.message()); d.dismiss(); });
|
||||
const calls = [];
|
||||
await page.route("**/*", serve(lang, calls));
|
||||
await page.goto("http://magpie.test/?view=providers");
|
||||
const nav = page.locator("#nav").getByRole("button", { name: navs[lang], exact: true });
|
||||
if (await nav.isVisible()) await nav.click();
|
||||
else await page.evaluate(() => show("sessions"));
|
||||
const view = page.locator("#view-sessions");
|
||||
const tr = (k, vars) => page.evaluate(([k, vars]) => t(k, vars), [k, vars]);
|
||||
const folder = (name) => view.locator(".row.sm-folder").filter({ has: page.locator(".fold .name", { hasText: new RegExp("^" + name + "$") }) });
|
||||
await folder("old-app").waitFor();
|
||||
|
||||
// every string has its translation
|
||||
if (lang !== "en") {
|
||||
const missing = await page.evaluate(([lang, keys]) => keys.filter((k) => !I18N[lang][k]), [lang, keys]);
|
||||
assert.deepEqual(missing, [], `${lang} has every string`);
|
||||
}
|
||||
|
||||
const relocate = await tr("Relocate project");
|
||||
assert.equal(await folder("desk").getByRole("button", { name: relocate }).count(), 0, "no Relocate where a session is read-only");
|
||||
const move = folder("old-app").getByRole("button", { name: relocate, exact: true });
|
||||
await move.scrollIntoViewIfNeeded();
|
||||
const box = await move.boundingBox();
|
||||
assert(box && box.x + box.width <= width, "Relocate fits in the row");
|
||||
const open0 = await folder("old-app").locator(".fold").getAttribute("aria-expanded");
|
||||
const y0 = await page.evaluate(() => document.querySelector("#view-sessions").scrollTop);
|
||||
await move.click();
|
||||
const ask = page.locator("#modal .sm-ask");
|
||||
await ask.waitFor();
|
||||
assert.equal(await page.evaluate(() => document.querySelector("#view-sessions").scrollTop), y0, "the click held the page still");
|
||||
assert.equal(await folder("old-app").locator(".fold").getAttribute("aria-expanded"), open0, "Relocate didn't unfold the folder");
|
||||
assert.equal((await ask.locator(".ehead b").textContent()).trim(), await tr("Relocate Claude Code project"));
|
||||
assert.equal((await ask.locator(".sm-ask-path").textContent()).trim(), "/work/old-app");
|
||||
const over = await ask.evaluate((e) => e.scrollWidth > e.clientWidth || e.getBoundingClientRect().right > innerWidth);
|
||||
assert.equal(over, false, "the dialog fits the window");
|
||||
|
||||
const input = ask.locator("input[type=text]");
|
||||
assert.equal(await input.inputValue(), "/work/old-app");
|
||||
const go = ask.locator("button.primary");
|
||||
assert.equal((await go.textContent()).trim(), await tr("Preview relocation"));
|
||||
await input.fill("/work/new-app");
|
||||
await go.click();
|
||||
await page.waitForFunction((x) => document.querySelector("#modal .sm-ask button.primary")?.textContent === x, await tr("Confirm relocation"));
|
||||
assert.deepEqual(calls, [{ from: "/work/old-app", to: "/work/new-app", wsl: "", token: "" }]);
|
||||
const info = ask.locator("p.lib-confirm").last();
|
||||
assert((await info.textContent()).includes("/work/new-app"), "the preview names the new path");
|
||||
|
||||
// editing the path asks for a new preview, never confirms the old one
|
||||
await input.fill("/work/newer-app");
|
||||
assert.equal((await go.textContent()).trim(), await tr("Preview relocation"));
|
||||
await input.fill("/work/new-app");
|
||||
await go.click();
|
||||
await page.waitForFunction((x) => document.querySelector("#modal .sm-ask button.primary")?.textContent === x, await tr("Confirm relocation"));
|
||||
await go.click();
|
||||
await page.waitForFunction(() => document.querySelector("#modal .sm-ask button.primary")?.hidden);
|
||||
assert.equal(calls.length, 3);
|
||||
assert.deepEqual(calls[2], { from: "/work/old-app", to: "/work/new-app", wsl: "", token: "tk-/work/new-app" });
|
||||
assert.equal((await info.textContent()).trim(), await tr("Relocation complete. Original files and recovery manifest: {dir}", { dir: "/home/me/.claude/magpie-relocations/project-1" }));
|
||||
await folder("new-app").waitFor();
|
||||
assert.equal(await folder("old-app").count(), 0);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user