diff --git a/README.md b/README.md index 837b114..15e12f4 100644 --- a/README.md +++ b/README.md @@ -677,7 +677,7 @@ dsh-purge --edit purge_status purge_apply purge_revert ``` -Patched packages load only after a restart. Apply does not restart by itself. Under the patch title, **Stable** and **Beta** are separate: each has its own version list and switch action. A rollback is pinned; click **Update** to return to that channel's tip. +Patched packages load only after a restart. Apply does not restart by itself. Under the patch title is the stable release: you can see versions and switch. A rollback is pinned; click **Update** to return to the latest. The beta channel is gone. The composer **Undo** button drops the last turn and puts the last user sentence back in the input. On the main agent you can rewind once or the whole last round (including subagents). After rewind, send only what is in the box now. `/rewind` does the same. The host cannot truncate a session in place, so rewind opens another session for the shortened transcript and removes the old one from the sidebar. Repeating undo does not leave a stack of branches in the list. diff --git a/README.zh-CN.md b/README.zh-CN.md index 3719964..ae2c3e5 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -680,7 +680,7 @@ dsh-purge --edit purge_status purge_apply purge_revert ``` -设置页「应用」完成后需要重启才会加载已改的包文件。点「重启」才会重启,不会自动重启。补丁标题下正式版和测试版分开两栏:各自看版本、各自切换;回退后会固定在该版本,要回到该通道最新再点「更新」。 +设置页「应用」完成后需要重启才会加载已改的包文件。点「重启」才会重启,不会自动重启。补丁标题下是正式版:可以看版本和切换。回退后会固定在该版本,要回到最新再点「更新」。测试版通道已去掉。 输入框旁的「回退」会丢掉最近一轮对话,并把上一句填回输入框;聊天里 `/rewind` 同样可用。宿主不能在原会话里截断,所以回退会另开一条承载截断后的内容,并把原来那条从侧边栏移出。多退几次不会在列表里堆出一串分支。 diff --git a/client.js b/client.js index fed4311..cc4343e 100644 --- a/client.js +++ b/client.js @@ -1522,7 +1522,6 @@ body[data-ds-dark-theme] .dshp-dock-body .dshp-switch button.is-on{background:#3 ), h("div", { className: "dshp-editions" }, renderEdition("stable"), - renderEdition("beta"), ), noticeNode(updateNotice), ), @@ -1886,14 +1885,12 @@ body[data-ds-dark-theme] .dshp-dock-body .dshp-switch button.is-on{background:#3 return best; } - function keepListedVersion(item, ceiling) { - const ver = String((item && (item.version || item.ref)) || "").replace(/^v/i, ""); - if (/^1\.1\.11-beta/i.test(ver)) return false; - if (!item || item.channel !== "beta") return true; - // 与 lib/update.hideListedVersion 一致:测试 tip / beta 分支始终可见(并行通道)。 - if (item.ref === "beta" || item.kind === "head" || item.latest) return true; - if (!ceiling) return true; - return listedVersionNewer(ver, ceiling); + function keepListedVersion(item, _ceiling) { + const ver = String((item && (item.version || item.ref || item.id)) || ""); + if (!item) return false; + if (item.channel === "beta" || item.ref === "beta") return false; + if (/(?:^|[-._])(beta|rc|pre|preview|test)(?:\d|$|[-._])/i.test(ver)) return false; + return true; } function preferListed(list, localVer, pin) { diff --git a/lib/update.js b/lib/update.js index c48ff9a..a1b1f47 100644 --- a/lib/update.js +++ b/lib/update.js @@ -91,8 +91,8 @@ function markAutoUpdateGuard(ref, sha = "") { }, null, 2)}\n`, "utf8"); } -export function normalizeChannel(value) { - return String(value || "").toLowerCase() === "beta" ? "beta" : "stable"; +export function normalizeChannel(_value) { + return "stable"; } function isBetaName(name) { @@ -136,27 +136,22 @@ export function latestStableVersion(versions) { return best; } -/** 正式版已经追上的旧测试版标签不再列出。1.1.11-beta 始终下线。 - * 正式/测试是并行通道(测试带红队等),beta 分支 tip 始终保留,避免 1.1.25 正式把 1.1.25-beta 整通道藏掉。 */ -export function hideListedVersion(item, stableVersion = "") { +/** 测试通道已下线。beta 分支、测试标签和名称里带 beta/rc/pre 的条目都不再列出。 */ +export function hideListedVersion(item, _stableVersion = "") { if (!item || withdrawnVersion(item)) return true; - const beta = item.channel === "beta" || isBetaName(item.version) || isBetaName(item.ref) || isBetaName(item.id); - if (!beta) return false; - // 并行测试通道 tip:始终可见。 - if (item.ref === BETA_REF || item.kind === "head") return false; - const ceiling = String(stableVersion || "").replace(/^v/i, ""); - if (!ceiling || isBetaName(ceiling)) return false; - const ver = String(item.version || item.ref || item.id || "").replace(/^v/i, ""); - if (!/^\d+\.\d+/.test(ver)) return false; - return !versionIsNewer(ver, ceiling); + return item.channel === "beta" || isBetaName(item.version) || isBetaName(item.ref) || isBetaName(item.id); } export function readChannelState() { const raw = readJson(channelStatePath()) || {}; - return { - channel: normalizeChannel(raw.channel), - pin: typeof raw.pin === "string" ? raw.pin.trim() : "", + const stored = String(raw.channel || "").toLowerCase(); + const pin = typeof raw.pin === "string" ? raw.pin.trim() : ""; + const state = { + channel: "stable", + pin: isBetaName(pin) || pin === BETA_REF ? "" : pin, }; + if (stored === "beta" || state.pin !== pin) writeChannelState(state); + return state; } function writeChannelState(next) { @@ -719,9 +714,8 @@ async function listRemoteVersions() { if (next) out.push(next); }; - const [stableSha, betaSha, tags] = await Promise.all([ + const [stableSha, tags] = await Promise.all([ remoteHeadSha(STABLE_REF), - remoteHeadSha(BETA_REF), listGithubTags(), ]); @@ -738,34 +732,6 @@ async function listRemoteVersions() { latest: true, }); } - if (betaSha) { - const version = await remotePackageVersion(betaSha, BETA_REF).catch(() => ""); - add({ - id: BETA_REF, - ref: BETA_REF, - sha: betaSha, - version: version || "", - channel: "beta", - label: `${versionLabel(version, "beta", betaSha)} · 最新`, - kind: "head", - latest: true, - }); - } else { - // API/atom 拿不到 tip 时,仍用 raw/jsDelivr 探一下 beta 分支,避免测试通道整栏空白。 - const version = await remotePackageVersion("", BETA_REF).catch(() => ""); - if (version) { - add({ - id: BETA_REF, - ref: BETA_REF, - sha: "", - version, - channel: "beta", - label: `${versionLabel(version, "beta")} · 最新`, - kind: "head", - latest: true, - }); - } - } for (const tag of tags) { if (!withdrawnVersion(tag)) add(tag); } @@ -786,26 +752,21 @@ async function listRemoteVersions() { localVer && !isBetaName(localVer) ? { channel: "stable", version: localVer } : null, ].filter(Boolean)); const visible = withLocal.filter((item) => !hideListedVersion(item, ceiling)); - const betaOpen = visible.some((item) => item.channel === "beta"); return { versions: markCurrent(visible, state, localVer, localSha), - hasBeta: betaOpen, + hasBeta: false, stableSha, - betaSha: betaOpen ? betaSha : "", + betaSha: "", }; } function alignChannelState(state, listed, localRev, localVer) { if (state.pin) return state; - if (listed.betaSha && localRev && sameRev(localRev, listed.betaSha) && state.channel !== "beta") { - return writeChannelState({ channel: "beta", pin: "" }); - } if (listed.stableSha && localRev && sameRev(localRev, listed.stableSha) && state.channel !== "stable") { return writeChannelState({ channel: "stable", pin: "" }); } - if (!localRev && localVer) { - const inferred = isBetaName(localVer) ? "beta" : "stable"; - if (inferred !== state.channel) return writeChannelState({ channel: inferred, pin: "" }); + if (!localRev && localVer && state.channel !== "stable") { + return writeChannelState({ channel: "stable", pin: "" }); } return state; } @@ -1134,28 +1095,8 @@ export async function applyUpdate(jobs = planUpdates(), options = {}) { } export async function switchChannel(channel, { apply = true } = {}) { + if (String(channel || "").toLowerCase() === "beta") throw new Error("测试版已下线"); const next = normalizeChannel(channel); - if (next === "beta") { - const listed = await listRemoteVersions(); - if (!listed.hasBeta) { - const state = readChannelState(); - const localVer = localVersion(); - const localRev = (gitOk() ? gitHead(PLUGIN_ROOT) : "") || readStamp(); - return rememberUpdate({ - ok: false, - error: "还没有测试版", - hasBeta: false, - localVersion: localVer, - versions: listed.versions, - lanes: lanesOf(listed, state, localVer, localRev), - ...channelPublic(state), - }); - } - if (!listed.betaSha && apply) { - const tag = listed.versions.find((item) => item.channel === "beta" && item.kind === "tag"); - if (tag) return applyUpdate(planUpdates(), { ref: tag.ref, channel: "beta", pin: false, force: true }); - } - } if (!apply) { writeChannelState({ channel: next, pin: "" }); return checkUpdate(); @@ -1199,11 +1140,12 @@ export async function handleUpdateOp(body = {}) { const requested = body.ref || currentChannelRef(state); const ref = safeUpdateRef(requested); if (!ref) throw new Error("未知版本"); - if (ref !== STABLE_REF && ref !== BETA_REF) { + if (ref === BETA_REF || isBetaName(ref)) throw new Error("测试版已下线"); + if (ref !== STABLE_REF) { const listed = await listRemoteVersions(); if (!listedUpdateRef(ref, listed)) throw new Error("未知版本"); } - const channel = body.channel || (ref === BETA_REF ? "beta" : ref === STABLE_REF ? "stable" : state.channel); + const channel = body.channel === "beta" ? "stable" : (body.channel || (ref === STABLE_REF ? "stable" : state.channel)); return applyUpdate(planUpdates(), { ref, channel, pin: false, force: true }); } diff --git a/scripts/test-update-guards.mjs b/scripts/test-update-guards.mjs index 0c5cf71..4069d93 100644 --- a/scripts/test-update-guards.mjs +++ b/scripts/test-update-guards.mjs @@ -40,18 +40,16 @@ const caughtUp = [ ]; const ceiling = latestStableVersion(caughtUp); assert.equal(ceiling, "1.1.12"); -assert.equal(hideListedVersion(caughtUp[2], ceiling), true); // 已追上的旧 beta 标签仍隐藏 -assert.equal(hideListedVersion(caughtUp[3], ceiling), false); // beta 分支 tip 始终保留(并行通道) -assert.equal(hideListedVersion(caughtUp[4], ceiling), false); +assert.equal(hideListedVersion(caughtUp[2], ceiling), true); +assert.equal(hideListedVersion(caughtUp[3], ceiling), true); +assert.equal(hideListedVersion(caughtUp[4], ceiling), true); assert.equal(hideListedVersion({ ref: "v1.1.11-beta.1", version: "1.1.11-beta.1", channel: "beta" }, ""), true); const visible = caughtUp.filter((item) => !hideListedVersion(item, ceiling)); -assert.deepEqual(visible.map((item) => item.ref), ["master", "v1.1.12", "beta", "v1.1.13-beta.1"]); +assert.deepEqual(visible.map((item) => item.ref), ["master", "v1.1.12"]); const staleSha = "423a91614baa747b56749003d054fedb8e725714"; const shown = markCurrent(visible, { channel: "stable", pin: "" }, "1.1.12", staleSha); assert.equal(shown.find((item) => item.ref === "master").current, true); assert.equal(shown.find((item) => item.ref === "v1.1.12").current, false); -assert.equal(shown.find((item) => item.ref === "beta").current, false); -assert.equal(shown.find((item) => item.ref === "v1.1.13-beta.1").current, false); console.log("ok: update guards");