+ row: (g, n) => g.fixed
+ ? `
${g.id === SPECIAL ? "★ " : ""}${g.name}${g.id === 0 ? "没放进任何分组的 UP 主都在这里。" : ""}${n} 个 UP 主B站 固定
${g.id === FIXED_GROUPS.at(-1) && !D.groups.length ? '
还没有自己建的分组
' : ""}`
+ : `
${n} 个 UP 主
@@ -1342,7 +1351,7 @@ const aiTags = {
async function runAi({ instruction, scope, allowRemove }) {
const mids = aiScopeMids(scope);
if (aiRunning() || !mids.length) return;
- const progress = (text) => TagDialogs.ai.progress(aiTags, text);
+ const progress = (text, fail) => TagDialogs.ai.progress(aiTags, text, "", fail && T.aiRemedy(fail));
AI.history = UI.aiHistoryAdd(AI.history, instruction);
T.store({ [AI_HISTORY_KEY]: AI.history });
const excluded = new Set(D.tags.filter((t) => AI.excluded.has(t.id)).map((t) => t.name));
@@ -1359,7 +1368,7 @@ async function runAi({ instruction, scope, allowRemove }) {
merge: (p, data) => UI.mergeAiBatch(p, data, { ...opts, tags: D.tags, map: D.map }),
send,
intervalMs,
- progress: (text) => (progress(text), renderSync()),
+ progress: (text, fail) => (progress(text, fail), renderSync()),
// 收藏夹设置's 粗看输出上限 does not apply here (triageAiCommand): no limitHint.
onError: T.aiError
});
diff --git a/extension/triage/follow.selftest.js b/extension/triage/follow.selftest.js
index b4283e35..19b19a9a 100644
--- a/extension/triage/follow.selftest.js
+++ b/extension/triage/follow.selftest.js
@@ -193,17 +193,16 @@ const base = () => ({ list: null, last: null, content: {}, people: {}, tags: [],
// ----- 关注分组 writes: the follow-group-move requests from where each UP is to where it should be -----
{
- // 移到 / 复制到 / ★ as the wanted groups.
+ // 加进 / 移到 / ★ as the wanted groups.
assert.deepStrictEqual(plain(t.regrouped([7], 7, 8)), [8], "move");
assert.deepStrictEqual(plain(t.regrouped([7], null, 8)), [7, 8], "copy");
assert.deepStrictEqual(plain(t.regrouped([7, 8], null, 8)), [7, 8], "already there");
assert.deepStrictEqual(plain(t.regrouped([-10, 7], -10, 0)), [7], "out of 特别关注 to 默认分组");
assert.deepStrictEqual(plain(t.regrouped([], 0, 7)), [7], "from 默认分组");
- // 特别关注 is a flag on top of the groups: 默认分组 → 特别关注 adds, the UP stays in 默认分组; the words say so.
- assert.strictEqual(t.groupMoveLabel(0, -10, true, { groups: [] }), "加进「特别关注」", "默认分组 → 特别关注 is an add");
- assert.strictEqual(t.groupMoveLabel(0, 7, true, { groups: [{ id: 7, name: "数码" }] }), "移到「数码」");
- assert.strictEqual(t.groupMoveLabel(7, -10, true, { groups: [] }), "移到「特别关注」");
- assert.strictEqual(t.groupMoveLabel(null, -10, false, { groups: [] }), "复制到「特别关注」");
+ // B站's groups are tags on an UP: what is no move adds one more group, and the words say so.
+ assert.strictEqual(t.groupMoveLabel(7, false, { groups: [{ id: 7, name: "数码" }] }), "加进「数码」");
+ assert.strictEqual(t.groupMoveLabel(-10, true, { groups: [] }), "移到「特别关注」");
+ assert.strictEqual(t.groupMoveLabel(-10, false, { groups: [] }), "加进「特别关注」");
const cur = { a: [7], b: [7], c: [7, 8], d: [], e: [-10] };
const calls = (want, mids = Object.keys(want), size) => plain(t.groupCalls(mids, (m) => cur[m], (m) => want[m], size));
const mv = (mids, from, to) => ({ type: "follow-group-move", mids, from, to });
@@ -445,10 +444,10 @@ assert.ok(/render\(\);\s*if \(up\) \{\s*setCur\(up, false\);\s*E\.list\.querySel
assert.ok(/back: \(\) => groupCalls\(done, \(m\) => groupsOf\(m, D\), \(m\) => before\[m\]\)/.test(rg) && /ask: \[`在 B站撤销/.test(rg) && rg.includes("groups: true"), "U puts back the groups they had, asked for 2+");
assert.ok(/async function starOne\(mid\) \{[\s\S]*?await regroup\(\[mid\],[^\n]*SPECIAL/.test(source), "★ is a move of group -10");
const mc = fn("moveOrCopy");
- assert.ok(/UI\.askTransfer\(\{\s*title: `在 B站把这 \$\{mids\.length\} 个 UP 主\$\{verb\}到分组`,\s*n: mids\.length,\s*hows: \[how\],/.test(mc), "the batch confirm: 在 B站…, the count on its one button");
+ assert.ok(/UI\.askTransfer\(\{\s*title: `在 B站把这 \$\{mids\.length\} 个 UP 主\$\{verb\}分组`,\s*n: mids\.length,\s*hows: \[how\],\s*verbs: \{ copy: "加进", move: "移到" \},/.test(mc), "the batch confirm: 在 B站…, the count on its one button, in 关注's words");
assert.ok(mc.indexOf("createGroup(") < mc.indexOf("regroup("), "新建分组… first");
- assert.ok(mc.includes("const label = groupMoveLabel(move ? from : null, to, move, D);") && mc.includes("放进自己建的分组后,就不在默认分组里了。"), "toast and U use the add words");
- assert.ok(/note: \(v\) => \(v === String\(SPECIAL\) \? `\$\{move && from === 0 \? "还留在默认分组里/.test(mc), "the dialog says 特别关注 keeps them in 默认分组");
+ assert.ok(mc.includes("const label = groupMoveLabel(to, move, D);"), "toast and U use the same words");
+ assert.ok(!/\bhow: /.test(mc), "one hint, under the target");
const del = fn("deleteGroup");
assert.ok(/askConfirm\([\s\S]*?\);\s*if \(!ok\) return;\s*if \(W\.busy\(\)\)[^\n]*\n\s*const r = await send\(\{ type: "follow-group-delete"/.test(del) && del.includes("默认分组") && del.includes("不能按 U 撤销") && del.includes("T.dropModeUndo((step) => step.groups)"), "删除: confirm first, members → 默认分组, no U");
assert.ok(/T\.pushUndo\(\{\s*kind: "mode",\s*groups: true,\s*undo: async \(\) => \(\(await renameGroup\(\{ id: g\.id, name \}, old, true\)\)/.test(fn("renameGroup")), "改名: U renames back");
@@ -629,7 +628,7 @@ async function followPage({ store = {}, sync = {}, handlers = {}, setup = () =>
Object.assign(ctx.MoonTriage, { toast, askConfirm });
setup(ctx);
const follow = fs.readFileSync(path.join(__dirname, "follow.js"), "utf8").replace(/^import "\.\/triage\.js";.*$/m, "");
- await vm.runInContext(`(async () => {\n${follow}\n;globalThis.FW = { F, E, W, D: () => D, relationRun, pushWriteUndo, render, refollow, regroup, pickSide, aiTags, AI, manageTags, openSettings };\n})()`, ctx);
+ await vm.runInContext(`(async () => {\n${follow}\n;globalThis.FW = { F, E, W, D: () => D, relationRun, pushWriteUndo, render, refollow, regroup, pickSide, aiTags, AI, manageTags, manageGroups, moveOrCopy, openSettings };\n})()`, ctx);
const settle = async (n = 30) => {
for (let i = 0; i < n; i++) await new Promise((r) => setTimeout(r, 1));
};
@@ -805,7 +804,13 @@ const p0Throttled = () => vm.runInContext("MdgErrors.TEXT.biliThrottled", ctx);
F.sel.delete("u2");
p.FW.render();
const bar = E.sel.innerHTML;
- assert.ok(!bar.includes("AI 打标签") && bar.includes(">移动选中的 1 个到分组…<") && bar.includes(">复制选中的 1 个到分组…<"), bar);
+ assert.ok(!bar.includes("AI 打标签") && bar.includes(">加进分组…<") && bar.includes(">取消关注<"), bar);
+ // 移到分组… is there only in a group one can leave: not in 全部 or 默认分组 (absent, not disabled).
+ const groupBtns = (s) => ((F.side = s), p.FW.render(), [">加进分组…<", ">移到分组…<"].map((b) => E.sel.innerHTML.includes(b)));
+ const at = F.side;
+ assert.deepStrictEqual(["all", "g:0", "g:-10", "g:5"].map(groupBtns), [[true, false], [true, false], [true, true], [true, true]]);
+ F.side = at;
+ p.FW.render();
const running = p.FW.relationRun([{ type: "follow-relation", mid: "u2", act: 2 }], "取消关注");
await p.until(() => release);
assert.ok(E.sel.innerHTML.includes('disabled title="取消关注还在跑,等它完成"'), E.sel.innerHTML);
@@ -834,7 +839,7 @@ const p0Throttled = () => vm.runInContext("MdgErrors.TEXT.biliThrottled", ctx);
p.FW.render();
assert.ok(p.$("fwBarR").innerHTML.includes('aria-label="清理选中的 1 个" disabled title="选中的都被筛选隐藏了"'), p.$("fwBarR").innerHTML);
// J14: the bar's buttons count the whole hidden selection too, off with why.
- assert.ok(E.sel.innerHTML.includes('aria-label="重新关注选中的 1 个" disabled title="选中的都被筛选隐藏了"'), E.sel.innerHTML);
+ assert.ok(E.sel.innerHTML.includes('aria-label="重新关注" disabled title="选中的都被筛选隐藏了"'), E.sel.innerHTML);
const asked = p.asked.length;
p.click("followMain", "[data-fw]", { fw: "clean" });
await p.settle();
@@ -842,7 +847,7 @@ const p0Throttled = () => vm.runInContext("MdgErrors.TEXT.biliThrottled", ctx);
F.tagState = "";
// K1: none of the selection can take it: the count is the selection's, never 0, off with why.
p.FW.render();
- assert.ok(E.sel.innerHTML.includes('aria-label="取消关注选中的 1 个" disabled title="选中的都已取消关注"'), E.sel.innerHTML);
+ assert.ok(E.sel.innerHTML.includes('aria-label="取消关注" disabled title="选中的都已取消关注"'), E.sel.innerHTML);
}
// J11: ✦ AI 打标签 with no UP 主 here is off and says why, as 收藏夹's in an empty folder.
@@ -1129,6 +1134,34 @@ const p0Throttled = () => vm.runInContext("MdgErrors.TEXT.biliThrottled", ctx);
assert.deepStrictEqual([plain(done), p.ctx.S.modeUndo.length], [["u1"], 1]);
}
+ // 分组管理 heads its list with B站's two fixed groups, read-only: no data-id, field or 删除 for the dialog to act on.
+ {
+ const rowsOf = ({ manageGroups: m }) => m.tags().map((g) => m.row(g, m.count(g.id)));
+ const p = await followPage({ store: page({ follow_groups: [{ id: 5, name: "五", count: 1 }], follow_list: { list: ["u1", "u2"], groups: { u1: [5] } } }) });
+ const [def, star, own, ...more] = rowsOf(p.FW);
+ assert.ok(def.includes("默认分组") && def.includes("1 个 UP 主") && def.includes("B站 固定") && star.includes("★ 特别关注") && star.includes("0 个 UP 主"), def + star);
+ assert.ok(![def, star].some((r) => /data-id|
还没有自己建的分组'), "no group of your own: said under the fixed two");
+
+ // 加进 / 移到分组: one line under the target. 默认分组 is being in none of your own groups, so the ones only there (u2)
+ // leave it by joining one; 特别关注 takes nobody out of it; a move says the group it leaves.
+ const asks = [];
+ p.ctx.TriageUi.askTransfer = async (o) => (asks.push(o), null);
+ const note = async (side, how, target, mids = ["u1", "u2"]) => ((p.FW.F.side = side), await p.FW.moveOrCopy(mids, how), asks.at(-1).note(target));
+ assert.strictEqual(await note("g:0", "copy", "5", ["u2"]), "加进分组后,就不在默认分组里了。");
+ assert.deepStrictEqual([asks.at(-1).title, asks.at(-1).verbs.copy], ["在 B站把这 1 个 UP 主加进分组", "加进"]);
+ assert.strictEqual(await note("g:0", "copy", "-10", ["u2"]), "特别关注的 UP 主发视频,手机 B站会推送。");
+ assert.strictEqual(await note("all", "copy", "5"), "其中 1 个只在默认分组,加进分组后,就不在默认分组里了。");
+ assert.strictEqual(await note("g:5", "copy", "-10", ["u1"]), "特别关注的 UP 主发视频,手机 B站会推送。");
+ assert.strictEqual(await note("g:5", "move", "0", ["u1"]), "从「五」移走。不在别的分组的会回到默认分组,还关注着。");
+ assert.strictEqual(await note("g:5", "move", "-10", ["u1"]), "从「五」移走。特别关注的 UP 主发视频,手机 B站会推送。");
+ assert.strictEqual(asks.at(-1).title, "在 B站把这 1 个 UP 主移到分组");
+ const asked = asks.length;
+ for (const side of ["all", "g:0"]) ((p.FW.F.side = side), await p.FW.moveOrCopy(["u2"], "move"));
+ assert.strictEqual(asks.length, asked, "no move out of 全部 or 默认分组");
+ assert.ok(asks.every((o) => !o.how), "nothing in the dialog's second hint line");
+ }
+
// The head's refresh error, as 收藏夹's: 刷新失败:reason, B站限流 in MdgErrors' words.
{
const p = await followPage({ store: page({ follow_jobs: { state: "failed", error: p0Throttled(), errorCode: "THROTTLED" } }) });
diff --git a/extension/triage/shared.js b/extension/triage/shared.js
index d713fe77..a5f7d34f 100644
--- a/extension/triage/shared.js
+++ b/extension/triage/shared.js
@@ -27,7 +27,7 @@
// 播放量 / 粉丝: 12.3万 and 2.5亿 (one decimal, dropped when 0), plain below 万.
const fmtCount = (n) => (n >= 1e8 ? `${Math.round(n / 1e7) / 10}亿` : n >= 1e4 ? `${Math.round(n / 1e3) / 10}万` : String(n));
// Tag names, colors and ids: ../tag-core.js, which badges.js on B站 pages loads too.
- const { cleanTagName, nextTagColor, cycleTagColor } = globalThis.MdgTagCore;
+ const { cleanTagName, nextTagColor, TAG_COLORS } = globalThis.MdgTagCore;
// A plain primary click on a video link plays it in the viewer here; with ⌘ / Ctrl / Shift / Alt the browser opens it.
const plainClick = (e) => e.button === 0 && !e.metaKey && !e.ctrlKey && !e.shiftKey && !e.altKey;
// A video card plays on a plain click anywhere on it (收藏夹 and 视频投稿 alike), except on a control inside it
@@ -376,7 +376,8 @@
return new Promise((resolve) => dlg.addEventListener("close", () => resolve(dlg.returnValue === "ok"), { once: true }));
}
// ----- 移动 / 复制 (#transferDialog): 收藏夹's folders and 关注's groups -----
- // o = { title, list (html), n, hows ("copy" / "move" / "add" buttons shown; the last is the blue one), label (目标收藏夹 /
+ // o = { title, list (html: confirmList), aside (html under the list, optional), n, hows ("copy" / "move" / "add" buttons shown; the last is the blue one),
+ // verbs (the buttons' words when not 复制 / 移动 / 收藏: 关注's 加进 / 移到), label (目标收藏夹 /
// 目标分组), options [[value, text]], newText (新建收藏夹… / 新建分组…), newPlaceholder, newMax, privacy (show 设为私密),
// how (the hint under it, "" hides it), note(value) (html of the amber line for that target, "" hides it) }.
// Resolves { how, target: { id } | { create, privacy } }, or null when cancelled.
@@ -397,12 +398,15 @@
}
$("transferTitle").textContent = o.title;
dlg.setAttribute("aria-label", o.title);
- $("transferBody").innerHTML = o.list;
+ // More than one: a line with the first name and 「等 N 个」 that opens into the list. aside stays in sight under it.
+ const first = /
([\s\S]*?)<\/li>/.exec(o.list)?.[1] || "";
+ const body = `${o.list}
`;
+ $("transferBody").innerHTML = (o.n > 1 ? `${first}等 ${o.n} 个
${body} ` : body) + (o.aside || "");
$("transferLabel").textContent = o.label;
for (const b of dlg.querySelectorAll("button[value=copy], button[value=move], button[value=add]")) {
b.hidden = !o.hows.includes(b.value);
b.classList.toggle("primary", b.value === o.hows.at(-1));
- b.textContent = `${TRANSFER_VERB[b.value]} ${o.n} 个`;
+ b.textContent = `${o.verbs?.[b.value] || TRANSFER_VERB[b.value]} ${o.n} 个`;
b.setAttribute("aria-label", b.textContent);
}
$("transferHow").textContent = o.how || "";
@@ -457,7 +461,7 @@
const upWho = "UP 主";
const sp = (who) => (/^[A-Za-z]/.test(who) ? ` ${who}` : who);
// A unit's tags: 「视频标签」, 「 UP 标签」 (DESIGN's name for the tags on an UP, not 「UP 主标签」).
- const tagsWord = (who) => (who === upWho ? " UP 标签" : `${sp(who)}标签`);
+ const tagsWord = (who) => (who === upWho ? ` ${MdgErrors.LABEL.upTags}` : `${sp(who)}标签`);
// The delete confirm's title and body.
const deleteTagAsk = (t, n, who) => [`删除标签「${t.name}」?`, `将从 ${n} 个${sp(who)}上去掉这个标签,无法撤销。
`];
// A batch confirm's list: the first CONFIRM_NAMES names, then 「等 N 个」.
@@ -465,7 +469,7 @@
const confirmList = (names) => `${names.slice(0, CONFIRM_NAMES).map((n) => `- ${esc(n)}
`).join("")}
${names.length > CONFIRM_NAMES ? `等 ${names.length} 个
` : ""}`;
// The tag picker's title: 「给「名字」打视频标签 / 打 UP 标签」 (a name alone does not say which), or for several
// 「给选中的 N 个视频打标签」.
- const pickTitle = (n, name, who) => (n > 1 ? `给选中的 ${n} 个${sp(who)}打标签` : who === upWho ? MdgErrors.upTagTitle(name) : `给「${name}」打${tagsWord(who)}`);
+ const pickTitle = (n, name, who) => (n > 1 ? `给选中的 ${n} 个${sp(who)}${MdgErrors.LABEL.keyTag}` : who === upWho ? MdgErrors.upTagTitle(name) : `给「${name}」打${tagsWord(who)}`);
// U on a step that changed n ≥ 2 items asks this first: kind is tags (one 标签… save), ai (one applied AI 打标签) or
// keep (one batch 保留).
const UNDO_ASK = {
@@ -485,7 +489,7 @@
const why = tagNameError(name, others);
return why ? { why } : { tag: { ...t, name } };
}
- if (field === "color") return { tag: { ...t, color: cycleTagColor(t.color) } };
+ if (field === "color") return TAG_COLORS.includes(value) ? { tag: { ...t, color: value } } : {};
if (field !== "rule") return {};
const { rule: _, ...rest } = t;
const rule = String(value ?? "").trim().slice(0, TAG_RULE_MAX);
@@ -568,14 +572,6 @@
const tip = `最近一次 AI 打标签改动的${sp(who)},${check}。\n${AI_RECENT_RULES.map((r) => `· ${r}`).join("\n")}\n${aiRecentUndo(who)}`;
return stateGroup(AI_RECENT, filterBtn(`${attrs} title="${esc(tip)}"`, AI_RECENT, n, on, AI_SPARK) + AI_RECENT_X(xAttrs), " ai-recent");
}
- // One row of 标签管理: color, name, the line for the AI, how many carry it, 删除. Edits save on change.
- const tagRowHtml = (t, { count, who }) => `
-
-
-
- ${count} 个${esc(sp(who))}
-
-
`;
// 「+ 标签 T」 on 视频投稿 cards and the viewer lines; attrs say what it tags. key: false leaves out the T where T acts
// on something else.
const tagPlusBtn = (attrs, label, key = true) =>
@@ -894,5 +890,5 @@
};
}
- globalThis.TriageUi = { https, gearBtn, keepScroll, UP_RECENT, upTitles, AI_RECENT, AI_RECENT_CHECK, aiRef, esc, pad, dayText, fmtDate, fmtAgo, agoHtml, setSearchScope, confirmList, pickTitle, fmtDuration, fmtCount, cleanTagName, plainClick, cardPlayClick, cardPickClick, pickCard, img, toCsv, cardTagChip, untagStep, changedFields, syncedText, headMeta, titleHtml, AI_SPARK, byValue, dirWords, sortControl, filterBtn, labeledRow, tagFilterChip, kindTabs, originChip, stateGroup, tagRowHead, aiRecentChip, searchBox, bindSearch, resultCount, rowButtons, menuItem, BACKUP_ITEM, CLEAN_BACKUP, reasonAttrs, setReason, WARN_DOT, selectAllState, selectAllBox, toggleAll, aiTagsLabel, READING_AI_CHARS, setActivity, BILI_STUCK, waitText, BILI_HOLD_MS, WRITE_STOPPING, busyText, syncPill, setSync, bindSync, tagButtons, sideFoot, actBtn, cleanBtn, HIDDEN_ALL, selbar, toast, askConfirm, askTransfer, sideItem, emptyState, refreshEmpty, noMatch, fillSetRows, fillNumHints, numBox, NUM_SETTINGS, TITLES_PER_REQUEST, INTRO_CHARS, DEEP_COMMENTS, autoMaxTokens, numSetting, clampNumber, intIn, clampNumbers, mergeAiBatch, aiChanges, aiProposalOk, previewId, aiTally, nextTagColor, TAG_RULE_MAX, AI_TAGS_PENDING, tagNameError, deleteTagAsk, editedTag, withoutTag, tagUses, undoAsk, tagRowHtml, sp, tagsWord, AI_RECENT_RULES, aiRecentUndo, tagPlusBtn, viewerLine, viewerKeyFrom, headFold, FOLLOW_WRITE_GAP_MS, AI_TAGS_DONE, aiTagsFailed, AI_TAG_GONE, AI_APPLY_FAILED, NEW_TAG_MAX_ZERO, aiApplied, aiHistoryAdd, GROUP_NAME_MAX, groupNameError, UNDO, untagged, searchScope, cardCleanBtn, REFRESHING, stopWords, upWho, withFeedInProgress, UP_GONE_CODES, FOLLOW_SPECIAL, FEED_CACHE_MS, aiRoomHint, scopeLabel, batchesText, videoUrl, FAV_PAGE_SIZE, ZONE_BATCH, removedName, transferVerb: TRANSFER_VERB, tagManage: TAG_MANAGE };
+ globalThis.TriageUi = { https, gearBtn, keepScroll, UP_RECENT, upTitles, AI_RECENT, AI_RECENT_CHECK, aiRef, esc, pad, dayText, fmtDate, fmtAgo, agoHtml, setSearchScope, confirmList, pickTitle, fmtDuration, fmtCount, cleanTagName, plainClick, cardPlayClick, cardPickClick, pickCard, img, toCsv, cardTagChip, untagStep, changedFields, syncedText, headMeta, titleHtml, AI_SPARK, byValue, dirWords, sortControl, filterBtn, labeledRow, tagFilterChip, kindTabs, originChip, stateGroup, tagRowHead, aiRecentChip, searchBox, bindSearch, resultCount, rowButtons, menuItem, BACKUP_ITEM, CLEAN_BACKUP, reasonAttrs, setReason, WARN_DOT, selectAllState, selectAllBox, toggleAll, aiTagsLabel, READING_AI_CHARS, setActivity, BILI_STUCK, waitText, BILI_HOLD_MS, WRITE_STOPPING, busyText, syncPill, setSync, bindSync, tagButtons, sideFoot, actBtn, cleanBtn, HIDDEN_ALL, selbar, toast, askConfirm, askTransfer, sideItem, emptyState, refreshEmpty, noMatch, fillSetRows, fillNumHints, numBox, NUM_SETTINGS, TITLES_PER_REQUEST, INTRO_CHARS, DEEP_COMMENTS, autoMaxTokens, numSetting, clampNumber, intIn, clampNumbers, mergeAiBatch, aiChanges, aiProposalOk, previewId, aiTally, nextTagColor, TAG_RULE_MAX, AI_TAGS_PENDING, tagNameError, deleteTagAsk, editedTag, withoutTag, tagUses, undoAsk, sp, tagsWord, AI_RECENT_RULES, aiRecentUndo, tagPlusBtn, viewerLine, viewerKeyFrom, headFold, FOLLOW_WRITE_GAP_MS, AI_TAGS_DONE, aiTagsFailed, AI_TAG_GONE, AI_APPLY_FAILED, NEW_TAG_MAX_ZERO, aiApplied, aiHistoryAdd, GROUP_NAME_MAX, groupNameError, UNDO, untagged, searchScope, cardCleanBtn, REFRESHING, stopWords, upWho, withFeedInProgress, UP_GONE_CODES, FOLLOW_SPECIAL, FEED_CACHE_MS, aiRoomHint, scopeLabel, batchesText, videoUrl, FAV_PAGE_SIZE, ZONE_BATCH, removedName, transferVerb: TRANSFER_VERB, tagManage: TAG_MANAGE };
})();
diff --git a/extension/triage/shared.selftest.js b/extension/triage/shared.selftest.js
index a478d1d0..7b9965da 100644
--- a/extension/triage/shared.selftest.js
+++ b/extension/triage/shared.selftest.js
@@ -380,18 +380,9 @@ for (const [file, fns, src] of [["收藏夹", ["mergeAiBatch"], PS.text(PS.favor
assert.strictEqual(UI.nextTagColor([]), C[0]);
assert.strictEqual(UI.nextTagColor([{ color: C[0] }, { color: C[2] }]), C[1], "a deleted tag's color is reused, not a taken one");
assert.strictEqual(UI.nextTagColor(C.map((color) => ({ color }))), C[0], "all taken: round again");
- assert.strictEqual(TAG.cycleTagColor(C[0]), C[1]);
- assert.strictEqual(TAG.cycleTagColor(C.at(-1)), C[0]);
- assert.strictEqual(TAG.cycleTagColor("#000"), C[0], "a color from elsewhere starts the palette");
assert.strictEqual(UI.tagNameError("", []), "标签名不能为空");
assert.strictEqual(UI.tagNameError("a", [{ name: "a" }]), "已有同名标签");
assert.strictEqual(UI.tagNameError("a", [{ name: "b" }]), "");
- // Both modes' 管理 rows: the color button, the who in placeholder and count, escaped names.
- const row = (who) => UI.tagRowHtml({ id: "x", name: "", color: "#fff", rule: "r" }, { count: 3, who });
- for (const [who, words] of [["视频", "视频"], ["UP 主", " UP 主"]]) {
- assert.ok(row(who).includes("data-tag-color") && row(who).includes("data-tag-del") && row(who).includes(`3 个${words}<`) && row(who).includes(`什么样的${words}打这个标签`));
- assert.ok(row(who).includes('value="<i>"') && !row(who).includes(""));
- }
assert.ok(UI.deleteTagAsk({ name: "甲" }, 2, "UP 主")[1].includes("2 个 UP 主上"));
assert.deepStrictEqual([...UI.deleteTagAsk({ name: "甲" }, 2, "视频")], ["删除标签「甲」?", "将从 2 个视频上去掉这个标签,无法撤销。
"]);
// The picker's title names which tags: a lone name does not say whether it is a video or an UP 主.
@@ -413,7 +404,8 @@ for (const [file, fns, src] of [["收藏夹", ["mergeAiBatch"], PS.text(PS.favor
assert.strictEqual(UI.editedTag(t0, "rule", ` ${"讲".repeat(90)} `).tag.rule.length, 80);
assert.strictEqual(UI.editedTag(t0, "name", " 乙, ", []).tag.name, "乙");
assert.deepStrictEqual(plain(UI.editedTag(t0, "name", "乙", [{ name: "乙" }])), { why: "已有同名标签" });
- assert.strictEqual(UI.editedTag(t0, "color").tag.color, TAG.TAG_COLORS[1]);
+ assert.strictEqual(UI.editedTag(t0, "color", TAG.TAG_COLORS[4]).tag.color, TAG.TAG_COLORS[4]);
+ assert.strictEqual(UI.editedTag(t0, "color", "red").tag, undefined, "only a palette color");
assert.strictEqual(t0.rule, "旧说明", "the tag itself is not changed");
assert.deepStrictEqual([...UI.undoAsk("tags", 3, "UP 主")], ["撤销批量改标签?", "上一步改了 3 个 UP 主的标签,撤销后都改回去。
", "撤销"]);
assert.deepStrictEqual(plain(UI.withoutTag({ x: ["a", "b"], y: ["a"] }, "a")), { x: ["b"] });
@@ -728,13 +720,13 @@ for (const [file, fns, src] of [["收藏夹", ["mergeAiBatch"], PS.text(PS.favor
nodes.transferDialog.L.close.at(-1)();
};
const group = {
- title: "在 B站把这 2 个 UP 主复制到分组", n: 2, hows: ["copy"], list: "", label: "目标分组",
+ title: "在 B站把这 2 个 UP 主加进分组", n: 2, hows: ["copy"], verbs: { copy: "加进" }, list: "", label: "目标分组",
options: [["-10", "特别关注 (3)"], ["7", "<数码> (2)"]], newText: "新建分组…", newPlaceholder: "新分组名称", newMax: 16, how: "原来的分组里也留着。",
note: (v) => (v === "-10" ? "会推送" : "")
};
let p = UI.askTransfer(group);
assert.ok(nodes.transferDialog.open && nodes.transferLabel.textContent === "目标分组" && nodes.transferName.maxLength === 16);
- assert.deepStrictEqual(buttons.map((b) => [b.value, b.hidden, b.textContent, b.cls.has("primary")]), [["copy", false, "复制 2 个", true], ["move", true, "移动 2 个", false], ["add", true, "收藏 2 个", false]], "only the mode's button, blue, with the count");
+ assert.deepStrictEqual(buttons.map((b) => [b.value, b.hidden, b.textContent, b.cls.has("primary")]), [["copy", false, "加进 2 个", true], ["move", true, "移动 2 个", false], ["add", true, "收藏 2 个", false]], "only the mode's button, blue, with the count");
assert.ok(nodes.transferTarget.innerHTML.includes("<数码>") && nodes.transferTarget.innerHTML.endsWith(''));
assert.ok(nodes.transferPrivateRow.hidden, "设为私密 is 收藏夹's");
nodes.transferTarget.value = "-10";
@@ -754,11 +746,15 @@ for (const [file, fns, src] of [["收藏夹", ["mergeAiBatch"], PS.text(PS.favor
close("move", "7");
assert.deepStrictEqual(plain(await p), { how: "move", target: { id: "7" } });
assert.strictEqual(nodes.transferTarget.L.change.length, 1, "bound once");
+ // What is moved: one name shows as it is; more fold into 「first 等 N 个」, and aside stays outside the fold.
+ UI.askTransfer({ ...group, n: 1, list: UI.confirmList(["甲"]) });
+ assert.strictEqual(nodes.transferBody.innerHTML, '');
+ UI.askTransfer({ ...group, list: UI.confirmList(["<甲>", "乙"]), aside: "另有 1 个
" });
+ assert.ok(nodes.transferBody.innerHTML.startsWith('<甲>等 2 个
') && nodes.transferBody.innerHTML.endsWith("另有 1 个
"), nodes.transferBody.innerHTML);
for (const bad of XSS) {
assertInert(UI.titleHtml(bad, 2), "titleHtml");
assertInert(UI.cardTagChip({ id: bad, name: bad, color: "#fff" }, bad), "cardTagChip");
- assertInert(UI.tagRowHtml({ id: bad, name: bad, color: "#fff", rule: bad }, { count: 1, who: "视频" }), "tagRowHtml");
assertInert(UI.tagPlusBtn('data-x="1"', `给 ${bad} 打 UP 标签`), "tagPlusBtn");
assertInert(UI.sideItem({ attrs: "", label: bad }), "sideItem");
}
diff --git a/extension/triage/tag-dialogs.js b/extension/triage/tag-dialogs.js
index a96f479f..53c29828 100644
--- a/extension/triage/tag-dialogs.js
+++ b/extension/triage/tag-dialogs.js
@@ -8,61 +8,89 @@
const manageDlg = $("tagManageDialog");
const aiDlg = $("aiTagDialog");
if (!manageDlg || !aiDlg) return;
- // The page has the empty dialog; its markup is here, so the 分拣台 and 摘读记录 share one copy.
+ // The page has the empty dialog; its markup is here, so the 分拣台 and 摘读记录 share one copy. Two pages in one form: the
+ // setup (#aiForm, #aiFormActs) and the review (#aiReviewHead, #aiReview, #aiReviewActs). Only .dlg-body scrolls
+ // (tags.css); the columns are the 判断标准 dialog's (.crit-cols, triage.css).
aiDlg.innerHTML = ``;
// ----- 标签管理 (and 关注's 分组管理, the same list of named things) -----
- // a = { who: 视频 | UP 主, hint() (where the tags live, the limit), reason() ("" or why nothing can be edited here),
- // tags(), count(id), addReason(name) ("" or why this name cannot be added: empty, taken, the list full), add(name) →
- // tag | null, edit(t, field, value) → saved?, remove(t) }; all may be async but addReason.
- // 分组管理 also passes text: { title, saved (what saves at once), newName, newMax, add, addLabel } and row(t, count)
- // (its row html).
- const TAG_TEXT = { title: UI.tagManage, saved: "改名、颜色、说明和删除立即保存。", newName: MdgErrors.LABEL.newTagName, newMax: MdgTagCore.TAG_NAME_MAX, add: "新建", addLabel: MdgErrors.LABEL.newTag };
+ // a = { who: 视频 | UP 主, hint() (where the tags live, the limit: the one sentence under the title), reason() ("" or
+ // why nothing can be edited here), tags(), count(id), addReason(name) ("" or why this name cannot be added: empty,
+ // taken, the list full), add(name) → tag | null, edit(t, field, value) → saved?, remove(t) }; all may be async but
+ // addReason.
+ // 标签管理 (.tm) is two panes: the tags on the left with 新建 under them, the picked tag's name, color, 说明 and 删除
+ // on the right. 分组管理 also passes text: { title, saved (what saves at once), newName, newMax, add, addLabel } and
+ // row(t, count) (its row html), and stays one list of rows.
+ const TAG_TEXT = { title: UI.tagManage, newName: MdgErrors.LABEL.newTagName, newMax: MdgTagCore.TAG_NAME_MAX, add: "新建", addLabel: MdgErrors.LABEL.newTag };
let man = null;
const rows = $("tagsRows");
+ const detail = $("tmDetail");
const newInput = $("newTagInput");
+ // 标签管理's picked tag, and its place in the list: deleted, the tag now there takes over.
+ let sel = "";
+ let selAt = 0;
function openManage(a) {
man = a;
const text = { ...TAG_TEXT, ...a.text };
$("tagManageTitle").textContent = text.title;
+ manageDlg.classList.toggle("tm", !a.row);
+ sel = "";
+ selAt = 0;
newInput.value = "";
newInput.placeholder = text.newName;
newInput.maxLength = text.newMax;
@@ -76,33 +104,79 @@
function renderManage() {
const a = man;
const why = a.reason?.() || "";
- // Nothing can be edited (why): 「…立即保存」 would say the opposite.
- $("tagManageHint").textContent = `${a.hint()}${why ? "" : { ...TAG_TEXT, ...a.text }.saved}`;
+ // Nothing can be edited (why): 「…立即保存」 would say the opposite. 标签管理 says it beside 完成, 分组管理 here.
+ $("tagManageHint").textContent = `${a.hint()}${why || !a.row ? "" : a.text.saved}`;
UI.setReason(newInput, why);
syncAdd();
const tags = a.tags();
- rows.innerHTML = why
- ? `${esc(why)}
`
- : tags.length
- ? tags.map((t) => (a.row ? a.row(t, a.count(t.id)) : UI.tagRowHtml(t, { count: a.count(t.id), who: a.who }))).join("")
- : `还没有${a.row ? "自己建的分组" : esc(tagsWord(a.who))}
`;
+ $("tmMeta").textContent = a.row || why ? "" : `${tags.length} 个标签 · 改动立即保存`;
+ if (!a.row) return drawList(), drawDetail(why);
+ detail.innerHTML = "";
+ rows.innerHTML = why ? `${esc(why)}
` : tags.length ? tags.map((t) => a.row(t, a.count(t.id))).join("") : `还没有自己建的分组
`;
+ }
+ // The tags 标签管理 lists: none where nothing can be edited (the pane says why).
+ const listed = () => (man.reason?.() ? [] : man.tags());
+ const curTag = () => listed().find((t) => String(t.id) === sel);
+ function drawList() {
+ const tags = listed();
+ const cur = curTag() || tags[Math.min(selAt, tags.length - 1)];
+ sel = cur ? String(cur.id) : "";
+ selAt = Math.max(0, tags.indexOf(cur));
+ const who = esc(sp(man.who));
+ rows.innerHTML = tags
+ .map((t) => {
+ const n = man.count(t.id);
+ return ``;
+ })
+ .join("");
+ }
+ function drawDetail(why) {
+ const t = curTag();
+ if (!t) return void (detail.innerHTML = `${esc(why || `还没有${tagsWord(man.who)}`)}
`);
+ const who = esc(sp(man.who));
+ const others = listed().filter((x) => x !== t);
+ const dots = MdgTagCore.swatchColors(t.color, others)
+ .map((c, i) => {
+ const taken = others.filter((x) => x.color === c).map((x) => x.name);
+ const note = taken.length ? `「${esc(taken.join("」「"))}」在用` : "";
+ return ``;
+ })
+ .join("");
+ const rule = t.rule || "";
+ detail.innerHTML = `
+
+
+ 写给 AI 看。不写时,AI 只看到标签名。${rule.length} / ${UI.TAG_RULE_MAX}
+ `;
}
const rowTag = (target) => {
const id = target.closest(".tag-row")?.dataset.id;
return id && man.tags().find((t) => String(t.id) === id);
};
// 新建 is off with why while the name cannot be added, updated as you type; Enter follows it, the typed text stays.
+ // 标签管理 also writes the why under the box once something is typed.
const addWhy = () => man.reason?.() || man.addReason(newInput.value);
- const syncAdd = () => UI.setReason($("addTagBtn"), addWhy());
+ function syncAdd() {
+ const why = addWhy();
+ UI.setReason($("addTagBtn"), why);
+ $("tmWhy").textContent = !man.row && newInput.value.trim() ? why : "";
+ }
// A second 新建 (a double click, Enter twice) before the first one's answer would create the name twice.
let adding = false;
async function addTag() {
if (adding || addWhy()) return;
adding = true;
try {
- if (await man.add(newInput.value)) {
+ const tag = await man.add(newInput.value);
+ if (tag) {
newInput.value = "";
+ // 标签管理 picks the new tag, the caret in its 说明.
+ if (!man.row) sel = String(tag.id);
renderManage();
+ if (!man.row) $("tmRule")?.focus();
}
} finally {
adding = false;
@@ -115,18 +189,39 @@
if (t && field && !(await man.edit(t, field, e.target.value))) renderManage();
});
rows.addEventListener("click", async (e) => {
+ const pick = e.target.closest(".tm-item")?.dataset.id;
+ if (pick) return (sel = pick), renderManage();
const t = rowTag(e.target);
+ if (!t || !e.target.closest("[data-tag-del]")) return;
+ await man.remove(t);
+ renderManage();
+ });
+ detail.addEventListener("change", async (e) => {
+ const t = curTag();
+ const field = e.target.dataset.field;
+ if (!t || !field) return;
+ // A saved edit redraws only the list (the new name), so the focus stays where it moved; a refused name goes back.
+ if (await man.edit(t, field, e.target.value)) drawList();
+ else renderManage();
+ });
+ detail.addEventListener("input", (e) => {
+ if (e.target.id === "tmRule") $("tmCnt").textContent = `${e.target.value.length} / ${UI.TAG_RULE_MAX}`;
+ });
+ detail.addEventListener("click", async (e) => {
+ const t = curTag();
if (!t) return;
+ const color = e.target.closest("[data-color]")?.dataset.color;
if (e.target.closest("[data-tag-del]")) await man.remove(t);
- else if (e.target.closest("[data-tag-color]")) await man.edit(t, "color");
+ else if (color) await man.edit(t, "color", color);
else return;
renderManage();
+ if (color) detail.querySelector(`[data-color="${color}"]`)?.focus();
});
$("addTagBtn").addEventListener("click", addTag);
newInput.addEventListener("input", () => man && syncAdd());
// Enter in a name field: the new-tag box adds; a rename would submit the form and close the dialog.
manageDlg.addEventListener("keydown", (e) => {
- if (MdgTyping.composing(e) || e.key !== "Enter" || !e.target.matches?.('#newTagInput, [data-field="name"], [data-field="rule"]')) return;
+ if (MdgTyping.composing(e) || e.key !== "Enter" || !e.target.matches?.('#newTagInput, [data-field="name"]')) return;
e.preventDefault();
if (e.target === newInput) addTag();
});
@@ -148,11 +243,28 @@
const notMade = (a, p) => a.notMade?.(p) || { keys: new Set(), why: "" };
const changesOf = (a, p, skip = notMade(a, p).keys) => UI.aiChanges(p, a.map(), a.live(), (key) => !skip.has(key) && UI.previewId(p, key, allTags(a)));
let ai = null;
- // adapter → { where, text }: its run's progress line and the folder the run is in, kept while the dialog is closed and
- // shown only there.
+ // adapter → { where, text, remedy }: its run's progress line and the folder the run is in, kept while the dialog is
+ // closed and shown only there. remedy ({ label, run }) is the button the adapter's page gives the error that stopped
+ // the run (去设置, 授权), or null.
const progressOf = new Map();
const whereOf = (a) => a.where?.() ?? "";
const progressText = (a) => (progressOf.get(a)?.where === whereOf(a) ? progressOf.get(a).text : "");
+ // The line left when no run is on is why the last one gave no proposal: red, at the left of the buttons. While one
+ // runs it is its progress, in grey there.
+ function drawProgress(a) {
+ const text = progressText(a);
+ const failed = Boolean(text) && !a.running();
+ $("aiProgress").textContent = failed ? "" : text;
+ $("aiFail").textContent = failed ? text : "";
+ $("aiFail").hidden = !failed;
+ const remedy = failed && progressOf.get(a).remedy;
+ if (remedy) {
+ $("aiFail").insertAdjacentHTML("beforeend", ``);
+ $("aiFail").querySelector("button").addEventListener("click", () => remedy.run());
+ }
+ }
+ // adapter → { where, instruction }: what the last run here was asked, for the review's 依据.
+ const ranOf = new Map();
const scopeSel = $("aiScope");
const instr = $("aiInstruction");
let instrKey = null; // [adapter, where] the instruction was written for; another mode or folder starts empty
@@ -179,8 +291,8 @@
const isOpen = (a) => aiDlg.open && ai === a;
function renderAi(want) {
const p = !ai.running() && ai.proposal();
- $("aiForm").hidden = Boolean(p);
- $("aiReview").hidden = !p;
+ for (const id of ["aiForm", "aiFormActs"]) $(id).hidden = Boolean(p);
+ for (const id of ["aiReviewHead", "aiReview", "aiReviewActs"]) $(id).hidden = !p;
if (p) renderReview(p);
else renderForm(want);
}
@@ -191,7 +303,7 @@
// want: the scope to pick when it has items (else the one picked stays, if it still has any).
function renderForm(want = scopeSel.value) {
const a = ai;
- $("aiHint").textContent = `用一句话让 AI 给一批${sp(a.who)}打标签。AI 看${a.sees},只给建议,你点「应用」后才生效。`;
+ $("aiHint").textContent = `AI 看${a.sees},只给建议,你点「应用」后才生效。`;
const scopes = a.scopes();
// 选中 counts like the row-4 button: the listed selected ones, or all of them when filters hide every one.
scopeSel.innerHTML = scopes.map((s) => ``).join("");
@@ -207,14 +319,15 @@
// The link only where 标签管理 can edit (not in 所有收藏夹, whose tags belong to each folder).
const manageable = !a.manage?.reason?.();
const manageLink = ``;
+ const tagsHead = `可用标签`;
$("aiTagsPreview").innerHTML = blocked
? `${esc(blocked)}
`
: tags.length
- ? `可用标签${tags.map(useChip).join("")}
点掉的标签这次不给 AI 用。
${a.roomHint()}
`
- : `还没有${esc(tagsWord(a.who))}。${a.roomHint()}${manageable ? `想打得准,先在${manageLink}里建好标签、每个写一句说明。` : ""}
`;
+ ? `${tagsHead}${tags.map(useChip).join("")}
点掉的标签这次不给 AI 用。${a.roomHint()}
`
+ : `${tagsHead}还没有${esc(tagsWord(a.who))}。${a.roomHint()}${manageable ? `想打得准,先在${manageLink}里建好标签、每个写一句说明。` : ""}
`;
const history = a.history();
$("aiHistory").innerHTML = history.length
- ? `最近:${history.map((h, i) => ``).join("")}`
+ ? `最近${history.map((h, i) => ``).join("")}`
: "";
const running = a.running();
const run = $("aiRunBtn");
@@ -229,7 +342,7 @@
stop.textContent = stopping ? MdgErrors.LABEL.stopping : MdgErrors.LABEL.stop;
stop.setAttribute("aria-label", stop.textContent);
UI.setReason(stop, stopping ? UI.WRITE_STOPPING : "");
- $("aiProgress").textContent = progressText(a);
+ drawProgress(a);
}
// AI may propose more new tags than the run's cap; they are all kept, and this says by how much. Not under a hard
// limit (notMade), which says instead which ones 应用 will not create.
@@ -256,8 +369,11 @@
`;
})
.join("");
- $("aiReviewHint").textContent = `应用后列表只显示「✦ ${UI.AI_RECENT}」这些${who},${a.check || UI.AI_RECENT_CHECK}。`;
- $("aiRecentMeta").innerHTML = `「${UI.AI_RECENT}」只显示最近一次 AI 打标签改动的${esc(who)}:
${UI.AI_RECENT_RULES.map((r) => `- ${esc(r)}
`).join("")}
${esc(UI.aiRecentUndo(a.who))}`;
+ // The chip's tooltip has the full rules (UI.aiRecentChip).
+ $("aiReviewHint").textContent = `应用后列表只显示「✦ ${UI.AI_RECENT}」这些${who},${a.check || UI.AI_RECENT_CHECK},按 U 整批撤销。`;
+ // Failed batches (and a stop): red, at the left of the buttons.
+ $("aiErrors").textContent = p.errors.join(";");
+ $("aiErrors").hidden = !p.errors.length;
renderTally(p);
}
function renderTally(p) {
@@ -268,14 +384,20 @@
// Redrawn with each tick: which new tags 应用 cannot create follows them.
const unmade = p.newTags.filter((t) => skip.keys.has(t.key)).map((t) => cleanTagName(t.name));
const warns = unmade.length ? [`「${unmade.join("」「")}」不会新建:${skip.why},用到它们的${who}也不会打上。取消勾选别的新标签可以腾出位置。`] : overCapLines(p);
- $("aiNotes").innerHTML = p.errors.map((e) => `
${esc(e)}
`).join("") + p.notes.map((n) => `
AI 说明:${esc(n)}
`).join("") +
- [...warns, ...(p.excludedHits?.length ? [`AI 想用的「${p.excludedHits.join("」「")}」是你点掉的标签,没有采用。`] : [])].map((l) => `
${esc(l)}
`).join("");
+ const ran = ranOf.get(a)?.where === whereOf(a) ? ranOf.get(a).instruction : "";
+ const basis = [
+ ...(ran ? [["指令", ran]] : []),
+ ...[...new Set(p.notes)].map((n) => ["AI 说明", n]),
+ ...warns.map((l) => ["新标签", l, " warn"]),
+ ...(p.excludedHits?.length ? [["没有采用", `AI 想用的「${p.excludedHits.join("」「")}」是你点掉的标签,没有采用。`, " warn"]] : [])
+ ];
+ $("aiNotes").innerHTML = (basis.length ? basis : [["AI 说明", "没有"]]).map(([k, v, cls = ""]) => `
${k}${esc(v)}`).join("");
// A new tag whose name an existing one has is that tag (previewId), not a new one.
const newN = p.newTags.filter((t) => t.checked && !skip.keys.has(t.key) && UI.aiRef.keyOf(String(UI.previewId(p, t.key, allTags(a)) || ""))).length;
- $("aiReviewSummary").textContent = `· ${changes.length} 个${who}有改动 · 新标签 ${newN} 个 · 点「应用」前不会改动任何东西`;
- const tally = UI.aiTally(p, changes, a.tagName);
// Nothing to apply: the AI proposed nothing, or what it proposed was unticked or left the list since.
const none = p.rows.length || p.newTags.length ? "没有可应用的改动" : "AI 没有提出改动";
+ $("aiReviewSummary").innerHTML = changes.length || newN ? `
${changes.length} 个${esc(who)}有改动,新建
${newN} 个标签` : none;
+ const tally = UI.aiTally(p, changes, a.tagName);
$("aiRows").innerHTML = tally.length
? `
${tally.map((t) => `${esc(t.text)} ${t.n}`).join("")}
`
: `
${newN ? `没有${esc(who)}的标签改动,应用只创建新标签` : none}
`;
@@ -290,6 +412,9 @@
const scope = ai.scopes().find((s) => s.value === scopeSel.value) || {};
// 运行 is off with its reason then (renderForm); a stale click does nothing.
if (ai.running() || ai.blocked() || !instruction || hiddenAll(scope) || !scope.n || noTagsToUse(ai)) return;
+ // The last run's failure line goes; the review shows what this one was asked.
+ progressOf.delete(ai);
+ ranOf.set(ai, { where: whereOf(ai), instruction });
ai.run({ instruction, scope: scopeSel.value, allowRemove: $("aiRemoveInput").checked });
renderAi();
}
@@ -361,9 +486,9 @@
// Redraw for a mode whose run moved on; nothing when the dialog is closed or shows the other mode.
render: (a) => isOpen(a) && renderAi(),
// where: the folder the run is in (a.where() when it started).
- progress(a, text, where = "") {
- progressOf.set(a, { where, text });
- if (isOpen(a) && !$("aiForm").hidden) $("aiProgress").textContent = progressText(a);
+ progress(a, text, where = "", remedy = null) {
+ progressOf.set(a, { where, text, remedy });
+ if (isOpen(a) && !$("aiForm").hidden) drawProgress(a);
}
}
};
diff --git a/extension/triage/tag-dialogs.selftest.js b/extension/triage/tag-dialogs.selftest.js
index cc98a2e5..3c37454a 100644
--- a/extension/triage/tag-dialogs.selftest.js
+++ b/extension/triage/tag-dialogs.selftest.js
@@ -25,10 +25,11 @@ function node(id, extra = {}) {
return (nodes[id] = Object.assign({ id, L, attrs, hidden: false, disabled: false, value: "", innerHTML: "", textContent: "", dataset: {}, addEventListener: (t, f) => (L[t] ||= []).push(f), setAttribute: (k, v) => (attrs[k] = v), removeAttribute: (k) => delete attrs[k], focus() { focused = id; } }, extra));
}
let focused = "";
-const dialog = (id) => node(id, { open: false, showModal() { this.open = true; }, close() { this.open = false; }, querySelector: () => null });
+const dialog = (id) => node(id, { open: false, showModal() { this.open = true; }, close() { this.open = false; }, querySelector: () => null, classList: { on: new Set(), toggle(c, v) { v ? this.on.add(c) : this.on.delete(c); } } });
dialog("tagManageDialog");
dialog("aiTagDialog");
-for (const id of ["tagManageTitle", "tagManageHint", "tagsRows", "newTagInput", "addTagBtn", "aiForm", "aiReview", "aiHint", "aiInstruction", "aiHistory", "aiScope", "aiScopeCount", "aiTagsPreview", "aiRemoveInput", "aiProgress", "aiCloseBtn", "aiStopBtn", "aiRunBtn", "aiReviewSummary", "aiNotes", "aiNewTagsHead", "aiNewTags", "aiRows", "aiReviewHint", "aiRecentMeta", "aiDiscardBtn", "aiApplyBtn"]) node(id);
+for (const id of ["tagManageTitle", "tagManageHint", "tagsRows", "newTagInput", "addTagBtn", "aiForm", "aiReview", "aiHint", "aiInstruction", "aiHistory", "aiScope", "aiScopeCount", "aiTagsPreview", "aiRemoveInput", "aiProgress", "aiCloseBtn", "aiStopBtn", "aiRunBtn", "aiReviewSummary", "aiNotes", "aiNewTagsHead", "aiNewTags", "aiRows", "aiReviewHint", "aiDiscardBtn", "aiApplyBtn", "tmMeta", "tmWhy", "aiFormActs", "aiReviewHead", "aiReviewActs", "aiFail", "aiErrors"]) node(id);
+node("tmDetail", { querySelector: () => null });
const fire = (id, type, e = {}) => {
const ev = { prevented: 0, preventDefault() { this.prevented++; }, isComposing: false, keyCode: 0, ...e };
for (const f of nodes[id].L[type] || []) f(ev);
@@ -102,8 +103,14 @@ function adapters(who) {
// 标签管理: only the tags, from the adapter; AI 打标签 stays closed.
D.manage.open(manage);
assert.ok(nodes.tagManageDialog.open && !nodes.aiTagDialog.open && D.manage.isOpen(manage), `${who}: 标签管理 opens alone`);
- assert.strictEqual(nodes.tagManageHint.textContent, "这里的标签。改名、颜色、说明和删除立即保存。");
- assert.ok(nodes.tagsRows.innerHTML.includes(`2 个${unit}`) && nodes.tagsRows.innerHTML.includes("data-tag-color"), `${who}: rows count in the mode's unit`);
+ // Two panes: the tags on the left, the first one's name, the color dots, 说明 and 删除 on the right. One sentence
+ // under the title; what saves at once is beside 完成.
+ assert.ok(nodes.tagManageDialog.classList.on.has("tm"));
+ assert.deepStrictEqual([nodes.tagManageHint.textContent, nodes.tmMeta.textContent], ["这里的标签。", "1 个标签 · 改动立即保存"]);
+ assert.ok(nodes.tagsRows.innerHTML.includes('class="tm-item" data-id="a" aria-current="true"') && nodes.tagsRows.innerHTML.includes(`title="2 个${unit}">2<`), nodes.tagsRows.innerHTML);
+ const pane = () => nodes.tmDetail.innerHTML;
+ assert.ok(pane().includes('value="科普" data-field="name"') && pane().includes(`什么样的${unit}打这个标签`) && pane().includes(`用在 2 个${unit}`) && pane().includes("data-tag-del"), `${who}: the pane counts in the mode's unit`);
+ assert.strictEqual(pane().split("data-color=").length - 1, ctx.MdgTagCore.TAG_COLORS.length, "a dot per palette color");
assert.strictEqual(focused, "newTagInput");
// IME: Enter that picks a candidate adds nothing; a plain Enter adds and clears the box.
nodes.newTagInput.value = "zhong";
@@ -134,14 +141,40 @@ function adapters(who) {
// Enter in a rename stays in the dialog (it would submit the form), but not mid-IME.
assert.strictEqual(enter(target('[data-field="name"]')).prevented, 1);
assert.strictEqual(enter(target('[data-field="name"]'), { isComposing: true }).prevented, 0);
- // A refused rename redraws the row with the saved name; 删除 goes to the adapter.
- nodes.tagsRows.innerHTML = "";
- fire("tagsRows", "change", { target: { value: "重名", dataset: { field: "name" }, closest: () => ({ dataset: { id: "a" } }) } });
+ // 新建 says why under the box once something is typed.
+ nodes.newTagInput.value = "重名";
+ fire("newTagInput", "input");
+ assert.strictEqual(nodes.tmWhy.textContent, "已有同名标签");
+ nodes.newTagInput.value = "";
+ fire("newTagInput", "input");
+ assert.strictEqual(nodes.tmWhy.textContent, "");
+ // A saved edit redraws only the list, so the focus stays in the pane; a refused rename redraws the pane with the
+ // saved name; a color dot sets that color; 删除 goes to the adapter.
+ const inPane = (sel, dataset = {}) => ({ dataset: {}, closest: (s) => (s === sel ? { dataset } : null) });
+ nodes.tmDetail.innerHTML = nodes.tagsRows.innerHTML = "";
+ fire("tmDetail", "change", { target: { value: "写给 AI 的说明", dataset: { field: "rule" } } });
+ await wait();
+ assert.deepStrictEqual([calls.at(-1), pane()], [["edit", "a", "rule", "写给 AI 的说明"], ""]);
+ assert.ok(nodes.tagsRows.innerHTML.includes("科普"));
+ fire("tmDetail", "change", { target: { value: "重名", dataset: { field: "name" } } });
+ await wait();
+ assert.ok(pane().includes('value="科普"'), `${who}: a refused name goes back`);
+ fire("tmDetail", "click", { target: inPane("[data-color]", { color: "#298287" }) });
await wait();
- assert.ok(nodes.tagsRows.innerHTML.includes("科普"), `${who}: a refused name goes back`);
- fire("tagsRows", "click", { target: { closest: (s) => (s === ".tag-row" ? { dataset: { id: "a" } } : s === "[data-tag-del]" ? {} : null) } });
+ assert.deepStrictEqual(calls.at(-1), ["edit", "a", "color", "#298287"]);
+ // A click on the left picks the tag the pane shows; a color another tag has is dimmed and named. Names are escaped.
+ tags.push({ id: "b", name: '
"', color: "#da86c3" });
+ fire("tagsRows", "click", { target: inPane(".tm-item", { id: "b" }) });
+ assert.ok(pane().includes('value="<i>""') && !pane().includes("") && !nodes.tagsRows.innerHTML.includes(""), pane());
+ tags[0].color = "#298287";
+ D.manage.open(manage);
+ fire("tagsRows", "click", { target: inPane(".tm-item", { id: "b" }) });
+ assert.ok(/class="tag-color used" style="--c:#298287"[^>]*title="「科普」在用"/.test(pane()) && pane().includes('data-color="#da86c3" aria-pressed="true"'), pane());
+ fire("tmDetail", "click", { target: inPane("[data-tag-del]") });
await wait();
- assert.deepStrictEqual(calls.at(-1), ["remove", "a"]);
+ assert.deepStrictEqual(calls.at(-1), ["remove", "b"]);
+ tags.pop();
+ tags[0].color = "#111";
nodes.tagManageDialog.close();
// AI 打标签: the form, its own title and no 标签管理 part; 选中 is picked when something is selected.
@@ -151,7 +184,7 @@ function adapters(who) {
assert.ok(!nodes.aiForm.hidden && nodes.aiReview.hidden);
assert.strictEqual(nodes.aiScope.value, "selected");
assert.strictEqual(ai.excluded.size, 0, "each opening starts with every tag usable");
- assert.strictEqual(nodes.aiHint.textContent, `用一句话让 AI 给一批${unit}打标签。AI 看名字,只给建议,你点「应用」后才生效。`);
+ assert.strictEqual(nodes.aiHint.textContent, "AI 看名字,只给建议,你点「应用」后才生效。");
assert.ok(nodes.aiTagsPreview.innerHTML.includes('data-use="a"') && nodes.aiRemoveInput.checked);
// No tags: the hint links to 标签管理 (a text link), which closes this dialog and opens 标签管理 with the mode's adapter.
tags.length = 0;
@@ -210,22 +243,52 @@ function adapters(who) {
assert.deepStrictEqual(JSON.parse(JSON.stringify(calls.at(-1))), ["run", { instruction: "按内容分", scope: "selected", allowRemove: true }]);
assert.ok(nodes.aiRunBtn.disabled && nodes.aiRunBtn.innerHTML === "运行中…" && !nodes.aiStopBtn.hidden);
D.ai.progress(ai, "AI 正在处理第 1 / 2 批…");
- assert.strictEqual(nodes.aiProgress.textContent, "AI 正在处理第 1 / 2 批…");
+ assert.deepStrictEqual([nodes.aiProgress.textContent, nodes.aiFail.hidden], ["AI 正在处理第 1 / 2 批…", true]);
// 停止, as the pill's: 停止中, off with the pill's reason; the progress line stays the run's.
fire("aiTagDialog", "click", { target: target("#aiStopBtn", { id: "aiStopBtn" }) });
assert.deepStrictEqual([calls.at(-1)[0], nodes.aiStopBtn.textContent, nodes.aiStopBtn.disabled, nodes.aiStopBtn.title], ["stop", "停止中", true, ctx.TriageUi.WRITE_STOPPING]);
assert.strictEqual(nodes.aiProgress.textContent, "AI 正在处理第 1 / 2 批…");
ai.isStopping = false;
+ // X7: a run that ends with no proposal leaves why in the red banner beside the buttons, not in the grey progress
+ // line; the next run takes it away.
+ ai.isRunning = false;
+ D.ai.progress(ai, "第 1 批失败:API Key 不对");
+ D.ai.render(ai);
+ assert.deepStrictEqual([nodes.aiProgress.textContent, nodes.aiFail.textContent, nodes.aiFail.hidden], ["", "第 1 批失败:API Key 不对", false]);
+ // The banner draws the button it is handed (the page's 去设置 / 授权 for the error's code), and none without one.
+ {
+ const btn = { L: [], addEventListener: (type, f) => btn.L.push(f) };
+ let ran = 0;
+ nodes.aiFail.added = "";
+ nodes.aiFail.insertAdjacentHTML = (where, h) => (nodes.aiFail.added += h);
+ nodes.aiFail.querySelector = () => btn;
+ assert.strictEqual(nodes.aiFail.added, "", "no remedy: no button");
+ D.ai.progress(ai, "第 1 批失败:API Key 不对", "", { label: "去设置", run: () => ran++ });
+ assert.deepStrictEqual([nodes.aiFail.textContent, nodes.aiFail.added], ["第 1 批失败:API Key 不对", '']);
+ btn.L[0]();
+ assert.strictEqual(ran, 1, "the button runs the remedy");
+ nodes.aiFail.added = "";
+ D.ai.progress(ai, "第 1 批失败:格式不对");
+ assert.strictEqual(nodes.aiFail.added, "", "an error without a remedy: the banner alone");
+ }
+ fire("aiTagDialog", "click", { target: target("#aiRunBtn", { id: "aiRunBtn" }) });
+ assert.deepStrictEqual([nodes.aiProgress.textContent, nodes.aiFail.hidden], ["", true]);
// Done: the open dialog turns to the proposal, counted in the mode's unit; 应用 closes it.
ai.isRunning = false;
// A row for an item that left (unfavorited, unfollowed) counts nowhere: not in 应用到, not in 用在.
const row = (id, add) => ({ id, add, remove: [] });
- ai.p = { newTags: [{ key: "n", name: "新", checked: true }], rows: [row("x", ["new:n"]), row("y", ["id:a"]), row("left", ["new:n"])], notes: [], errors: [] };
+ ai.p = { newTags: [{ key: "n", name: "新", checked: true }], rows: [row("x", ["new:n"]), row("y", ["id:a"]), row("left", ["new:n"])], notes: ["看不出的没打", "看不出的没打"], errors: ["第 2 批失败:超时"], excludedHits: ["数学"] };
D.ai.render(ai);
- assert.ok(nodes.aiForm.hidden && !nodes.aiReview.hidden);
+ assert.ok(nodes.aiForm.hidden && nodes.aiFormActs.hidden && !nodes.aiReview.hidden && !nodes.aiReviewHead.hidden && !nodes.aiReviewActs.hidden);
assert.strictEqual(nodes.aiApplyBtn.textContent, `应用到 2 个${unit}`);
- assert.ok(nodes.aiReviewHint.textContent.includes(`这些${unit},在卡片上逐个看`) && nodes.aiNewTags.innerHTML.includes(`用在 1 个${unit}`));
+ // The verdict in one line; one sentence under it; failed batches in the red banner; on the right what it rests on:
+ // the instruction it ran with, the AI's notes (each once) and what was not used.
+ assert.strictEqual(nodes.aiReviewSummary.innerHTML, `2 个${unit}有改动,新建 1 个标签`);
+ assert.strictEqual(nodes.aiReviewHint.textContent, `应用后列表只显示「✦ AI 刚打的」这些${unit},在卡片上逐个看,不对的按 T 改,按 U 整批撤销。`);
+ assert.deepStrictEqual([nodes.aiErrors.textContent, nodes.aiErrors.hidden], ["第 2 批失败:超时", false]);
+ assert.strictEqual(nodes.aiNotes.innerHTML, '指令按内容分AI 说明看不出的没打没有采用AI 想用的「数学」是你点掉的标签,没有采用。');
+ assert.ok(nodes.aiNewTags.innerHTML.includes(`用在 1 个${unit}`));
assert.ok(nodes.aiRows.innerHTML.includes("+ 新 1") && nodes.aiRows.innerHTML.includes("+ 科普 1"), nodes.aiRows.innerHTML);
// Nothing to apply: 应用 is off and says why. A48/A49: unticked or left proposals are not 「AI 没有提出改动」.
ai.p.newTags[0].checked = false;
@@ -236,6 +299,7 @@ function adapters(who) {
ai.p = { newTags: [], rows: [], notes: [], errors: [] };
D.ai.render(ai);
assert.ok(nodes.aiApplyBtn.disabled && nodes.aiApplyBtn.title === "AI 没有提出改动" && nodes.aiRows.innerHTML.includes("AI 没有提出改动"), `${who}: the AI proposed nothing`);
+ assert.deepStrictEqual([nodes.aiReviewSummary.innerHTML, nodes.aiErrors.hidden], ["AI 没有提出改动", true]);
ai.p = proposed;
ai.p.newTags[0].checked = true;
D.ai.render(ai);
@@ -254,16 +318,16 @@ function adapters(who) {
D.ai.open(ai);
nodes.aiInstruction.value = "A 的指令";
D.ai.progress(ai, "第 1 批失败", "A");
- assert.strictEqual(nodes.aiProgress.textContent, "第 1 批失败");
+ assert.strictEqual(nodes.aiFail.textContent, "第 1 批失败");
nodes.aiTagDialog.close();
D.ai.open(ai);
assert.strictEqual(nodes.aiInstruction.value, "A 的指令", "reopened in the same folder, the instruction stays");
folder = "B";
D.ai.open(ai);
- assert.deepStrictEqual([nodes.aiProgress.textContent, nodes.aiInstruction.value], ["", ""], "folder A's failure and instruction stay out of B");
+ assert.deepStrictEqual([nodes.aiFail.textContent, nodes.aiFail.hidden, nodes.aiInstruction.value], ["", true, ""], "folder A's failure and instruction stay out of B");
folder = "A";
D.ai.open(ai);
- assert.strictEqual(nodes.aiProgress.textContent, "第 1 批失败", "back in A, its line is there again");
+ assert.strictEqual(nodes.aiFail.textContent, "第 1 批失败", "back in A, its line is there again");
D.ai.open(adapters("UP 主").ai);
assert.strictEqual(nodes.aiInstruction.value, "", "another mode starts with an empty instruction");
nodes.aiTagDialog.close();
@@ -295,6 +359,7 @@ function adapters(who) {
assert.deepStrictEqual([nodes.tagManageTitle.textContent, nodes.newTagInput.placeholder, nodes.newTagInput.maxLength, nodes.addTagBtn.textContent, nodes.addTagBtn.attrs["aria-label"]], ["分组管理", "新分组名称", 16, "新建", "新建分组"]);
assert.strictEqual(nodes.tagManageHint.textContent, "B站 的分组。立即在 B站 生效。");
assert.strictEqual(nodes.tagsRows.innerHTML, '每周必看/4
', "its own rows");
+ assert.deepStrictEqual([nodes.tagManageDialog.classList.on.has("tm"), nodes.tmDetail.innerHTML, nodes.tmMeta.textContent], [false, "", ""], "one list, no pane");
fire("tagsRows", "change", { target: { value: "新名", dataset: { field: "name" }, closest: () => ({ dataset: { id: "101" } }) } });
await wait();
assert.deepStrictEqual(calls.at(-1), ["edit", 101, "name", "新名"], "a number id is found from the row's data-id");
@@ -305,7 +370,7 @@ function adapters(who) {
D.manage.open(adapters("视频").manage);
// K24: making a tag is 新建标签 here too, as in the picker and on B站 pages.
assert.deepStrictEqual([nodes.tagManageTitle.textContent, nodes.newTagInput.maxLength, nodes.addTagBtn.textContent, nodes.addTagBtn.attrs["aria-label"]], ["标签管理", 12, "新建", "新建标签"]);
- assert.ok(nodes.tagsRows.innerHTML.includes("data-tag-color"));
+ assert.ok(nodes.tagManageDialog.classList.on.has("tm") && nodes.tmDetail.innerHTML.includes("data-color"));
}
// C488 / C490 / C495 / C496 / C500.
@@ -314,7 +379,7 @@ function adapters(who) {
// Nothing editable here: the hint does not promise 立即保存.
manage.reason = () => "所有收藏夹里不能改标签";
D.manage.open(manage);
- assert.strictEqual(nodes.tagManageHint.textContent, "这里的标签。");
+ assert.deepStrictEqual([nodes.tagManageHint.textContent, nodes.tmMeta.textContent, nodes.tmDetail.innerHTML], ["这里的标签。", "", '所有收藏夹里不能改标签
']);
manage.reason = null;
// 新建 twice before the first answer creates the tag once.
let answer;
@@ -346,13 +411,13 @@ function adapters(who) {
tags.push({ id: "a", name: "科普", color: "#111" });
ai.p = { newTags: [{ key: "n", name: "科普", checked: true }, { key: "m", name: "新", checked: true }], rows: [{ id: "x", add: ["new:n", "new:m"], remove: [] }], notes: [], errors: [] };
D.ai.render(ai);
- assert.ok(nodes.aiReviewSummary.textContent.includes("新标签 1 个"), nodes.aiReviewSummary.textContent);
+ assert.ok(nodes.aiReviewSummary.innerHTML.includes("新建
1 个标签"), nodes.aiReviewSummary.innerHTML);
// C491: 所有收藏夹 lists one tag per name (A's 科普); B's new 科普 is B's own 科普, found among allTags().
ai.allTags = () => [...tags, { id: "b", name: "科普", color: "#222", folder: "B" }];
tags[0].folder = "A";
ai.p = { newTags: [{ key: "B/科普", name: "科普", checked: true, folder: "B" }], rows: [{ id: "x", add: ["new:B/科普"], remove: [] }], notes: [], errors: [] };
D.ai.render(ai);
- assert.ok(nodes.aiReviewSummary.textContent.includes("新标签 0 个"), nodes.aiReviewSummary.textContent);
+ assert.ok(nodes.aiReviewSummary.innerHTML.includes("新建
0 个标签"), nodes.aiReviewSummary.innerHTML);
// H3: under a hard limit (摘读记录's), the ticked new tags 应用 cannot create are named up front, not said to be kept, and
// count as unticked, as 应用 skips them.
delete ai.allTags;
@@ -362,7 +427,7 @@ function adapters(who) {
ai.notMade = (p) => ({ keys: new Set(p.newTags.filter((t) => t.checked).slice(1).map((t) => t.key)), why: "最多 50 个" });
D.ai.render(ai);
assert.ok(nodes.aiNotes.innerHTML.includes("「乙」不会新建:最多 50 个") && !nodes.aiNotes.innerHTML.includes("超过上限"), nodes.aiNotes.innerHTML);
- assert.ok(nodes.aiReviewSummary.textContent.includes("1 个") && nodes.aiReviewSummary.textContent.includes("新标签 1 个") && nodes.aiApplyBtn.textContent.startsWith("应用到 1 个"), nodes.aiReviewSummary.textContent);
+ assert.ok(nodes.aiReviewSummary.innerHTML === "
1 个视频有改动,新建
1 个标签" && nodes.aiApplyBtn.textContent.startsWith("应用到 1 个"), nodes.aiReviewSummary.innerHTML);
delete ai.notMade;
ai.p = null;
nodes.aiTagDialog.close();
diff --git a/extension/triage/tag-picker.js b/extension/triage/tag-picker.js
index 90905d44..01177df5 100644
--- a/extension/triage/tag-picker.js
+++ b/extension/triage/tag-picker.js
@@ -36,6 +36,8 @@
const list = dlg.querySelector(".picker-list");
const title = dlg.querySelector(".tp-title");
const note = dlg.querySelector(".tp-note");
+ // The modal has no button: its last line says how it closes (true of the popover too, which is known by its place and hides it).
+ dlg.querySelector(".tp-foot").textContent = "按 Esc 或点外面关闭并保存";
// The open picker: opts, sets (the ticks), before (ids at opening), rows, index (the active row).
let cur = null;
@@ -89,8 +91,9 @@
const n = countOf(sets, r.tag.id);
const all = n === sets.size;
const some = sets.size > 1 && n ? `
${n} 个有` : "";
- const key = !input.value && keyOf(i) ? `
${keyOf(i)}` : "";
- return `
${all ? "✓" : n ? "–" : ""}${esc(r.tag.name)}${some}${key}`;
+ // A key cap before the name, so it is not read as part of 「N 个有」; the popover draws it as a faint digit at the right (tags.css).
+ const key = !input.value && keyOf(i) ? `
${keyOf(i)}` : "";
+ return `
${key}${all ? "✓" : n ? "–" : ""}${esc(r.tag.name)}${some}`;
})
.join("") || (opts.empty ? `
${esc(opts.empty)}` : "");
list.querySelector(".active")?.scrollIntoView?.({ block: "nearest" });
@@ -112,14 +115,17 @@
render();
}
- // Under the anchor, or above it when there is no room below; always inside the window (an anchor scrolled out of it).
+ // Under the anchor, or above it when there is no room below; always inside the window (an anchor scrolled out of it),
+ // and not past the right edge of the anchor's card.
function place() {
- const r = (document.querySelector(cur.opts.anchor) || document.body).getBoundingClientRect();
+ const anchor = document.querySelector(cur.opts.anchor);
+ const r = (anchor || document.body).getBoundingClientRect();
const w = dlg.offsetWidth;
const h = dlg.offsetHeight;
let y = r.bottom + 6;
if (y + h > innerHeight - 8) y = Math.max(8, r.top - h - 6);
- dlg.style.left = `${Math.min(Math.max(8, r.left), innerWidth - w - 8)}px`;
+ const right = Math.min(innerWidth - 8, anchor?.closest?.("article")?.getBoundingClientRect().right ?? Infinity);
+ dlg.style.left = `${Math.max(8, Math.min(r.left, right - w))}px`;
dlg.style.top = `${Math.max(8, Math.min(y, innerHeight - h - 8))}px`;
}
diff --git a/extension/triage/tag-picker.selftest.js b/extension/triage/tag-picker.selftest.js
index 6cb25458..eff72190 100644
--- a/extension/triage/tag-picker.selftest.js
+++ b/extension/triage/tag-picker.selftest.js
@@ -16,7 +16,7 @@ const fire = (n, type, e = {}) => {
};
const input = node({ value: "", focused: 0, focus() { this.focused++; }, setAttribute(k, v) { this[k] = v; } });
const list = node({ innerHTML: "", querySelector: () => null });
-const parts = { ".tp-input": input, ".picker-list": list, ".tp-title": node({ textContent: "" }), ".tp-note": node({ textContent: "" }) };
+const parts = { ".tp-input": input, ".picker-list": list, ".tp-title": node({ textContent: "" }), ".tp-note": node({ textContent: "" }), ".tp-foot": node({ textContent: "" }) };
const calls = [];
const dlg = node({
open: false,
@@ -107,7 +107,8 @@ const key = (k, o = {}) => fire(dlg, "keydown", { key: k, target: input, ...o })
P.open(opts());
assert.deepStrictEqual(calls.splice(0), ["showModal"]);
assert.ok(input.focused && P.isOpen());
- assert.ok(list.innerHTML.includes('aria-checked="true">
✓') && list.innerHTML.includes('
3'));
+ assert.strictEqual(parts[".tp-foot"].textContent, "按 Esc 或点外面关闭并保存", "the modal's one line: Esc and a click outside close and save (below)");
+ assert.ok(list.innerHTML.includes('aria-checked="true">
1✓') && list.innerHTML.includes('
3'), list.innerHTML);
// → then Enter ticks the second tag; 1 ticks the first (游戏 off); Enter that picks an IME candidate ticks nothing.
assert.strictEqual(key("ArrowRight").prevented, 1);
@@ -133,7 +134,7 @@ const key = (k, o = {}) => fire(dlg, "keydown", { key: k, target: input, ...o })
input.value = " ";
fire(input, "input");
await wait();
- assert.ok(!list.innerHTML.includes('class="n"'), list.innerHTML);
+ assert.ok(!list.innerHTML.includes(" fire(dlg, "keydown", { key: k, target: input, ...o })
// Several targets: – for some, a click puts it on all, a second click takes it off all.
P.open(opts({ targets: ["a", "b"] }));
- assert.ok(list.innerHTML.includes('aria-checked="mixed">–') && list.innerHTML.includes("1 个有"));
+ assert.ok(list.innerHTML.includes('aria-checked="mixed">1–') && list.innerHTML.includes("1 个有"));
fire(list, "click", { target: { closest: () => ({ dataset: { i: "0" } }) } });
- assert.ok(list.innerHTML.includes('style="--c:#1" title="游戏" aria-checked="true">✓游戏'));
+ assert.ok(list.innerHTML.includes('style="--c:#1" title="游戏" aria-checked="true">1✓游戏'));
P.close();
assert.deepStrictEqual(saved.splice(0), [[{ key: "b", add: ["g"], remove: [] }]]);
@@ -192,6 +193,14 @@ const key = (k, o = {}) => fire(dlg, "keydown", { key: k, target: input, ...o })
P.open(opts({ anchor: "#x" }));
fire(win, "blur");
assert.ok(!P.isOpen());
+ // An anchor near its card's right edge: the popover ends at that edge, not past it.
+ const anchorOf = doc.querySelector;
+ doc.querySelector = () => ({ getBoundingClientRect: () => ({ left: 900, right: 940, top: 300, bottom: 320 }), closest: (s) => s === "article" && { getBoundingClientRect: () => ({ right: 1000 }) } });
+ P.open(opts({ anchor: "#x" }));
+ assert.strictEqual(dlg.style.left, "752px");
+ P.close();
+ doc.querySelector = anchorOf;
+ saved.length = 0;
// A modal ignores both, and sits centered (no popover position left over).
P.open(opts());
assert.ok(!dlg.classList.on.has("tp-pop") && dlg.style.top === "" && dlg.style.left === "");
diff --git a/extension/triage/tag-store.js b/extension/triage/tag-store.js
index 7a8aee15..eaaa71eb 100644
--- a/extension/triage/tag-store.js
+++ b/extension/triage/tag-store.js
@@ -365,7 +365,9 @@
// answer in, send(msg) sends one. An AI 429 or timeout sends the same batch again, up to AI_THROTTLE_WAITS /
// AI_TIMEOUT_TRIES in a row; an error that fails every batch alike (aiEnds) ends the run. name(i), when given, says
// which batch in the progress line and errors (所有收藏夹 names the folder); where() follows the pill's line.
- // progress(text) is the dialog's line, counting down with the pill. onError(error, code) shows an error with its
+ // progress(text, fail) is the dialog's line, counting down with the pill; a run that ends with no proposal leaves why
+ // in it, which the dialog then draws as its red banner (tag-dialogs.js), with fail = { error, code } when an error
+ // stopped the run, for the adapter to give the banner the button its page gives that code. onError(error, code) shows an error with its
// remedy (收藏夹's banner): the stop's, and a cut answer's when limitHint. A proposal naming a tag deleted meanwhile
// is dropped. Resolves { proposal (null when no batch got through), errors, error, code }.
async function runAi({ R, job, total, request, merge, send, intervalMs, progress, name = null, where = () => "", onError = () => {}, limitHint = false }) {
@@ -396,7 +398,7 @@
if (r.stopped) p.errors.push(answered ? "已手动停止,这里只有已完成批次的建议" : "已手动停止,还没有批次完成");
// A new tag no item uses starts unticked.
for (const t of p.newTags) t.checked = p.rows.some((row) => row.add.includes(UI.aiRef.new(t.key)));
- progress(answered ? "" : p.errors.join(";"));
+ progress(answered ? "" : p.errors.join(";"), !answered && r.error ? { error: r.error, code: r.code } : null);
let proposal = answered ? p : null;
// A tag deleted during the run is still named by the batches before it: dropped like a saved proposal.
if (proposal && !fits(proposal)) {
diff --git a/extension/triage/tag-store.selftest.js b/extension/triage/tag-store.selftest.js
index 6b76ec53..cd025077 100644
--- a/extension/triage/tag-store.selftest.js
+++ b/extension/triage/tag-store.selftest.js
@@ -306,6 +306,13 @@ const proposal = (newTags, rows) => ({ newTags: newTags.map((name) => ({ key: na
let n = 0;
r = await run({ send: async () => (++n === 1 && R.stop("ai"), { ok: true, data: { assignments: { a: { add: ["甲"] } } } }) });
assert.deepStrictEqual([r.proposal.rows.length, r.errors.at(-1)], [1, "已手动停止,这里只有已完成批次的建议"]);
+ // An error that stops the run reaches progress with its code, for the dialog banner's button; one batch failing
+ // on its own, or a stop by hand, brings none.
+ const ends = [];
+ r = await run({ total: 1, progress: (...a) => ends.push(a), send: async () => ({ ok: false, error: "API Key 不对", code: "AI_AUTH" }) });
+ assert.deepStrictEqual(JSON.parse(JSON.stringify(ends.at(-1))), ["第 1 批失败:API Key 不对", { error: "API Key 不对", code: "AI_AUTH" }]);
+ r = await run({ total: 1, progress: (...a) => ends.push(a), send: async () => ({ ok: false, error: "格式不对" }) });
+ assert.deepStrictEqual(JSON.parse(JSON.stringify(ends.at(-1))), ["第 1 批失败:格式不对", null]);
const progress = [];
const merge = (q, data) => (UI.mergeAiBatch(q, data, { tags: p.tags, map: p.map, maxNewTags: 5, scope: new Set(["a"]) }), (p.tags = []));
r = await run({ total: 1, merge, progress: (x) => progress.push(x), send: async () => ({ ok: true, data: { assignments: { a: { add: ["甲"] } } } }) });
diff --git a/extension/triage/tags.css b/extension/triage/tags.css
index 343efe83..4ab92b0b 100644
--- a/extension/triage/tags.css
+++ b/extension/triage/tags.css
@@ -49,6 +49,16 @@ dialog:where(:not(.mdg-overwrite)) textarea { resize: vertical; }
.dialog-hint.warn { color: var(--warn); }
/* Status lines fill in later; empty ones must not add the form's gap. */
dialog:where(:not(.mdg-overwrite)) :is(p, div):empty { display: none; }
+/* A dialog taller than the window: the form's .dlg-body scrolls; what is before it (the title) and after it
+ (.dialog-actions) stay put. A dialog without a .dlg-body scrolls whole, as above. */
+dialog[open]:where(:not(.mdg-overwrite)):has(> form > .dlg-body) { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
+dialog:has(> form > .dlg-body) > form { flex: 1; min-height: 0; gap: 0; }
+dialog:has(> form > .dlg-body) > form > * { flex: none; margin: 0; padding: 10px 16px; }
+dialog:has(> form > .dlg-body) > form > .dlg-body { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 0 16px 12px; }
+dialog:has(> form > .dlg-body) > form > :first-child { padding-top: 16px; }
+/* A scrolling middle takes the focus when the dialog opens (the arrow keys scroll it): no ring around the whole content. */
+dialog > form > .dlg-body:focus-visible { outline: none; }
+dialog:has(> form > .dlg-body) > form > .dlg-body ~ .dialog-actions { border-top: 1px solid var(--border); }
/* The tag picker (tag-picker.js): the filter on top, three equal columns of tags under it. A popover under 「+ 标签」 is
known by its place, so it has no title (kept for screen readers). */
@@ -70,50 +80,108 @@ dialog:where(:not(.mdg-overwrite)) :is(p, div):empty { display: none; }
.picker-opt .slot { flex: none; display: flex; align-items: center; justify-content: center; width: 12px; font-weight: 700; }
.picker-opt .dot { --c: inherit; display: flex; align-items: center; justify-content: center; width: 12px; height: 12px; color: #fff; font-size: 9px; line-height: 1; }
.picker-opt .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
-.picker-opt .muted, .picker-opt .n { flex: none; }
-.picker-opt .n { color: var(--faint); font-variant-numeric: tabular-nums; }
+.picker-opt .muted { flex: none; }
+/* The digit that ticks the tag: a key cap before the name in the modal, a faint number at the right in the popover. */
+.picker-opt kbd { flex: none; min-width: 1.5em; padding: 0 3px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); color: var(--text-2); font: 600 11px/1.4 ui-monospace, Menlo, monospace; text-align: center; }
+.tp-pop .picker-opt kbd { order: 1; min-width: 0; padding: 0; border: 0; background: none; color: var(--faint); font: inherit; font-variant-numeric: tabular-nums; }
+/* The modal has no button: one line says how it closes and saves. The popover is known by its place. */
+.tp-foot { margin: 0; padding: 6px 12px 8px; border-top: 1px solid var(--border); }
+.tp-pop .tp-foot { display: none; }
+/* In the popover the filter is a boxed field, as the dialogs' inputs. */
+#tagPicker.tp-pop .tp-input { width: calc(100% - 16px); height: 28px; margin: 8px 8px 0; padding: 0 8px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--field-bg); }
+#tagPicker.tp-pop .tp-input:focus-visible { border-color: var(--text-2); }
.picker-opt.tp-new { grid-column: 1 / -1; border-style: dashed; border-color: var(--border-strong); font-weight: 500; }
/* 「+ 标签 T」 (shared.js tagPlusBtn) on cards and the viewer line: quiet, a dashed outline on hover; T is a faint letter
after the word, as the card keys. button. to win over tokens.css button.quiet. */
button.tag-plus { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 6px; border: 1px dashed transparent; border-radius: 4px; color: var(--text-2); font-size: var(--fs-xs); text-decoration: none; }
button.tag-plus:hover { border-color: var(--border-strong); color: var(--text); background: none; }
-/* 标签管理 and AI 打标签 (tag-dialogs.js) */
+/* 标签管理 and AI 打标签 (tag-dialogs.js). Both have a .dlg-body: the title and the buttons stay, the middle scrolls. */
dialog.wide { width: min(620px, calc(100% - 32px)); }
.tag-rows { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; }
.tag-row { display: grid; grid-template-columns: 22px minmax(0, 9em) minmax(0, 1fr) 5.5em auto; align-items: center; gap: 6px; }
.tag-color { width: 18px; height: 18px; padding: 0; border: 2px solid var(--surface); border-radius: 50%; background: var(--c); box-shadow: 0 0 0 1px var(--border-strong); }
.tag-color:hover { background: var(--c); box-shadow: 0 0 0 2px var(--c); }
-@media (max-width: 760px) {
- .tag-row { grid-template-columns: 22px minmax(0, 1fr) auto auto; }
- .tag-row [data-field="rule"] { grid-column: 1 / -1; grid-row: 2; }
-}
.tag-row .muted { text-align: right; font-size: var(--fs-xs); }
.tag-add { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tag-add input { flex: 1; min-width: 120px; }
-.ai-section { display: flex; flex-direction: column; gap: 6px; }
-.ai-section > h3:first-child { margin-top: 0; }
+/* 分组管理 is one list: the rows, then 新建. 标签管理 (.tm) is two panes: the tags and 新建 on the left, the picked tag's
+ name, color, 说明 and 删除 on the right; the panes run edge to edge between the hint and the buttons, the list scrolls. */
+.tm-cols, .tm-list { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
+.tm-why { margin: 0; font-size: var(--fs-xs); color: var(--warn); }
+#tagManageDialog.tm { width: min(720px, calc(100% - 32px)); }
+.tm .tm-cols { flex: none; display: grid; grid-template-columns: 232px minmax(0, 1fr); gap: 0; height: min(340px, calc(100vh - 220px)); margin: 6px -16px -12px; border-top: 1px solid var(--border); }
+.tm .tm-list { gap: 8px; min-height: 0; padding: 12px; border-right: 1px solid var(--border); }
+.tm .tag-rows { flex: 1 1 0; gap: 2px; max-height: none; }
+.tm-item { flex: none; display: flex; align-items: center; gap: 8px; width: 100%; height: 32px; padding: 0 8px; border: 0; border-radius: var(--radius-sm); background: none; text-align: left; }
+.tm-item:hover { background: var(--field-bg); }
+.tm-item[aria-current="true"] { background: var(--field-bg); box-shadow: inset 2px 0 0 var(--accent); font-weight: 600; }
+.tm-item .dot { flex: none; }
+.tm-item .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+.tm-item .n { color: var(--faint); font-size: var(--fs-xs); font-weight: 400; font-variant-numeric: tabular-nums; }
+.tm .tag-add { flex-wrap: nowrap; padding-top: 10px; border-top: 1px solid var(--border); }
+.tm .tag-add input { min-width: 0; }
+.tm-detail { display: flex; flex-direction: column; min-width: 0; padding: 14px 16px 12px 20px; overflow-y: auto; }
+.tm-top { display: flex; flex-wrap: wrap; gap: 8px 24px; margin-bottom: 16px; }
+.tm-top label, .tm-top .lbl { display: block; margin-bottom: 4px; font-size: var(--fs-xs); color: var(--text-2); }
+.tm-top input { width: 13em; }
+/* The row offers the colors no other tag here has; one another tag took goes to the end, dimmed (MdgTagCore.swatchColors). */
+.tm-swatches { display: flex; align-items: center; gap: 8px; height: 28px; }
+.tm-swatches .tag-color.used { opacity: 0.4; }
+.tm-swatches .tag-color[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--text); opacity: 1; }
+.tm-detail textarea { display: block; width: 100%; min-height: 96px; margin-top: 6px; line-height: 1.6; }
+.tm-under { display: flex; justify-content: space-between; gap: 12px; margin-top: 6px; font-size: var(--fs-xs); color: var(--text-2); }
+#tmCnt { flex: none; color: var(--faint); font-variant-numeric: tabular-nums; }
+.tm-foot { display: flex; align-items: center; margin-top: auto; padding-top: 14px; }
+/* 删除标签 is grey until pointed at. */
+button.tm-del:hover { background: var(--danger-bg); color: var(--danger); }
+.tm-empty { margin: auto; color: var(--faint); }
+@media (max-width: 640px) {
+ .tm .tm-cols { grid-template-columns: minmax(0, 1fr); height: auto; }
+ .tm .tm-list { border-right: 0; border-bottom: 1px solid var(--border); }
+ .tm .tag-rows { flex: none; max-height: 132px; }
+}
/* Label column on the left; anything that is not a label or a field (counts, switches, chips) sits under its field. */
.ai-grid { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px 12px; align-items: baseline; }
/* A count or quota line hangs under the field it describes. */
-.ai-grid > .dialog-meta, #aiTagsPreview > .dialog-meta { margin-top: -6px; }
-.ai-grid > label:not(.toggle), .ai-grid .grid-label { grid-column: 1; font-size: var(--fs-sm); color: var(--text-2); }
-.ai-grid > :not(label, select, textarea, input), .ai-grid > .toggle, #aiTagsPreview > :not(.grid-label) { grid-column: 2; }
-/* Its label, chips and hint join the grid as if they were the grid's own children. */
-#aiTagsPreview { display: contents; }
-#aiTagsPreview .chips { margin: 0; }
-.chip.tag-use[aria-pressed="false"] { border: 1px dashed var(--border-strong); color: var(--faint); }
+.ai-grid > .dialog-meta { margin-top: -6px; }
+.ai-grid > label:not(.toggle) { grid-column: 1; font-size: var(--fs-sm); color: var(--text-2); }
+.ai-grid > :not(label, select, textarea, input), .ai-grid > .toggle { grid-column: 2; }
.ai-grid select { width: 100%; max-width: none; }
-.ai-history { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
+/* AI 打标签, the setup: the 判断标准 dialog's two columns (.crit-cols, triage.css). Left: the instruction, what the AI
+ reads under it, the last instructions. Right: one block per option, each with its one line under it. */
+#aiTagDialog { width: min(780px, calc(100% - 32px)); }
+#aiForm textarea { min-height: 124px; line-height: 1.6; }
+.ai-past { margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--border); }
+.ai-past button { display: block; width: calc(100% + 16px); height: 28px; margin: 0 -8px; padding: 0 8px; border: 0; background: none; color: var(--text-2); text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+.ai-past button:hover { background: var(--field-bg); color: var(--text); }
+.ai-opt { display: flex; flex-direction: column; gap: 6px; }
+.ai-opt + .ai-opt { margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--border); }
+.ai-opt select { width: 100%; max-width: none; }
+.ai-opt .chips { margin: 0; }
+.chip.tag-use[aria-pressed="false"] { border: 1px dashed var(--border-strong); color: var(--faint); }
+/* A run that gave no proposal, and the review's failed batches: a red banner at the left of the buttons. */
+.ai-fail { flex: 1 1 200px; display: flex; align-items: center; gap: 6px; min-width: 0; margin: 0; padding: 5px 10px; border: 1px solid var(--danger-border); border-radius: var(--radius-sm); background: var(--danger-bg); color: var(--danger); font-size: var(--fs-xs); line-height: 1.4; }
+.ai-fail::before { content: "⚠"; flex: none; }
+.ai-fail button { flex: none; margin-left: auto; }
+.ai-fail:not([hidden]) + .spacer { display: none; }
+/* The review: the verdict in large type under the title; left what to decide, right what it rests on. */
+#aiReviewHead { padding-top: 0; }
+.ai-verdict { margin: 0; font-size: var(--fs-xl); font-weight: 600; line-height: 1.35; }
+.ai-verdict b { font-variant-numeric: tabular-nums; }
+#aiReviewHint { margin-top: 4px; }
+#aiNewTags { flex: none; max-height: none; margin-bottom: 10px; }
+.ai-newtag { display: flex; gap: 6px; align-items: center; }
+.ai-newtag input[type="text"] { flex: 0 1 200px; min-width: 100px; }
+.ai-newtag:has(input[type="checkbox"]:not(:checked)) input[type="text"] { color: var(--faint); text-decoration: line-through; }
.chip.add { --c: var(--ok); color: var(--ok); }
.chip.remove { --c: var(--danger); color: var(--danger); text-decoration: line-through; }
-#aiReviewSummary { font-weight: 400; }
-#aiNotes p { margin: 0; }
.ai-tally .chips { margin: 0; }
.ai-tally b { font-weight: 600; margin-left: 2px; }
-.ai-recent-rules { margin: 2px 0 0; padding-left: 18px; }
-.ai-newtag { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
-.ai-newtag input[type="text"] { flex: 0 1 240px; min-width: 120px; }
+.ai-basis { padding: 10px 12px; border-radius: var(--radius-md); background: var(--surface-muted); }
+#aiNotes { display: grid; gap: 10px; margin: 0; }
+#aiNotes dt { font-size: var(--fs-xs); color: var(--faint); }
+#aiNotes dd { margin: 0; overflow-wrap: anywhere; }
/* Settings rows (收藏夹设置, 关注设置, 摘读记录设置) follow the settings page: name and hint on the left, the control on the right. */
.settings-ai { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
@@ -126,3 +194,6 @@ dialog.wide { width: min(620px, calc(100% - 32px)); }
.set-row .name { font-size: var(--fs-sm); color: var(--text); }
.set-row .hint { margin: 2px 0 0; font-size: var(--fs-xs); color: var(--faint); line-height: 1.5; }
.set-row input[type="number"] { flex: none; width: 72px; text-align: right; }
+/* 关注设置 and 摘读记录设置: one 560px column, a group under a group. */
+dialog.set-single { width: min(560px, calc(100% - 32px)); }
+.set-stack { display: flex; flex-direction: column; gap: 16px; }
diff --git a/extension/triage/triage.css b/extension/triage/triage.css
index a837194b..de1b9ad0 100644
--- a/extension/triage/triage.css
+++ b/extension/triage/triage.css
@@ -57,9 +57,9 @@ select { height: 28px; max-width: 240px; }
color: var(--faint);
}
.search-icon { width: 14px; height: 14px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
-.search input { flex: 1; min-width: 0; height: 100%; padding: 0; border: 0; background: none; color: var(--text); }
+.search input { flex: 1; min-width: 0; height: 100%; padding: 0; border: 0; background: none; color: var(--text); text-overflow: ellipsis; }
.search input:focus-visible { outline: none; box-shadow: none; }
-.search:focus-within { box-shadow: 0 0 0 2px var(--focus-ring); }
+.search:focus-within { box-shadow: 0 0 0 3px color-mix(in srgb, var(--text-2) 18%, transparent); }
.search .muted { white-space: nowrap; }
.search-key { font: 12px var(--font-mono); padding: 0 5px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); color: var(--faint); }
.search:focus-within .search-key, .search:has(input:not(:placeholder-shown)) .search-key { display: none; }
@@ -257,7 +257,22 @@ select { height: 28px; max-width: 240px; }
/* Row 2: the tabs; search and the mode's buttons sit on the right of the same line. */
.tabrow { display: flex; flex-wrap: wrap; align-items: center; column-gap: 24px; }
.row-tools { display: flex; align-items: center; gap: 2px; margin: 0 -8px 0 auto; padding: 6px 0; }
-/* While it reads, 刷新 gives its place to the progress pill: one thing on screen, not two. */
+/* The progress pill sits left of the search, so the search, 刷新 and 导出 stay where they are when it comes and goes. */
+.row-tools .activity { order: -1; margin-right: 8px; }
+/* Row 2 stays one line when the pill needs room: the search gets narrower instead of the whole group dropping a line. */
+@media (min-width: 1100px) {
+ .tabrow { flex-wrap: nowrap; }
+ .tabrow .tabs { flex: none; }
+ .row-tools { min-width: 0; }
+ /* The search gives way first, down to 160px; only then is the pill's line cut (the huge factor keeps the pill's share
+ of the squeeze under a pixel). */
+ .row-tools .search { flex: 0 100000 280px; min-width: 160px; }
+}
+/* 暂停粗看 / 暂停细看 is row 3's button; the pill carries it only while row 3 does not show it (another tab or folder, a
+ folded header). */
+.main:not(.head-folded) .activity .in-row3 { display: none; }
+.main:not(.head-folded) .activity:has(.in-row3) { padding-right: 12px; }
+/* While it reads, 刷新 is hidden: the pill says it, one thing on screen, not two. */
.row-tools:has(.activity:not([hidden])) .act-btn[aria-busy="true"] { display: none; }
.tabs { display: flex; flex: 0 1 auto; min-width: 0; min-height: 40px; align-items: center; gap: 2px; }
.tabs button { display: flex; align-items: center; gap: 4px; height: 26px; padding: 0 12px; border: 0; border-radius: var(--radius-pill); background: none; color: var(--text-2); font-variant-numeric: tabular-nums; }
@@ -379,6 +394,8 @@ select { height: 28px; max-width: 240px; }
.sel-actions .danger::before { content: ""; position: absolute; left: -12px; top: 8px; height: 16px; border-left: 1px solid var(--border-strong); }
.list { min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; margin: 0 -8px; padding: calc(var(--head-h, 0px) + 8px) 8px 80px; }
+/* With the selection bar up (72px from the bottom), the last card stops 32px above it, scrolled to by J / K too. */
+.listpane:has(.selbar) .list { padding-bottom: 104px; scroll-padding-bottom: 104px; }
/* Two card states. Current (hover or J/K) is the dark ring; selected (a click on the card or X) is the blue outline and tint. Both can show at once. */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); transition: border-color 0.12s, box-shadow 0.12s; }
/* Current: a dark ring, so it reads at a glance; selected (below) swaps the ring for blue. */
@@ -520,7 +537,12 @@ button.icon { width: 26px; height: 24px; padding: 0; }
.k-faint { padding: 0; border: 0; background: none; color: var(--faint); font: inherit; font-size: var(--fs-xs); }
/* 关注's 分组管理 in the same dialog: name, count, 删除. */
-.tag-row.group-row { grid-template-columns: minmax(0, 1fr) 6em auto; }
+.tag-row.group-row { grid-template-columns: minmax(0, 1fr) 6em 4.5em; }
+/* B站's two fixed groups head the list on the same grid: grey, read-only, 「B站 固定」 where 删除 would be. */
+.group-row.fixed { border-radius: var(--radius-sm); background: var(--surface-muted); color: var(--text-2); }
+.group-row.fixed .fixed-name { padding: 4px 8px; border: 1px solid transparent; }
+.group-row.fixed .fixed-name small { display: block; color: var(--muted); font-size: var(--fs-xs); }
+.group-row.fixed .fixed-why { font-size: var(--fs-xs); color: var(--faint); text-align: center; cursor: default; }
/* viewer: the video page next to the list */
/* Its tag lines: 「视频标签」 (收藏夹) and 「UP 标签」 (the UP and its tags; 收藏夹 for a followed UP, and 关注). */
@@ -606,6 +628,20 @@ button.icon { width: 26px; height: 24px; padding: 0; }
.form-error { margin: 4px 0 0; color: var(--danger); font-size: var(--fs-xs); }
.confirm-body ul { margin: 0; padding-left: 18px; }
+/* Every confirm spaces its paragraphs and its list of names the same: 8px apart, none above the first or under the last. */
+.confirm-body > :is(p, ul) { margin: 8px 0 0; }
+.confirm-body > :first-child { margin-top: 0; }
+/* A confirm's sentences (取消勾选收藏夹): no gap under the title, what is lost on its own line in the text color. */
+.confirm-body .lead { margin: 0; color: var(--text-2); }
+.confirm-body :is(p, ul) + .lead { margin-top: 6px; }
+.confirm-body .conseq { margin: 6px 0 0; color: var(--text); font-weight: 600; }
+/* 移动 / 复制: what is moved is one line, the first name and 「等 N 个」; it opens into the list, which scrolls in its box. */
+/* The folded name list is a details.fold (tokens.css): the first name, then 「等 N 个」. */
+.transfer-list .first { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+.transfer-list .n { flex: none; margin-left: 8px; color: var(--faint); font-size: var(--fs-xs); font-weight: 400; }
+.transfer-list .confirm-body { max-height: 150px; margin-top: 6px; padding: 8px 10px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-md); }
+.transfer-list .confirm-body p { margin: 4px 0 0; color: var(--muted); font-size: var(--fs-xs); }
+#transferDialog .dialog-actions .spacer { min-width: 24px; }
/* 判断标准: the criteria on the left, as tall as the column; the folder's AI platform and its two switches on the right. The
list stops at about five rows and scrolls inside, so the switches stay in view. */
dialog.crit-dialog { width: min(780px, calc(100% - 32px)); }
@@ -639,17 +675,26 @@ dialog .crit-switch .name { color: var(--text); font-size: var(--fs-sm); font-we
/* 所有收藏夹's runs: each folder's 判断标准 under its name. */
.crit-row { display: grid; gap: 4px; margin-top: 8px; }
.help-cols { display: grid; gap: 24px 32px; }
-.help-cols h2 { margin: 0 0 4px; }
+#helpDialog h2 { margin: 0 0 4px; }
+/* Two columns in the 分拣台; 摘读记录's help is the keys alone and keeps the dialog's own width. */
@media (min-width: 760px) {
- #helpDialog { width: min(920px, calc(100% - 32px)); }
+ #helpDialog:has(.help-cols) { width: min(920px, calc(100% - 32px)); }
.help-cols { grid-template-columns: 1.2fr 1fr; }
}
-/* The four-step notes are what the dialog is for, so they read as body text; the key column is key caps. */
#helpDialog .stack { gap: 8px; }
-#helpDialog .stack:first-child .dialog-hint { color: var(--text); }
-.keys { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; align-items: center; margin: 0; }
-.keys dt { display: flex; gap: 4px; }
-.keys dd { margin: 0; }
+/* No entry ends with a character or two alone on its last line. */
+#helpDialog :is(dd, small, p, li) { text-wrap: pretty; }
+/* A group's name over its keys or facts. */
+#helpDialog h3 { margin: 10px 0 0; font-size: var(--fs-xs); color: var(--muted); }
+#helpDialog h2 + h3 { margin-top: 0; }
+/* A key's caps and a fact's word sit on the first line of what they explain; the caps column is one width in every group. */
+.keys { display: grid; grid-template-columns: 84px 1fr; gap: 6px 12px; align-items: baseline; margin: 0; }
+.keys dt { display: flex; align-items: baseline; gap: 4px; }
+.keys dd, .facts dd { margin: 0; }
+.facts { display: grid; grid-template-columns: 7.5em 1fr; gap: 8px 12px; align-items: baseline; margin: 0; }
+.facts.wide-term { grid-template-columns: 10.5em 1fr; }
+.facts dt { font-weight: 600; }
+:is(.keys, .facts) small { display: block; font-size: var(--fs-xs); color: var(--faint); }
.keys kbd { min-width: 1.6em; padding: 0 4px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); font: 600 var(--fs-xs)/1.3 ui-monospace, Menlo, monospace; text-align: center; }
@media (max-width: 899px) {
@@ -660,7 +705,7 @@ dialog .crit-switch .name { color: var(--text); font-size: var(--fs-sm); font-we
.field-row input[type="text"] { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 6px; }
.steps { margin: 0 0 4px; padding-left: 20px; }
-.steps li { margin: 2px 0; }
+.steps li { margin: 4px 0; }
.recent-unfav { margin-top: 16px; padding-top: 8px; border-top: 1px solid var(--border); }
.recent-unfav h3 { margin: 0 0 6px; font-size: var(--fs-sm); }
@@ -669,8 +714,8 @@ dialog .crit-switch .name { color: var(--text); font-size: var(--fs-sm); font-we
.recent-batch { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; }
.recent-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
-/* 收藏夹设置 and 关注设置: folders (or 更新状态) on the left, the rest on the right (the first run asks only for folders).
- The rows' own rules are in tags.css, which 摘读记录设置 shares. */
+/* 收藏夹设置: folders and 标签 on the left, the rest on the right (the first run asks only for folders). 关注设置 is a
+ single column (dialog.set-single). The rows' own rules are in tags.css, which 摘读记录设置 shares. */
.settings-cols { display: grid; gap: 16px 24px; }
.set-head { display: flex; align-items: baseline; gap: 10px; }
.set-head h3 { margin-right: auto; }
@@ -683,6 +728,27 @@ dialog:has(.settings-ai:not([hidden])) { width: min(800px, calc(100% - 32px)); }
/* The folder list runs as tall as the right column and scrolls inside. */
.settings-cols:has(.settings-ai:not([hidden])) .folder-toggles { flex: 1 1 0; min-height: 200px; max-height: none; }
}
+/* 收藏夹设置: the folders and 标签 on the left, 请求和 AI 参数 and 高级 (the two 输出上限, closed) on the right, both columns
+ ending on one line. The first open (.settings-ai hidden) asks only for folders. */
+#settingsDialog:has(.settings-ai:not([hidden])) { width: min(840px, calc(100% - 32px)); }
+.st-left { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
+.st-left:has(+ .settings-ai[hidden]) .st-tags { display: none; }
+/* 高级 is a details.fold (tokens.css) in a card: the line keeps the card's padding, and a rule under it when open. */
+.st-adv > summary { margin-block: 6px; }
+.st-adv[open] > summary { margin-bottom: 6px; }
+.st-adv summary .hint { margin-left: 8px; font-size: var(--fs-xs); font-weight: 400; color: var(--faint); }
+@media (min-width: 640px) {
+ #settingsDialog .settings-cols:has(.settings-ai:not([hidden])) { grid-template-columns: 1fr 1fr; }
+ .st-folders { flex: 1 1 auto; }
+ /* The folder list takes what is left of the left column: it grows with the right one and scrolls inside. On its own
+ it shows three rows, or four and a half when there are more to scroll to. */
+ #settingsDialog .settings-cols:has(.settings-ai:not([hidden])) .folder-toggles { flex: 1 1 0; height: 0; min-height: 90px; max-height: none; }
+ #settingsDialog .settings-cols:has(.settings-ai:not([hidden])) .folder-toggles:has(> :nth-child(4)) { min-height: 129px; }
+ /* What the left column is taller by is shared among the right card's rows, so 高级 sits right under it. */
+ #settingsDialog .settings-ai > .set-group, #settingsDialog .settings-ai > .set-group .set-card { flex: 1; }
+ #settingsDialog .settings-ai > .set-group .set-card { display: flex; flex-direction: column; }
+ #settingsDialog .settings-ai > .set-group .set-row { flex: 1; }
+}
.pick-folders { max-width: 420px; margin: 40px auto; text-align: center; }
.pick-folders p { margin: 0 0 10px; }
diff --git a/extension/triage/triage.html b/extension/triage/triage.html
index 7beff5d5..ac6f22a0 100644
--- a/extension/triage/triage.html
+++ b/extension/triage/triage.html
@@ -98,8 +98,11 @@