-
setDeviceLabel(event.target.value)} placeholder="Main MacBook" />
-
void connect()}>
- {initializing ? "Checking…" : connected ? "Reconnect" : "Connect"}
-
+ return (
+
+
+
+
D·
+
+ Dockmark
+
+
+ {connectionLabel}
+
+
-
-
- {connected && (
-
- Private cloud pairing {paired ? "Authenticated" : "Required"}
- {paired ? (
- <>
- This extension holds a revocable per-device token. It can read launcher data, save Sessions and append reviewed captures to Inbox. It cannot edit or delete existing Dockmark bookmarks, settings or public-page selection.
- void unpairLocal()}>Remove local device token
- >
- ) : (
- <>
- Open Dockmark → Settings → Security , create a one-time pairing code, then enter it here. Pair codes expire after 10 minutes and work once.
-
- setPairCode(event.target.value.toUpperCase())} placeholder="ABCD-EFGH-JK" autoComplete="off" />
- void pairDevice()}>Pair device
-
- >
+
+ {connected && serverUrl && (
+ void browser.tabs.create({ url: apiUrl(serverUrl, "/app"), active: true })}
+ >↗
)}
-
- )}
+ setSettingsOpen((open) => !open)}
+ >⚙
+
+
-
- Native bookmarks {bookmarkAccess ? "Enabled" : "Optional"}
- Used to read your browser bookmark tree for reviewed import/mapping and, only when you explicitly choose Write Dockmark → Browser in the Web review UI, update that mapped bookmark's title and URL. Dockmark never writes browser bookmarks in the background.
- void (bookmarkAccess ? disableBookmarkAccess() : enableBookmarkAccess())}>
- {bookmarkAccess ? "Disable bookmark access" : "Enable bookmark access"}
-
-
-
- {connected && paired && (
-
- Quick Capture Current tab → Inbox
- {activeSavableTab ? (
-
- {activeSavableTab.title || activeSavableTab.url}
- {hostLabel(activeSavableTab.url)}
-
+ {settingsOpen ? (
+ { setServerUrl(value); setConnected(false); setPaired(false); setCaptureResult(null); }}
+ onDeviceLabelChange={setDeviceLabel}
+ onPairCodeChange={setPairCode}
+ onConnect={() => void connect()}
+ onPairDevice={() => void pairDevice()}
+ onUnpairLocal={() => void unpairLocal()}
+ onToggleBookmarkAccess={() => void toggleBookmarkAccess()}
+ onSelectAppearance={handleSelectAppearance}
+ onSelectLocale={handleSelectLocale}
+ onClose={() => setSettingsOpen(false)}
+ />
+ ) : (
+ <>
+ {!isDailyReady ? (
+ { setServerUrl(value); setConnected(false); setPaired(false); setCaptureResult(null); }}
+ onDeviceLabelChange={setDeviceLabel}
+ onPairCodeChange={setPairCode}
+ onConnect={() => void connect()}
+ onPairDevice={() => void pairDevice()}
+ />
) : (
- Open an HTTP/HTTPS page to capture it.
- )}
- void saveCurrentTab()}>Save current tab
- {captureResult && (
-
- {captureResult.result === "created" ? "Saved to Inbox" : "Duplicate review"}
- {captureResult.bookmark.title}
- {captureResult.bookmark.categoryName ?? (captureResult.duplicateState === "inbox" ? "Already waiting in Inbox" : "Already in Dockmark library")}
- void openCaptureReview()}>
- {captureResult.duplicateState === "library" ? "Open Dockmark" : "Open Inbox"}
+
+ setActiveTab("capture")}>
+ {tx(locale, "Capture", "收录与标签页")}
+
+ setActiveTab("multitab")}>
+ {tx(locale, "Multi-Tab", "批量收录")}
+
+ setActiveTab("sessions")}>
+ {tx(locale, "Sessions", "会话")}
+ {sessions.length > 0 && {sessions.length} }
-
+
)}
-
- )}
-
- {connected && paired && }
- {connected && paired && (
-
- )}
+ {isDailyReady && activeTab === "capture" && (
+
+
+ {tx(locale, "Quick Capture", "快速收录")}
+ {tx(locale, "Active tab → Inbox", "当前标签页 → 收件箱")}
+
+ {activeSavableTab ? (
+
+
{hostMonogram(activeSavableTab.url, activeSavableTab.title)}
+
+ {activeSavableTab.title || activeSavableTab.url}
+ {hostLabel(activeSavableTab.url)}
+
+
void saveCurrentTab()}>
+ {tx(locale, "Save to Inbox", "存至收件箱")}
+
+
+ ) : (
+ {tx(locale, "Open an HTTP/HTTPS page to capture it.", "打开一个 HTTP/HTTPS 网页即可快速收录。")}
+ )}
+
+ {captureResult && (
+
+
+ {captureResult.result === "created" ? tx(locale, "Saved to Inbox", "已存入收件箱") : tx(locale, "Duplicate review", "检测到重复书签")}
+ {captureResult.bookmark.title}
+
+ {captureResult.bookmark.categoryName ?? (captureResult.duplicateState === "inbox" ? tx(locale, "Already waiting in Inbox", "已在收件箱待整理") : tx(locale, "Already in Dockmark library", "已在 Dockmark 书签库"))}
+
+
+
void browser.tabs.create({ url: apiUrl(serverUrl, captureResult.duplicateState === "library" ? "/app" : "/app/inbox"), active: true })}>
+ {captureResult.duplicateState === "library" ? tx(locale, "Open Web", "打开网页端") : tx(locale, "Open Inbox", "打开收件箱")}
+
+
+ )}
+
+ )}
- {(status || error) && {error ?? status}
}
+ {isDailyReady && activeTab === "multitab" && }
+
+ {isDailyReady && activeTab === "sessions" && (
+ void saveWindow()}
+ onRestoreSession={(session) => void restoreSession(session)}
+ />
+ )}
- {connected && paired && (
-
- Recent sessions {sessions.length}
-
- {sessions.slice(0, 4).map((session) => (
-
void restoreSession(session)}>
- {session.name} {session.items.length} tabs{session.sourceDevice ? ` · ${session.sourceDevice}` : ""}
- Restore
-
- ))}
- {!sessions.length &&
No cloud sessions yet.
}
-
-
+ {(!isDailyReady || activeTab === "capture") && }
+ >
)}
-
- Open tabs {tabs.length}
-
- {tabs.slice(0, 6).map((tab) => (
- browser.runtime.sendMessage({ type: "dockmark:activate-tab", tabId: tab.id })}
- >
- {tab.title}
- {tab.active ? "Current" : "Switch"}
-
- ))}
-
-
+ {(status || error) && (
+ {error ?? status}
+ )}
);
}
diff --git a/apps/extension/entrypoints/popup/style.css b/apps/extension/entrypoints/popup/style.css
index d75b877..3b0e1cd 100644
--- a/apps/extension/entrypoints/popup/style.css
+++ b/apps/extension/entrypoints/popup/style.css
@@ -6,156 +6,190 @@
--dm-surface-raised: #121915;
--dm-surface-hover: #17201b;
--dm-surface-selected: #1d2a23;
- --dm-input-bg: #0d1410;
- --dm-border: #26302b;
- --dm-border-strong: #34403a;
+ --dm-input-bg: #0c120e;
+ --dm-border: #232d28;
+ --dm-border-strong: #324039;
--dm-text: #edf3ef;
- --dm-text-soft: #a9b4ad;
- --dm-text-muted: #8b968f;
- --dm-placeholder: #64726a;
+ --dm-text-soft: #b2bdb6;
+ --dm-text-muted: #84918a;
+ --dm-placeholder: #5f6d65;
--dm-accent: #91bc9f;
--dm-accent-strong: #b8e0c5;
- --dm-focus-ring: rgba(145, 188, 159, .16);
- --dm-success-border: #355442;
- --dm-success-bg: #101a14;
+ --dm-accent-soft: rgba(145, 188, 159, .14);
+ --dm-focus-ring: rgba(145, 188, 159, .18);
+ --dm-success-border: #335440;
+ --dm-success-bg: #101b15;
--dm-success-text: #a9d1b5;
--dm-warning-border: #5d5033;
--dm-warning-bg: #1a170f;
- --dm-warning-text: #d1b876;
+ --dm-warning-text: #d4bc7b;
--dm-danger-border: #5a3734;
--dm-danger-bg: #211413;
--dm-danger-text: #d7a09d;
color: var(--dm-text);
background: var(--dm-bg);
}
-* { box-sizing: border-box; scrollbar-color: #34483d var(--dm-bg); }
+
+* { box-sizing: border-box; scrollbar-width: thin; scrollbar-color: #32453b transparent; }
::selection { color: #f6fbf8; background: #315f47; }
-body { margin: 0; width: 370px; min-height: 420px; background: var(--dm-bg); }
-main { display: grid; gap: 12px; padding: 16px; }
-header { display: flex; justify-content: space-between; align-items: center; padding-bottom: 2px; }
-header > div { display: grid; grid-template-columns: 28px 1fr; column-gap: 8px; row-gap: 1px; align-items: center; }
-header > div::before {
- content: "D·";
- grid-row: 1 / span 2;
- display: grid;
- place-items: center;
- width: 28px;
- height: 28px;
- border: 1px solid var(--dm-border-strong);
- border-radius: 8px;
- background: var(--dm-surface-hover);
- color: var(--dm-accent-strong);
- font-size: 12px;
- font-weight: 780;
- letter-spacing: -.08em;
-}
-header strong { font-size: 15px; }
-header span, header small, p, small, .section-heading span { color: var(--dm-text-muted); }
-header small { font-size: 10px; }
-header > span { font-size: 11px; }
-.card { display: grid; gap: 9px; padding: 12px; border: 1px solid var(--dm-border); border-radius: 12px; background: var(--dm-surface-raised); }
-.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
-.section-heading strong { font-size: 12px; }
-.section-heading span { font-size: 10px; }
-.online { color: var(--dm-accent) !important; }
-.offline { color: #919c96 !important; }
-.permission-card p { margin: 0; font-size: 10px; line-height: 1.5; }
-input {
- width: 100%;
- height: 36px;
- padding: 0 10px;
- border: 1px solid var(--dm-border-strong);
- border-radius: 9px;
- outline: 0;
- color: var(--dm-text);
- background: var(--dm-input-bg);
- caret-color: var(--dm-accent);
- font: inherit;
- font-size: 11px;
-}
+body { margin: 0; width: 384px; min-height: 360px; max-height: 590px; overflow-y: auto; background: var(--dm-bg); color: var(--dm-text); }
+.popup-shell { display: grid; gap: 10px; padding: 12px 14px 14px; }
+button, input { font: inherit; }
+button:focus-visible, input:focus-visible { outline: 2px solid var(--dm-accent); outline-offset: 1px; }
+
+/* Header */
+.popup-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
+.popup-brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
+.brand-mark { display: grid; place-items: center; width: 26px; height: 26px; flex-shrink: 0; border: 1px solid var(--dm-border-strong); border-radius: 7px; background: var(--dm-surface-hover); color: var(--dm-accent-strong); font-size: 11px; font-weight: 760; letter-spacing: -.08em; }
+.brand-meta { display: flex; align-items: center; gap: 7px; min-width: 0; }
+.brand-meta strong { font-size: 14px; font-weight: 680; letter-spacing: -.02em; }
+.status-pill { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 7px; border: 1px solid var(--dm-border); border-radius: 999px; background: var(--dm-surface); color: var(--dm-text-muted); font-size: 10px; font-weight: 560; white-space: nowrap; }
+.status-dot { width: 5px; height: 5px; border-radius: 999px; background: var(--dm-text-muted); }
+.status-pill.paired { border-color: var(--dm-success-border); background: var(--dm-success-bg); color: var(--dm-success-text); }
+.status-pill.paired .status-dot { background: var(--dm-accent); }
+.status-pill.connected { border-color: var(--dm-warning-border); background: var(--dm-warning-bg); color: var(--dm-warning-text); }
+.status-pill.connected .status-dot { background: var(--dm-warning-text); }
+.header-actions { display: flex; align-items: center; gap: 5px; }
+.icon-btn { display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 1px solid var(--dm-border); border-radius: 8px; background: var(--dm-surface-raised); color: var(--dm-text-soft); font-size: 13px; line-height: 1; cursor: pointer; transition: border-color .12s ease, background .12s ease, color .12s ease; }
+.icon-btn:hover { border-color: var(--dm-border-strong); background: var(--dm-surface-hover); color: var(--dm-text); }
+.icon-btn.active { border-color: var(--dm-accent); background: var(--dm-surface-selected); color: var(--dm-accent-strong); }
+
+/* Segmented Tabs & Controls */
+.segmented-tabs, .segmented-control { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px; padding: 3px; border: 1px solid var(--dm-border); border-radius: 10px; background: var(--dm-surface); }
+.tab-trigger, .segment-btn { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-height: 28px; padding: 0 6px; border: 1px solid transparent; border-radius: 7px; background: transparent; color: var(--dm-text-muted); font-size: 11px; font-weight: 560; cursor: pointer; white-space: nowrap; transition: background .12s ease, color .12s ease, border-color .12s ease; }
+.tab-trigger:hover, .segment-btn:hover { color: var(--dm-text); }
+.tab-trigger.active, .segment-btn.active { border-color: var(--dm-border-strong); background: var(--dm-surface-selected); color: var(--dm-text); font-weight: 620; }
+.tab-badge { padding: 0 5px; border-radius: 999px; background: var(--dm-accent-soft); color: var(--dm-accent-strong); font-size: 9px; font-style: normal; line-height: 15px; }
+
+/* Cards, Pills & Inputs */
+.card { display: grid; gap: 8px; padding: 11px; border: 1px solid var(--dm-border); border-radius: 11px; background: var(--dm-surface-raised); }
+.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
+.section-heading strong { font-size: 11.5px; font-weight: 640; letter-spacing: -.01em; }
+.section-heading span { color: var(--dm-text-muted); font-size: 10px; }
+.pill { padding: 2px 7px; border: 1px solid var(--dm-border); border-radius: 999px; font-size: 10px; font-weight: 560; }
+.pill.online { border-color: var(--dm-success-border); background: var(--dm-success-bg); color: var(--dm-success-text); }
+.pill.offline { background: var(--dm-surface); color: var(--dm-text-muted); }
+.pill.neutral { background: var(--dm-surface); color: var(--dm-text-soft); }
+input { width: 100%; height: 32px; padding: 0 9px; border: 1px solid var(--dm-border-strong); border-radius: 8px; outline: 0; color: var(--dm-text); background: var(--dm-input-bg); caret-color: var(--dm-accent); font-size: 11.5px; transition: border-color .12s ease, box-shadow .12s ease; }
input::placeholder { color: var(--dm-placeholder); opacity: 1; }
-input:hover { border-color: #405148; }
-input:focus-visible { border-color: var(--dm-accent); box-shadow: 0 0 0 3px var(--dm-focus-ring); }
-.inline-fields { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
-button { font: inherit; }
-button:focus-visible { outline: 2px solid var(--dm-accent); outline-offset: 2px; }
-.primary, .secondary { min-height: 36px; padding: 0 11px; border-radius: 9px; cursor: pointer; transition: border-color .12s ease, background .12s ease, color .12s ease; }
-.primary { border: 1px solid #7ea88d; background: var(--dm-accent); color: #0a100d; font-weight: 650; }
+input:hover:not(:disabled) { border-color: #41544a; }
+input:focus-visible { border-color: var(--dm-accent); box-shadow: 0 0 0 3px var(--dm-focus-ring); outline: 0; }
+input:disabled { opacity: .45; cursor: default; }
+.inline-fields { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; }
+.primary, .secondary { min-height: 32px; padding: 0 11px; border-radius: 8px; font-size: 11px; white-space: nowrap; cursor: pointer; transition: border-color .12s ease, background .12s ease, color .12s ease; }
+.compact-btn { min-height: 28px; padding: 0 9px; font-size: 10.5px; }
+.primary { border: 1px solid #7ea88d; background: var(--dm-accent); color: #0a100d; font-weight: 660; }
.primary:hover:not(:disabled) { border-color: #a7cfb3; background: #a1c9ad; }
-.secondary { border: 1px solid var(--dm-border-strong); background: var(--dm-surface-hover); color: #c0cbc5; }
+.secondary { border: 1px solid var(--dm-border-strong); background: var(--dm-surface-hover); color: var(--dm-text-soft); font-weight: 560; }
.secondary:hover:not(:disabled) { border-color: #4e6859; background: var(--dm-surface-selected); color: var(--dm-text); }
-.primary:disabled, .secondary:disabled, .session-row:disabled, .tab-row:disabled { opacity: .45; cursor: default; }
-.notice { padding: 9px 10px; border-radius: 9px; font-size: 10px; line-height: 1.45; }
-.notice.success { border: 1px solid var(--dm-success-border); background: var(--dm-success-bg); color: var(--dm-success-text); }
-.notice.error { border: 1px solid var(--dm-danger-border); background: var(--dm-danger-bg); color: var(--dm-danger-text); }
-.capture-current { display: grid; gap: 3px; min-width: 0; }
-.capture-current strong, .capture-current small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
-.capture-current strong { font-size: 11px; font-weight: 600; }
-.capture-current small { font-size: 10px; }
-.capture-review { display: grid; gap: 5px; padding: 9px; border: 1px solid var(--dm-success-border); border-radius: 9px; background: var(--dm-success-bg); }
+.secondary.danger-subtle:hover:not(:disabled) { border-color: var(--dm-danger-border); background: var(--dm-danger-bg); color: var(--dm-danger-text); }
+.primary:disabled, .secondary:disabled, .session-row:disabled, .tab-row:disabled { opacity: .44; cursor: default; }
+
+/* Setup Wizard & Settings Drawer */
+.wizard-card { gap: 10px; }
+.wizard-intro { display: grid; gap: 2px; }
+.wizard-intro strong { font-size: 13px; font-weight: 660; }
+.wizard-intro span { color: var(--dm-text-muted); font-size: 10.5px; line-height: 1.45; }
+.wizard-step { display: grid; gap: 6px; padding: 9px; border: 1px solid var(--dm-border); border-radius: 9px; background: var(--dm-surface); }
+.wizard-step.current { border-color: var(--dm-border-strong); }
+.wizard-step.done { border-color: var(--dm-success-border); background: var(--dm-success-bg); }
+.wizard-step.locked { opacity: .68; }
+.step-header { display: flex; align-items: center; gap: 6px; }
+.step-badge { display: grid; place-items: center; width: 17px; height: 17px; border-radius: 999px; background: var(--dm-surface-selected); color: var(--dm-accent-strong); font-size: 10px; font-weight: 700; }
+.step-header strong { font-size: 11px; font-weight: 620; }
+.step-header small { margin-left: auto; color: var(--dm-text-muted); font-size: 10px; }
+.settings-drawer { display: grid; gap: 9px; }
+.drawer-header { display: flex; align-items: center; justify-content: space-between; padding: 0 2px; }
+.drawer-header strong { font-size: 12px; font-weight: 650; }
+.pref-group { display: grid; gap: 6px; }
+.drawer-divider { display: grid; gap: 7px; padding-top: 8px; border-top: 1px solid var(--dm-border); }
+.inline-action-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
+.muted-copy { margin: 0; color: var(--dm-text-muted); font-size: 10px; line-height: 1.42; }
+
+/* Quick Capture & Monograms */
+.row-monogram { display: grid; place-items: center; width: 24px; height: 24px; flex-shrink: 0; border: 1px solid var(--dm-border); border-radius: 6px; background: var(--dm-surface); color: var(--dm-text-soft); font-size: 10px; font-weight: 700; }
+.row-monogram.accent { border-color: var(--dm-success-border); background: var(--dm-accent-soft); color: var(--dm-accent-strong); }
+.capture-current-row { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; align-items: center; gap: 8px; }
+.capture-current { display: grid; gap: 1px; min-width: 0; }
+.capture-current strong, .capture-current small, .capture-review-copy strong, .capture-review-copy small, .row-copy strong, .row-copy small, .session-row strong, .session-row small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+.capture-current strong { font-size: 11.5px; font-weight: 600; }
+.capture-current small, .capture-review-copy small { color: var(--dm-text-muted); font-size: 10px; }
+.capture-review { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 9px; border: 1px solid var(--dm-success-border); border-radius: 8px; background: var(--dm-success-bg); }
.capture-review.duplicate { border-color: var(--dm-warning-border); background: var(--dm-warning-bg); }
-.capture-review > span { color: var(--dm-accent); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; }
-.capture-review.duplicate > span { color: var(--dm-warning-text); }
-.capture-review strong { overflow: hidden; color: var(--dm-text); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
-.capture-review small { font-size: 10px; }
-.capture-review .secondary { min-height: 30px; justify-self: start; font-size: 10px; }
-.capture-help { margin: 0; color: var(--dm-text-muted); font-size: 10px; line-height: 1.5; }
+.capture-review-copy { display: grid; gap: 1px; min-width: 0; }
+.capture-review-copy span { color: var(--dm-accent); font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
+.capture-review.duplicate .capture-review-copy span { color: var(--dm-warning-text); }
+.capture-review-copy strong { font-size: 10.5px; font-weight: 600; }
+
+/* Multi-Tab Review */
+.capture-help { margin: 0; color: var(--dm-text-muted); font-size: 10.5px; line-height: 1.45; }
.capture-review-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
-.capture-review-summary span { display: grid; gap: 1px; padding: 7px; border: 1px solid var(--dm-border); border-radius: 8px; background: var(--dm-surface); color: var(--dm-text-muted); font-size: 10px; text-align: center; }
-.capture-review-summary strong { color: var(--dm-text); font-size: 11px; }
-.capture-selection-actions { display: flex; gap: 10px; }
-.text-button { padding: 0; border: 0; background: transparent; color: var(--dm-accent); cursor: pointer; font-size: 10px; }
+.summary-pill { display: grid; gap: 1px; padding: 6px 4px; border: 1px solid var(--dm-border); border-radius: 8px; background: var(--dm-surface); text-align: center; }
+.summary-pill strong { font-size: 12px; font-weight: 700; color: var(--dm-text); }
+.summary-pill small { font-size: 9.5px; color: var(--dm-text-muted); }
+.summary-pill.is-new { border-color: var(--dm-success-border); background: var(--dm-success-bg); }
+.summary-pill.is-new strong { color: var(--dm-accent-strong); }
+.summary-pill.is-existing, .summary-pill.is-repeated { border-color: var(--dm-warning-border); background: var(--dm-warning-bg); }
+.summary-pill.is-existing strong, .summary-pill.is-repeated strong { color: var(--dm-warning-text); }
+.capture-selection-actions { display: flex; align-items: center; gap: 10px; }
+.selection-count { margin-left: auto; color: var(--dm-text-muted); font-size: 10px; }
+.text-button { padding: 0; border: 0; background: transparent; color: var(--dm-accent); font-size: 10.5px; font-weight: 560; cursor: pointer; }
.text-button:hover:not(:disabled) { color: var(--dm-accent-strong); }
.text-button:disabled { opacity: .4; cursor: default; }
-.capture-review-list { display: grid; gap: 5px; max-height: 220px; overflow-y: auto; padding-right: 2px; }
-.capture-review-row { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 8px; align-items: center; padding: 8px; border: 1px solid var(--dm-border); border-radius: 9px; background: var(--dm-surface); cursor: pointer; transition: border-color .12s ease, background .12s ease; }
-.capture-review-row:hover { border-color: #3e5548; background: var(--dm-surface-hover); }
+.capture-review-list { display: grid; gap: 4px; max-height: 224px; overflow-y: auto; padding-right: 2px; }
+.capture-review-row { display: grid; grid-template-columns: 16px 24px minmax(0, 1fr); gap: 7px; align-items: center; padding: 6px 7px; border: 1px solid var(--dm-border); border-radius: 8px; background: var(--dm-surface); cursor: pointer; transition: border-color .12s ease, background .12s ease; }
+.capture-review-row:hover { border-color: #3d5447; background: var(--dm-surface-hover); }
.capture-review-row:has(input[type="checkbox"]:checked) { border-color: #486657; background: var(--dm-surface-selected); }
-.capture-review-row.state-duplicate, .capture-review-row.state-selection-duplicate { border-color: #4a4331; background: var(--dm-warning-bg); cursor: default; }
-.capture-review-row input[type="checkbox"] { width: 15px; height: 15px; margin: 0; padding: 0; border-radius: 4px; accent-color: var(--dm-accent); box-shadow: none; }
-.capture-review-row > span { display: grid; min-width: 0; gap: 2px; }
-.capture-review-row strong, .capture-review-row small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
-.capture-review-row strong { color: var(--dm-text); font-size: 10px; font-weight: 600; }
-.capture-review-row small { color: var(--dm-text-muted); font-size: 10px; }
-.capture-review-row.state-duplicate small, .capture-review-row.state-selection-duplicate small { color: #b8a46f; }
-.capture-review-actions { display: grid; grid-template-columns: auto 1fr; gap: 8px; }
-.capture-batch-notice { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 9px; border-radius: 8px; font-size: 10px; line-height: 1.4; }
-.capture-batch-notice.success { border: 1px solid var(--dm-success-border); background: var(--dm-success-bg); color: var(--dm-success-text); }
-.capture-batch-notice.error { border: 1px solid var(--dm-danger-border); background: var(--dm-danger-bg); color: var(--dm-danger-text); }
-.capture-batch-notice span { color: inherit; }
-.session-section, .open-tabs-section { display: grid; gap: 7px; }
-.session-list, .tabs { display: grid; gap: 6px; }
-.session-row, .tab-row { display: flex; gap: 12px; justify-content: space-between; width: 100%; border: 1px solid var(--dm-border); border-radius: 10px; padding: 9px 10px; color: var(--dm-text-soft); background: var(--dm-surface-raised); text-align: left; cursor: pointer; transition: border-color .12s ease, background .12s ease, color .12s ease; }
-.session-row:hover, .tab-row:hover { border-color: #496455; background: var(--dm-surface-selected); color: var(--dm-text); }
+.capture-review-row.state-duplicate, .capture-review-row.state-selection-duplicate { border-color: #463f2e; background: var(--dm-warning-bg); cursor: default; }
+.capture-review-row input[type="checkbox"] { width: 14px; height: 14px; margin: 0; padding: 0; accent-color: var(--dm-accent); box-shadow: none; }
+.row-copy { display: grid; min-width: 0; gap: 1px; }
+.row-copy strong { color: var(--dm-text); font-size: 11px; font-weight: 580; }
+.row-copy small { color: var(--dm-text-muted); font-size: 9.5px; }
+.capture-review-row.state-duplicate .row-copy small, .capture-review-row.state-selection-duplicate .row-copy small { color: var(--dm-warning-text); }
+.capture-review-actions { display: grid; grid-template-columns: auto 1fr; gap: 7px; }
+.capture-batch-notice { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 9px; border-radius: 8px; font-size: 10.5px; line-height: 1.4; }
+.capture-batch-notice.success, .notice.success { border: 1px solid var(--dm-success-border); background: var(--dm-success-bg); color: var(--dm-success-text); }
+.capture-batch-notice.error, .notice.error { border: 1px solid var(--dm-danger-border); background: var(--dm-danger-bg); color: var(--dm-danger-text); }
+
+/* Open Tabs & Sessions */
+.sessions-view, .session-section, .open-tabs-section { display: grid; gap: 7px; }
+.tab-search-input { height: 30px; font-size: 11px; }
+.tabs, .session-list { display: grid; gap: 5px; max-height: 248px; overflow-y: auto; padding-right: 2px; }
+.tab-row, .session-row { display: grid; width: 100%; border: 1px solid var(--dm-border); border-radius: 9px; padding: 7px 9px; color: var(--dm-text-soft); background: var(--dm-surface-raised); text-align: left; cursor: pointer; transition: border-color .12s ease, background .12s ease, color .12s ease; }
+.tab-row { grid-template-columns: 24px minmax(0, 1fr) auto; align-items: center; gap: 8px; }
+.session-row { grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; }
+.tab-row:hover, .tab-row.is-selected, .session-row:hover { border-color: #496455; background: var(--dm-surface-selected); color: var(--dm-text); }
+.tab-row.is-active { border-color: var(--dm-success-border); }
+.tab-action-pill { padding: 2px 6px; border-radius: 6px; background: var(--dm-surface); color: var(--dm-text-muted); font-size: 9.5px; font-style: normal; font-weight: 560; }
+.tab-action-pill.current { background: var(--dm-accent-soft); color: var(--dm-accent-strong); }
.session-row > span { display: grid; min-width: 0; gap: 2px; }
-.session-row strong, .session-row small, .tab-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
-.session-row strong { font-size: 11px; font-weight: 600; }
-.session-row small, .tab-row small { font-size: 10px; }
-.session-row em { align-self: center; color: #9ac0a6; font-size: 10px; font-style: normal; }
-.tab-row span { flex: 1; font-size: 10px; }
-.empty { margin: 3px 0 0; color: var(--dm-text-muted); font-size: 10px; }
+.session-row strong { color: var(--dm-text); font-size: 11.5px; font-weight: 600; }
+.session-row small { color: var(--dm-text-muted); font-size: 10px; }
+.session-row em { color: var(--dm-accent); font-size: 10.5px; font-style: normal; font-weight: 600; }
+.empty { margin: 2px 0; color: var(--dm-text-muted); font-size: 10.5px; }
+.notice { padding: 8px 10px; border-radius: 8px; font-size: 10.5px; line-height: 1.42; }
-/* The popup follows the same Dockmark appearance preference as New Tab and Web,
- so it needs the light palette rather than being pinned to dark. */
+/* Light Theme */
html[data-theme="light"] {
--dm-bg: #f4f7f5;
- --dm-surface: #edf2ef;
+ --dm-surface: #ebf1ed;
--dm-surface-raised: #ffffff;
- --dm-surface-hover: #e7efea;
- --dm-surface-selected: #dceae1;
+ --dm-surface-hover: #e5eee8;
+ --dm-surface-selected: #dae9df;
--dm-input-bg: #ffffff;
--dm-border: #d1ddd6;
- --dm-border-strong: #b7c9bf;
+ --dm-border-strong: #b6c8be;
--dm-text: #173126;
- --dm-text-soft: #4e665b;
- --dm-text-muted: #5f7168;
- --dm-placeholder: #91a097;
+ --dm-text-soft: #475f54;
+ --dm-text-muted: #5d7066;
+ --dm-placeholder: #8d9d94;
--dm-accent: #4f8063;
- --dm-accent-strong: #315f47;
+ --dm-accent-strong: #2f5b44;
+ --dm-accent-soft: rgba(79, 128, 99, .12);
--dm-focus-ring: rgba(79, 128, 99, .14);
--dm-success-border: #a8cbb5;
--dm-success-bg: #eef8f1;
- --dm-success-text: #315f47;
+ --dm-success-text: #2f5b44;
--dm-warning-border: #dfc995;
--dm-warning-bg: #fff8e9;
--dm-warning-text: #7a6328;
@@ -163,15 +197,13 @@ html[data-theme="light"] {
--dm-danger-bg: #fff3f2;
--dm-danger-text: #9f4e49;
}
-
-html[data-theme="light"] .primary { border-color: #6c9a7d; color: #f8fffa; }
-html[data-theme="light"] .primary:hover:not(:disabled) { border-color: #4f8063; background: #5f9075; }
-html[data-theme="light"] .secondary { border-color: var(--dm-border); background: #fff; color: var(--dm-text-soft); }
-html[data-theme="light"] .secondary:hover:not(:disabled) { border-color: #a8c7b5; background: var(--dm-surface-selected); color: var(--dm-text); }
-html[data-theme="light"] input:hover { border-color: #a8c7b5; }
-html[data-theme="light"] .offline { color: var(--dm-text-muted) !important; }
-html[data-theme="light"] .capture-review-row:hover { border-color: #a8c7b5; }
-html[data-theme="light"] .capture-review-row:has(input[type="checkbox"]:checked) { border-color: #8eb79c; }
-html[data-theme="light"] .capture-review-row.state-duplicate small,
-html[data-theme="light"] .capture-review-row.state-selection-duplicate small { color: #7a6328; }
-html[data-theme="light"] .session-row em { color: var(--dm-accent-strong); }
+html[data-theme="light"] .primary { border-color: #4f8063; color: #f8fffa; }
+html[data-theme="light"] .primary:hover:not(:disabled) { border-color: #3f6c52; background: #427055; }
+html[data-theme="light"] .secondary { border-color: var(--dm-border); background: #ffffff; color: var(--dm-text-soft); }
+html[data-theme="light"] .secondary:hover:not(:disabled) { border-color: #9ec0ac; background: var(--dm-surface-selected); color: var(--dm-text); }
+html[data-theme="light"] input:hover:not(:disabled),
+html[data-theme="light"] .tab-row:hover,
+html[data-theme="light"] .tab-row.is-selected,
+html[data-theme="light"] .session-row:hover,
+html[data-theme="light"] .capture-review-row:hover { border-color: #9ec0ac; }
+html[data-theme="light"] .capture-review-row:has(input[type="checkbox"]:checked) { border-color: #84b195; }
diff --git a/apps/extension/lib/ext-locale.ts b/apps/extension/lib/ext-locale.ts
new file mode 100644
index 0000000..240aa16
--- /dev/null
+++ b/apps/extension/lib/ext-locale.ts
@@ -0,0 +1,203 @@
+/**
+ * [INPUT]: depends on LOCALE_STORAGE_KEY, normalizeLocalePreference, resolveLocale, tx, normalizeAppearancePreference from @dockmark/core; depends on browser from wxt/browser
+ * [OUTPUT]: exports theme and locale persistence, DOM application, storage hydration, and reactive listeners for extension UI pages
+ * [POS]: shared UI preference runtime in apps/extension/lib used by popup and local-health-permission entrypoints
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
+import {
+ LOCALE_STORAGE_KEY,
+ normalizeAppearancePreference,
+ normalizeLocalePreference,
+ resolveLocale,
+ tx,
+ type AppearancePreference,
+ type LocalePreference,
+ type ResolvedLocale,
+} from "@dockmark/core";
+import { browser } from "wxt/browser";
+
+export const APPEARANCE_STORAGE_KEY = "dockmarkAppearanceV1";
+export { LOCALE_STORAGE_KEY, tx };
+export type { AppearancePreference, LocalePreference, ResolvedLocale };
+
+export function resolvedTheme(preference: AppearancePreference): "light" | "dark" {
+ if (preference === "system") {
+ return matchMedia("(prefers-color-scheme: light)").matches ? "light" : "dark";
+ }
+ return preference;
+}
+
+export function readLocalAppearance(): AppearancePreference {
+ try {
+ return normalizeAppearancePreference(localStorage.getItem(APPEARANCE_STORAGE_KEY));
+ } catch {
+ return "system";
+ }
+}
+
+export function readLocalLocalePreference(): LocalePreference {
+ try {
+ return normalizeLocalePreference(localStorage.getItem(LOCALE_STORAGE_KEY));
+ } catch {
+ return "system";
+ }
+}
+
+export function applyExtensionAppearance(
+ preference: unknown,
+ persist = true,
+): AppearancePreference {
+ const normalized = normalizeAppearancePreference(preference);
+ const theme = resolvedTheme(normalized);
+ document.documentElement.dataset.appearance = normalized;
+ document.documentElement.dataset.theme = theme;
+ document.documentElement.style.colorScheme = theme;
+ const meta = document.querySelector('meta[name="theme-color"]');
+ if (meta) meta.setAttribute("content", theme === "light" ? "#f4f7f5" : "#0a0f0c");
+ if (persist) {
+ try {
+ localStorage.setItem(APPEARANCE_STORAGE_KEY, normalized);
+ } catch {
+ // Ignore storage errors in restricted contexts.
+ }
+ void browser.storage.local.set({ [APPEARANCE_STORAGE_KEY]: normalized }).catch(() => undefined);
+ }
+ return normalized;
+}
+
+export function applyExtensionLocale(
+ preference: unknown,
+ persist = true,
+): { preference: LocalePreference; locale: ResolvedLocale } {
+ const normalized = normalizeLocalePreference(preference);
+ const locale = resolveLocale(normalized);
+ document.documentElement.dataset.localePreference = normalized;
+ document.documentElement.dataset.locale = locale;
+ document.documentElement.lang = locale;
+ if (persist) {
+ try {
+ localStorage.setItem(LOCALE_STORAGE_KEY, normalized);
+ } catch {
+ // Ignore storage errors in restricted contexts.
+ }
+ void browser.storage.local.set({ [LOCALE_STORAGE_KEY]: normalized }).catch(() => undefined);
+ }
+ return { preference: normalized, locale };
+}
+
+export async function hydrateExtensionPreferences(): Promise<{
+ appearance: AppearancePreference;
+ localePreference: LocalePreference;
+ locale: ResolvedLocale;
+}> {
+ const rawLocalAppearance = safeGetLocalStorage(APPEARANCE_STORAGE_KEY);
+ const rawLocalLocale = safeGetLocalStorage(LOCALE_STORAGE_KEY);
+
+ let storedAppearance: unknown = undefined;
+ let storedLocale: unknown = undefined;
+ try {
+ const stored = await browser.storage.local.get([APPEARANCE_STORAGE_KEY, LOCALE_STORAGE_KEY]);
+ storedAppearance = stored[APPEARANCE_STORAGE_KEY];
+ storedLocale = stored[LOCALE_STORAGE_KEY];
+ } catch {
+ // Fall back to localStorage values.
+ }
+
+ const appearancePref = rawLocalAppearance !== null
+ ? normalizeAppearancePreference(rawLocalAppearance)
+ : storedAppearance !== undefined
+ ? normalizeAppearancePreference(storedAppearance)
+ : "system";
+
+ const localePref = rawLocalLocale !== null
+ ? normalizeLocalePreference(rawLocalLocale)
+ : storedLocale !== undefined
+ ? normalizeLocalePreference(storedLocale)
+ : "system";
+
+ const appliedAppearance = applyExtensionAppearance(appearancePref, false);
+ const appliedLocale = applyExtensionLocale(localePref, false);
+ return {
+ appearance: appliedAppearance,
+ localePreference: appliedLocale.preference,
+ locale: appliedLocale.locale,
+ };
+}
+
+function safeGetLocalStorage(key: string): string | null {
+ try {
+ return localStorage.getItem(key);
+ } catch {
+ return null;
+ }
+}
+
+export function subscribeExtensionPreferences(handlers: {
+ onAppearance?: (preference: AppearancePreference) => void;
+ onLocale?: (preference: LocalePreference, locale: ResolvedLocale) => void;
+}): () => void {
+ const media = matchMedia("(prefers-color-scheme: light)");
+ const handleMedia = () => {
+ const current = readLocalAppearance();
+ if (current === "system") {
+ applyExtensionAppearance("system", false);
+ handlers.onAppearance?.("system");
+ }
+ };
+ const handleLanguage = () => {
+ const current = readLocalLocalePreference();
+ if (current === "system") {
+ const next = applyExtensionLocale("system", false);
+ handlers.onLocale?.(next.preference, next.locale);
+ }
+ };
+ const handleStorage = (event: StorageEvent) => {
+ if (event.key === APPEARANCE_STORAGE_KEY) {
+ const pref = applyExtensionAppearance(event.newValue, false);
+ handlers.onAppearance?.(pref);
+ } else if (event.key === LOCALE_STORAGE_KEY) {
+ const next = applyExtensionLocale(event.newValue, false);
+ handlers.onLocale?.(next.preference, next.locale);
+ }
+ };
+ const handleBrowserStorage: Parameters
[0] = (
+ changes,
+ areaName,
+ ) => {
+ if (areaName !== "local") return;
+ if (changes[APPEARANCE_STORAGE_KEY]) {
+ const nextValue = changes[APPEARANCE_STORAGE_KEY].newValue;
+ const pref = applyExtensionAppearance(nextValue, false);
+ try {
+ if (nextValue === undefined) localStorage.removeItem(APPEARANCE_STORAGE_KEY);
+ else localStorage.setItem(APPEARANCE_STORAGE_KEY, pref);
+ } catch {
+ // Ignore storage write errors.
+ }
+ handlers.onAppearance?.(pref);
+ }
+ if (changes[LOCALE_STORAGE_KEY]) {
+ const nextValue = changes[LOCALE_STORAGE_KEY].newValue;
+ const next = applyExtensionLocale(nextValue, false);
+ try {
+ if (nextValue === undefined) localStorage.removeItem(LOCALE_STORAGE_KEY);
+ else localStorage.setItem(LOCALE_STORAGE_KEY, next.preference);
+ } catch {
+ // Ignore storage write errors.
+ }
+ handlers.onLocale?.(next.preference, next.locale);
+ }
+ };
+
+ media.addEventListener("change", handleMedia);
+ window.addEventListener("languagechange", handleLanguage);
+ window.addEventListener("storage", handleStorage);
+ browser.storage.onChanged.addListener(handleBrowserStorage);
+
+ return () => {
+ media.removeEventListener("change", handleMedia);
+ window.removeEventListener("languagechange", handleLanguage);
+ window.removeEventListener("storage", handleStorage);
+ browser.storage.onChanged.removeListener(handleBrowserStorage);
+ };
+}
diff --git a/apps/extension/lib/launcher-access.ts b/apps/extension/lib/launcher-access.ts
index 4b103e1..dbf8bb7 100644
--- a/apps/extension/lib/launcher-access.ts
+++ b/apps/extension/lib/launcher-access.ts
@@ -1,3 +1,9 @@
+/**
+ * [INPUT]: depends on browser from wxt/browser; reads dockmarkNewTabCacheV1 from browser.storage.local
+ * [OUTPUT]: exports openDockmarkLauncher and registerLauncherAccess for Alt+Shift+D shortcut and d+Space omnibox
+ * [POS]: quick-access launcher integration in apps/extension/lib registered by entrypoints/background.ts
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
import { browser } from "wxt/browser";
const CACHE_KEY = "dockmarkNewTabCacheV1";
diff --git a/apps/extension/lib/local-health.ts b/apps/extension/lib/local-health.ts
index b3d34a0..90d59d6 100644
--- a/apps/extension/lib/local-health.ts
+++ b/apps/extension/lib/local-health.ts
@@ -1,3 +1,9 @@
+/**
+ * [INPUT]: depends on inferHealthPolicy and HealthStatus from @dockmark/core; depends on browser from wxt/browser
+ * [OUTPUT]: exports LOCAL_HEALTH_PENDING_KEY, localHealthPermissionPattern, checkLocalHealth, and probe result types
+ * [POS]: local/private bookmark health probe runner in apps/extension/lib invoked by background.ts and paired with local-health-permission page
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
import { inferHealthPolicy, type HealthStatus } from "@dockmark/core";
import { browser } from "wxt/browser";
diff --git a/apps/extension/package.json b/apps/extension/package.json
index f549337..9609d91 100644
--- a/apps/extension/package.json
+++ b/apps/extension/package.json
@@ -1,6 +1,6 @@
{
"name": "@dockmark/extension",
- "version": "1.5.5",
+ "version": "1.6.0",
"private": true,
"type": "module",
"scripts": {
diff --git a/apps/extension/public/_locales/en/messages.json b/apps/extension/public/_locales/en/messages.json
new file mode 100644
index 0000000..61bc1e7
--- /dev/null
+++ b/apps/extension/public/_locales/en/messages.json
@@ -0,0 +1,14 @@
+{
+ "extDescription": {
+ "message": "Browser bridge for Dockmark tabs, reviewed Capture Inbox, sessions, Smart Collection-aware local-first search, reviewed bookmark sync, local health checks and device pairing.",
+ "description": "Manifest description for the standard Dockmark browser extension."
+ },
+ "cmdOpenLauncher": {
+ "message": "Open or focus the Dockmark launcher",
+ "description": "Keyboard shortcut description for opening or focusing the Dockmark launcher."
+ },
+ "newtabDescription": {
+ "message": "Dockmark browser bridge with a local-first, offline-capable Dockmark launcher on every new tab.",
+ "description": "Manifest description for the Dockmark New Tab extension variant."
+ }
+}
diff --git a/apps/extension/public/_locales/zh_CN/messages.json b/apps/extension/public/_locales/zh_CN/messages.json
new file mode 100644
index 0000000..a64209e
--- /dev/null
+++ b/apps/extension/public/_locales/zh_CN/messages.json
@@ -0,0 +1,14 @@
+{
+ "extDescription": {
+ "message": "Dockmark 浏览器桥接:支持打开的标签页、收件箱快速收录与批量审查、会话保存与恢复、智能合集本地搜索、书签同步、本地健康检查与设备配对。",
+ "description": "Manifest description for the standard Dockmark browser extension in Simplified Chinese."
+ },
+ "cmdOpenLauncher": {
+ "message": "打开或聚焦 Dockmark 启动台",
+ "description": "Keyboard shortcut description for opening or focusing the Dockmark launcher in Simplified Chinese."
+ },
+ "newtabDescription": {
+ "message": "Dockmark 浏览器桥接,在每个新标签页提供本地优先、支持离线使用的 Dockmark 启动台。",
+ "description": "Manifest description for the Dockmark New Tab extension variant in Simplified Chinese."
+ }
+}
diff --git a/apps/extension/public/newtab-auth.js b/apps/extension/public/newtab-auth.js
index 9910297..4abef5b 100644
--- a/apps/extension/public/newtab-auth.js
+++ b/apps/extension/public/newtab-auth.js
@@ -1,3 +1,9 @@
+/**
+ * [INPUT]: depends on chrome.storage.local (dockmarkServerUrl, dockmarkDeviceToken) and chrome.tabs
+ * [OUTPUT]: patches window.fetch with Bearer device token for Dockmark /api/* requests and routes #manage clicks to /app
+ * [POS]: auth transport layer loaded before newtab.js in apps/extension/public/newtab.html
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
(() => {
const nativeFetch = window.fetch.bind(window);
const SERVER_KEY = "dockmarkServerUrl";
diff --git a/apps/extension/public/newtab-i18n.js b/apps/extension/public/newtab-i18n.js
new file mode 100644
index 0000000..be7385b
--- /dev/null
+++ b/apps/extension/public/newtab-i18n.js
@@ -0,0 +1,166 @@
+/**
+ * [INPUT]: depends on localStorage, navigator.language, and optional chrome.storage.local
+ * [OUTPUT]: exposes window.dockmarkI18n ({ STORAGE_KEY, normalize, resolve, currentPreference, currentLocale, tx, formatRelativeTime, connectionText, offlineText, apply, applyStaticDom, hydrate, toggleLocale })
+ * [POS]: head-loaded EN/zh-CN localization runtime and copy catalog for apps/extension/public/newtab.html and its classic launcher scripts
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
+(() => {
+ const STORAGE_KEY = "dockmarkLocaleV1";
+
+ const CONNECTION_COPY = {
+ starting: ["Starting…", "启动中…"],
+ refreshing: ["Refreshing…", "刷新中…"],
+ online: ["Online · synced", "在线 · 已同步"],
+ "offline-cache": ["Offline cache", "离线缓存"],
+ offline: ["Offline", "离线"],
+ "cache-cleared": ["Cache cleared", "缓存已清除"],
+ "not-connected": ["Not connected", "未连接"],
+ "cached-not-connected": ["Cached · not connected", "已缓存 · 未连接"],
+ "cached-manual": ["Cached · manual refresh", "已缓存 · 手动刷新"],
+ "cached-refreshing": ["Cached · refreshing", "已缓存 · 刷新中"],
+ connecting: ["Connecting…", "连接中…"],
+ };
+
+ function normalize(value) {
+ if (typeof value !== "string") return "system";
+ const cleaned = value.trim().toLowerCase().replace(/_/g, "-");
+ if (cleaned === "en" || cleaned.startsWith("en-")) return "en";
+ if (cleaned === "zh" || cleaned.startsWith("zh-")) return "zh-CN";
+ return "system";
+ }
+
+ function resolve(preference, browserLanguage) {
+ const normalized = normalize(preference);
+ if (normalized === "en" || normalized === "zh-CN") return normalized;
+ const candidate = typeof browserLanguage === "string" && browserLanguage
+ ? browserLanguage
+ : (typeof navigator !== "undefined" ? navigator.language : "en");
+ return String(candidate || "").toLowerCase().startsWith("zh") ? "zh-CN" : "en";
+ }
+
+ function safeLocalGet() {
+ try { return localStorage.getItem(STORAGE_KEY); } catch { return null; }
+ }
+
+ function safeLocalSet(value) {
+ try { localStorage.setItem(STORAGE_KEY, value); } catch { /* ignore */ }
+ }
+
+ function currentPreference() { return normalize(safeLocalGet()); }
+ function currentLocale() { return resolve(currentPreference()); }
+ function tx(en, zh) { return currentLocale() === "zh-CN" ? zh : en; }
+
+ function formatRelativeTime(isoValue) {
+ const isZh = currentLocale() === "zh-CN";
+ if (!isoValue) return isZh ? "从未" : "never";
+ const timestamp = Date.parse(isoValue);
+ if (!Number.isFinite(timestamp)) return isZh ? "未知" : "unknown";
+ const seconds = Math.max(0, Math.round((Date.now() - timestamp) / 1000));
+ if (seconds < 45) return isZh ? "刚刚" : "just now";
+ if (seconds < 3600) {
+ const mins = Math.round(seconds / 60);
+ return isZh ? `${mins} 分钟前` : `${mins}m ago`;
+ }
+ if (seconds < 86400) {
+ const hours = Math.round(seconds / 3600);
+ return isZh ? `${hours} 小时前` : `${hours}h ago`;
+ }
+ const days = Math.round(seconds / 86400);
+ return isZh ? `${days} 天前` : `${days}d ago`;
+ }
+
+ function connectionText(key) {
+ const pair = CONNECTION_COPY[key];
+ return pair ? tx(pair[0], pair[1]) : key;
+ }
+
+ function offlineText(key, syncedAt) {
+ switch (key) {
+ case "refresh-failed-cached":
+ return tx(
+ `Cloud refresh failed. Using the local snapshot from ${formatRelativeTime(syncedAt)}. Search and launch still work.`,
+ `云端刷新失败,正在使用同步于 ${formatRelativeTime(syncedAt)} 的本地快照。搜索与启动仍可正常使用。`,
+ );
+ case "cache-cleared-connected":
+ return tx(
+ "Local snapshot cleared. Use Refresh to seed it again. Server connection, settings and bookmark mappings were kept.",
+ "本地快照已清除,可点击刷新重新同步。服务器连接、设置与书签映射已保留。",
+ );
+ case "cache-cleared-local":
+ return tx("Local snapshot cleared. Settings and bookmark mappings were kept.", "本地快照已清除。设置与书签映射已保留。");
+ case "no-origin-cached":
+ return tx("No Dockmark origin is configured. Using the last local snapshot.", "尚未配置 Dockmark 服务器地址,正在使用上一次本地快照。");
+ case "connect-first":
+ return tx("Connect a Dockmark origin from the extension popup first.", "请先在扩展弹窗中连接 Dockmark 服务器地址。");
+ default:
+ return "";
+ }
+ }
+
+ function applyStaticDom() {
+ const isZh = currentLocale() === "zh-CN";
+ document.title = isZh ? "Dockmark 新标签页" : "Dockmark New Tab";
+ for (const node of document.querySelectorAll("[data-i18n-en]")) {
+ node.textContent = isZh ? (node.getAttribute("data-i18n-zh") || node.getAttribute("data-i18n-en") || "") : (node.getAttribute("data-i18n-en") || "");
+ }
+ for (const node of document.querySelectorAll("[data-i18n-placeholder-en]")) {
+ node.setAttribute("placeholder", isZh ? (node.getAttribute("data-i18n-placeholder-zh") || node.getAttribute("data-i18n-placeholder-en") || "") : (node.getAttribute("data-i18n-placeholder-en") || ""));
+ }
+ for (const node of document.querySelectorAll("[data-i18n-title-en]")) {
+ const title = isZh ? (node.getAttribute("data-i18n-title-zh") || node.getAttribute("data-i18n-title-en") || "") : (node.getAttribute("data-i18n-title-en") || "");
+ node.setAttribute("title", title);
+ if (node.hasAttribute("aria-label")) node.setAttribute("aria-label", title);
+ }
+ }
+
+ function apply(preference, persist = true) {
+ const normalized = normalize(preference);
+ const locale = resolve(normalized);
+ document.documentElement.dataset.localePreference = normalized;
+ document.documentElement.dataset.locale = locale;
+ document.documentElement.lang = locale;
+ if (persist) {
+ safeLocalSet(normalized);
+ try { chrome?.storage?.local?.set({ [STORAGE_KEY]: normalized }).catch?.(() => undefined); } catch { /* ignore */ }
+ }
+ applyStaticDom();
+ window.dispatchEvent(new CustomEvent("dockmark:locale", { detail: { preference: normalized, locale } }));
+ return { preference: normalized, locale };
+ }
+
+ function toggleLocale() {
+ return apply(currentLocale() === "zh-CN" ? "en" : "zh-CN", true);
+ }
+
+ async function hydrate() {
+ const localRaw = safeLocalGet();
+ if (localRaw !== null) return apply(localRaw, false);
+ try {
+ const stored = await chrome?.storage?.local?.get(STORAGE_KEY);
+ if (stored && stored[STORAGE_KEY] !== undefined) return apply(stored[STORAGE_KEY], false);
+ } catch { /* fall back */ }
+ return apply("system", false);
+ }
+
+ apply(currentPreference(), false);
+ window.addEventListener("languagechange", () => { if (currentPreference() === "system") apply("system", false); });
+ window.addEventListener("storage", (event) => { if (event.key === STORAGE_KEY) apply(event.newValue, false); });
+
+ try {
+ chrome?.storage?.onChanged?.addListener((changes, areaName) => {
+ if (areaName !== "local" || !changes[STORAGE_KEY]) return;
+ const nextValue = changes[STORAGE_KEY].newValue;
+ const applied = apply(nextValue, false);
+ if (nextValue === undefined) {
+ try { localStorage.removeItem(STORAGE_KEY); } catch { /* ignore */ }
+ } else {
+ safeLocalSet(applied.preference);
+ }
+ });
+ } catch { /* ignore */ }
+
+ window.dockmarkI18n = {
+ STORAGE_KEY, normalize, resolve, currentPreference, currentLocale, tx,
+ formatRelativeTime, connectionText, offlineText, apply, applyStaticDom, hydrate, toggleLocale,
+ };
+})();
diff --git a/apps/extension/public/newtab-library-cache.js b/apps/extension/public/newtab-library-cache.js
index 2439873..2fbbffc 100644
--- a/apps/extension/public/newtab-library-cache.js
+++ b/apps/extension/public/newtab-library-cache.js
@@ -1,12 +1,23 @@
+/**
+ * [INPUT]: depends on globals from newtab.js (refreshCloud, requestJson, hasOriginPermission, snapshot, settings, elements) and window.dockmarkAppearance/dockmarkI18n
+ * [OUTPUT]: overrides refreshCloud to atomically cache bookmarks, tags, Smart Collections, Inbox membership, Sessions, appearance, and locale
+ * [POS]: single-pass snapshot sync layer loaded after newtab.js in apps/extension/public/newtab.html
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
(() => {
refreshCloud = async function refreshCloudWithLibraryMetadata({ quiet = false } = {}) {
if (refreshing || !origin) return false;
refreshing = true;
- if (!quiet) setConnection("Refreshing…");
+ if (!quiet) setConnectionKey("refreshing");
try {
if (!(await hasOriginPermission())) {
- throw new Error("Dockmark site access is not granted. Open the extension popup and reconnect this origin.");
+ throw new Error(
+ tx(
+ "Dockmark site access is not granted. Open the extension popup and reconnect this origin.",
+ "尚未授予 Dockmark 站点访问权限,请打开扩展弹窗重新连接该地址。",
+ ),
+ );
}
const previousSessions = asArray(snapshot.sessions);
@@ -36,6 +47,13 @@
const appearancePreference = window.dockmarkAppearance?.apply(
appearancePayload?.settings?.preference ?? snapshot.appearancePreference ?? "system",
) ?? "system";
+ const remoteLocale = typeof appearancePayload?.settings?.locale === "string"
+ ? appearancePayload.settings.locale
+ : null;
+ const localePreference = remoteLocale
+ ? (window.dockmarkI18n?.apply(remoteLocale)?.preference ?? "system")
+ : (window.dockmarkI18n?.currentPreference() ?? "system");
+
snapshot = {
version: CACHE_VERSION,
origin,
@@ -51,6 +69,7 @@
smartCollections: asArray(settingsPayload?.smartCollections),
inboxBookmarkIds: asArray(settingsPayload?.inboxBookmarkIds).filter((id) => typeof id === "string" && id.trim()),
appearancePreference,
+ localePreference,
};
await chrome.storage.local.set({
@@ -58,19 +77,26 @@
[SETTINGS_KEY]: settings,
});
await loadOpenTabs();
- setConnection("Online · synced", "online");
+ setConnectionKey("online", "online");
setOfflineMessage("");
elements.setup.hidden = true;
renderSnapshot();
return true;
} catch (error) {
const hasCache = Boolean(snapshot.syncedAt || snapshot.bookmarks.length || snapshot.workspaces.length);
- setConnection(hasCache ? "Offline cache" : "Offline", "offline");
- setOfflineMessage(
- hasCache
- ? `Cloud refresh failed. Using the local snapshot from ${timeAgo(snapshot.syncedAt)}. Search and launch still work.`
- : (error instanceof Error ? error.message : "Dockmark is unavailable and there is no local snapshot yet."),
- );
+ setConnectionKey(hasCache ? "offline-cache" : "offline", "offline");
+ if (hasCache) {
+ setOfflineKey("refresh-failed-cached");
+ } else {
+ setOfflineMessage(
+ error instanceof Error
+ ? error.message
+ : tx(
+ "Dockmark is unavailable and there is no local snapshot yet.",
+ "无法连接 Dockmark,且当前没有可用的本地快照。",
+ ),
+ );
+ }
elements.setup.hidden = hasCache;
return false;
} finally {
diff --git a/apps/extension/public/newtab-parity.js b/apps/extension/public/newtab-parity.js
index ff067da..f3ffee6 100644
--- a/apps/extension/public/newtab-parity.js
+++ b/apps/extension/public/newtab-parity.js
@@ -1,3 +1,9 @@
+/**
+ * [INPUT]: depends on globals from newtab.js and newtab-ux.js (buildResults, renderSearchResults, tx) and window.dockmarkI18n
+ * [OUTPUT]: enforces canonical Web Launcher result ranking, eight-result cap with default search slot, localized kind badges, and Escape-to-blur
+ * [POS]: final parity wrapper loaded last in apps/extension/public/newtab.html
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
(() => {
const LAUNCHER_RESULT_LIMIT = 8;
const SOURCE_WEIGHT = {
@@ -9,15 +15,27 @@
navigation: 200,
search: 100,
};
- const KIND_LABEL = {
- tab: "Open tab",
- workspace: "Workspace",
- session: "Session",
- collection: "Collection",
- bookmark: "Bookmark",
- navigation: "Navigation",
- search: "Search",
- "search-shortcut": "Bang",
+ const KIND_LABELS = {
+ en: {
+ tab: "Open tab",
+ workspace: "Workspace",
+ session: "Session",
+ collection: "Collection",
+ bookmark: "Bookmark",
+ navigation: "Navigation",
+ search: "Search",
+ "search-shortcut": "Bang",
+ },
+ "zh-CN": {
+ tab: "打开的标签页",
+ workspace: "工作区",
+ session: "会话",
+ collection: "智能合集",
+ bookmark: "书签",
+ navigation: "导航",
+ search: "搜索",
+ "search-shortcut": "快捷搜索",
+ },
};
const originalBuildResults = buildResults;
const originalRenderSearchResults = renderSearchResults;
@@ -52,13 +70,13 @@
function workspaceResult(query, workspace) {
const items = asArray(workspace?.items).filter((item) => isHttpUrl(item?.url));
- const subtitle = `${items.length} tab${items.length === 1 ? "" : "s"}`;
+ const subtitle = tx(`${items.length} tab${items.length === 1 ? "" : "s"}`, `${items.length} 个标签页`);
const secondary = [workspace?.description, subtitle, ...items.flatMap((item) => [item?.title, item?.url])];
const match = parityTextScore(query, workspace?.name, secondary, 30);
if (match < 0) return null;
return {
kind: "workspace",
- title: workspace?.name || "Workspace",
+ title: workspace?.name || tx("Workspace", "工作区"),
subtitle,
workspace,
score: SOURCE_WEIGHT.workspace + match,
@@ -70,8 +88,13 @@
const keyword = typeof engine?.keyword === "string" ? engine.keyword.trim() : "";
return {
kind: "search",
- title: `Search ${engine?.name || "the web"} for “${query}”`,
- subtitle: keyword ? `Default · !${keyword}` : "Default search engine",
+ title: tx(
+ `Search ${engine?.name || "the web"} for “${query}”`,
+ `使用 ${engine?.name || "网页搜索"} 搜索“${query}”`,
+ ),
+ subtitle: keyword
+ ? tx(`Default · !${keyword}`, `默认引擎 · !${keyword}`)
+ : tx("Default search engine", "默认搜索引擎"),
url: searchUrl(engine, query),
score: SOURCE_WEIGHT.search,
};
@@ -91,10 +114,11 @@
}) || null;
const source = sourceDevice ? ` · ${sourceDevice}` : "";
const itemMatch = matchedItem ? ` · ${matchedItem.title || displayHost(matchedItem.url)} · ${matchedItem.url}` : "";
+ const countLabel = tx(`${items.length} tab${items.length === 1 ? "" : "s"}`, `${items.length} 个标签页`);
return {
kind: "session",
- title: session?.name || "Session",
- subtitle: `${items.length} tab${items.length === 1 ? "" : "s"}${source}${itemMatch}`,
+ title: session?.name || tx("Session", "会话"),
+ subtitle: `${countLabel}${source}${itemMatch}`,
session,
score: SOURCE_WEIGHT.session + match - index * 0.001,
};
@@ -139,10 +163,12 @@
renderSearchResults = function parityRenderSearchResults() {
originalRenderSearchResults();
+ const locale = window.dockmarkI18n?.currentLocale?.() === "zh-CN" ? "zh-CN" : "en";
+ const labelsMap = KIND_LABELS[locale] || KIND_LABELS.en;
const labels = elements.results.querySelectorAll(".result-kind");
labels.forEach((label, index) => {
const kind = visibleResults[index]?.kind;
- label.textContent = KIND_LABEL[kind] || kind || "";
+ label.textContent = labelsMap[kind] || kind || "";
});
};
diff --git a/apps/extension/public/newtab-search.js b/apps/extension/public/newtab-search.js
index cb0768c..3c7219c 100644
--- a/apps/extension/public/newtab-search.js
+++ b/apps/extension/public/newtab-search.js
@@ -1,3 +1,9 @@
+/**
+ * [INPUT]: depends on globals from newtab.js (buildResults, executeResult, refreshCloud, collectionMatchesBookmark, normalizedTags, tx)
+ * [OUTPUT]: enhances buildResults and executeResult with #tag filtering, Smart Collection search, and @Collection browsing
+ * [POS]: local-first Smart Collection and tag search layer loaded after newtab-library-cache.js in apps/extension/public/newtab.html
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
(() => {
const LOCAL_CACHE_KEY = "dockmarkNewTabCacheV1";
const originalBuildResults = buildResults;
@@ -5,12 +11,6 @@
const originalExecuteResult = executeResult;
let syncingLibraryMetadata = false;
- function normalizedTags(bookmark) {
- return asArray(bookmark?.tags)
- .filter((tag) => typeof tag === "string" && tag.trim())
- .map((tag) => tag.trim());
- }
-
function bookmarkResult(rawQuery, bookmark) {
if (!isHttpUrl(bookmark?.url)) return null;
const query = rawQuery.trim().toLocaleLowerCase();
@@ -64,42 +64,6 @@
};
}
- function inboxIdSet() {
- return new Set(
- asArray(snapshot.inboxBookmarkIds)
- .filter((id) => typeof id === "string" && id.trim()),
- );
- }
-
- function collectionMatchesBookmark(collection, bookmark) {
- if (!collection || !isHttpUrl(bookmark?.url)) return false;
- const filters = collection.filters && typeof collection.filters === "object" && !Array.isArray(collection.filters)
- ? collection.filters
- : {};
-
- if (Object.prototype.hasOwnProperty.call(filters, "categoryId")) {
- if (filters.categoryId === null ? Boolean(bookmark.categoryId) : bookmark.categoryId !== filters.categoryId) return false;
- }
-
- if (Array.isArray(filters.tags) && filters.tags.length) {
- const tags = new Set(normalizedTags(bookmark).map((tag) => tag.toLocaleLowerCase()));
- if (!filters.tags.every((tag) => typeof tag === "string" && tags.has(tag.toLocaleLowerCase()))) return false;
- }
-
- if (typeof filters.domain === "string" && filters.domain) {
- let host = "";
- try { host = new URL(bookmark.url).hostname.toLocaleLowerCase(); } catch { return false; }
- const domain = filters.domain.toLocaleLowerCase();
- if (host !== domain && !host.endsWith(`.${domain}`)) return false;
- }
-
- if (typeof filters.healthStatus === "string" && bookmark.healthStatus !== filters.healthStatus) return false;
- const inboxIds = inboxIdSet();
- if (filters.inbox === "inbox" && !inboxIds.has(bookmark.id)) return false;
- if (filters.inbox === "library" && inboxIds.has(bookmark.id)) return false;
- return true;
- }
-
function collectionMembers(collection) {
return asArray(snapshot.bookmarks)
.filter((bookmark) => collectionMatchesBookmark(collection, bookmark))
@@ -112,15 +76,15 @@
: {};
const labels = [];
if (Object.prototype.hasOwnProperty.call(filters, "categoryId")) {
- labels.push(filters.categoryId === null ? "Uncategorized" : categoryName(filters.categoryId));
+ labels.push(filters.categoryId === null ? tx("Uncategorized", "未分类") : categoryName(filters.categoryId));
}
for (const tag of asArray(filters.tags)) {
if (typeof tag === "string" && tag.trim()) labels.push(`#${tag.trim()}`);
}
if (typeof filters.domain === "string" && filters.domain) labels.push(filters.domain);
if (typeof filters.healthStatus === "string" && filters.healthStatus) labels.push(filters.healthStatus);
- if (filters.inbox === "inbox") labels.push("Inbox only");
- if (filters.inbox === "library") labels.push("Filed library");
+ if (filters.inbox === "inbox") labels.push(tx("Inbox only", "仅收件箱"));
+ if (filters.inbox === "library") labels.push(tx("Filed library", "已归档书签库"));
return labels;
}
@@ -141,11 +105,15 @@
else if (nameLower.includes(query)) score += 45;
else score += 20;
const count = collectionMembers(collection).length;
+ const countLabel = tx(`${count} bookmark${count === 1 ? "" : "s"}`, `${count} 条书签`);
+ const suffix = labels.length
+ ? ` · ${labels.slice(0, 4).join(" · ")}`
+ : tx(" · All bookmarks", " · 全部书签");
return {
kind: "collection",
title: name,
- subtitle: `${count} bookmark${count === 1 ? "" : "s"}${labels.length ? ` · ${labels.slice(0, 4).join(" · ")}` : " · All bookmarks"}`,
+ subtitle: `${countLabel}${suffix}`,
collection,
score,
};
@@ -257,7 +225,6 @@
renderSearchResults();
return true;
} catch {
- // Legacy cache hydration is additive. Keep the last-known-good snapshot if this optional read fails.
return false;
} finally {
syncingLibraryMetadata = false;
@@ -287,8 +254,6 @@
}
}
- // Current refreshes persist tags, Smart Collections and Inbox membership with the base snapshot.
- // Only an older last-known-good cache should need this one-time additive hydration path.
setTimeout(() => hydrateLegacySnapshotWhenReady(), 0);
queueMicrotask(() => renderSearchResults());
})();
diff --git a/apps/extension/public/newtab-theme.js b/apps/extension/public/newtab-theme.js
index 0ab31bf..a1b0285 100644
--- a/apps/extension/public/newtab-theme.js
+++ b/apps/extension/public/newtab-theme.js
@@ -1,3 +1,9 @@
+/**
+ * [INPUT]: depends on localStorage, matchMedia, and optional chrome.storage.local
+ * [OUTPUT]: exposes window.dockmarkAppearance ({ apply, current, cycle, hydrate }) and updates html[data-theme] before first paint
+ * [POS]: head-loaded theme bootstrapper for apps/extension/public/newtab.html
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
(() => {
const STORAGE_KEY = "dockmarkAppearanceV1";
@@ -5,6 +11,22 @@
return value === "light" || value === "dark" || value === "system" ? value : "system";
}
+ function safeLocalGet() {
+ try {
+ return localStorage.getItem(STORAGE_KEY);
+ } catch {
+ return null;
+ }
+ }
+
+ function safeLocalSet(value) {
+ try {
+ localStorage.setItem(STORAGE_KEY, value);
+ } catch {
+ // Ignore storage errors in restricted contexts.
+ }
+ }
+
function resolved(preference) {
if (preference === "system") {
return matchMedia("(prefers-color-scheme: light)").matches ? "light" : "dark";
@@ -12,6 +34,10 @@
return preference;
}
+ function notify(preference, theme) {
+ window.dispatchEvent(new CustomEvent("dockmark:appearance", { detail: { preference, theme } }));
+ }
+
function apply(preference, persist = true) {
const normalized = normalize(preference);
const theme = resolved(normalized);
@@ -20,19 +46,67 @@
document.documentElement.style.colorScheme = theme;
const meta = document.querySelector('meta[name="theme-color"]');
if (meta) meta.setAttribute("content", theme === "light" ? "#f4f7f5" : "#0a0f0c");
- if (persist) localStorage.setItem(STORAGE_KEY, normalized);
+ if (persist) {
+ safeLocalSet(normalized);
+ try {
+ chrome?.storage?.local?.set({ [STORAGE_KEY]: normalized }).catch?.(() => undefined);
+ } catch {
+ // Ignore when running outside extension context.
+ }
+ }
+ notify(normalized, theme);
return normalized;
}
function current() {
- return normalize(localStorage.getItem(STORAGE_KEY));
+ return normalize(safeLocalGet());
+ }
+
+ function cycle() {
+ const order = ["system", "light", "dark"];
+ const next = order[(order.indexOf(current()) + 1) % order.length];
+ return apply(next, true);
+ }
+
+ async function hydrate() {
+ const localRaw = safeLocalGet();
+ if (localRaw !== null) return apply(localRaw, false);
+ try {
+ const stored = await chrome?.storage?.local?.get(STORAGE_KEY);
+ if (stored && stored[STORAGE_KEY] !== undefined) {
+ return apply(stored[STORAGE_KEY], false);
+ }
+ } catch {
+ // Fall back to system appearance.
+ }
+ return apply("system", false);
}
apply(current(), false);
+
const media = matchMedia("(prefers-color-scheme: light)");
media.addEventListener("change", () => {
if (current() === "system") apply("system", false);
});
- window.dockmarkAppearance = { apply, current };
+ window.addEventListener("storage", (event) => {
+ if (event.key === STORAGE_KEY) apply(event.newValue, false);
+ });
+
+ try {
+ chrome?.storage?.onChanged?.addListener((changes, areaName) => {
+ if (areaName !== "local" || !changes[STORAGE_KEY]) return;
+ const nextValue = changes[STORAGE_KEY].newValue;
+ const normalized = apply(nextValue, false);
+ if (nextValue === undefined) {
+ try { localStorage.removeItem(STORAGE_KEY); } catch { /* ignore */ }
+ } else {
+ safeLocalSet(normalized);
+ }
+ });
+ } catch {
+ // Ignore outside extension context.
+ }
+
+ window.dockmarkAppearance = { STORAGE_KEY, apply, current, cycle, hydrate, resolved };
})();
diff --git a/apps/extension/public/newtab-ux.js b/apps/extension/public/newtab-ux.js
index 03cf05e..eb60d13 100644
--- a/apps/extension/public/newtab-ux.js
+++ b/apps/extension/public/newtab-ux.js
@@ -1,3 +1,9 @@
+/**
+ * [INPUT]: depends on globals from newtab.js and newtab-search.js (buildResults, executeResult, refreshCloud, tx)
+ * [OUTPUT]: adds bare ! bang suggestions, Session search/restore, Shift/Ctrl+Enter open modifiers, / focus shortcut, and launcher focus messages
+ * [POS]: launcher keyboard and Session UX layer loaded after newtab-search.js in apps/extension/public/newtab.html
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
(() => {
const LOCAL_CACHE_KEY = "dockmarkNewTabCacheV1";
const SERVER_URL_KEY = "dockmarkServerUrl";
@@ -23,7 +29,7 @@
return {
kind: "search-shortcut",
title: engine.name || `!${engine.keyword}`,
- subtitle: `!${engine.keyword} · type a query`,
+ subtitle: tx(`!${engine.keyword} · type a query`, `!${engine.keyword} · 输入搜索关键词`),
engine,
score: 1200 - index,
};
@@ -59,7 +65,8 @@
const itemMatch = matchedItem
? ` · ${matchedItem.title || displayHost(matchedItem.url)} · ${matchedItem.url}`
: "";
- const subtitle = `${items.length} tab${items.length === 1 ? "" : "s"}${source}${itemMatch}`;
+ const countLabel = tx(`${items.length} tab${items.length === 1 ? "" : "s"}`, `${items.length} 个标签页`);
+ const subtitle = `${countLabel}${source}${itemMatch}`;
let score = searchScore(query, session?.name, sourceDevice, 430);
if (score < 0 && matchedItem) score = searchScore(query, matchedItem?.title, matchedItem?.url, 400);
@@ -67,7 +74,7 @@
return {
kind: "session",
- title: session.name || "Session",
+ title: session.name || tx("Session", "会话"),
subtitle,
session,
score: score - index * 0.001,
@@ -210,8 +217,6 @@
const refreshed = await originalRefreshCloud(options);
if (!refreshed) return refreshed;
- // Current library refreshes persist Sessions with the normal snapshot. This fallback
- // only covers an early bootstrap that began before the library wrapper was installed.
if (!Array.isArray(snapshot.sessions)) await hydrateSessions(previousSessions);
return refreshed;
};
@@ -225,8 +230,6 @@
return;
}
- // bootstrap() can start before this UX layer is installed and write a base snapshot
- // without Sessions. Observe that write so the race cannot erase Session search.
const previousSessions = asArray(change.oldValue?.sessions);
if (previousSessions.length) applySessions(previousSessions);
void hydrateSessions(previousSessions);
diff --git a/apps/extension/public/newtab.css b/apps/extension/public/newtab.css
index cb536ec..c48f42b 100644
--- a/apps/extension/public/newtab.css
+++ b/apps/extension/public/newtab.css
@@ -7,112 +7,628 @@
--dm-surface-hover: #17201b;
--dm-surface-selected: #1d2a23;
--dm-input-bg: #0d1410;
- --dm-border: #26302b;
- --dm-border-strong: #34403a;
+ --dm-border: #232d28;
+ --dm-border-strong: #324039;
--dm-text: #edf3ef;
- --dm-text-soft: #a9b4ad;
- --dm-text-muted: #8b968f;
- --dm-placeholder: #64726a;
+ --dm-text-soft: #b2bdb6;
+ --dm-text-muted: #84918a;
+ --dm-placeholder: #5f6d65;
--dm-accent: #91bc9f;
--dm-accent-strong: #b8e0c5;
- --dm-focus-ring: rgba(145, 188, 159, .16);
+ --dm-accent-soft: rgba(145, 188, 159, .14);
+ --dm-focus-ring: rgba(145, 188, 159, .18);
background: var(--dm-bg);
color: var(--dm-text);
}
-* { box-sizing: border-box; scrollbar-color: #34483d var(--dm-bg); }
+
+* { box-sizing: border-box; scrollbar-width: thin; scrollbar-color: #34483d transparent; }
::selection { color: #f6fbf8; background: #315f47; }
html, body { margin: 0; min-height: 100%; }
+
body {
min-height: 100vh;
background:
- radial-gradient(circle at 18% 0%, rgba(104, 156, 120, .13), transparent 34rem),
- radial-gradient(circle at 85% 12%, rgba(86, 115, 98, .08), transparent 26rem),
+ radial-gradient(circle at 22% 0%, rgba(104, 156, 120, .12), transparent 32rem),
+ radial-gradient(circle at 84% 10%, rgba(86, 115, 98, .07), transparent 24rem),
var(--dm-bg);
}
+
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--dm-accent); outline-offset: 2px; }
-.app-shell { width: min(1120px, calc(100vw - 40px)); margin: 0 auto; padding: 30px 0 46px; }
-.topbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; min-height: 42px; }
-.brand { display: flex; align-items: center; gap: 11px; }
-.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--dm-border-strong); border-radius: 10px; background: var(--dm-surface-hover); color: var(--dm-accent-strong); font-weight: 760; letter-spacing: -.08em; }
-.brand-copy { display: grid; gap: 1px; }
-.brand-copy strong { font-size: 14px; letter-spacing: -.02em; }
-.brand-copy span { color: var(--dm-text-muted); font-size: 11px; }
-.top-actions { display: flex; align-items: center; gap: 8px; }
-.state-chip { padding: 7px 10px; border: 1px solid var(--dm-border); border-radius: 999px; color: var(--dm-text-muted); background: rgba(15, 21, 18, .88); font-size: 11px; }
-.state-chip.online { border-color: #315a3e; color: #9dcdab; background: rgba(24, 46, 31, .58); }
-.state-chip.offline { border-color: #5d5033; color: #d0b476; background: rgba(54, 45, 24, .42); }
-.icon-button, .ghost-button {
+
+.app-shell {
+ width: min(1100px, calc(100vw - 36px));
+ margin: 0 auto;
+ padding: 20px 0 36px;
+}
+
+/* Compact Topbar */
+.topbar {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 14px;
+ min-height: 36px;
+}
+
+.brand {
+ display: flex;
+ align-items: center;
+ gap: 9px;
+}
+
+.brand-mark {
+ display: grid;
+ place-items: center;
+ width: 30px;
+ height: 30px;
+ border: 1px solid var(--dm-border-strong);
+ border-radius: 8px;
+ background: var(--dm-surface-hover);
+ color: var(--dm-accent-strong);
+ font-size: 12px;
+ font-weight: 760;
+ letter-spacing: -.08em;
+}
+
+.brand-copy {
+ display: flex;
+ align-items: baseline;
+ gap: 7px;
+}
+
+.brand-copy strong {
+ font-size: 14px;
+ font-weight: 680;
+ letter-spacing: -.02em;
+}
+
+.brand-copy span {
+ color: var(--dm-text-muted);
+ font-size: 11px;
+}
+
+.top-actions {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+}
+
+.state-chip {
+ display: inline-flex;
+ align-items: center;
+ height: 30px;
+ padding: 0 10px;
border: 1px solid var(--dm-border);
- border-radius: 10px;
+ border-radius: 999px;
+ color: var(--dm-text-muted);
+ background: rgba(15, 21, 18, .88);
+ font-size: 11px;
+ white-space: nowrap;
+}
+
+.state-chip.online {
+ border-color: #315a3e;
+ color: #9dcdab;
+ background: rgba(24, 46, 31, .56);
+}
+
+.state-chip.offline {
+ border-color: #5d5033;
+ color: #d0b476;
+ background: rgba(54, 45, 24, .42);
+}
+
+.icon-button,
+.pill-button,
+.ghost-button {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ height: 30px;
+ border: 1px solid var(--dm-border);
+ border-radius: 8px;
background: rgba(18, 25, 21, .9);
+ color: var(--dm-text-soft);
cursor: pointer;
transition: border-color .12s ease, background .12s ease, color .12s ease;
}
-.icon-button { width: 35px; height: 35px; }
-.ghost-button { padding: 8px 11px; color: var(--dm-text-soft); font-size: 12px; }
-.icon-button:hover, .ghost-button:hover { border-color: #4b6254; background: var(--dm-surface-selected); color: var(--dm-text); }
-.hero { padding: clamp(52px, 9vh, 96px) 0 30px; text-align: center; }
-.eyebrow { margin: 0 0 14px; color: #84ae91; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; }
-.hero h1 { margin: 0 auto; max-width: 760px; font-size: clamp(38px, 6vw, 68px); line-height: .96; letter-spacing: -.055em; font-weight: 720; }
-.hero-subtitle { margin: 18px auto 0; max-width: 620px; color: var(--dm-text-muted); font-size: 14px; line-height: 1.6; }
-.hero-subtitle strong { color: var(--dm-text-soft); font-weight: 620; }
-.command-wrap { position: relative; width: min(760px, 100%); margin: 30px auto 0; text-align: left; }
+
+.icon-button {
+ width: 30px;
+ padding: 0;
+ font-size: 13px;
+}
+
+.pill-button {
+ padding: 0 9px;
+ font-size: 11px;
+ font-weight: 560;
+}
+
+.ghost-button {
+ padding: 0 10px;
+ font-size: 11.5px;
+ font-weight: 540;
+}
+
+.icon-button:hover,
+.pill-button:hover,
+.ghost-button:hover {
+ border-color: #4b6254;
+ background: var(--dm-surface-selected);
+ color: var(--dm-text);
+}
+
+/* Spotlight Command Area */
+.hero {
+ padding: 28px 0 18px;
+ text-align: center;
+}
+
+.command-wrap {
+ position: relative;
+ width: min(740px, 100%);
+ margin: 0 auto;
+ text-align: left;
+}
+
+.command-icon {
+ position: absolute;
+ left: 16px;
+ top: 50%;
+ transform: translateY(-50%);
+ color: var(--dm-text-muted);
+ font-size: 16px;
+ pointer-events: none;
+}
+
.command-input {
width: 100%;
- height: 58px;
- padding: 0 52px 0 18px;
+ height: 52px;
+ padding: 0 46px 0 42px;
border: 1px solid var(--dm-border-strong);
- border-radius: 16px;
+ border-radius: 14px;
background: rgba(13, 20, 16, .96);
color: var(--dm-text);
caret-color: var(--dm-accent);
- box-shadow: 0 18px 60px rgba(0,0,0,.22), inset 0 0 0 1px rgba(255,255,255,.018);
- font-size: 16px;
+ box-shadow: 0 14px 48px rgba(0, 0, 0, .24), inset 0 0 0 1px rgba(255, 255, 255, .02);
+ font-size: 15px;
+ transition: border-color .14s ease, box-shadow .14s ease;
+}
+
+.command-input:hover { border-color: #41554a; }
+.command-input:focus-visible {
+ border-color: var(--dm-accent);
+ box-shadow: 0 0 0 3px var(--dm-focus-ring), 0 14px 48px rgba(0, 0, 0, .24);
+ outline: 0;
}
-.command-input:hover { border-color: #405148; }
-.command-input:focus-visible { border-color: var(--dm-accent); box-shadow: 0 0 0 3px var(--dm-focus-ring), 0 18px 60px rgba(0,0,0,.22); outline: 0; }
.command-input::placeholder { color: var(--dm-placeholder); opacity: 1; }
-.command-hint { position: absolute; right: 15px; top: 17px; padding: 4px 6px; border: 1px solid var(--dm-border); border-radius: 6px; color: var(--dm-text-muted); background: var(--dm-surface); font: 10px ui-monospace, SFMono-Regular, Menlo, monospace; }
-.command-results { position: absolute; z-index: 20; inset: 66px 0 auto; overflow: hidden; border: 1px solid var(--dm-border-strong); border-radius: 14px; background: rgba(10, 15, 12, .985); box-shadow: 0 26px 80px rgba(0,0,0,.42); }
+
+.command-hint {
+ position: absolute;
+ right: 13px;
+ top: 50%;
+ transform: translateY(-50%);
+ padding: 3px 6px;
+ border: 1px solid var(--dm-border);
+ border-radius: 6px;
+ color: var(--dm-text-muted);
+ background: var(--dm-surface);
+ font: 10px ui-monospace, SFMono-Regular, Menlo, monospace;
+}
+
+.syntax-hints {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ justify-content: center;
+ gap: 8px;
+ margin-top: 10px;
+ color: var(--dm-text-muted);
+ font-size: 11px;
+}
+
+.syntax-hints span {
+ display: inline-flex;
+ align-items: center;
+ gap: 5px;
+}
+
+.syntax-hints em {
+ font-style: normal;
+}
+
+.syntax-hints kbd {
+ padding: 1px 5px;
+ border: 1px solid var(--dm-border);
+ border-radius: 5px;
+ background: var(--dm-surface);
+ color: var(--dm-text-soft);
+ font: 10px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
+}
+
+.hint-sep {
+ opacity: .45;
+}
+
+.command-results {
+ position: absolute;
+ z-index: 25;
+ inset: 58px 0 auto;
+ overflow: hidden;
+ border: 1px solid var(--dm-border-strong);
+ border-radius: 13px;
+ background: rgba(10, 15, 12, .985);
+ box-shadow: 0 24px 72px rgba(0, 0, 0, .44);
+}
+
.command-results[hidden] { display: none; }
-.result-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px; width: 100%; min-height: 57px; padding: 11px 14px; border: 0; border-top: 1px solid #1f2923; background: transparent; cursor: pointer; text-align: left; transition: background .1s ease; }
+
+.result-row {
+ display: grid;
+ grid-template-columns: minmax(0, 1fr) auto;
+ gap: 16px;
+ width: 100%;
+ min-height: 52px;
+ padding: 9px 14px;
+ border: 0;
+ border-top: 1px solid #1d2721;
+ background: transparent;
+ cursor: pointer;
+ text-align: left;
+ transition: background .1s ease;
+}
+
.result-row:first-child { border-top: 0; }
.result-row:hover, .result-row.active { background: var(--dm-surface-selected); }
-.result-copy { min-width: 0; display: grid; gap: 3px; }
-.result-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dm-text); font-size: 13px; font-weight: 620; }
-.result-copy small { overflow: hidden; color: var(--dm-text-muted); text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
-.result-kind { align-self: center; color: #8da597; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; }
-.dashboard { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr); gap: 16px; margin-top: 22px; }
-.panel { min-width: 0; padding: 20px; border: 1px solid var(--dm-border); border-radius: 18px; background: rgba(15, 21, 18, .82); }
-.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
-.panel-heading h2 { margin: 0; font-size: 13px; font-weight: 650; letter-spacing: -.01em; }
-.panel-heading span { color: var(--dm-text-muted); font-size: 11px; }
-.bookmark-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
-.bookmark-card, .workspace-card { width: 100%; border: 1px solid var(--dm-border); border-radius: 12px; background: var(--dm-surface-raised); color: var(--dm-text-soft); cursor: pointer; text-align: left; transition: border-color .12s ease, background .12s ease, color .12s ease; }
-.bookmark-card { min-height: 68px; padding: 12px; }
-.bookmark-card:hover, .workspace-card:hover { border-color: #466052; background: var(--dm-surface-selected); color: var(--dm-text); }
-.bookmark-card strong, .workspace-card strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dm-text); font-size: 12px; font-weight: 620; }
-.bookmark-card small, .workspace-card small { display: block; overflow: hidden; margin-top: 5px; color: var(--dm-text-muted); text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
-.workspace-list { display: grid; gap: 8px; }
-.workspace-card { padding: 13px; }
-.workspace-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 6px; color: var(--dm-text-muted); font-size: 10px; }
-.empty-state { padding: 24px 4px; color: var(--dm-text-muted); font-size: 12px; line-height: 1.6; }
-.footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 14px; color: #68756d; font-size: 10px; }
-.footer strong { color: #8c9a92; font-weight: 580; }
-.footer-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
-.footer-button { min-height: 26px; padding: 0 7px; border: 0; border-radius: 7px; background: transparent; color: #8ca095; cursor: pointer; font-size: 10px; }
-.footer-button:hover { color: var(--dm-accent-strong); background: var(--dm-surface); }
-.offline-banner { margin: 14px auto 0; width: min(760px, 100%); padding: 10px 12px; border: 1px solid #5d5033; border-radius: 10px; background: rgba(74, 57, 23, .16); color: #c2ad7c; font-size: 11px; line-height: 1.5; text-align: left; }
+
+.result-copy {
+ min-width: 0;
+ display: grid;
+ gap: 2px;
+}
+
+.result-copy strong {
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ color: var(--dm-text);
+ font-size: 13px;
+ font-weight: 600;
+}
+
+.result-copy small {
+ overflow: hidden;
+ color: var(--dm-text-muted);
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ font-size: 11px;
+}
+
+.result-kind {
+ align-self: center;
+ padding: 2px 7px;
+ border-radius: 6px;
+ background: var(--dm-surface);
+ color: #93b09f;
+ font-size: 10px;
+ font-weight: 560;
+ letter-spacing: .04em;
+ text-transform: uppercase;
+}
+
+/* Dashboard Panels */
+.dashboard {
+ display: grid;
+ grid-template-columns: minmax(0, 1.42fr) minmax(272px, .58fr);
+ gap: 14px;
+ margin-top: 12px;
+}
+
+.panel {
+ min-width: 0;
+ padding: 16px 18px 18px;
+ border: 1px solid var(--dm-border);
+ border-radius: 15px;
+ background: rgba(15, 21, 18, .84);
+}
+
+.panel-heading {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 12px;
+ margin-bottom: 12px;
+}
+
+.panel-heading h2 {
+ margin: 0;
+ font-size: 13px;
+ font-weight: 650;
+ letter-spacing: -.01em;
+}
+
+.panel-heading span {
+ color: var(--dm-text-muted);
+ font-size: 11px;
+}
+
+/* Category & @Collection Quick Filter Pills */
+.filter-strip {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 6px;
+ margin-bottom: 12px;
+}
+
+.filter-strip[hidden] { display: none; }
+
+.filter-pill {
+ display: inline-flex;
+ align-items: center;
+ gap: 4px;
+ height: 26px;
+ padding: 0 9px;
+ border: 1px solid var(--dm-border);
+ border-radius: 999px;
+ background: var(--dm-surface);
+ color: var(--dm-text-soft);
+ font-size: 11px;
+ font-weight: 520;
+ cursor: pointer;
+ transition: border-color .12s ease, background .12s ease, color .12s ease;
+}
+
+.filter-pill:hover {
+ border-color: var(--dm-border-strong);
+ background: var(--dm-surface-hover);
+ color: var(--dm-text);
+}
+
+.filter-pill.active {
+ border-color: var(--dm-accent);
+ background: var(--dm-accent-soft);
+ color: var(--dm-accent-strong);
+ font-weight: 620;
+}
+
+.filter-pill.is-collection::before {
+ content: "@";
+ color: var(--dm-accent);
+ font-weight: 700;
+}
+
+/* Upgraded Bookmark Cards */
+.bookmark-grid {
+ display: grid;
+ grid-template-columns: repeat(2, minmax(0, 1fr));
+ gap: 8px;
+}
+
+.bookmark-card,
+.workspace-card {
+ width: 100%;
+ border: 1px solid var(--dm-border);
+ border-radius: 11px;
+ background: var(--dm-surface-raised);
+ color: var(--dm-text-soft);
+ cursor: pointer;
+ text-align: left;
+ transition: border-color .12s ease, background .12s ease, color .12s ease, transform .12s ease;
+}
+
+.bookmark-card {
+ display: grid;
+ grid-template-columns: 30px minmax(0, 1fr);
+ align-items: start;
+ gap: 10px;
+ min-height: 62px;
+ padding: 10px 11px;
+}
+
+.bookmark-card:hover,
+.workspace-card:hover:not(:disabled) {
+ border-color: #466052;
+ background: var(--dm-surface-selected);
+ color: var(--dm-text);
+ transform: translateY(-1px);
+}
+
+.bookmark-card:active,
+.workspace-card:active:not(:disabled) {
+ transform: translateY(0);
+}
+
+.card-monogram {
+ display: grid;
+ place-items: center;
+ width: 30px;
+ height: 30px;
+ border: 1px solid var(--dm-border-strong);
+ border-radius: 8px;
+ background: var(--dm-accent-soft);
+ color: var(--dm-accent-strong);
+ font-size: 12px;
+ font-weight: 700;
+}
+
+.bookmark-card-body {
+ display: grid;
+ gap: 3px;
+ min-width: 0;
+}
+
+.bookmark-card strong,
+.workspace-card strong {
+ display: block;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ color: var(--dm-text);
+ font-size: 12.5px;
+ font-weight: 600;
+}
+
+.bookmark-card-meta {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ min-width: 0;
+}
+
+.bookmark-card small {
+ overflow: hidden;
+ color: var(--dm-text-muted);
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ font-size: 10.5px;
+}
+
+.bookmark-tag-pill {
+ flex-shrink: 0;
+ padding: 1px 6px;
+ border: 1px solid var(--dm-border);
+ border-radius: 999px;
+ background: var(--dm-surface);
+ color: var(--dm-accent);
+ font-size: 9.5px;
+ font-weight: 560;
+}
+
+/* Upgraded Workspace Cards */
+.workspace-list {
+ display: grid;
+ gap: 8px;
+}
+
+.workspace-card {
+ padding: 11px 12px;
+}
+
+.workspace-card:disabled {
+ opacity: .52;
+ cursor: default;
+}
+
+.workspace-head {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 8px;
+}
+
+.workspace-action {
+ color: var(--dm-accent);
+ font-size: 11px;
+ font-weight: 580;
+ white-space: nowrap;
+}
+
+.workspace-meta {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ gap: 6px;
+ margin-top: 6px;
+ color: var(--dm-text-muted);
+ font-size: 10.5px;
+}
+
+.mode-badge {
+ padding: 1px 6px;
+ border: 1px solid var(--dm-border);
+ border-radius: 999px;
+ background: var(--dm-surface);
+ color: var(--dm-text-soft);
+ font-size: 9.5px;
+}
+
+.empty-state {
+ padding: 20px 4px;
+ color: var(--dm-text-muted);
+ font-size: 12px;
+ line-height: 1.55;
+}
+
+/* Banners & Footer */
+.offline-banner {
+ margin: 12px auto 0;
+ width: min(740px, 100%);
+ padding: 9px 12px;
+ border: 1px solid #5d5033;
+ border-radius: 10px;
+ background: rgba(74, 57, 23, .16);
+ color: #c7b280;
+ font-size: 11px;
+ line-height: 1.5;
+ text-align: left;
+}
+
.offline-banner[hidden] { display: none; }
-.setup-card { width: min(620px, 100%); margin: 26px auto 0; padding: 22px; border: 1px solid var(--dm-border-strong); border-radius: 16px; background: rgba(15, 21, 18, .94); text-align: left; }
-.setup-card h2 { margin: 0 0 8px; font-size: 18px; }
-.setup-card p { margin: 0; color: var(--dm-text-muted); line-height: 1.6; font-size: 12px; }
+
+.setup-card {
+ width: min(620px, 100%);
+ margin: 18px auto 0;
+ padding: 18px 20px;
+ border: 1px solid var(--dm-border-strong);
+ border-radius: 14px;
+ background: rgba(15, 21, 18, .94);
+ text-align: left;
+}
+
+.setup-card h2 {
+ margin: 0 0 6px;
+ font-size: 15px;
+ font-weight: 650;
+}
+
+.setup-card p {
+ margin: 0;
+ color: var(--dm-text-muted);
+ line-height: 1.55;
+ font-size: 12px;
+}
+
.setup-card[hidden] { display: none; }
-@media (max-width: 780px) {
- .app-shell { width: min(100% - 24px, 1120px); padding-top: 18px; }
- .hero { padding-top: 44px; }
+
+.footer {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 14px;
+ margin-top: 14px;
+ color: #6b7870;
+ font-size: 10.5px;
+}
+
+.footer-actions {
+ display: flex;
+ align-items: center;
+ justify-content: flex-end;
+ gap: 10px;
+}
+
+.footer-button {
+ min-height: 26px;
+ padding: 0 8px;
+ border: 0;
+ border-radius: 7px;
+ background: transparent;
+ color: #8ca095;
+ cursor: pointer;
+ font-size: 10.5px;
+}
+
+.footer-button:hover {
+ color: var(--dm-accent-strong);
+ background: var(--dm-surface);
+}
+
+@media (max-width: 820px) {
+ .app-shell { width: min(100% - 24px, 1100px); padding-top: 14px; }
+ .hero { padding-top: 20px; }
.dashboard { grid-template-columns: 1fr; }
.bookmark-grid { grid-template-columns: 1fr; }
.brand-copy span { display: none; }
@@ -120,54 +636,92 @@ button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid
.footer-actions { justify-content: flex-start; flex-wrap: wrap; }
}
-
+/* Light Theme */
html[data-theme="light"] {
--dm-bg: #f4f7f5;
- --dm-surface: #edf2ef;
+ --dm-surface: #ebf1ed;
--dm-surface-raised: #ffffff;
- --dm-surface-hover: #e7efea;
- --dm-surface-selected: #dceae1;
+ --dm-surface-hover: #e5eee8;
+ --dm-surface-selected: #dae9df;
--dm-input-bg: #ffffff;
--dm-border: #d1ddd6;
- --dm-border-strong: #b7c9bf;
+ --dm-border-strong: #b6c8be;
--dm-text: #173126;
- --dm-text-soft: #4e665b;
- --dm-text-muted: #5f7168;
- --dm-placeholder: #91a097;
+ --dm-text-soft: #475f54;
+ --dm-text-muted: #5d7066;
+ --dm-placeholder: #8d9d94;
--dm-accent: #4f8063;
- --dm-accent-strong: #315f47;
+ --dm-accent-strong: #2f5b44;
+ --dm-accent-soft: rgba(79, 128, 99, .12);
--dm-focus-ring: rgba(79, 128, 99, .14);
}
html[data-theme="light"] body {
background:
- radial-gradient(circle at 18% 0%, rgba(81, 132, 101, .11), transparent 34rem),
- radial-gradient(circle at 85% 12%, rgba(86, 115, 98, .05), transparent 26rem),
+ radial-gradient(circle at 22% 0%, rgba(81, 132, 101, .1), transparent 32rem),
+ radial-gradient(circle at 84% 10%, rgba(86, 115, 98, .05), transparent 24rem),
var(--dm-bg);
}
+
html[data-theme="light"] .state-chip,
html[data-theme="light"] .icon-button,
+html[data-theme="light"] .pill-button,
html[data-theme="light"] .ghost-button,
html[data-theme="light"] .command-input,
html[data-theme="light"] .panel,
html[data-theme="light"] .setup-card {
border-color: var(--dm-border);
- background: rgba(255,255,255,.86);
+ background: rgba(255, 255, 255, .88);
color: var(--dm-text-soft);
}
-html[data-theme="light"] .command-input { box-shadow: 0 18px 60px rgba(40,67,54,.08); color: var(--dm-text); }
-html[data-theme="light"] .command-results { border-color: var(--dm-border-strong); background: rgba(255,255,255,.985); box-shadow: 0 26px 80px rgba(40,67,54,.14); }
+
+html[data-theme="light"] .command-input {
+ box-shadow: 0 14px 44px rgba(40, 67, 54, .08);
+ color: var(--dm-text);
+}
+
+html[data-theme="light"] .command-results {
+ border-color: var(--dm-border-strong);
+ background: rgba(255, 255, 255, .985);
+ box-shadow: 0 24px 72px rgba(40, 67, 54, .14);
+}
+
html[data-theme="light"] .result-row { border-color: var(--dm-border); }
+html[data-theme="light"] .result-kind { color: var(--dm-accent-strong); }
+
html[data-theme="light"] .bookmark-card,
-html[data-theme="light"] .workspace-card { border-color: var(--dm-border); background: #fff; color: var(--dm-text-soft); }
+html[data-theme="light"] .workspace-card {
+ border-color: var(--dm-border);
+ background: #ffffff;
+ color: var(--dm-text-soft);
+}
+
html[data-theme="light"] .bookmark-card:hover,
-html[data-theme="light"] .workspace-card:hover,
+html[data-theme="light"] .workspace-card:hover:not(:disabled),
html[data-theme="light"] .result-row:hover,
html[data-theme="light"] .result-row.active,
html[data-theme="light"] .icon-button:hover,
-html[data-theme="light"] .ghost-button:hover { border-color: #a8c7b5; background: var(--dm-surface-selected); color: var(--dm-text); }
-html[data-theme="light"] .state-chip.online { border-color: #a8cbb5; color: #315f47; background: #eef8f1; }
+html[data-theme="light"] .pill-button:hover,
+html[data-theme="light"] .ghost-button:hover {
+ border-color: #9ec0ac;
+ background: var(--dm-surface-selected);
+ color: var(--dm-text);
+}
+
+html[data-theme="light"] .state-chip.online {
+ border-color: #a8cbb5;
+ color: #2f5b44;
+ background: #eef8f1;
+}
+
html[data-theme="light"] .state-chip.offline,
-html[data-theme="light"] .offline-banner { border-color: #dfc995; color: #7a6328; background: #fff8e9; }
+html[data-theme="light"] .offline-banner {
+ border-color: #dfc995;
+ color: #7a6328;
+ background: #fff8e9;
+}
+
html[data-theme="light"] .footer,
-html[data-theme="light"] .footer-button { color: var(--dm-text-muted); }
+html[data-theme="light"] .footer-button {
+ color: var(--dm-text-muted);
+}
diff --git a/apps/extension/public/newtab.html b/apps/extension/public/newtab.html
index 3ace7a7..2151b4e 100644
--- a/apps/extension/public/newtab.html
+++ b/apps/extension/public/newtab.html
@@ -8,47 +8,115 @@
Dockmark New Tab
+
-
- NEW TAB · LOCAL FIRST
- Your Dockmark, ready before the network is.
- Search cached Smart Collections, bookmarks, Sessions, Workspaces and open tabs. Use !g / !gh for search engines, @Collection to browse a Collection, and #tag for tag filters. From anywhere in the browser, press Alt+Shift+D to return here or type d + Space in the address bar for Dockmark Omnibox search.
-
+
+
+
+ !g Search
+ ·
+ @ Collection
+ ·
+ # Tag
+ ·
+ Alt+Shift+D Focus launcher
+
+
-
Connect and pair Dockmark once to seed this launcher.
-
Open the Dockmark extension popup, connect it to your Dockmark server, then pair the device with a one-time code from Dockmark Settings → Security. This New Tab page keeps a last-known-good local snapshot for fast startup and offline use.
+
Connect and pair Dockmark once to seed this launcher.
+
Open the Dockmark extension popup, connect your server URL, then pair with a one-time code from Settings → Security. New Tab keeps a local snapshot for instant startup and offline search.
-
-
Bookmarks 0 cached
+
+
+
Bookmarks
+ 0 cached
+
+
-
-
Workspaces 0 cached
+
+
+
Workspaces
+ 0 cached
+
@@ -58,7 +126,16 @@ Connect and pair Dockmark once to seed this launcher.
No local snapshot yet.
diff --git a/apps/extension/public/newtab.js b/apps/extension/public/newtab.js
index d3b9e93..6a7f145 100644
--- a/apps/extension/public/newtab.js
+++ b/apps/extension/public/newtab.js
@@ -1,3 +1,9 @@
+/**
+ * [INPUT]: depends on chrome.storage.local, chrome.tabs, chrome.windows, chrome.permissions, window.dockmarkAppearance, and window.dockmarkI18n
+ * [OUTPUT]: defines shared launcher state (origin, snapshot, settings, openTabs, visibleResults), filter pills, bookmark/workspace rendering, and command execution
+ * [POS]: core runtime for apps/extension/public/newtab.html extended by newtab-library-cache.js, newtab-search.js, newtab-ux.js, and newtab-parity.js
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
const SERVER_KEY = "dockmarkServerUrl";
const CACHE_KEY = "dockmarkNewTabCacheV1";
const SETTINGS_KEY = "dockmarkBrowserSettingsV1";
@@ -8,24 +14,21 @@ const DEFAULT_SEARCH_URL = "https://www.google.com/search?q=%s";
const DEFAULT_SETTINGS = {
version: SETTINGS_VERSION,
conflictPreference: "ask",
- newTab: {
- defaultSearchEngineId: null,
- showOpenTabs: true,
- bookmarkLimit: 12,
- workspaceLimit: 8,
- autoRefresh: true,
- },
+ newTab: { defaultSearchEngineId: null, showOpenTabs: true, bookmarkLimit: 12, workspaceLimit: 8, autoRefresh: true },
updatedAt: null,
};
const elements = {
connection: document.getElementById("connection-state"),
+ themeToggle: document.getElementById("theme-toggle"),
+ localeToggle: document.getElementById("locale-toggle"),
refresh: document.getElementById("refresh"),
manage: document.getElementById("manage"),
search: document.getElementById("search"),
results: document.getElementById("command-results"),
offline: document.getElementById("offline-banner"),
setup: document.getElementById("setup-card"),
+ bookmarkFilters: document.getElementById("bookmark-filters"),
bookmarks: document.getElementById("bookmarks"),
workspaces: document.getElementById("workspaces"),
bookmarkCount: document.getElementById("bookmark-count"),
@@ -42,51 +45,40 @@ let openTabs = [];
let activeResult = 0;
let visibleResults = [];
let refreshing = false;
+let activeFilter = { type: "all", id: null };
+let connectionState = { key: "starting", customLabel: null, tone: "" };
+let offlineState = { key: "", customMessage: "" };
+
+function tx(en, zh) {
+ return window.dockmarkI18n ? window.dockmarkI18n.tx(en, zh) : en;
+}
function emptySnapshot() {
return {
- version: CACHE_VERSION,
- origin: "",
- syncedAt: null,
- bookmarks: [],
- categories: [],
- workspaces: [],
- searchEngines: [],
- appearancePreference: "system",
+ version: CACHE_VERSION, origin: "", syncedAt: null,
+ bookmarks: [], categories: [], workspaces: [], searchEngines: [],
+ smartCollections: [], inboxBookmarkIds: [],
+ appearancePreference: "system", localePreference: "system",
};
}
function normalizeSettings(value) {
const input = value && typeof value === "object" && !Array.isArray(value) ? value : {};
- const rawNewTab = input.newTab && typeof input.newTab === "object" && !Array.isArray(input.newTab)
- ? input.newTab
- : {};
- const conflictPreference = input.conflictPreference === "browser" || input.conflictPreference === "dockmark"
- ? input.conflictPreference
- : "ask";
- const defaultSearchEngineId = typeof rawNewTab.defaultSearchEngineId === "string" && rawNewTab.defaultSearchEngineId.trim()
- ? rawNewTab.defaultSearchEngineId.trim()
- : null;
- const bookmarkLimit = Number.isInteger(rawNewTab.bookmarkLimit)
- ? Math.min(24, Math.max(0, rawNewTab.bookmarkLimit))
- : DEFAULT_SETTINGS.newTab.bookmarkLimit;
- const workspaceLimit = Number.isInteger(rawNewTab.workspaceLimit)
- ? Math.min(12, Math.max(0, rawNewTab.workspaceLimit))
- : DEFAULT_SETTINGS.newTab.workspaceLimit;
+ const rawNewTab = input.newTab && typeof input.newTab === "object" && !Array.isArray(input.newTab) ? input.newTab : {};
+ const conflictPreference = input.conflictPreference === "browser" || input.conflictPreference === "dockmark" ? input.conflictPreference : "ask";
+ const defaultSearchEngineId = typeof rawNewTab.defaultSearchEngineId === "string" && rawNewTab.defaultSearchEngineId.trim() ? rawNewTab.defaultSearchEngineId.trim() : null;
+ const bookmarkLimit = Number.isInteger(rawNewTab.bookmarkLimit) ? Math.min(24, Math.max(0, rawNewTab.bookmarkLimit)) : DEFAULT_SETTINGS.newTab.bookmarkLimit;
+ const workspaceLimit = Number.isInteger(rawNewTab.workspaceLimit) ? Math.min(12, Math.max(0, rawNewTab.workspaceLimit)) : DEFAULT_SETTINGS.newTab.workspaceLimit;
return {
version: SETTINGS_VERSION,
conflictPreference,
newTab: {
defaultSearchEngineId,
- showOpenTabs: typeof rawNewTab.showOpenTabs === "boolean"
- ? rawNewTab.showOpenTabs
- : DEFAULT_SETTINGS.newTab.showOpenTabs,
+ showOpenTabs: typeof rawNewTab.showOpenTabs === "boolean" ? rawNewTab.showOpenTabs : DEFAULT_SETTINGS.newTab.showOpenTabs,
bookmarkLimit,
workspaceLimit,
- autoRefresh: typeof rawNewTab.autoRefresh === "boolean"
- ? rawNewTab.autoRefresh
- : DEFAULT_SETTINGS.newTab.autoRefresh,
+ autoRefresh: typeof rawNewTab.autoRefresh === "boolean" ? rawNewTab.autoRefresh : DEFAULT_SETTINGS.newTab.autoRefresh,
},
updatedAt: typeof input.updatedAt === "string" && input.updatedAt ? input.updatedAt : null,
};
@@ -96,11 +88,8 @@ function validOrigin(value) {
if (typeof value !== "string" || !value) return null;
try {
const url = new URL(value);
- if (url.protocol !== "http:" && url.protocol !== "https:") return null;
- return url.origin;
- } catch {
- return null;
- }
+ return url.protocol === "http:" || url.protocol === "https:" ? url.origin : null;
+ } catch { return null; }
}
function isHttpUrl(value) {
@@ -108,9 +97,7 @@ function isHttpUrl(value) {
try {
const url = new URL(value);
return url.protocol === "http:" || url.protocol === "https:";
- } catch {
- return false;
- }
+ } catch { return false; }
}
function tabMatchKey(value) {
@@ -118,61 +105,130 @@ function tabMatchKey(value) {
const url = new URL(value);
url.hash = "";
return url.href;
- } catch {
- return value;
- }
+ } catch { return value; }
}
-function asArray(value) {
- return Array.isArray(value) ? value : [];
+function asArray(value) { return Array.isArray(value) ? value : []; }
+
+function normalizedTags(bookmark) {
+ return asArray(bookmark?.tags).filter((tag) => typeof tag === "string" && tag.trim()).map((tag) => tag.trim());
}
function cacheIsUsable(value, expectedOrigin) {
return Boolean(
- value &&
- typeof value === "object" &&
- value.version === CACHE_VERSION &&
- typeof value.origin === "string" &&
- (!expectedOrigin || value.origin === expectedOrigin) &&
- Array.isArray(value.bookmarks) &&
- Array.isArray(value.workspaces),
+ value && typeof value === "object" && value.version === CACHE_VERSION &&
+ typeof value.origin === "string" && (!expectedOrigin || value.origin === expectedOrigin) &&
+ Array.isArray(value.bookmarks) && Array.isArray(value.workspaces),
);
}
function timeAgo(value) {
- if (!value) return "never";
- const timestamp = Date.parse(value);
- if (!Number.isFinite(timestamp)) return "unknown";
- const seconds = Math.max(0, Math.round((Date.now() - timestamp) / 1000));
- if (seconds < 45) return "just now";
- if (seconds < 3600) return `${Math.round(seconds / 60)}m ago`;
- if (seconds < 86400) return `${Math.round(seconds / 3600)}h ago`;
- return `${Math.round(seconds / 86400)}d ago`;
+ return window.dockmarkI18n ? window.dockmarkI18n.formatRelativeTime(value) : String(value || "never");
}
function displayHost(url) {
- try {
- return new URL(url).host;
- } catch {
- return url;
- }
+ try { return new URL(url).host; } catch { return url; }
+}
+
+function hostMonogram(url, fallbackTitle) {
+ const host = displayHost(url).replace(/^www\./i, "");
+ const match = String(host || fallbackTitle || "D").match(/[A-Za-z0-9\u4e00-\u9fff]/);
+ return (match?.[0] || "D").toUpperCase();
}
function categoryName(categoryId) {
- if (!categoryId) return "Uncategorized";
- return snapshot.categories.find((category) => category?.id === categoryId)?.name || "Uncategorized";
+ if (!categoryId) return tx("Uncategorized", "未分类");
+ return snapshot.categories.find((category) => category?.id === categoryId)?.name || tx("Uncategorized", "未分类");
}
-function setConnection(label, tone = "") {
+function collectionMatchesBookmark(collection, bookmark) {
+ if (!collection || !isHttpUrl(bookmark?.url)) return false;
+ const filters = collection.filters && typeof collection.filters === "object" && !Array.isArray(collection.filters) ? collection.filters : {};
+ if (Object.prototype.hasOwnProperty.call(filters, "categoryId")) {
+ if (filters.categoryId === null ? Boolean(bookmark.categoryId) : bookmark.categoryId !== filters.categoryId) return false;
+ }
+ if (Array.isArray(filters.tags) && filters.tags.length) {
+ const tags = new Set(normalizedTags(bookmark).map((tag) => tag.toLocaleLowerCase()));
+ if (!filters.tags.every((tag) => typeof tag === "string" && tags.has(tag.toLocaleLowerCase()))) return false;
+ }
+ if (typeof filters.domain === "string" && filters.domain) {
+ let host = "";
+ try { host = new URL(bookmark.url).hostname.toLocaleLowerCase(); } catch { return false; }
+ const domain = filters.domain.toLocaleLowerCase();
+ if (host !== domain && !host.endsWith(`.${domain}`)) return false;
+ }
+ if (typeof filters.healthStatus === "string" && bookmark.healthStatus !== filters.healthStatus) return false;
+ const inboxIds = new Set(asArray(snapshot.inboxBookmarkIds).filter((id) => typeof id === "string" && id.trim()));
+ if (filters.inbox === "inbox" && !inboxIds.has(bookmark.id)) return false;
+ if (filters.inbox === "library" && inboxIds.has(bookmark.id)) return false;
+ return true;
+}
+
+function renderConnectionState() {
+ const label = connectionState.customLabel ?? (window.dockmarkI18n ? window.dockmarkI18n.connectionText(connectionState.key) : connectionState.key);
elements.connection.textContent = label;
- elements.connection.className = `state-chip${tone ? ` ${tone}` : ""}`;
+ elements.connection.className = `state-chip${connectionState.tone ? ` ${connectionState.tone}` : ""}`;
}
-function setOfflineMessage(message) {
- elements.offline.textContent = message || "";
+function setConnection(label, tone = "") {
+ connectionState = { key: "", customLabel: label, tone };
+ renderConnectionState();
+}
+
+function setConnectionKey(key, tone = "") {
+ connectionState = { key, customLabel: null, tone };
+ renderConnectionState();
+}
+
+function renderOfflineMessage() {
+ const message = offlineState.customMessage || (window.dockmarkI18n ? window.dockmarkI18n.offlineText(offlineState.key, snapshot.syncedAt) : "");
+ elements.offline.textContent = message;
elements.offline.hidden = !message;
}
+function setOfflineMessage(message) {
+ offlineState = { key: "", customMessage: message || "" };
+ renderOfflineMessage();
+}
+
+function setOfflineKey(key) {
+ offlineState = { key, customMessage: "" };
+ renderOfflineMessage();
+}
+
+function updateTopbarControls() {
+ if (elements.themeToggle && window.dockmarkAppearance) {
+ const pref = window.dockmarkAppearance.current();
+ const icons = { system: "◐", light: "☀", dark: "☾" };
+ const labels = {
+ system: tx("Theme: System (click to switch)", "主题:跟随系统(点击切换)"),
+ light: tx("Theme: Light (click to switch)", "主题:浅色(点击切换)"),
+ dark: tx("Theme: Dark (click to switch)", "主题:深色(点击切换)"),
+ };
+ elements.themeToggle.textContent = icons[pref] || "◐";
+ elements.themeToggle.title = labels[pref] || labels.system;
+ elements.themeToggle.setAttribute("aria-label", labels[pref] || labels.system);
+ }
+ if (elements.localeToggle && window.dockmarkI18n) {
+ const locale = window.dockmarkI18n.currentLocale();
+ elements.localeToggle.textContent = locale === "zh-CN" ? "EN" : "中文";
+ const title = locale === "zh-CN" ? "Switch to English" : "切换为简体中文";
+ elements.localeToggle.title = title;
+ elements.localeToggle.setAttribute("aria-label", title);
+ }
+}
+
+async function patchCloudAppearance(payload) {
+ if (!origin || !(await hasOriginPermission())) return;
+ try {
+ await fetch(new URL("/api/settings/appearance", `${origin}/`).toString(), {
+ method: "PATCH", cache: "no-store", credentials: "omit",
+ headers: { accept: "application/json", "content-type": "application/json" },
+ body: JSON.stringify(payload),
+ });
+ } catch { /* best-effort cloud sync */ }
+}
+
function renderEmpty(container, message) {
container.replaceChildren();
const empty = document.createElement("div");
@@ -182,74 +238,174 @@ function renderEmpty(container, message) {
}
function settingsSummary() {
- const tabs = settings.newTab.showOpenTabs ? "tabs on" : "tabs off";
- const refresh = settings.newTab.autoRefresh ? "auto refresh" : "manual refresh";
- return `${settings.newTab.bookmarkLimit} bookmarks · ${settings.newTab.workspaceLimit} workspaces · ${tabs} · ${refresh}`;
+ const tabs = settings.newTab.showOpenTabs ? tx("tabs on", "标签页开") : tx("tabs off", "标签页关");
+ const refresh = settings.newTab.autoRefresh ? tx("auto refresh", "自动刷新") : tx("manual refresh", "手动刷新");
+ return tx(
+ `${settings.newTab.bookmarkLimit} bookmarks · ${settings.newTab.workspaceLimit} workspaces · ${tabs} · ${refresh}`,
+ `${settings.newTab.bookmarkLimit} 条书签 · ${settings.newTab.workspaceLimit} 个工作区 · ${tabs} · ${refresh}`,
+ );
+}
+
+function renderBookmarkFilters(allBookmarks) {
+ const container = elements.bookmarkFilters;
+ if (!container) return;
+ const collections = asArray(snapshot.smartCollections).filter((c) => typeof c?.name === "string" && c.name.trim()).sort((a, b) => (a.position ?? 0) - (b.position ?? 0));
+ const categories = asArray(snapshot.categories).filter((c) => typeof c?.name === "string" && c.name.trim()).sort((a, b) => (a.position ?? 0) - (b.position ?? 0));
+
+ if (activeFilter.type === "collection" && !collections.some((c) => c.id === activeFilter.id)) activeFilter = { type: "all", id: null };
+ else if (activeFilter.type === "category" && activeFilter.id !== "__uncategorized__" && !categories.some((c) => c.id === activeFilter.id)) activeFilter = { type: "all", id: null };
+
+ if (!collections.length && !categories.length) {
+ container.replaceChildren();
+ container.hidden = true;
+ return;
+ }
+
+ container.hidden = false;
+ container.replaceChildren();
+
+ const makePill = (label, filter, isCollection = false) => {
+ const isActive = activeFilter.type === filter.type && activeFilter.id === filter.id;
+ const button = document.createElement("button");
+ button.type = "button";
+ button.role = "tab";
+ button.setAttribute("aria-selected", String(isActive));
+ button.className = `filter-pill${isCollection ? " is-collection" : ""}${isActive ? " active" : ""}`;
+ button.textContent = label;
+ button.addEventListener("click", () => {
+ activeFilter = isActive && filter.type !== "all" ? { type: "all", id: null } : filter;
+ renderSnapshot();
+ });
+ return button;
+ };
+
+ container.append(makePill(tx("All", "全部"), { type: "all", id: null }));
+ for (const collection of collections) container.append(makePill(collection.name.trim(), { type: "collection", id: collection.id }, true));
+ for (const category of categories) container.append(makePill(category.name.trim(), { type: "category", id: category.id }, false));
+ if (categories.length && allBookmarks.some((b) => !b.categoryId)) {
+ container.append(makePill(tx("Uncategorized", "未分类"), { type: "category", id: "__uncategorized__" }, false));
+ }
+}
+
+function applyActiveBookmarkFilter(bookmarks) {
+ if (activeFilter.type === "collection") {
+ const collection = asArray(snapshot.smartCollections).find((item) => item?.id === activeFilter.id);
+ return collection ? bookmarks.filter((bookmark) => collectionMatchesBookmark(collection, bookmark)) : bookmarks;
+ }
+ if (activeFilter.type === "category") {
+ return activeFilter.id === "__uncategorized__"
+ ? bookmarks.filter((bookmark) => !bookmark.categoryId)
+ : bookmarks.filter((bookmark) => bookmark.categoryId === activeFilter.id);
+ }
+ return bookmarks;
}
function renderSnapshot() {
- const bookmarks = [...snapshot.bookmarks]
- .filter((bookmark) => isHttpUrl(bookmark?.url))
- .sort((a, b) => (a.position ?? 0) - (b.position ?? 0));
- const workspaces = [...snapshot.workspaces]
- .sort((a, b) => (a.position ?? 0) - (b.position ?? 0));
+ const bookmarks = [...snapshot.bookmarks].filter((b) => isHttpUrl(b?.url)).sort((a, b) => (a.position ?? 0) - (b.position ?? 0));
+ const workspaces = [...snapshot.workspaces].sort((a, b) => (a.position ?? 0) - (b.position ?? 0));
const bookmarkLimit = settings.newTab.bookmarkLimit;
const workspaceLimit = settings.newTab.workspaceLimit;
- elements.bookmarkCount.textContent = bookmarkLimit < bookmarks.length
- ? `${bookmarks.length} cached · ${bookmarkLimit} shown`
- : `${bookmarks.length} cached`;
+ renderBookmarkFilters(bookmarks);
+ const filteredBookmarks = applyActiveBookmarkFilter(bookmarks);
+ const isFiltered = activeFilter.type !== "all";
+
+ elements.bookmarkCount.textContent = isFiltered
+ ? tx(`${filteredBookmarks.length} matching`, `匹配 ${filteredBookmarks.length} 条`)
+ : bookmarkLimit < bookmarks.length
+ ? tx(`${bookmarks.length} cached · ${bookmarkLimit} shown`, `${bookmarks.length} 条已缓存 · 显示 ${bookmarkLimit} 条`)
+ : tx(`${bookmarks.length} cached`, `${bookmarks.length} 条已缓存`);
+
elements.workspaceCount.textContent = workspaceLimit < workspaces.length
- ? `${workspaces.length} cached · ${workspaceLimit} shown`
- : `${workspaces.length} cached`;
+ ? tx(`${workspaces.length} cached · ${workspaceLimit} shown`, `${workspaces.length} 个已缓存 · 显示 ${workspaceLimit} 个`)
+ : tx(`${workspaces.length} cached`, `${workspaces.length} 个已缓存`);
+
elements.syncStatus.textContent = snapshot.syncedAt
- ? `Local snapshot synced ${timeAgo(snapshot.syncedAt)}.`
- : "No local snapshot yet.";
+ ? tx(`Local snapshot synced ${timeAgo(snapshot.syncedAt)}.`, `本地快照同步于 ${timeAgo(snapshot.syncedAt)}。`)
+ : tx("No local snapshot yet.", "暂无本地快照。");
elements.settingsStatus.textContent = settingsSummary();
elements.bookmarks.replaceChildren();
if (bookmarkLimit === 0) {
- renderEmpty(elements.bookmarks, "Bookmark cards are hidden by New Tab settings. They remain available in command search.");
+ renderEmpty(elements.bookmarks, tx("Bookmark cards are hidden by New Tab settings. They remain available in command search.", "新标签页设置已隐藏书签卡片,仍可通过上方搜索框检索。"));
} else {
- for (const bookmark of bookmarks.slice(0, bookmarkLimit)) {
+ const visibleList = isFiltered ? filteredBookmarks.slice(0, Math.max(bookmarkLimit, 24)) : filteredBookmarks.slice(0, bookmarkLimit);
+ for (const bookmark of visibleList) {
const button = document.createElement("button");
button.type = "button";
button.className = "bookmark-card";
+ const monogram = document.createElement("span");
+ monogram.className = "card-monogram";
+ monogram.setAttribute("aria-hidden", "true");
+ monogram.textContent = hostMonogram(bookmark.url, bookmark.title);
+ const body = document.createElement("span");
+ body.className = "bookmark-card-body";
const title = document.createElement("strong");
title.textContent = bookmark.title || bookmark.url;
+ const metaRow = document.createElement("span");
+ metaRow.className = "bookmark-card-meta";
const meta = document.createElement("small");
meta.textContent = `${categoryName(bookmark.categoryId)} · ${displayHost(bookmark.url)}`;
- button.append(title, meta);
+ metaRow.append(meta);
+ const tags = normalizedTags(bookmark);
+ if (tags.length) {
+ const tagPill = document.createElement("span");
+ tagPill.className = "bookmark-tag-pill";
+ tagPill.textContent = `#${tags[0]}`;
+ metaRow.append(tagPill);
+ }
+ body.append(title, metaRow);
+ button.append(monogram, body);
button.addEventListener("click", () => void navigateCurrent(bookmark.url));
elements.bookmarks.append(button);
}
- if (!bookmarks.length) renderEmpty(elements.bookmarks, "No cached bookmarks yet. Connect once while online to seed this launcher.");
+ if (!visibleList.length) {
+ renderEmpty(elements.bookmarks, isFiltered ? tx("No bookmarks match this filter.", "该筛选条件下暂无书签。") : tx("No cached bookmarks yet. Connect once while online to seed this launcher.", "暂无缓存书签,联网连接一次后将自动同步到本地启动台。"));
+ }
}
elements.workspaces.replaceChildren();
if (workspaceLimit === 0) {
- renderEmpty(elements.workspaces, "Workspace cards are hidden by New Tab settings. They remain available in command search.");
+ renderEmpty(elements.workspaces, tx("Workspace cards are hidden by New Tab settings. They remain available in command search.", "新标签页设置已隐藏工作区卡片,仍可通过上方搜索框检索。"));
} else {
for (const workspace of workspaces.slice(0, workspaceLimit)) {
const items = asArray(workspace.items).filter((item) => isHttpUrl(item?.url));
+ const pinnedCount = items.filter((item) => item?.openMode === "pinned").length;
+ const newTabCount = items.filter((item) => item?.openMode === "new-tab").length;
const button = document.createElement("button");
button.type = "button";
button.className = "workspace-card";
button.disabled = !items.length;
+ const head = document.createElement("div");
+ head.className = "workspace-head";
const title = document.createElement("strong");
- title.textContent = workspace.name || "Workspace";
+ title.textContent = workspace.name || tx("Workspace", "工作区");
+ const action = document.createElement("span");
+ action.className = "workspace-action";
+ action.textContent = items.length ? tx("Open →", "打开 →") : tx("Empty", "空");
+ head.append(title, action);
const meta = document.createElement("div");
meta.className = "workspace-meta";
const count = document.createElement("span");
- count.textContent = `${items.length} tab${items.length === 1 ? "" : "s"}`;
- const action = document.createElement("span");
- action.textContent = items.length ? "Open →" : "Empty";
- meta.append(count, action);
- button.append(title, meta);
+ count.textContent = tx(`${items.length} tab${items.length === 1 ? "" : "s"}`, `${items.length} 个标签页`);
+ meta.append(count);
+ if (pinnedCount > 0) {
+ const badge = document.createElement("span");
+ badge.className = "mode-badge";
+ badge.textContent = tx(`${pinnedCount} pinned`, `${pinnedCount} 固定`);
+ meta.append(badge);
+ }
+ if (newTabCount > 0) {
+ const badge = document.createElement("span");
+ badge.className = "mode-badge";
+ badge.textContent = tx(`${newTabCount} new`, `${newTabCount} 新开`);
+ meta.append(badge);
+ }
+ button.append(head, meta);
button.addEventListener("click", () => void openWorkspace(workspace));
elements.workspaces.append(button);
}
- if (!workspaces.length) renderEmpty(elements.workspaces, "No cached Workspaces yet.");
+ if (!workspaces.length) renderEmpty(elements.workspaces, tx("No cached Workspaces yet.", "暂无缓存工作区。"));
}
renderSearchResults();
@@ -257,10 +413,7 @@ function renderSnapshot() {
async function requestJson(path) {
const response = await fetch(new URL(path, `${origin}/`).toString(), {
- method: "GET",
- cache: "no-store",
- credentials: "omit",
- headers: { accept: "application/json" },
+ method: "GET", cache: "no-store", credentials: "omit", headers: { accept: "application/json" },
});
if (!response.ok) throw new Error(`Dockmark returned ${response.status}.`);
return response.json();
@@ -268,23 +421,18 @@ async function requestJson(path) {
async function hasOriginPermission() {
if (!origin) return false;
- try {
- return await chrome.permissions.contains({ origins: [`${origin}/*`] });
- } catch {
- return false;
- }
+ try { return await chrome.permissions.contains({ origins: [`${origin}/*`] }); } catch { return false; }
}
async function refreshCloud({ quiet = false } = {}) {
if (refreshing || !origin) return false;
refreshing = true;
- if (!quiet) setConnection("Refreshing…");
+ if (!quiet) setConnectionKey("refreshing");
try {
if (!(await hasOriginPermission())) {
- throw new Error("Dockmark site access is not granted. Open the extension popup and reconnect this origin.");
+ throw new Error(tx("Dockmark site access is not granted. Open the extension popup and reconnect this origin.", "尚未授予 Dockmark 站点访问权限,请打开扩展弹窗重新连接该地址。"));
}
-
const [bookmarkPayload, categoryPayload, workspacePayload, enginePayload, settingsPayload, appearancePayload] = await Promise.all([
requestJson("/api/bookmarks"),
requestJson("/api/categories"),
@@ -295,37 +443,31 @@ async function refreshCloud({ quiet = false } = {}) {
]);
settings = normalizeSettings(settingsPayload.settings);
- const appearancePreference = window.dockmarkAppearance?.apply(
- appearancePayload?.settings?.preference ?? snapshot.appearancePreference ?? "system",
- ) ?? "system";
+ const appearancePreference = window.dockmarkAppearance?.apply(appearancePayload?.settings?.preference ?? snapshot.appearancePreference ?? "system") ?? "system";
+ const remoteLocale = typeof appearancePayload?.settings?.locale === "string" ? appearancePayload.settings.locale : null;
+ const localePreference = remoteLocale
+ ? (window.dockmarkI18n?.apply(remoteLocale)?.preference ?? "system")
+ : (window.dockmarkI18n?.currentPreference() ?? "system");
+
snapshot = {
- version: CACHE_VERSION,
- origin,
- syncedAt: new Date().toISOString(),
- bookmarks: asArray(bookmarkPayload.bookmarks),
- categories: asArray(categoryPayload.categories),
- workspaces: asArray(workspacePayload.workspaces),
- searchEngines: asArray(enginePayload.engines),
- appearancePreference,
+ version: CACHE_VERSION, origin, syncedAt: new Date().toISOString(),
+ bookmarks: asArray(bookmarkPayload.bookmarks), categories: asArray(categoryPayload.categories),
+ workspaces: asArray(workspacePayload.workspaces), searchEngines: asArray(enginePayload.engines),
+ smartCollections: asArray(settingsPayload?.smartCollections), inboxBookmarkIds: asArray(settingsPayload?.inboxBookmarkIds),
+ appearancePreference, localePreference,
};
- await chrome.storage.local.set({
- [CACHE_KEY]: snapshot,
- [SETTINGS_KEY]: settings,
- });
+ await chrome.storage.local.set({ [CACHE_KEY]: snapshot, [SETTINGS_KEY]: settings });
await loadOpenTabs();
- setConnection("Online · synced", "online");
+ setConnectionKey("online", "online");
setOfflineMessage("");
elements.setup.hidden = true;
renderSnapshot();
return true;
} catch (error) {
const hasCache = Boolean(snapshot.syncedAt || snapshot.bookmarks.length || snapshot.workspaces.length);
- setConnection(hasCache ? "Offline cache" : "Offline", "offline");
- setOfflineMessage(
- hasCache
- ? `Cloud refresh failed. Using the local snapshot from ${timeAgo(snapshot.syncedAt)}. Search and launch still work.`
- : (error instanceof Error ? error.message : "Dockmark is unavailable and there is no local snapshot yet."),
- );
+ setConnectionKey(hasCache ? "offline-cache" : "offline", "offline");
+ if (hasCache) setOfflineKey("refresh-failed-cached");
+ else setOfflineMessage(error instanceof Error ? error.message : tx("Dockmark is unavailable and there is no local snapshot yet.", "无法连接 Dockmark,且当前没有可用的本地快照。"));
elements.setup.hidden = hasCache;
return false;
} finally {
@@ -334,25 +476,15 @@ async function refreshCloud({ quiet = false } = {}) {
}
async function loadOpenTabs() {
- if (!settings.newTab.showOpenTabs) {
- openTabs = [];
- return;
- }
+ if (!settings.newTab.showOpenTabs) { openTabs = []; return; }
try {
const tabs = await chrome.tabs.query({});
- openTabs = tabs.flatMap((tab) => {
- if (tab.id == null || tab.windowId == null || !isHttpUrl(tab.url)) return [];
- return [{
- id: tab.id,
- windowId: tab.windowId,
- title: tab.title || tab.url,
- url: tab.url,
- active: Boolean(tab.active),
- }];
- });
- } catch {
- openTabs = [];
- }
+ openTabs = tabs.flatMap((tab) => (
+ tab.id == null || tab.windowId == null || !isHttpUrl(tab.url)
+ ? []
+ : [{ id: tab.id, windowId: tab.windowId, title: tab.title || tab.url, url: tab.url, active: Boolean(tab.active) }]
+ ));
+ } catch { openTabs = []; }
}
function searchScore(query, title, subtitle, base) {
@@ -374,19 +506,15 @@ function searchUrl(engine, query) {
const url = new URL(template);
url.searchParams.set("q", query);
return url.toString();
- } catch {
- return DEFAULT_SEARCH_URL.replace("%s", encoded);
- }
+ } catch { return DEFAULT_SEARCH_URL.replace("%s", encoded); }
}
function searchEngineCommand(rawQuery) {
const trimmed = rawQuery.trim();
- const engines = snapshot.searchEngines;
- for (const engine of engines) {
+ for (const engine of snapshot.searchEngines) {
const keyword = typeof engine?.keyword === "string" ? engine.keyword.trim() : "";
if (!keyword) continue;
- const forms = [`${keyword} `, `!${keyword} `];
- const form = forms.find((value) => trimmed.toLocaleLowerCase().startsWith(value.toLocaleLowerCase()));
+ const form = [`${keyword} `, `!${keyword} `].find((v) => trimmed.toLocaleLowerCase().startsWith(v.toLocaleLowerCase()));
if (!form) continue;
const query = trimmed.slice(form.length).trim();
if (!query) return null;
@@ -407,25 +535,18 @@ function preferredSearchEngine() {
function buildResults(rawQuery) {
const query = rawQuery.trim();
if (!query) return [];
-
const directEngine = searchEngineCommand(query);
if (directEngine) {
- return [{
- kind: "search",
- title: `Search ${directEngine.engine.name}`,
- subtitle: directEngine.query,
- url: searchUrl(directEngine.engine, directEngine.query),
- score: 1000,
- }];
+ return [{ kind: "search", title: tx(`Search ${directEngine.engine.name}`, `使用 ${directEngine.engine.name} 搜索`), subtitle: directEngine.query, url: searchUrl(directEngine.engine, directEngine.query), score: 1000 }];
}
-
const results = [];
for (const tab of openTabs) {
const score = searchScore(query, tab.title, tab.url, 500);
if (score >= 0) results.push({ kind: "tab", title: tab.title, subtitle: tab.url, tab, score });
}
for (const workspace of snapshot.workspaces) {
- const subtitle = `${asArray(workspace.items).length} tabs`;
+ const count = asArray(workspace.items).length;
+ const subtitle = tx(`${count} tab${count === 1 ? "" : "s"}`, `${count} 个标签页`);
const score = searchScore(query, workspace.name, `${workspace.description || ""} ${subtitle}`, 400);
if (score >= 0) results.push({ kind: "workspace", title: workspace.name, subtitle, workspace, score });
}
@@ -434,27 +555,17 @@ function buildResults(rawQuery) {
const score = searchScore(query, bookmark.title, `${bookmark.url} ${categoryName(bookmark.categoryId)}`, 300);
if (score >= 0) results.push({ kind: "bookmark", title: bookmark.title || bookmark.url, subtitle: bookmark.url, url: bookmark.url, score });
}
-
const defaultEngine = preferredSearchEngine();
- results.push({
- kind: "search",
- title: `Search ${defaultEngine?.name || "the web"}`,
- subtitle: query,
- url: searchUrl(defaultEngine, query),
- score: 100,
- });
-
+ results.push({ kind: "search", title: tx(`Search ${defaultEngine?.name || "the web"}`, `使用 ${defaultEngine?.name || "网页搜索"} 搜索`), subtitle: query, url: searchUrl(defaultEngine, query), score: 100 });
return results.sort((a, b) => b.score - a.score).slice(0, 10);
}
function syncActiveResultStyles() {
- const rows = elements.results.querySelectorAll(".result-row");
- rows.forEach((row, index) => row.classList.toggle("active", index === activeResult));
+ elements.results.querySelectorAll(".result-row").forEach((row, index) => row.classList.toggle("active", index === activeResult));
}
function renderSearchResults() {
- const query = elements.search.value;
- visibleResults = buildResults(query);
+ visibleResults = buildResults(elements.search.value);
activeResult = Math.min(activeResult, Math.max(0, visibleResults.length - 1));
elements.results.replaceChildren();
elements.results.hidden = !visibleResults.length;
@@ -474,10 +585,7 @@ function renderSearchResults() {
kind.className = "result-kind";
kind.textContent = result.kind;
row.append(copy, kind);
- row.addEventListener("mouseenter", () => {
- activeResult = index;
- syncActiveResultStyles();
- });
+ row.addEventListener("mouseenter", () => { activeResult = index; syncActiveResultStyles(); });
row.addEventListener("click", () => void executeResult(result));
elements.results.append(row);
});
@@ -485,11 +593,7 @@ function renderSearchResults() {
async function navigateCurrent(url) {
if (!isHttpUrl(url)) return;
- try {
- await chrome.tabs.update({ url });
- } catch {
- window.location.assign(url);
- }
+ try { await chrome.tabs.update({ url }); } catch { window.location.assign(url); }
}
async function activateTab(tab) {
@@ -498,14 +602,11 @@ async function activateTab(tab) {
}
async function openWorkspace(workspace) {
- const items = asArray(workspace?.items)
- .filter((item) => isHttpUrl(item?.url))
- .map((item) => ({
- url: item.url,
- openMode: item.openMode === "new-tab" || item.openMode === "pinned" ? item.openMode : "reuse",
- }));
+ const items = asArray(workspace?.items).filter((item) => isHttpUrl(item?.url)).map((item) => ({
+ url: item.url,
+ openMode: item.openMode === "new-tab" || item.openMode === "pinned" ? item.openMode : "reuse",
+ }));
if (!items.length) return;
-
const current = await chrome.tabs.getCurrent().catch(() => null);
const tabs = await chrome.tabs.query({});
const byUrl = new Map();
@@ -514,36 +615,25 @@ async function openWorkspace(workspace) {
const key = tabMatchKey(tab.url);
if (!byUrl.has(key)) byUrl.set(key, tab);
}
-
let firstTabId = null;
for (const item of items) {
const key = tabMatchKey(item.url);
const reusable = item.openMode === "new-tab" ? null : byUrl.get(key);
if (reusable?.id != null) {
- if (item.openMode === "pinned" && !reusable.pinned) {
- await chrome.tabs.update(reusable.id, { pinned: true });
- }
+ if (item.openMode === "pinned" && !reusable.pinned) await chrome.tabs.update(reusable.id, { pinned: true });
firstTabId ??= reusable.id;
continue;
}
-
- const created = await chrome.tabs.create({
- url: item.url,
- active: false,
- pinned: item.openMode === "pinned",
- });
+ const created = await chrome.tabs.create({ url: item.url, active: false, pinned: item.openMode === "pinned" });
if (created.id == null) continue;
firstTabId ??= created.id;
byUrl.set(key, created);
}
-
if (firstTabId != null) {
const first = await chrome.tabs.update(firstTabId, { active: true });
if (first?.windowId != null) await chrome.windows.update(first.windowId, { focused: true });
}
- if (current?.id != null && current.id !== firstTabId) {
- await chrome.tabs.remove(current.id).catch(() => undefined);
- }
+ if (current?.id != null && current.id !== firstTabId) await chrome.tabs.remove(current.id).catch(() => undefined);
}
async function executeResult(result) {
@@ -556,55 +646,52 @@ async function executeResult(result) {
async function clearLocalSnapshot() {
await chrome.storage.local.remove(CACHE_KEY);
snapshot = emptySnapshot();
+ activeFilter = { type: "all", id: null };
elements.search.value = "";
visibleResults = [];
activeResult = 0;
renderSnapshot();
- setConnection(origin ? "Cache cleared" : "Not connected", origin ? "offline" : "");
- setOfflineMessage(
- origin
- ? "Local snapshot cleared. Use Refresh to seed it again. Server connection, settings and bookmark mappings were kept."
- : "Local snapshot cleared. Settings and bookmark mappings were kept.",
- );
+ setConnectionKey(origin ? "cache-cleared" : "not-connected", origin ? "offline" : "");
+ setOfflineKey(origin ? "cache-cleared-connected" : "cache-cleared-local");
elements.setup.hidden = Boolean(origin);
}
async function bootstrap() {
+ window.dockmarkI18n?.applyStaticDom();
+ updateTopbarControls();
+ await Promise.all([window.dockmarkAppearance?.hydrate?.(), window.dockmarkI18n?.hydrate?.()]);
+
const stored = await chrome.storage.local.get([SERVER_KEY, CACHE_KEY, SETTINGS_KEY]);
origin = validOrigin(stored[SERVER_KEY]);
settings = normalizeSettings(stored[SETTINGS_KEY]);
if (cacheIsUsable(stored[CACHE_KEY], origin)) snapshot = stored[CACHE_KEY];
if (snapshot.appearancePreference) window.dockmarkAppearance?.apply(snapshot.appearancePreference);
+ if (snapshot.localePreference && localStorage.getItem(window.dockmarkI18n?.STORAGE_KEY || "dockmarkLocaleV1") === null) {
+ window.dockmarkI18n?.apply(snapshot.localePreference, false);
+ }
+ updateTopbarControls();
await loadOpenTabs();
renderSnapshot();
if (!origin) {
- setConnection(snapshot.syncedAt ? "Cached · not connected" : "Not connected", snapshot.syncedAt ? "offline" : "");
- setOfflineMessage(snapshot.syncedAt ? "No Dockmark origin is configured. Using the last local snapshot." : "");
+ setConnectionKey(snapshot.syncedAt ? "cached-not-connected" : "not-connected", snapshot.syncedAt ? "offline" : "");
+ if (snapshot.syncedAt) setOfflineKey("no-origin-cached");
+ else setOfflineMessage("");
elements.setup.hidden = Boolean(snapshot.syncedAt);
return;
}
-
if (snapshot.syncedAt && !settings.newTab.autoRefresh) {
- setConnection("Cached · manual refresh");
+ setConnectionKey("cached-manual");
elements.setup.hidden = true;
return;
}
-
- if (snapshot.syncedAt) {
- setConnection("Cached · refreshing");
- elements.setup.hidden = true;
- } else {
- setConnection("Connecting…");
- }
+ setConnectionKey(snapshot.syncedAt ? "cached-refreshing" : "connecting");
+ if (snapshot.syncedAt) elements.setup.hidden = true;
void refreshCloud({ quiet: Boolean(snapshot.syncedAt) });
}
-elements.search.addEventListener("input", () => {
- activeResult = 0;
- renderSearchResults();
-});
+elements.search.addEventListener("input", () => { activeResult = 0; renderSearchResults(); });
elements.search.addEventListener("keydown", (event) => {
if (event.key === "ArrowDown" && visibleResults.length) {
event.preventDefault();
@@ -624,14 +711,24 @@ elements.search.addEventListener("keydown", (event) => {
}
});
+elements.themeToggle?.addEventListener("click", () => {
+ const next = window.dockmarkAppearance?.cycle?.();
+ updateTopbarControls();
+ if (next) void patchCloudAppearance({ preference: next });
+});
+elements.localeToggle?.addEventListener("click", () => {
+ const next = window.dockmarkI18n?.toggleLocale?.();
+ updateTopbarControls();
+ if (next?.preference) void patchCloudAppearance({ locale: next.preference });
+});
+window.addEventListener("dockmark:appearance", () => updateTopbarControls());
+window.addEventListener("dockmark:locale", () => { updateTopbarControls(); renderConnectionState(); renderOfflineMessage(); renderSnapshot(); });
+
elements.refresh.addEventListener("click", () => void refreshCloud());
elements.clearCache.addEventListener("click", () => void clearLocalSnapshot());
elements.manage.addEventListener("click", () => {
if (origin) void navigateCurrent(origin);
- else {
- elements.setup.hidden = false;
- setOfflineMessage("Connect a Dockmark origin from the extension popup first.");
- }
+ else { elements.setup.hidden = false; setOfflineKey("connect-first"); }
});
chrome.tabs.onCreated?.addListener(() => void loadOpenTabs().then(renderSearchResults));
@@ -639,8 +736,5 @@ chrome.tabs.onRemoved?.addListener(() => void loadOpenTabs().then(renderSearchRe
chrome.tabs.onUpdated?.addListener((_tabId, changeInfo) => {
if (changeInfo.url !== undefined || changeInfo.title !== undefined) void loadOpenTabs().then(renderSearchResults);
});
-
-window.addEventListener("online", () => {
- if (settings.newTab.autoRefresh) void refreshCloud({ quiet: true });
-});
+window.addEventListener("online", () => { if (settings.newTab.autoRefresh) void refreshCloud({ quiet: true }); });
void bootstrap();
diff --git a/apps/extension/wxt.config.ts b/apps/extension/wxt.config.ts
index 3450082..8930d9f 100644
--- a/apps/extension/wxt.config.ts
+++ b/apps/extension/wxt.config.ts
@@ -1,3 +1,9 @@
+/**
+ * [INPUT]: depends on defineConfig from wxt
+ * [OUTPUT]: exports WXT build configuration and MV3 manifest definition for Chrome and Firefox
+ * [POS]: extension build root for apps/extension; declares version 1.6.0, default_locale, localized manifest messages, and optional permissions
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
import { defineConfig } from "wxt";
export default defineConfig({
@@ -5,8 +11,9 @@ export default defineConfig({
modules: ["@wxt-dev/module-react"],
manifest: ({ browser }) => ({
name: "Dockmark",
- version: "1.5.5",
- description: "Browser bridge for Dockmark tabs, reviewed Capture Inbox, sessions, Smart Collection-aware local-first search, reviewed bookmark sync, local health checks and device pairing.",
+ version: "1.6.0",
+ default_locale: "en",
+ description: "__MSG_extDescription__",
icons: {
16: "icons/dockmark-16.png",
32: "icons/dockmark-32.png",
@@ -19,7 +26,7 @@ export default defineConfig({
commands: {
"open-dockmark-launcher": {
suggested_key: { default: "Alt+Shift+D" },
- description: "Open or focus the Dockmark launcher",
+ description: "__MSG_cmdOpenLauncher__",
},
},
omnibox: { keyword: "d" },
diff --git a/apps/web/GEMINI.md b/apps/web/GEMINI.md
new file mode 100644
index 0000000..fe4c427
--- /dev/null
+++ b/apps/web/GEMINI.md
@@ -0,0 +1,87 @@
+# apps/web/
+> L2 | Parent: /GEMINI.md
+
+Dockmark Web SPA (React 19 + Vite 8) and Cloudflare Worker API (`worker/`). Routes `/` to the read-only public page and `/app/*` to the authenticated workspace, launcher, triage views, and settings.
+
+## Submodules
+- `worker/` — Cloudflare Worker HTTP API layer and D1 data handlers (see `apps/web/worker/GEMINI.md`)
+- `migrations/` — Ordered D1 SQL schema migrations for bookmarks, workspaces, sessions, auth, tags, inbox, smart collections, and change journal
+- `public/` — Static SVG icon assets served by Vite and Cloudflare Workers
+
+## Entry & Build Files
+index.html: SPA HTML shell with pre-paint appearance and locale FOUC-prevention script
+vite.config.ts: Vite + React + Cloudflare Worker dev/build configuration
+package.json: `@dockmark/web` workspace scripts (`dev`, `build`, `typecheck`) and dependencies
+tsconfig.json: TypeScript project configuration extending `tsconfig.base.json`
+
+## `src/` — Shell, Launcher, Settings & Public UI
+src/main.tsx: SPA bootstrapper applying local appearance/locale before paint, binding system listeners, syncing cloud settings, and mounting PrivateRoot or PublicPage
+src/PrivateRoot.tsx: Session auth gate (`LoginCard`, `SetupRequired`) and sticky 46px private utility bar with inbox badge and 1-click theme/locale quick-toggles
+src/App.tsx: Authenticated workspace shell with sticky 64px topbar, Raycast-style command bar (`!bang`, `@collection`, `#tag`), keyboard-navigable results, and section router
+src/LauncherDashboard.tsx: Command ranking (`buildLauncherResults`), keyboard-navigable `LauncherCommandPanel`, empty-query dashboard (open tabs, workspaces, filterable bookmarks), and `SafeFavicon`
+src/PublicPage.tsx: Read-only curated public directory (`/`) using visitor-local `usePublicI18n()` and local theme toggle without mutating owner D1
+src/SettingsPage.tsx: Client-side `/app/settings/*` router coordinating Appearance & Language, Browser, Security, and Public Page panels
+src/AppearanceSettings.tsx: Theme (`System / Light / Dark`) and Language (`System / English / 简体中文`) selector cards synced via `PATCH /api/settings/appearance`
+src/BrowserSettingsManager.tsx: Local-first and D1-synced New Tab launcher limits, default engine, and bookmark conflict policy settings
+src/SecuritySettings.tsx: One-time extension pairing code generator and active/revoked paired-device management
+src/PublicPageSettings.tsx: Single and bulk bookmark publication manager plus canonical category/bookmark public ordering
+src/BrowserExtensionManager.tsx: Extension hub (`/app/extension`) with Chromium New Tab, Chromium Standard, and Firefox MV3 profiles, install guide, and live bridge diagnostics
+
+## `src/` — Library, Workspace & Triage Managers
+src/BookmarkManager.tsx: Tabbed Bookmarks hub coordinating Library, Organize, Health, and Change Journal views
+src/BookmarkManagerLegacy.tsx: Category sidebar and bookmark CRUD/tagging/reordering library manager
+src/BookmarkCategorySidebar.tsx: Left sidebar of BookmarkManagerLegacy handling category CRUD/reordering and tag filter chips
+src/BookmarkFormFields.tsx: Shared bookmark form field grid (`BookmarkFields`) and localized `HealthBadge` extracted from BookmarkManagerLegacy
+src/BookmarkFavicon.tsx: Shared HTTP/HTTPS favicon renderer with domain monogram fallback and `safeDomainLabel` helper
+src/BookmarkMaintenance.tsx: URL reachability checks (server + local bridge), health policy overrides, metadata refresh, and archive management
+src/LibraryBulkOrganizer.tsx: Bulk category/tag organizer and reviewed AI batch organization workflow
+src/LibraryBulkMaintenance.tsx: Bulk archive, restore, and health-policy maintenance actions
+src/AiOrganizationSettings.tsx: AI provider status inspection and locale-aware bookmark organization suggestions
+src/ChangeJournal.tsx: Audit trail viewer for reversible library mutations
+src/WorkspaceManager.tsx: Named Workspace CRUD, open-mode (`new_tab` / `reuse` / `pinned`) editor, and bridge/web launch actions
+src/SessionManager.tsx: Saved tab-window Session CRUD, capture from live tabs, and pinned/standard restore
+src/SearchEngineManager.tsx: Custom search engine and `!bang` keyword CRUD with default engine selection
+src/TransferManager.tsx: HTML/JSON bookmark import/export workflow and native browser import hub
+src/NativeBookmarkImport.tsx: Reviewed native browser bookmark import, mapping reconciliation, conflict review, and manual writeback
+src/NativeBookmarkSyncPanels.tsx: Extracted mapping preview (`NativeMappingPreviewPanel`) and import tree (`NativeImportTreePanel`) views for NativeBookmarkImport
+src/InboxPage.tsx: Capture Inbox triage view with AI/metadata review and filing/archiving actions
+src/InboxReviewCard.tsx: Single-bookmark Inbox review card handling filing, AI triage selection, and opt-in metadata suggestions
+src/SmartCollectionsPage.tsx: Saved dynamic filter collection builder, live preview, and bulk handoff
+src/DuplicateReviewPage.tsx: Duplicate URL group detector and reviewed merge/archive workflow
+
+## `src/` — Client Data, Bridge, Theme & i18n Modules
+src/i18n.ts: Web locale state (`dockmarkLocaleV1`, `dockmarkPublicLocaleV1`), cloud sync, `useI18n()`, and visitor-only `usePublicI18n()`
+src/theme.ts: Local/cloud appearance (`dockmarkAppearanceV1`), theme-color/favicon updates, and `saveAppearanceAndLocale`
+src/api.ts: Typed HTTP client for categories, bookmarks, workspaces, sessions, and search engines
+src/auth-client.ts: Web session auth, pairing code creation, and paired-device revocation API client
+src/browser-bridge.ts: `window.postMessage` Browser Bridge client for extension handshake, open tabs, workspace/session launch, and native bookmark permissions
+src/extension-distribution.ts: Release version constant (`1.6.0`), download URLs, and semver comparison helper
+src/ai-organization.ts: AI status and locale-aware `/api/ai/organize` + `/api/ai/apply` client helpers
+src/bookmark-details-api.ts: Composite bookmark + tag mutation API client
+src/bookmark-search.ts: Tokenized bookmark and `#tag` client-side search predicates
+src/bookmark-transfer.ts: Netscape HTML and Dockmark JSON bookmark parsers and serializers
+src/change-journal-api.ts: Change journal listing API client
+src/duplicate-review-api.ts: Duplicate group listing and resolution API client
+src/inbox-api.ts: Capture Inbox listing, count, filing, and `INBOX_CHANGED_EVENT` broadcaster
+src/library-batch-api.ts: Bulk library category/tag batch API client
+src/library-maintenance-api.ts: Archived bookmark listing and bulk maintenance API client
+src/local-health-api.ts: Local-network health probe submission API client
+src/native-bookmark-sync.ts: Native browser bookmark diff, mapping, and conflict normalization helpers
+src/reorder-api.ts: Category and bookmark position reorder API client
+src/smart-collection-match.ts: Client-side Smart Collection filter predicate and label formatter
+src/smart-collections-api.ts: Smart Collection CRUD API client
+src/tag-api.ts: Bookmark tag map and per-bookmark tag mutation API client
+
+## `src/` — Global, Shell & Feature Stylesheets
+src/styles.css: Base reset, launcher command bar, LauncherDashboard grid, compact management headers, and shared form/card primitives
+src/theme.css: Dark (`#0a0f0c`) and light (`#f4f7f5`) semantic `--dm-*` design tokens plus Appearance & Language card styles
+src/ui-polish.css: Unified focus rings, form control states, hover/selection tokens, and light-theme surface alignment
+src/light-theme-consistency.css: Light-theme overrides for Extension, Transfer, Auth, and Public Page curation cards
+src/responsive-shell.css: Sticky 46px utility bar, sticky 64px topbar (`top: 46px`), 128px sticky sidebar offset, and 900/720/520px responsive nav rules
+src/settings.css: Settings subnav, preference cards, segmented controls, and public curation layout styles
+src/security.css: Private utility bar, quick theme/locale pills, auth screens, and paired-device list styles
+src/extension.css: Extension hub hero, profile cards, installation guide, diagnostics, and compact launcher nudge strip
+src/public-page.css: Curated public page topbar, visitor controls, compact hero, and responsive card grid
+src/*.css (feature sheets): Scoped styles for `ai-organization`, `bookmark-tags`, `bridge`, `change-journal`, `duplicate-review`, `health`, `inbox`, `library-bulk`, `maintenance`, `reorder`, `search-engines`, `session`, `smart-collections`, `transfer`, and `workspaces`
+
+[PROTOCOL]: Update this header on change, then check GEMINI.md
diff --git a/apps/web/index.html b/apps/web/index.html
index bf8a799..0cd0ecc 100644
--- a/apps/web/index.html
+++ b/apps/web/index.html
@@ -19,9 +19,23 @@
document.documentElement.style.colorScheme = theme;
const meta = document.querySelector('meta[name="theme-color"]');
if (meta) meta.setAttribute("content", theme === "light" ? "#f4f7f5" : "#0a0f0c");
+
+ const isPrivate = location.pathname === "/app" || location.pathname.startsWith("/app/");
+ const storedLocale = localStorage.getItem(isPrivate ? "dockmarkLocaleV1" : "dockmarkPublicLocaleV1");
+ const localePref = storedLocale === "en" || storedLocale === "zh-CN" || storedLocale === "system"
+ ? storedLocale
+ : "system";
+ const resolvedLocale = localePref === "system"
+ ? ((navigator.language || "en").toLowerCase().startsWith("zh") ? "zh-CN" : "en")
+ : localePref;
+ document.documentElement.dataset.localePreference = localePref;
+ document.documentElement.dataset.locale = resolvedLocale;
+ document.documentElement.lang = resolvedLocale;
} catch {
document.documentElement.dataset.appearance = "system";
document.documentElement.dataset.theme = "dark";
+ document.documentElement.dataset.localePreference = "system";
+ document.documentElement.dataset.locale = "en";
}
})();
diff --git a/apps/web/src/AiOrganizationSettings.tsx b/apps/web/src/AiOrganizationSettings.tsx
index 2879f95..7688e55 100644
--- a/apps/web/src/AiOrganizationSettings.tsx
+++ b/apps/web/src/AiOrganizationSettings.tsx
@@ -1,5 +1,12 @@
+/**
+ * [INPUT]: depends on Bookmark, Category, HEALTH_POLICY_LABELS from @dockmark/core; AI APIs from ./ai-organization; listBookmarkTags from ./tag-api; useI18n from ./i18n
+ * [OUTPUT]: exports AiOrganizationSettings component
+ * [POS]: provider configuration, bookmark selection queue, and diff review workbench for AI-assisted organization inside the Organize tab
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
+
import { useEffect, useMemo, useState } from "react";
-import type { Bookmark, Category } from "@dockmark/core";
+import { HEALTH_POLICY_LABELS, type Bookmark, type Category } from "@dockmark/core";
import {
applyAiOrganizationPatches,
generateAiOrganizationSuggestions,
@@ -12,6 +19,7 @@ import {
type AiOrganizationSuggestion,
type AiProviderSettings,
} from "./ai-organization";
+import { useI18n } from "./i18n";
import { listBookmarkTags } from "./tag-api";
import "./ai-organization.css";
@@ -23,8 +31,8 @@ interface Props {
type QueueFilter = "pending" | "generated" | "all";
-function messageFrom(error: unknown) {
- return error instanceof Error ? error.message : "Something went wrong.";
+function messageFrom(error: unknown, fallback: string) {
+ return error instanceof Error ? error.message : fallback;
}
function sameTags(left: string[], right: string[]) {
@@ -34,6 +42,10 @@ function sameTags(left: string[], right: string[]) {
}
export function AiOrganizationSettings({ bookmarks, categories, onChanged }: Props) {
+ const { locale, tx } = useI18n();
+ const policyLabels = HEALTH_POLICY_LABELS[locale];
+ const genericError = tx("Something went wrong.", "操作失败,请重试。");
+
const [provider, setProvider] = useState(() => loadAiProviderSettings());
const [apiKeyConfigured, setApiKeyConfigured] = useState(null);
const [bookmarkTags, setBookmarkTags] = useState>({});
@@ -59,7 +71,7 @@ export function AiOrganizationSettings({ bookmarks, categories, onChanged }: Pro
setBookmarkTags(nextTags);
setApiKeyConfigured(status.apiKeyConfigured);
} catch (caught) {
- if (!cancelled) setError(messageFrom(caught));
+ if (!cancelled) setError(messageFrom(caught, genericError));
} finally {
if (!cancelled) setLoadingTags(false);
}
@@ -123,11 +135,17 @@ export function AiOrganizationSettings({ bookmarks, categories, onChanged }: Pro
setError(null);
setMessage(null);
if (!providerTimeoutValid()) {
- setError(`Provider timeout must be between ${MIN_AI_TIMEOUT_SECONDS} and ${MAX_AI_TIMEOUT_SECONDS} seconds.`);
+ setError(tx(
+ `Provider timeout must be between ${MIN_AI_TIMEOUT_SECONDS} and ${MAX_AI_TIMEOUT_SECONDS} seconds.`,
+ `超时时间需在 ${MIN_AI_TIMEOUT_SECONDS} 到 ${MAX_AI_TIMEOUT_SECONDS} 秒之间。`,
+ ));
return;
}
saveAiProviderSettings(provider);
- setMessage("Provider endpoint, model and timeout saved in this browser. The API key stays in the Worker secret store.");
+ setMessage(tx(
+ "Provider endpoint, model, and timeout saved locally. The API key stays in the Worker secret store.",
+ "接口地址、模型与超时配置已保存到本地浏览器;API 密钥仅保存在 Worker 密钥库中。",
+ ));
}
async function refreshKeyStatus() {
@@ -135,9 +153,11 @@ export function AiOrganizationSettings({ bookmarks, categories, onChanged }: Pro
try {
const status = await getAiProviderStatus();
setApiKeyConfigured(status.apiKeyConfigured);
- setMessage(status.apiKeyConfigured ? "Worker AI secret is configured." : "Worker AI secret is still missing.");
+ setMessage(status.apiKeyConfigured
+ ? tx("Worker AI secret is configured.", "Worker AI 密钥已就绪。")
+ : tx("Worker AI secret is not configured yet.", "尚未配置 Worker AI 密钥。"));
} catch (caught) {
- setError(messageFrom(caught));
+ setError(messageFrom(caught, genericError));
}
}
@@ -177,20 +197,29 @@ export function AiOrganizationSettings({ bookmarks, categories, onChanged }: Pro
setGeneratedIds(new Set());
setQueueFilter("pending");
setSelectedIds(new Set());
- setMessage("AI generation progress reset for this page session. No bookmark data was changed.");
+ setMessage(tx(
+ "AI generation progress reset for this session. No bookmark data was changed.",
+ "已重置本次页面会话的生成进度,未修改任何书签数据。",
+ ));
setError(null);
}
function discardPreview() {
setSuggestions([]);
setAcceptedIds(new Set());
- setMessage("Current AI preview discarded. Generated markers and the next queue selection were kept.");
+ setMessage(tx(
+ "Current AI preview discarded. Session markers and next queue selection were kept.",
+ "已放弃当前 AI 预览,保留已生成标记与下一批待选队列。",
+ ));
setError(null);
}
async function generate() {
if (suggestions.length) {
- setError("Review, apply, or discard the current AI preview before generating another batch.");
+ setError(tx(
+ "Review, apply, or discard the current AI preview before generating another batch.",
+ "请先复核、应用或放弃当前 AI 建议,再生成下一批。",
+ ));
return;
}
const selected = bookmarks.filter((bookmark) => selectedIds.has(bookmark.id) && bookmark.healthPolicy === "normal");
@@ -202,7 +231,11 @@ export function AiOrganizationSettings({ bookmarks, categories, onChanged }: Pro
setAcceptedIds(new Set());
try {
saveAiProviderSettings(provider);
- const next = await generateAiOrganizationSuggestions(provider, selected.map((bookmark) => bookmark.id));
+ const next = await generateAiOrganizationSuggestions(
+ provider,
+ selected.map((bookmark) => bookmark.id),
+ locale,
+ );
const generatedAfter = new Set(generatedIds);
next.forEach((suggestion) => generatedAfter.add(suggestion.bookmarkId));
setGeneratedIds(generatedAfter);
@@ -214,11 +247,17 @@ export function AiOrganizationSettings({ bookmarks, categories, onChanged }: Pro
const remainingAfter = allEligible.filter((bookmark) => !generatedAfter.has(bookmark.id)).length;
setMessage(
next.length === selected.length
- ? `Generated ${next.length} suggestions. ${remainingAfter} eligible bookmark${remainingAfter === 1 ? "" : "s"} remain; ${nextBatch.length} next queued for selection. Review the current preview before generating again.`
- : `Generated ${next.length} of ${selected.length} requested suggestions. Missing rows remain pending and can be retried; ${nextBatch.length} bookmarks are queued next.`,
+ ? tx(
+ `Generated ${next.length} suggestions. ${remainingAfter} eligible bookmark${remainingAfter === 1 ? "" : "s"} remain; ${nextBatch.length} queued next.`,
+ `已生成 ${next.length} 条建议,剩余 ${remainingAfter} 个可整理书签,已自动预选下一批 ${nextBatch.length} 项。`,
+ )
+ : tx(
+ `Generated ${next.length} of ${selected.length} requested suggestions. Missing rows stay pending; ${nextBatch.length} queued next.`,
+ `已生成 ${next.length}/${selected.length} 条建议,未返回项仍保留在待生成队列,已预选下一批 ${nextBatch.length} 项。`,
+ ),
);
} catch (caught) {
- setError(messageFrom(caught));
+ setError(messageFrom(caught, genericError));
} finally {
setGenerating(false);
}
@@ -254,7 +293,10 @@ export function AiOrganizationSettings({ bookmarks, categories, onChanged }: Pro
if (suggestion.categoryName) {
const mapped = categoryByName.get(suggestion.categoryName.toLocaleLowerCase());
if (!mapped) {
- throw new Error(`Suggested category “${suggestion.categoryName}” no longer exists. Refresh and regenerate before applying.`);
+ throw new Error(tx(
+ `Suggested category “${suggestion.categoryName}” no longer exists. Refresh and regenerate before applying.`,
+ `建议的分类「${suggestion.categoryName}」已不存在,请刷新并重新生成后再应用。`,
+ ));
}
categoryId = mapped;
}
@@ -269,7 +311,10 @@ export function AiOrganizationSettings({ bookmarks, categories, onChanged }: Pro
}
if (!patches.length) {
- setMessage(`No reviewed AI patches were applied${skipped ? `; ${skipped} bookmarks are no longer AI-eligible` : ""}.`);
+ setMessage(tx(
+ `No reviewed AI patches were applied${skipped ? `; ${skipped} bookmarks are no longer AI-eligible` : ""}.`,
+ `未应用任何 AI 建议${skipped ? `;${skipped} 个书签已不符合 AI 整理条件` : ""}。`,
+ ));
return;
}
@@ -285,12 +330,12 @@ export function AiOrganizationSettings({ bookmarks, categories, onChanged }: Pro
await onChanged();
setSuggestions((current) => current.filter((suggestion) => !appliedIds.has(suggestion.bookmarkId)));
setAcceptedIds((current) => new Set(Array.from(current).filter((id) => !appliedIds.has(id))));
- setMessage(
- `Applied ${result.applied} reviewed AI suggestion${result.applied === 1 ? "" : "s"} in one atomic batch` +
- `${skipped ? `; ${skipped} skipped because the bookmark is no longer AI-eligible` : ""}. URLs and HealthPolicy were untouched.`,
- );
+ setMessage(tx(
+ `Applied ${result.applied} reviewed AI suggestion${result.applied === 1 ? "" : "s"} atomically${skipped ? `; ${skipped} skipped` : ""}. URLs and health policies were untouched.`,
+ `已一次性应用 ${result.applied} 条 AI 建议${skipped ? `(跳过 ${skipped} 项)` : ""},网址与健康策略未作修改。`,
+ ));
} catch (caught) {
- setError(messageFrom(caught));
+ setError(messageFrom(caught, genericError));
} finally {
setApplying(false);
}
@@ -298,33 +343,63 @@ export function AiOrganizationSettings({ bookmarks, categories, onChanged }: Pro
return (
-
+
-
AI-ASSISTED ORGANIZATION
-
Suggest first. Apply only after review.
-
Classify bookmarks into existing categories, clean titles, draft descriptions and suggest tags. Dockmark never sends a bookmark until you explicitly select it and click Generate, and it never applies a suggestion until you review the diff.
+
{tx("AI-assisted organization", "AI 辅助整理")}
+
+ {tx(
+ "Classify bookmarks into existing categories, clean titles, draft descriptions, and suggest tags. Nothing is sent or applied until you review.",
+ "按现有分类整理书签、优化标题、起草描述并推荐标签。仅在你手动生成并确认差异后才会写入。",
+ )}
+
- {apiKeyConfigured === null ? "Checking AI secret" : apiKeyConfigured ? "Worker secret ready" : "Worker secret required"}
- Max 20 bookmarks / request
+
+ {apiKeyConfigured === null
+ ? tx("Checking AI secret", "检查 AI 密钥中")
+ : apiKeyConfigured
+ ? tx("Worker secret ready", "Worker 密钥就绪")
+ : tx("Worker secret required", "需配置 Worker 密钥")}
+
+ {tx("Max 20 bookmarks / request", "单次最多 20 个书签")}
-
OpenAI-compatible provider Endpoint, model and timeout are browser-local preferences. The API key is never stored in Web localStorage or D1; the Worker reads it from DOCKMARK_AI_API_KEY.
+
+
{tx("OpenAI-compatible provider", "OpenAI 兼容接口配置")}
+
+ {tx(
+ "Endpoint, model, and timeout are saved locally in this browser. The API key is read by the Worker from ",
+ "接口地址、模型与超时仅保存在当前浏览器;API 密钥由 Worker 从 ",
+ )}
+ DOCKMARK_AI_API_KEY
+ {tx(".", " 读取,绝不暴露给前端。")}
+
+
- Chat completions endpoint
- setProvider({ ...provider, endpoint: event.target.value })} placeholder="https://api.example.com/v1/chat/completions" inputMode="url" />
+ {tx("Chat completions endpoint", "Chat Completions 接口地址")}
+ setProvider({ ...provider, endpoint: event.target.value })}
+ placeholder="https://api.example.com/v1/chat/completions"
+ inputMode="url"
+ />
- Model
- setProvider({ ...provider, model: event.target.value })} placeholder="Provider model id" autoComplete="off" />
+ {tx("Model", "模型")}
+ setProvider({ ...provider, model: event.target.value })}
+ placeholder={tx("Provider model id", "模型 ID(如 gpt-4o-mini)")}
+ autoComplete="off"
+ />
- Provider timeout · seconds
+ {tx("Provider timeout · seconds", "请求超时(秒)")}
setProvider({ ...provider, timeoutSeconds: Number(event.target.value) })}
/>
- Default 90 seconds · allowed {MIN_AI_TIMEOUT_SECONDS}–{MAX_AI_TIMEOUT_SECONDS}. Slower self-hosted models can use a longer request window.
+
+ {tx(
+ `Default 90s · allowed ${MIN_AI_TIMEOUT_SECONDS}–${MAX_AI_TIMEOUT_SECONDS}s. Slower self-hosted models can use a longer window.`,
+ `默认 90 秒 · 允许范围 ${MIN_AI_TIMEOUT_SECONDS}–${MAX_AI_TIMEOUT_SECONDS} 秒。响应较慢的自托管模型可适当调大。`,
+ )}
+
- Save provider locally
- void refreshKeyStatus()}>Refresh secret status
+
+ {tx("Save provider locally", "保存本地配置")}
+
+ void refreshKeyStatus()}>
+ {tx("Refresh secret status", "刷新密钥状态")}
+
- Configure the secret in your self-hosted Worker with npx wrangler secret put DOCKMARK_AI_API_KEY or the Cloudflare dashboard. The provider endpoint must be public HTTPS. Selected bookmark content is loaded by the Worker and sent only after Generate; the key never enters the page.
+ {tx("Set the secret with ", "使用 ")}
+ npx wrangler secret put DOCKMARK_AI_API_KEY
+ {tx(
+ " or in the Cloudflare dashboard. The endpoint must be public HTTPS.",
+ " 或在 Cloudflare 控制台配置密钥;接口地址须为公网 HTTPS。",
+ )}
-
Select bookmarks Generation progress is tracked only for this page session. Generated rows can be filtered out while the next ungenerated batch is queued automatically.
+
+
{tx("Select bookmarks", "选择待整理书签")}
+
+ {tx(
+ "Progress is tracked for this session so generated items can be filtered out while the next batch queues automatically.",
+ "进度仅在本次页面会话内跟踪,生成后会自动预选下一批待整理书签。",
+ )}
+
+
{selectedIds.size}/20
- setQuery(event.target.value)} placeholder="Filter title or URL…" aria-label="Filter bookmarks for AI organization" />
+ setQuery(event.target.value)}
+ placeholder={tx("Filter title or URL…", "按标题或网址筛选…")}
+ aria-label={tx("Filter bookmarks for AI organization", "筛选 AI 整理书签")}
+ />
-
-
setQueueFilter("pending")}>Pending {remainingCount}
-
setQueueFilter("generated")}>Generated {generatedCount}
-
setQueueFilter("all")}>All {bookmarks.length}
+
+ setQueueFilter("pending")}>
+ {tx(`Pending ${remainingCount}`, `待生成 ${remainingCount}`)}
+
+ setQueueFilter("generated")}>
+ {tx(`Generated ${generatedCount}`, `已生成 ${generatedCount}`)}
+
+ setQueueFilter("all")}>
+ {tx(`All ${bookmarks.length}`, `全部 ${bookmarks.length}`)}
+
-
{generatedCount} generated this session · {remainingCount} eligible remaining
+
+ {tx(
+ `${generatedCount} generated this session · ${remainingCount} remaining`,
+ `本次已生成 ${generatedCount} 项 · 剩余 ${remainingCount} 项`,
+ )}
+
- Select first {Math.min(20, eligible.length)} visible
- Select next pending
- Clear
- 0}>Reset progress
+
+ {tx(`Select first ${Math.min(20, eligible.length)} visible`, `选择当前前 ${Math.min(20, eligible.length)} 项`)}
+
+
+ {tx("Select next pending", "选择下一批待生成")}
+
+
+ {tx("Clear", "清空")}
+
+ 0}>
+ {tx("Reset progress", "重置进度")}
+
{selectedGeneratedCount > 0 && (
-
{selectedGeneratedCount} selected bookmark{selectedGeneratedCount === 1 ? " was" : "s were"} already generated in this session. Generate will intentionally refresh those suggestions.
+
+ {tx(
+ `${selectedGeneratedCount} selected bookmark${selectedGeneratedCount === 1 ? " was" : "s were"} already generated in this session and will be refreshed.`,
+ `已选中有 ${selectedGeneratedCount} 个书签在本次会话已生成过,继续生成将刷新其建议。`,
+ )}
+
)}
{filteredBookmarks.slice(0, 120).map((bookmark) => {
const protectedPolicy = bookmark.healthPolicy !== "normal";
const generated = generatedIds.has(bookmark.id);
- const category = categoryById.get(bookmark.categoryId ?? "") ?? "UNCATEGORIZED";
+ const category = categoryById.get(bookmark.categoryId ?? "") ?? tx("Uncategorized", "未分类");
return (
{bookmark.title}
{bookmark.url}
- {protectedPolicy ? bookmark.healthPolicy.toUpperCase() : generated ? `GENERATED · ${category}` : category}
+
+ {protectedPolicy
+ ? policyLabels[bookmark.healthPolicy]
+ : generated
+ ? tx(`Generated · ${category}`, `已生成 · ${category}`)
+ : category}
+
);
})}
- {!filteredBookmarks.length &&
No bookmarks match this queue view.
}
+ {!filteredBookmarks.length && (
+
{tx("No bookmarks match this queue view.", "当前队列视图下暂无匹配书签。")}
+ )}
-
0 || apiKeyConfigured !== true || !selectedIds.size || !provider.model.trim() || !provider.endpoint.trim() || !providerTimeoutValid()} onClick={() => void generate()}>
+ 0 || apiKeyConfigured !== true ||
+ !selectedIds.size || !provider.model.trim() || !provider.endpoint.trim() || !providerTimeoutValid()
+ }
+ onClick={() => void generate()}
+ >
{generating
- ? "Generating suggestions…"
+ ? tx("Generating suggestions…", "正在生成建议…")
: suggestions.length
- ? "Review or discard current suggestions first"
+ ? tx("Review or discard current suggestions first", "请先处理当前预览建议")
: apiKeyConfigured === false
- ? "Configure Worker AI secret first"
- : `Generate suggestions ${selectedIds.size}`}
+ ? tx("Configure Worker AI secret first", "请先配置 Worker AI 密钥")
+ : tx(`Generate suggestions (${selectedIds.size})`, `生成建议 (${selectedIds.size})`)}
@@ -408,13 +551,30 @@ export function AiOrganizationSettings({ bookmarks, categories, onChanged }: Pro
{suggestions.length > 0 && (
-
AI PREVIEW · NOTHING APPLIED YET
Review proposed organization
+
+
{tx("Review proposed organization", "复核 AI 整理建议")}
+
+ {tx("Preview only — nothing has been written yet.", "仅预览,尚未写入任何更改。")}
+
+
- setAcceptedIds(new Set(suggestions.map((suggestion) => suggestion.bookmarkId)))}>Select all
- setAcceptedIds(new Set())}>Clear
- Discard preview
+ setAcceptedIds(new Set(suggestions.map((suggestion) => suggestion.bookmarkId)))}
+ >
+ {tx("Select all", "全选")}
+
+ setAcceptedIds(new Set())}>
+ {tx("Clear", "清空")}
+
+
+ {tx("Discard preview", "放弃预览")}
+
void applySuggestions()}>
- {applying ? "Applying batch…" : `Apply reviewed ${acceptedIds.size}`}
+ {applying
+ ? tx("Applying batch…", "正在应用…")
+ : tx(`Apply reviewed (${acceptedIds.size})`, `应用已选 (${acceptedIds.size})`)}
@@ -422,35 +582,71 @@ export function AiOrganizationSettings({ bookmarks, categories, onChanged }: Pro
{suggestions.map((suggestion) => {
const bookmark = bookmarkById.get(suggestion.bookmarkId);
if (!bookmark) return null;
- const currentCategory = bookmark.categoryId ? categoryById.get(bookmark.categoryId) ?? "Unknown category" : "Uncategorized";
- const nextCategory = suggestion.categoryName ?? "Uncategorized";
+ const currentCategory = bookmark.categoryId
+ ? categoryById.get(bookmark.categoryId) ?? tx("Unknown category", "未知分类")
+ : tx("Uncategorized", "未分类");
+ const nextCategory = suggestion.categoryName ?? tx("Uncategorized", "未分类");
const currentTags = bookmarkTags[bookmark.id] ?? [];
const titleChanged = suggestion.title !== bookmark.title;
const descriptionChanged = suggestion.description !== (bookmark.description ?? "");
const categoryChanged = nextCategory !== currentCategory;
const tagsChanged = !sameTags(suggestion.tags, currentTags);
+ const changedLabels = [
+ titleChanged && tx("Title", "标题"),
+ descriptionChanged && tx("Description", "描述"),
+ categoryChanged && tx("Category", "分类"),
+ tagsChanged && tx("Tags", "标签"),
+ ].filter(Boolean).join(" · ") || tx("No field change", "无字段变动");
+
return (
- toggleSuggestion(suggestion.bookmarkId)} />
+ toggleSuggestion(suggestion.bookmarkId)}
+ />
{bookmark.title} {bookmark.url}
- {[titleChanged && "TITLE", descriptionChanged && "DESCRIPTION", categoryChanged && "CATEGORY", tagsChanged && "TAGS"].filter(Boolean).join(" · ") || "NO FIELD CHANGE"}
+ {changedLabels}
-
Title Current {bookmark.title} Suggested {suggestion.title || bookmark.title}
-
Category Current {currentCategory} Suggested {nextCategory}
-
Description Current {bookmark.description || "—"} Suggested {suggestion.description || "—"}
-
Tags Current {currentTags.join(", ") || "—"} Suggested {suggestion.tags.join(", ") || "—"}
+
+ {tx("Title", "标题")}
+ {tx("Current", "当前")} {bookmark.title}
+ {tx("Suggested", "建议")} {suggestion.title || bookmark.title}
+
+
+ {tx("Category", "分类")}
+ {tx("Current", "当前")} {currentCategory}
+ {tx("Suggested", "建议")} {nextCategory}
+
+
+ {tx("Description", "描述")}
+ {tx("Current", "当前")} {bookmark.description || "—"}
+ {tx("Suggested", "建议")} {suggestion.description || "—"}
+
+
+ {tx("Tags", "标签")}
+ {tx("Current", "当前")} {currentTags.join(", ") || "—"}
+ {tx("Suggested", "建议")} {suggestion.tags.join(", ") || "—"}
+
);
})}
-
Apply sends the reviewed title, description, category and tags once and commits them as one D1 batch. URL, HealthPolicy, HealthStatus, browser mappings and health history remain outside the AI write surface.
+
+ {tx(
+ "Applying commits reviewed titles, descriptions, categories, and tags in one atomic batch. URLs, health policies, health history, and browser mappings remain untouched.",
+ "应用后会以单次原子事务写入确认过的标题、描述、分类与标签;网址、健康策略、健康历史与浏览器映射不受影响。",
+ )}
+
)}
- {loadingTags &&
Loading existing tags and AI secret status…
}
+ {loadingTags && (
+
{tx("Loading existing tags and AI secret status…", "正在加载已有标签与 AI 密钥状态…")}
+ )}
);
}
diff --git a/apps/web/src/App.tsx b/apps/web/src/App.tsx
index 986c011..b27a26c 100644
--- a/apps/web/src/App.tsx
+++ b/apps/web/src/App.tsx
@@ -1,16 +1,17 @@
+/**
+ * [INPUT]: depends on @dockmark/core domain types, ./api, ./browser-bridge, ./i18n, ./LauncherDashboard, and workspace section manager views
+ * [OUTPUT]: exports App root workspace shell with sticky 64px topbar, command palette launcher, and section router
+ * [POS]: Primary authenticated workspace mounted by PrivateRoot for /app and /app/(workspaces|sessions|bookmarks|search|transfer|extension).
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
import { useCallback, useEffect, useMemo, useRef, useState, type KeyboardEvent as ReactKeyboardEvent } from "react";
-import {
- buildSearchUrl,
- launcherTextScore,
- matchingBangEngines,
- parseBangQuery,
- rankCommands,
- type Bookmark,
- type Category,
- type CommandResult,
- type SearchEngine,
- type SessionWithItems,
- type WorkspaceWithItems,
+import type {
+ Bookmark,
+ Category,
+ CommandResult,
+ SearchEngine,
+ SessionWithItems,
+ WorkspaceWithItems,
} from "@dockmark/core";
import {
activateBridgeTab,
@@ -28,9 +29,13 @@ import {
listSessions,
listWorkspaces,
} from "./api";
-import { bookmarkMatchesQuery } from "./bookmark-search";
+import { useI18n } from "./i18n";
import { listInbox } from "./inbox-api";
-import { matchesSmartCollection, smartCollectionFilterLabels } from "./smart-collection-match";
+import {
+ buildLauncherResults,
+ LauncherCommandPanel,
+ LauncherDashboard,
+} from "./LauncherDashboard";
import { listSmartCollections, type SmartCollection } from "./smart-collections-api";
import { listBookmarkTags } from "./tag-api";
import { BookmarkManager } from "./BookmarkManager";
@@ -40,16 +45,6 @@ import { SessionManager } from "./SessionManager";
import { TransferManager } from "./TransferManager";
import { WorkspaceManager } from "./WorkspaceManager";
-const sourceLabel: Record
= {
- tab: "Open tab",
- workspace: "Workspace",
- session: "Session",
- collection: "Collection",
- bookmark: "Bookmark",
- navigation: "Navigation",
- search: "Search",
-};
-
type View = "launcher" | "workspaces" | "sessions" | "bookmarks" | "search" | "transfer" | "extension";
const viewPaths: Record = {
@@ -84,19 +79,8 @@ function openUrls(urls: string[]) {
}
}
-function hostLabel(url: string) {
- try {
- return new URL(url).host;
- } catch {
- return url;
- }
-}
-
-function collectionResultId(id: string) {
- return `navigation:collection:${id}`;
-}
-
export function App() {
+ const { locale, tx } = useI18n();
const [view, setView] = useState(() => viewFromPath(window.location.pathname));
const [query, setQuery] = useState("");
const [selectedIndex, setSelectedIndex] = useState(0);
@@ -148,11 +132,11 @@ export function App() {
setSessions(nextSessions);
setSearchEngines(nextSearchEngines);
} catch (error) {
- setDataError(error instanceof Error ? error.message : "Could not load Dockmark data.");
+ setDataError(error instanceof Error ? error.message : tx("Could not load Dockmark data.", "无法加载 Dockmark 数据。"));
} finally {
setLoading(false);
}
- }, []);
+ }, [tx]);
const refreshBridge = useCallback(async () => {
try {
@@ -205,7 +189,14 @@ export function App() {
}
if (event.key !== "/" || event.metaKey || event.ctrlKey || event.altKey) return;
const target = event.target;
- if (target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement || target instanceof HTMLSelectElement || (target instanceof HTMLElement && target.isContentEditable)) return;
+ if (
+ target instanceof HTMLInputElement ||
+ target instanceof HTMLTextAreaElement ||
+ target instanceof HTMLSelectElement ||
+ (target instanceof HTMLElement && target.isContentEditable)
+ ) {
+ return;
+ }
event.preventDefault();
focusLauncher();
};
@@ -218,160 +209,57 @@ export function App() {
[searchEngines],
);
+ const primaryBangKeyword = useMemo(
+ () => searchEngines.find((engine) => engine.isDefault && engine.keyword)?.keyword
+ ?? searchEngines.find((engine) => engine.keyword)?.keyword
+ ?? "g",
+ [searchEngines],
+ );
+
const categoryById = useMemo(
() => new Map(categories.map((category) => [category.id, category.name])),
[categories],
);
- const results = useMemo(() => {
- const trimmed = query.trim();
- const normalized = trimmed.toLocaleLowerCase();
- const bang = parseBangQuery(trimmed, searchEngines);
-
- if (bang) {
- const canRun = Boolean(bang.query);
- return [{
- id: `search-run:${bang.engine.id}`,
- source: "search" as const,
- title: canRun ? `Search ${bang.engine.name} for “${bang.query}”` : `Search with ${bang.engine.name}`,
- subtitle: `!${bang.engine.keyword ?? ""} · ${bang.engine.searchUrl}`,
- ...(canRun ? { url: buildSearchUrl(bang.engine, bang.query) } : {}),
- score: 100,
- }];
- }
-
- const bangSuggestions = matchingBangEngines(trimmed, searchEngines);
- if (bangSuggestions.length) {
- return bangSuggestions.slice(0, 8).map((engine) => ({
- id: `search-shortcut:${engine.id}`,
- source: "search" as const,
- title: engine.name,
- subtitle: `!${engine.keyword} · type a query`,
- score: 100,
- }));
- }
-
- const tabCandidates = normalized ? openTabs : openTabs.slice(0, 4);
- const tabResults: CommandResult[] = tabCandidates.flatMap((tab) => {
- const subtitle = `${hostLabel(tab.url)}${tab.pinned ? " · Pinned" : ""}${tab.active ? " · Active" : ""}`;
- const score = launcherTextScore(trimmed, tab.title, [tab.url, subtitle], 40 + (tab.pinned ? 4 : 0) + (tab.active ? 2 : 0));
- if (normalized && score < 0) return [];
- return [{
- id: `tab:${tab.id}`,
- source: "tab" as const,
- title: tab.title,
- subtitle,
- url: tab.url,
- score,
- }];
- });
- const workspaceResults: CommandResult[] = workspaces.flatMap((workspace) => {
- const subtitle = `Open workspace · ${workspace.items.length} tabs`;
- const itemText = workspace.items.flatMap((item) => [item.title, item.url]);
- const score = launcherTextScore(trimmed, workspace.name, [workspace.description ?? "", subtitle, ...itemText], 30);
- if (normalized && score < 0) return [];
- return [{
- id: workspace.id,
- source: "workspace" as const,
- title: workspace.name,
- subtitle,
- score,
- }];
- });
- const sessionResults: CommandResult[] = sessions.flatMap((session, index) => {
- const subtitle = `Restore session · ${session.items.length} tabs${session.sourceDevice ? ` · ${session.sourceDevice}` : ""}`;
- const itemText = session.items.flatMap((item) => [item.title, item.url]);
- const score = launcherTextScore(trimmed, session.name, [session.sourceDevice ?? "", subtitle, ...itemText], Math.max(0, 30 - index));
- if (normalized && score < 0) return [];
- return [{
- id: session.id,
- source: "session" as const,
- title: session.name,
- subtitle,
- score,
- }];
- });
- const collectionResults: CommandResult[] = smartCollections.flatMap((collection) => {
- const labels = smartCollectionFilterLabels(collection.filters, categoryById);
- const count = bookmarks.filter((bookmark) =>
- matchesSmartCollection(bookmark, collection.filters, bookmarkTags[bookmark.id] ?? [], inboxIds),
- ).length;
- const subtitle = `${count} bookmark${count === 1 ? "" : "s"}${labels.length ? ` · ${labels.slice(0, 4).join(" · ")}` : " · All bookmarks"}`;
- const score = launcherTextScore(trimmed, collection.name, [subtitle, ...labels], 30);
- if (normalized && score < 0) return [];
- return [{
- id: collectionResultId(collection.id),
- source: "collection" as const,
- title: collection.name,
- subtitle,
- score,
- }];
- });
- const bookmarkResults: CommandResult[] = bookmarks.flatMap((bookmark) => {
- const tags = bookmarkTags[bookmark.id] ?? [];
- const category = bookmark.categoryId ? categoryById.get(bookmark.categoryId) ?? "" : "Uncategorized";
- const tagTokens = tags.map((tag) => `#${tag}`);
- if (normalized && !bookmarkMatchesQuery(bookmark, category, tags, trimmed)) return [];
- const subtitleParts = [hostLabel(bookmark.url)];
- if (category) subtitleParts.push(category);
- if (tagTokens.length) subtitleParts.push(tagTokens.slice(0, 3).join(" "));
- const score = launcherTextScore(trimmed, bookmark.title, [bookmark.url, bookmark.description ?? "", category, ...tags, ...tagTokens], 30);
- if (normalized && score < 0) return [];
- return [{
- id: bookmark.id,
- source: "bookmark" as const,
- title: bookmark.title,
- subtitle: subtitleParts.join(" · "),
- url: bookmark.url,
- score,
- }];
- });
- const navigationTitle = bridgeConnected ? "Browser extension" : "Install browser extension";
- const navigationSubtitle = bridgeConnected ? "Diagnostics, version and capabilities" : "Enable open tabs, Session restore and native bookmark import";
- const navigationScore = launcherTextScore(trimmed, navigationTitle, [navigationSubtitle], 20);
- const navigationResults: CommandResult[] = normalized && navigationScore < 0 ? [] : [{
- id: "navigation:extension",
- source: "navigation",
- title: navigationTitle,
- subtitle: navigationSubtitle,
- score: navigationScore,
- }];
-
- const localResults = rankCommands([
- ...tabResults,
- ...workspaceResults,
- ...sessionResults,
- ...collectionResults,
- ...bookmarkResults,
- ...navigationResults,
- ]).slice(0, trimmed && defaultEngine ? 7 : 8);
-
- if (trimmed && defaultEngine) {
- localResults.push({
- id: `search-run:${defaultEngine.id}`,
- source: "search",
- title: `Search ${defaultEngine.name} for “${trimmed}”`,
- subtitle: defaultEngine.keyword ? `Default · !${defaultEngine.keyword}` : "Default search engine",
- url: buildSearchUrl(defaultEngine, trimmed),
- score: 0,
- });
- }
+ const bookmarkById = useMemo(
+ () => new Map(bookmarks.map((bookmark) => [bookmark.id, bookmark])),
+ [bookmarks],
+ );
- return localResults;
- }, [
- bookmarkTags,
- bookmarks,
- bridgeConnected,
- categoryById,
- defaultEngine,
- inboxIds,
- openTabs,
- query,
- searchEngines,
- sessions,
- smartCollections,
- workspaces,
- ]);
+ const hasQuery = query.trim().length > 0;
+
+ const results = useMemo(
+ () => buildLauncherResults({
+ query,
+ bookmarks,
+ bookmarkTags,
+ categoryById,
+ smartCollections,
+ inboxIds,
+ workspaces,
+ sessions,
+ searchEngines,
+ defaultEngine,
+ openTabs,
+ bridgeConnected,
+ tx,
+ }),
+ [
+ bookmarkTags,
+ bookmarks,
+ bridgeConnected,
+ categoryById,
+ defaultEngine,
+ inboxIds,
+ openTabs,
+ query,
+ searchEngines,
+ sessions,
+ smartCollections,
+ tx,
+ workspaces,
+ ],
+ );
useEffect(() => {
setSelectedIndex(0);
@@ -381,6 +269,39 @@ export function App() {
if (selectedIndex >= results.length) setSelectedIndex(Math.max(0, results.length - 1));
}, [results.length, selectedIndex]);
+ const launchWorkspace = useCallback(async (workspace: WorkspaceWithItems) => {
+ const ordered = [...workspace.items].sort((a, b) => a.position - b.position);
+ if (bridgeConnected) {
+ try {
+ await openWorkspaceWithBridge(ordered.map((entry) => ({
+ url: entry.url,
+ openMode: entry.openMode,
+ })));
+ return;
+ } catch {
+ setBridgeConnected(false);
+ setOpenTabs([]);
+ }
+ }
+ openUrls(ordered.map((entry) => entry.url));
+ }, [bridgeConnected]);
+
+ const activateTab = useCallback(async (tab: BridgeTab, forceNewTab: boolean) => {
+ if (forceNewTab && tab.url) {
+ const opened = window.open(tab.url, "_blank", "noopener,noreferrer");
+ if (opened) opened.opener = null;
+ return;
+ }
+ try {
+ await activateBridgeTab(tab.id);
+ return;
+ } catch {
+ setBridgeConnected(false);
+ setOpenTabs([]);
+ }
+ if (tab.url) window.location.assign(tab.url);
+ }, []);
+
async function executeResult(item: CommandResult, forceNewTab = false) {
if (item.id.startsWith("search-shortcut:")) {
const engineId = item.id.slice("search-shortcut:".length);
@@ -416,7 +337,6 @@ export function App() {
if (opened) opened.opener = null;
return;
}
-
const tabId = Number(item.id.slice("tab:".length));
if (Number.isFinite(tabId)) {
try {
@@ -433,21 +353,7 @@ export function App() {
if (item.source === "workspace") {
const workspace = workspaces.find((candidate) => candidate.id === item.id);
- if (!workspace) return;
- const ordered = [...workspace.items].sort((a, b) => a.position - b.position);
- if (bridgeConnected) {
- try {
- await openWorkspaceWithBridge(ordered.map((entry) => ({
- url: entry.url,
- openMode: entry.openMode,
- })));
- return;
- } catch {
- setBridgeConnected(false);
- setOpenTabs([]);
- }
- }
- openUrls(ordered.map((entry) => entry.url));
+ if (workspace) await launchWorkspace(workspace);
return;
}
@@ -480,6 +386,16 @@ export function App() {
}
}
+ function prefillSyntax(prefix: string) {
+ setQuery(prefix);
+ requestAnimationFrame(() => {
+ const input = commandInputRef.current;
+ if (!input) return;
+ input.focus();
+ input.setSelectionRange(prefix.length, prefix.length);
+ });
+ }
+
function onCommandKeyDown(event: ReactKeyboardEvent) {
if (event.key === "ArrowDown") {
event.preventDefault();
@@ -500,6 +416,7 @@ export function App() {
return;
}
if (event.key === "Enter") {
+ if (!hasQuery) return;
const selected = results[selectedIndex];
if (selected) {
event.preventDefault();
@@ -515,28 +432,42 @@ export function App() {
}
const launcherStatus = loading
- ? "Loading…"
+ ? tx("Loading…", "加载中…")
: bridgeConnected
- ? `Browser bridge · ${openTabs.length} open tabs`
+ ? tx(`Browser bridge · ${openTabs.length} open tabs`, `浏览器桥接 · ${openTabs.length} 个标签页`)
: defaultEngine
- ? `Web mode · default ${defaultEngine.name}`
- : "Web mode";
+ ? tx(`Web mode · ${defaultEngine.name}`, `网页模式 · ${defaultEngine.name}`)
+ : tx("Web mode", "网页模式");
return (
- navigateView("launcher")} aria-label="Dockmark home">
+ navigateView("launcher")} aria-label={tx("Dockmark home", "Dockmark 启动台")}>
D·
Dockmark
-
- navigateView("launcher")}>Launcher
- navigateView("workspaces")}>Workspaces
- navigateView("sessions")}>Sessions
- navigateView("bookmarks")}>Bookmarks
- navigateView("search")}>Search
- navigateView("transfer")}>Transfer
- navigateView("extension")}>Extension
+
+ navigateView("launcher")}>
+ {tx("Launcher", "启动台")}
+
+ navigateView("workspaces")}>
+ {tx("Workspaces", "工作区")}
+
+ navigateView("sessions")}>
+ {tx("Sessions", "会话")}
+
+ navigateView("bookmarks")}>
+ {tx("Bookmarks", "书签")}
+
+ navigateView("search")}>
+ {tx("Search", "搜索")}
+
+ navigateView("transfer")}>
+ {tx("Transfer", "导入导出")}
+
+ navigateView("extension")}>
+ {tx("Extension", "扩展")}
+
@@ -567,11 +498,9 @@ export function App() {
) : (
<>
-
- YOUR PERSONAL LAUNCHER
- Everything you return to, one command away.
+
- ⌕
+ ⌕
setQuery(event.target.value)}
onFocus={() => void refreshBridge()}
onKeyDown={onCommandKeyDown}
- placeholder="Search tabs, Sessions, Workspaces, Collections, bookmarks or #tags; type !g, !gh, !ddg…"
- aria-label="Search Dockmark"
- aria-controls="dockmark-command-results"
- aria-activedescendant={results[selectedIndex] ? `command-result-${selectedIndex}` : undefined}
+ placeholder={tx(
+ "Search tabs, Workspaces, Sessions, Collections, bookmarks or #tags…",
+ "搜索标签页、工作区、会话、智能合集、书签或 #标签…",
+ )}
+ aria-label={tx("Search Dockmark", "搜索 Dockmark")}
+ aria-controls={hasQuery ? "dockmark-command-results" : undefined}
+ aria-activedescendant={hasQuery && results[selectedIndex] ? `command-result-${selectedIndex}` : undefined}
role="combobox"
- aria-expanded="true"
+ aria-expanded={hasQuery}
/>
+ {hasQuery && (
+ {
+ setQuery("");
+ commandInputRef.current?.focus();
+ }}
+ >
+ ×
+
+ )}
⌘ K
-
-
-
- {query ? "Command results" : "Quick access"}
- {launcherStatus}
-
- {dataError ? (
-
- Dockmark could not reach its database.
- {dataError}
- void refresh()}>Retry
-
- ) : (
-
- {results.map((item, index) => {
- const isCollection = item.source === "collection";
- return (
-
setSelectedIndex(index)}
- onClick={() => void executeResult(item)}
- >
- {isCollection ? "◇" : item.source === "tab" ? "↗" : item.source === "session" ? "↺" : item.source === "search" ? "⌕" : item.source === "navigation" ? "+" : item.title.slice(0, 1)}
-
- {item.title}
- {item.subtitle}
-
- {item.source === "search" && item.id.startsWith("search-shortcut:") ? Bang : sourceLabel[item.source]}
-
- );
- })}
- {!loading && !results.length &&
No matches. Configure a search engine or try another query.
}
+
+
+ prefillSyntax(`!${primaryBangKeyword} `)}>
+ !{primaryBangKeyword}
+ {tx("Search", "搜索")}
+
+ prefillSyntax("@")}>
+ @
+ {tx("Collections", "合集")}
+
+ prefillSyntax("#")}>
+ #
+ {tx("Tags", "标签")}
+
- )}
-
- ↑ ↓ select Enter run Tab accept bang
- Shift /⌘ /Ctrl +Enter new tab / focus Esc clear
+
+
+ {launcherStatus}
+
- {!bridgeConnected && (
-
navigateView("extension")}>
-
- Unlock browser integration
- Install Dockmark Extension for open tabs, pinned Session restore and native bookmark import.
-
- Install / diagnostics →
-
+ {dataError && (
+
+
+ {tx("Dockmark could not reach its database.", "Dockmark 暂时无法连接数据库。")}
+ {dataError}
+ void refresh()}>
+ {tx("Retry", "重试")}
+
+
+
)}
-
- 01 Open tabs With the browser bridge connected, jump to an existing tab before creating another copy.
- 02 Smart workspaces Workspace reuse and pinned modes become real browser actions while Web mode stays portable.
- 03 Cross-browser fallback Without the extension, the same launcher, workspaces, sessions and search still work normally.
-
+ {hasQuery ? (
+
+ ) : (
+ <>
+ {!bridgeConnected && (
+
navigateView("extension")}>
+
+ {tx("Browser bridge offline", "浏览器桥接未连接")}
+ {tx("Install Dockmark Extension for live tabs, pinned sessions and bookmark sync.", "安装 Dockmark 扩展即可解锁打开标签页切换、固定会话恢复与原生书签同步。")}
+
+ {tx("Extension →", "安装与诊断 →")}
+
+ )}
+
+
navigateView(target)}
+ />
+ >
+ )}
>
)}
diff --git a/apps/web/src/AppearanceSettings.tsx b/apps/web/src/AppearanceSettings.tsx
index c816865..c21048a 100644
--- a/apps/web/src/AppearanceSettings.tsx
+++ b/apps/web/src/AppearanceSettings.tsx
@@ -1,25 +1,47 @@
+/**
+ * [INPUT]: depends on AppearancePreference and LocalePreference from @dockmark/core; theme helpers from ./theme; locale helpers and useI18n from ./i18n
+ * [OUTPUT]: exports AppearanceSettings panel for switching and cloud-syncing Theme (System/Light/Dark) and Language (System/English/简体中文)
+ * [POS]: Default tab in SettingsPage (/app/settings/appearance). Applies theme and locale locally before syncing to D1 via PATCH /api/settings/appearance.
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
import { useEffect, useState } from "react";
-import type { AppearancePreference } from "@dockmark/core";
+import type { AppearancePreference, LocalePreference } from "@dockmark/core";
import {
+ applyLocalePreference,
+ saveAppearanceAndLocale,
+ useI18n,
+} from "./i18n";
+import {
+ APPEARANCE_STORAGE_KEY,
applyAppearance,
fetchAppearanceSettings,
localAppearance,
- saveAppearanceSettings,
} from "./theme";
-const options: Array<{ value: AppearancePreference; label: string; detail: string }> = [
- { value: "system", label: "System", detail: "Follow the browser or operating system preference." },
- { value: "light", label: "Light", detail: "Use Dockmark's light palette everywhere." },
- { value: "dark", label: "Dark", detail: "Keep the #0a0f0c Dockmark dark palette." },
-];
-
export function AppearanceSettings() {
+ const { localePreference, tx } = useI18n();
const [preference, setPreference] = useState(() => localAppearance());
const [loading, setLoading] = useState(true);
const [saving, setSaving] = useState(false);
const [message, setMessage] = useState(null);
const [error, setError] = useState(null);
+ useEffect(() => {
+ const onAppearance = (event: Event) => {
+ const detail = (event as CustomEvent<{ preference?: AppearancePreference }>).detail;
+ setPreference(detail?.preference ?? localAppearance());
+ };
+ const onStorage = (event: StorageEvent) => {
+ if (event.key === APPEARANCE_STORAGE_KEY) setPreference(localAppearance());
+ };
+ window.addEventListener("dockmark:appearance", onAppearance);
+ window.addEventListener("storage", onStorage);
+ return () => {
+ window.removeEventListener("dockmark:appearance", onAppearance);
+ window.removeEventListener("storage", onStorage);
+ };
+ }, []);
+
useEffect(() => {
let cancelled = false;
void fetchAppearanceSettings()
@@ -27,17 +49,22 @@ export function AppearanceSettings() {
if (cancelled) return;
setPreference(settings.preference);
applyAppearance(settings.preference);
+ applyLocalePreference(settings.locale);
})
.catch((caught) => {
- if (!cancelled) setError(caught instanceof Error ? caught.message : "Could not load appearance settings.");
+ if (!cancelled) {
+ setError(caught instanceof Error ? caught.message : tx("Could not load appearance settings.", "无法加载外观与语言设置。"));
+ }
})
.finally(() => {
if (!cancelled) setLoading(false);
});
- return () => { cancelled = true; };
- }, []);
+ return () => {
+ cancelled = true;
+ };
+ }, [tx]);
- async function choose(next: AppearancePreference) {
+ async function chooseTheme(next: AppearancePreference) {
const previous = preference;
setPreference(next);
setMessage(null);
@@ -45,58 +72,158 @@ export function AppearanceSettings() {
applyAppearance(next);
setSaving(true);
try {
- const settings = await saveAppearanceSettings(next);
+ const settings = await saveAppearanceAndLocale({ preference: next });
setPreference(settings.preference);
applyAppearance(settings.preference);
- setMessage("Appearance synced.");
+ setMessage(tx("Theme synced.", "主题偏好已同步。"));
} catch (caught) {
setPreference(previous);
applyAppearance(previous);
- setError(caught instanceof Error ? caught.message : "Could not save appearance settings.");
+ setError(caught instanceof Error ? caught.message : tx("Could not save appearance settings.", "无法保存主题设置。"));
+ } finally {
+ setSaving(false);
+ }
+ }
+
+ async function chooseLocale(next: LocalePreference) {
+ const previous = localePreference;
+ setMessage(null);
+ setError(null);
+ applyLocalePreference(next);
+ setSaving(true);
+ try {
+ const settings = await saveAppearanceAndLocale({ locale: next });
+ applyLocalePreference(settings.locale);
+ setMessage(
+ settings.locale === "zh-CN"
+ ? "语言偏好已同步。"
+ : settings.locale === "en"
+ ? "Language synced."
+ : tx("Language synced.", "语言偏好已同步。"),
+ );
+ } catch (caught) {
+ applyLocalePreference(previous);
+ setError(caught instanceof Error ? caught.message : tx("Could not save language setting.", "无法保存语言设置。"));
} finally {
setSaving(false);
}
}
+ const themeOptions: Array<{ value: AppearancePreference; label: string; detail: string }> = [
+ {
+ value: "system",
+ label: tx("System", "跟随系统"),
+ detail: tx("Match your browser or OS color scheme.", "自动跟随系统或浏览器外观设置。"),
+ },
+ {
+ value: "light",
+ label: tx("Light", "浅色"),
+ detail: tx("Clean sage-tinted light surfaces.", "清爽柔和的浅色界面。"),
+ },
+ {
+ value: "dark",
+ label: tx("Dark", "深色"),
+ detail: tx("Deep #0a0f0c Dockmark dark theme.", "深邃的 #0a0f0c 暗色主题。"),
+ },
+ ];
+
+ const localeOptions: Array<{ value: LocalePreference; badge: string; label: string; detail: string }> = [
+ {
+ value: "system",
+ badge: "AUTO",
+ label: tx("System", "跟随浏览器"),
+ detail: tx("Follow browser language automatically.", "自动匹配当前浏览器语言设置。"),
+ },
+ {
+ value: "en",
+ badge: "EN",
+ label: "English",
+ detail: tx("Always use English for the workspace and AI suggestions.", "工作台与 AI 整理建议始终使用英文。"),
+ },
+ {
+ value: "zh-CN",
+ badge: "中文",
+ label: "简体中文",
+ detail: tx("Always use Simplified Chinese across the workspace and AI suggestions.", "工作台与 AI 整理建议始终使用简体中文。"),
+ },
+ ];
+
return (
-
APPEARANCE
-
One Dockmark, three modes.
-
The choice is applied locally before first paint, then synchronized through D1 for the private workspace and curated public page.
+
{tx("Appearance & Language", "外观与语言")}
+
+ {tx(
+ "Applied locally before first paint, then synced through D1 across your workspace and extension.",
+ "在首屏渲染前即刻生效,并通过 D1 在工作台与浏览器扩展之间同步。",
+ )}
+
- {saving ? "Syncing…" : loading ? "Loading…" : "Local-first"}
- {message ?? "System / Light / Dark"}
+ {saving ? tx("Syncing…", "同步中…") : loading ? tx("Loading…", "加载中…") : tx("Local-first", "本地优先")}
+ {message ?? tx("Theme & locale synced", "主题与语言自动同步")}
{error && {error}
}
-
- {options.map((option) => (
-
void choose(option.value)}
- >
-
-
-
-
-
-
- {option.label}
- {option.detail}
-
- {preference === option.value ? "✓" : ""}
-
- ))}
+
+
+
{tx("Theme", "主题模式")}
+ {tx("System / Light / Dark", "跟随系统 / 浅色 / 深色")}
+
+
+ {themeOptions.map((option) => (
+ void chooseTheme(option.value)}
+ >
+
+
+
+
+
+
+ {option.label}
+ {option.detail}
+
+ {preference === option.value ? "✓" : ""}
+
+ ))}
+
+
+
+
+
+
{tx("Language", "界面语言")}
+ {tx("System / English / 简体中文", "跟随浏览器 / English / 简体中文")}
+
+
+ {localeOptions.map((option) => (
+ void chooseLocale(option.value)}
+ >
+ {option.badge}
+
+ {option.label}
+ {option.detail}
+
+ {localePreference === option.value ? "✓" : ""}
+
+ ))}
+
);
diff --git a/apps/web/src/BookmarkCategorySidebar.tsx b/apps/web/src/BookmarkCategorySidebar.tsx
new file mode 100644
index 0000000..f5c8621
--- /dev/null
+++ b/apps/web/src/BookmarkCategorySidebar.tsx
@@ -0,0 +1,191 @@
+/**
+ * [INPUT]: depends on Category from @dockmark/core; useI18n from ./i18n
+ * [OUTPUT]: exports BookmarkCategorySidebar component
+ * [POS]: left sidebar of BookmarkManagerLegacy handling category CRUD/reordering and tag filter chips
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
+
+import type { DragEvent, FormEvent } from "react";
+import type { Category } from "@dockmark/core";
+import { useI18n } from "./i18n";
+
+export interface TagCountItem {
+ name: string;
+ count: number;
+}
+
+interface Props {
+ categories: Category[];
+ tagSummary: TagCountItem[];
+ activeTag: string | null;
+ newCategory: string;
+ editingCategoryId: string | null;
+ editingCategoryName: string;
+ draggedCategoryId: string | null;
+ busy: boolean;
+ reordering: boolean;
+ onNewCategoryChange: (value: string) => void;
+ onSubmitCategory: (event: FormEvent) => void;
+ onStartEditCategory: (category: Category) => void;
+ onCancelEditCategory: () => void;
+ onEditingCategoryNameChange: (value: string) => void;
+ onSubmitCategoryEdit: (event: FormEvent, id: string) => void;
+ onDeleteCategory: (category: Category) => void;
+ onDragStartCategory: (id: string) => void;
+ onDragEndCategory: () => void;
+ onDropCategory: (event: DragEvent
, targetId: string) => void;
+ onMoveCategory: (id: string, offset: -1 | 1) => void;
+ onSelectTag: (tag: string | null) => void;
+}
+
+export function BookmarkCategorySidebar({
+ categories,
+ tagSummary,
+ activeTag,
+ newCategory,
+ editingCategoryId,
+ editingCategoryName,
+ draggedCategoryId,
+ busy,
+ reordering,
+ onNewCategoryChange,
+ onSubmitCategory,
+ onStartEditCategory,
+ onCancelEditCategory,
+ onEditingCategoryNameChange,
+ onSubmitCategoryEdit,
+ onDeleteCategory,
+ onDragStartCategory,
+ onDragEndCategory,
+ onDropCategory,
+ onMoveCategory,
+ onSelectTag,
+}: Props) {
+ const { tx } = useI18n();
+
+ return (
+
+ );
+}
diff --git a/apps/web/src/BookmarkFavicon.tsx b/apps/web/src/BookmarkFavicon.tsx
new file mode 100644
index 0000000..7a54bce
--- /dev/null
+++ b/apps/web/src/BookmarkFavicon.tsx
@@ -0,0 +1,75 @@
+/**
+ * [INPUT]: depends on useEffect, useState from react
+ * [OUTPUT]: exports BookmarkFavicon component and safeDomainLabel helper
+ * [POS]: shared icon renderer for web management cards, showing valid HTTP/HTTPS favicons with a crisp monogram fallback
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
+
+import { useEffect, useState } from "react";
+
+interface Props {
+ iconUrl?: string | null | undefined;
+ title: string;
+ url?: string | undefined;
+ className?: string | undefined;
+}
+
+function safeHttpUrl(value: string | null | undefined): string | null {
+ if (!value) return null;
+ const trimmed = value.trim();
+ if (!trimmed) return null;
+ try {
+ const parsed = new URL(trimmed);
+ return parsed.protocol === "http:" || parsed.protocol === "https:" ? parsed.toString() : null;
+ } catch {
+ return null;
+ }
+}
+
+export function safeDomainLabel(url: string): string {
+ try {
+ return new URL(url).hostname.replace(/^www\./i, "");
+ } catch {
+ return url;
+ }
+}
+
+function monogramFor(title: string, url?: string): string {
+ const cleanedTitle = title.trim();
+ if (cleanedTitle) return cleanedTitle.slice(0, 1).toUpperCase();
+ if (url) {
+ const host = safeDomainLabel(url).trim();
+ if (host) return host.slice(0, 1).toUpperCase();
+ }
+ return "•";
+}
+
+export function BookmarkFavicon({ iconUrl, title, url, className = "bookmark-icon" }: Props) {
+ const safeSrc = safeHttpUrl(iconUrl);
+ const [failed, setFailed] = useState(false);
+
+ useEffect(() => {
+ setFailed(false);
+ }, [safeSrc]);
+
+ if (safeSrc && !failed) {
+ return (
+
+
setFailed(true)}
+ />
+
+ );
+ }
+
+ return (
+
+ {monogramFor(title, url)}
+
+ );
+}
diff --git a/apps/web/src/BookmarkFormFields.tsx b/apps/web/src/BookmarkFormFields.tsx
new file mode 100644
index 0000000..4c002e7
--- /dev/null
+++ b/apps/web/src/BookmarkFormFields.tsx
@@ -0,0 +1,157 @@
+/**
+ * [INPUT]: depends on Bookmark, Category, HealthPolicy, HealthStatus, HEALTH_POLICY_LABELS, HEALTH_STATUS_LABELS from @dockmark/core; useI18n from ./i18n
+ * [OUTPUT]: exports BookmarkDraft, DraftPolicy, emptyDraft, BookmarkFields, and HealthBadge
+ * [POS]: form field grid and health badge primitives extracted from BookmarkManagerLegacy to keep modules compact
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
+
+import {
+ HEALTH_POLICY_LABELS,
+ HEALTH_STATUS_LABELS,
+ type Bookmark,
+ type Category,
+ type HealthPolicy,
+ type HealthStatus,
+} from "@dockmark/core";
+import { useI18n } from "./i18n";
+
+export type DraftPolicy = HealthPolicy | "auto";
+
+export interface BookmarkDraft {
+ title: string;
+ url: string;
+ description: string;
+ categoryId: string;
+ healthPolicy: DraftPolicy;
+ tagsText: string;
+}
+
+export const emptyDraft: BookmarkDraft = {
+ title: "",
+ url: "",
+ description: "",
+ categoryId: "",
+ healthPolicy: "auto",
+ tagsText: "",
+};
+
+export function HealthBadge({ bookmark }: { bookmark: Bookmark }) {
+ const { locale } = useI18n();
+ const status: HealthStatus = bookmark.healthPolicy === "local-only"
+ ? "local-only"
+ : bookmark.healthPolicy === "ignore"
+ ? "ignored"
+ : bookmark.healthStatus;
+
+ const label = bookmark.healthPolicy === "manual" && status === "unknown"
+ ? HEALTH_POLICY_LABELS[locale].manual
+ : HEALTH_STATUS_LABELS[locale][status];
+
+ return (
+
+ {label}
+
+ );
+}
+
+interface BookmarkFieldsProps {
+ draft: BookmarkDraft;
+ categories: Category[];
+ onChange: (draft: BookmarkDraft) => void;
+ allowAuto: boolean;
+ idPrefix: string;
+ urlError?: string | null;
+ tagsError?: string | null;
+}
+
+export function BookmarkFields({
+ draft,
+ categories,
+ onChange,
+ allowAuto,
+ idPrefix,
+ urlError,
+ tagsError,
+}: BookmarkFieldsProps) {
+ const { locale, tx } = useI18n();
+ const policyLabels = HEALTH_POLICY_LABELS[locale];
+ const tagsHelpId = `${idPrefix}-tags-help`;
+ const tagsErrorId = `${idPrefix}-tags-error`;
+ const urlErrorId = `${idPrefix}-url-error`;
+
+ return (
+
+
+ {tx("Title", "标题")}
+ onChange({ ...draft, title: event.target.value })}
+ placeholder="GitHub"
+ />
+
+
+ {tx("URL", "网址")}
+ onChange({ ...draft, url: event.target.value })}
+ placeholder="github.com"
+ inputMode="url"
+ aria-invalid={Boolean(urlError)}
+ aria-describedby={urlError ? urlErrorId : undefined}
+ />
+ {urlError && {urlError} }
+
+
+ {tx("Category", "分类")}
+ onChange({ ...draft, categoryId: event.target.value })}>
+ {tx("Uncategorized", "未分类")}
+ {categories.map((category) => (
+ {category.name}
+ ))}
+
+
+
+ {tx("Health policy", "健康检查策略")}
+ onChange({ ...draft, healthPolicy: event.target.value as DraftPolicy })}
+ >
+ {allowAuto && {policyLabels.auto} }
+ {policyLabels.normal}
+ {policyLabels["local-only"]}
+ {policyLabels.ignore}
+ {policyLabels.manual}
+
+
+
+ {tx("Description", "描述")}
+
+
+ {tx("Tags", "标签")}
+ onChange({ ...draft, tagsText: event.target.value })}
+ placeholder={tx("dev, docs, self-hosted", "dev, docs, 自托管")}
+ aria-invalid={Boolean(tagsError)}
+ aria-describedby={`${tagsHelpId}${tagsError ? ` ${tagsErrorId}` : ""}`}
+ />
+
+ {tx(
+ "Comma, semicolon, or newline separated · up to 12 tags · 40 characters each. Invalid input is rejected instead of truncated.",
+ "使用逗号、分号或换行分隔 · 最多 12 个标签 · 每个不超过 40 字符。无效输入会直接提示错误而非静默截断。",
+ )}
+
+ {tagsError && {tagsError} }
+
+
+ );
+}
diff --git a/apps/web/src/BookmarkMaintenance.tsx b/apps/web/src/BookmarkMaintenance.tsx
index 2dd2c1e..fd129ab 100644
--- a/apps/web/src/BookmarkMaintenance.tsx
+++ b/apps/web/src/BookmarkMaintenance.tsx
@@ -1,5 +1,19 @@
+/**
+ * [INPUT]: depends on Bookmark, HealthCheck, HealthStatus, HEALTH_POLICY_LABELS, HEALTH_STATUS_LABELS, ResolvedLocale from @dockmark/core; bookmark metadata/health APIs from ./api, ./browser-bridge, ./local-health-api; BookmarkFavicon from ./BookmarkFavicon; useI18n from ./i18n
+ * [OUTPUT]: exports BookmarkMaintenance component
+ * [POS]: per-bookmark metadata fetcher, health history inspector, and conservative cleanup review panel inside the Health tab
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
+
import { useEffect, useMemo, useState } from "react";
-import type { Bookmark, HealthCheck, HealthStatus } from "@dockmark/core";
+import {
+ HEALTH_POLICY_LABELS,
+ HEALTH_STATUS_LABELS,
+ type Bookmark,
+ type HealthCheck,
+ type HealthStatus,
+ type ResolvedLocale,
+} from "@dockmark/core";
import {
checkBookmarkHealth,
deleteBookmark,
@@ -9,11 +23,13 @@ import {
updateBookmark,
type BookmarkMetadata,
} from "./api";
+import { BookmarkFavicon } from "./BookmarkFavicon";
import {
checkLocalHealthWithBridge,
getBridgeStatus,
onBridgeEvent,
} from "./browser-bridge";
+import { useI18n } from "./i18n";
import { recordLocalBookmarkHealthResult } from "./local-health-api";
import "./maintenance.css";
@@ -22,50 +38,27 @@ interface Props {
onChanged: () => Promise;
}
-const healthLabels: Record = {
- unknown: "Unchecked",
- healthy: "Healthy",
- redirected: "Redirected",
- "auth-required": "Auth required",
- forbidden: "Forbidden",
- "rate-limited": "Rate limited",
- timeout: "Timeout",
- "dns-error": "DNS error",
- "tls-error": "TLS error",
- unavailable: "Unavailable",
- "local-only": "Local only",
- ignored: "Ignored",
-};
-
const cleanupStatuses = new Set(["dns-error", "tls-error", "unavailable"]);
-function messageFrom(error: unknown) {
- return error instanceof Error ? error.message : "Something went wrong.";
+function messageFrom(error: unknown, fallback: string) {
+ return error instanceof Error ? error.message : fallback;
}
-function displayTime(value: string) {
+function displayTime(value: string, locale: ResolvedLocale) {
const date = new Date(value);
- return Number.isNaN(date.valueOf()) ? value : date.toLocaleString();
-}
-
-function cleanupEligibility(bookmark: Bookmark | null) {
- if (!bookmark) return null;
- if (bookmark.healthPolicy !== "normal") {
- return `${bookmark.healthPolicy} policy is intentionally excluded from bulk cleanup.`;
- }
- if (cleanupStatuses.has(bookmark.healthStatus)) {
- return "Latest hard-failure status is eligible for Cleanup Review.";
- }
- if (bookmark.healthStatus === "timeout") {
- return "Timeout is treated as transient, so it is intentionally excluded from Cleanup Review.";
- }
- if (bookmark.healthStatus === "redirected") {
- return "Redirects stay in review and are never bulk-cleanup candidates.";
- }
- return null;
+ if (Number.isNaN(date.valueOf())) return value;
+ return new Intl.DateTimeFormat(locale, {
+ dateStyle: "medium",
+ timeStyle: "short",
+ }).format(date);
}
export function BookmarkMaintenance({ bookmarks, onChanged }: Props) {
+ const { locale, tx } = useI18n();
+ const statusLabels = HEALTH_STATUS_LABELS[locale];
+ const policyLabels = HEALTH_POLICY_LABELS[locale];
+ const genericError = tx("Something went wrong.", "操作失败,请重试。");
+
const [selectedId, setSelectedId] = useState(() => bookmarks[0]?.id ?? null);
const [query, setQuery] = useState("");
const [metadata, setMetadata] = useState(null);
@@ -115,9 +108,12 @@ export function BookmarkMaintenance({ bookmarks, onChanged }: Props) {
useEffect(() => onBridgeEvent((event) => {
if (event === "local-health-permission-updated") {
setError(null);
- setNotice("Local host access granted. Run Check locally again to record the result.");
+ setNotice(tx(
+ "Local host access granted. Run Check locally again to record the result.",
+ "本地主机访问权限已授予,请重新点击「本地检查」以记录结果。",
+ ));
}
- }), []);
+ }), [tx]);
useEffect(() => {
if (!selectedId) {
@@ -135,7 +131,7 @@ export function BookmarkMaintenance({ bookmarks, onChanged }: Props) {
setChecks(nextChecks);
})
.catch((caught) => {
- if (!cancelled) setError(messageFrom(caught));
+ if (!cancelled) setError(messageFrom(caught, genericError));
})
.finally(() => {
if (!cancelled) setLoading(false);
@@ -153,9 +149,12 @@ export function BookmarkMaintenance({ bookmarks, onChanged }: Props) {
try {
const next = await refreshBookmarkMetadata(selected.id);
setMetadata(next);
- setNotice("Metadata refreshed. Nothing was applied automatically.");
+ setNotice(tx(
+ "Metadata refreshed. Nothing was applied automatically.",
+ "已抓取最新页面元数据,尚未自动应用。",
+ ));
} catch (caught) {
- setError(messageFrom(caught));
+ setError(messageFrom(caught, genericError));
} finally {
setMetadataBusy(false);
}
@@ -171,16 +170,22 @@ export function BookmarkMaintenance({ bookmarks, onChanged }: Props) {
const history = await listBookmarkHealthChecks(selected.id);
setChecks(history);
const cleanupNote = selected.healthPolicy === "normal" && cleanupStatuses.has(check.status)
- ? " Added to Cleanup Review."
+ ? tx(" Added to Cleanup Review.", " 已加入清理复核列表。")
: check.status === "timeout"
- ? " Timeout is treated as transient and is excluded from Cleanup Review."
+ ? tx(" Timeout is transient and excluded from Cleanup Review.", " 超时视为临时故障,不列入清理复核。")
: selected.healthPolicy !== "normal"
- ? ` ${selected.healthPolicy} policy is excluded from bulk cleanup.`
+ ? tx(
+ ` ${policyLabels[selected.healthPolicy]} policy is excluded from bulk cleanup.`,
+ ` 「${policyLabels[selected.healthPolicy]}」策略不参与批量清理。`,
+ )
: "";
- setNotice(`Server health check: ${healthLabels[check.status]}.${cleanupNote}`);
+ setNotice(tx(
+ `Server health check: ${statusLabels[check.status]}.${cleanupNote}`,
+ `服务端健康检查结果:${statusLabels[check.status]}。${cleanupNote}`,
+ ));
await onChanged();
} catch (caught) {
- setError(messageFrom(caught));
+ setError(messageFrom(caught, genericError));
} finally {
setHealthBusy(false);
}
@@ -194,12 +199,18 @@ export function BookmarkMaintenance({ bookmarks, onChanged }: Props) {
try {
const bridge = await getBridgeStatus();
if (!bridge.capabilities.localHealth) {
- throw new Error("This Dockmark browser extension does not support local health checks. Update it to v0.9.0 or later.");
+ throw new Error(tx(
+ "This Dockmark browser extension does not support local health checks. Update it to v0.9.0 or later.",
+ "当前浏览器扩展版本不支持本地健康检查,请更新至 v0.9.0 或更高版本。",
+ ));
}
const result = await checkLocalHealthWithBridge(selected.url);
if (result.kind === "permission-required") {
- setNotice(`Browser host access is required for ${result.pattern}. Approve the permission in the extension tab, then run Check locally again.`);
+ setNotice(tx(
+ `Browser host access is required for ${result.pattern}. Approve the permission in the extension tab, then run Check locally again.`,
+ `需要授予 ${result.pattern} 的主机访问权限。请在扩展弹窗页面批准后重新点击「本地检查」。`,
+ ));
return;
}
@@ -213,9 +224,12 @@ export function BookmarkMaintenance({ bookmarks, onChanged }: Props) {
const history = await listBookmarkHealthChecks(selected.id);
setChecks(history);
await onChanged();
- setNotice(`Browser health check: ${healthLabels[check.status]}.`);
+ setNotice(tx(
+ `Browser health check: ${statusLabels[check.status]}.`,
+ `浏览器本地健康检查结果:${statusLabels[check.status]}。`,
+ ));
} catch (caught) {
- setError(messageFrom(caught));
+ setError(messageFrom(caught, genericError));
} finally {
setHealthBusy(false);
}
@@ -232,7 +246,7 @@ export function BookmarkMaintenance({ bookmarks, onChanged }: Props) {
await onChanged();
setNotice(success);
} catch (caught) {
- setError(messageFrom(caught));
+ setError(messageFrom(caught, genericError));
} finally {
setApplying(false);
}
@@ -250,7 +264,10 @@ export function BookmarkMaintenance({ bookmarks, onChanged }: Props) {
async function deleteCleanupSelection() {
const ids = [...cleanupSelection];
if (!ids.length) return;
- if (!window.confirm(`Delete ${ids.length} reviewed broken bookmark${ids.length === 1 ? "" : "s"}? This cannot be undone.`)) return;
+ if (!window.confirm(tx(
+ `Delete ${ids.length} reviewed broken bookmark${ids.length === 1 ? "" : "s"}? This cannot be undone.`,
+ `确认删除已复核的 ${ids.length} 个失效书签?此操作不可撤销。`,
+ ))) return;
setCleanupBusy(true);
setError(null);
@@ -261,14 +278,46 @@ export function BookmarkMaintenance({ bookmarks, onChanged }: Props) {
const failed = results.length - deleted;
setCleanupSelection(new Set());
await onChanged();
- setNotice(`Deleted ${deleted} reviewed bookmark${deleted === 1 ? "" : "s"}${failed ? `; ${failed} could not be deleted` : ""}.`);
+ setNotice(tx(
+ `Deleted ${deleted} reviewed bookmark${deleted === 1 ? "" : "s"}${failed ? `; ${failed} could not be deleted` : ""}.`,
+ `已删除 ${deleted} 个复核书签${failed ? `;${failed} 个删除失败` : ""}。`,
+ ));
} catch (caught) {
- setError(messageFrom(caught));
+ setError(messageFrom(caught, genericError));
} finally {
setCleanupBusy(false);
}
}
+ function cleanupEligibility(bookmark: Bookmark | null) {
+ if (!bookmark) return null;
+ if (bookmark.healthPolicy !== "normal") {
+ return tx(
+ `${policyLabels[bookmark.healthPolicy]} policy is excluded from bulk cleanup.`,
+ `「${policyLabels[bookmark.healthPolicy]}」策略不会进入批量清理列表。`,
+ );
+ }
+ if (cleanupStatuses.has(bookmark.healthStatus)) {
+ return tx(
+ "Latest hard-failure status is eligible for Cleanup Review.",
+ "最近一次硬性失败状态符合清理复核条件。",
+ );
+ }
+ if (bookmark.healthStatus === "timeout") {
+ return tx(
+ "Timeout is treated as transient and excluded from Cleanup Review.",
+ "超时属于临时故障,不会列入清理复核。",
+ );
+ }
+ if (bookmark.healthStatus === "redirected") {
+ return tx(
+ "Redirects stay in review and are never bulk-cleanup candidates.",
+ "重定向仅作复核提示,不会进入批量清理。",
+ );
+ }
+ return null;
+ }
+
const latest = checks[0] ?? null;
const redirectedUrl = latest?.status === "redirected" && latest.finalUrl && latest.finalUrl !== selected?.url
? latest.finalUrl
@@ -288,13 +337,17 @@ export function BookmarkMaintenance({ bookmarks, onChanged }: Props) {
-
METADATA & HEALTH
-
Inspect before you apply.
-
Fetch page metadata, review redirect targets and keep a compact health history. Dockmark never replaces your title or URL automatically.
+
{tx("Metadata & Health", "元数据与健康检查")}
+
+ {tx(
+ "Fetch page metadata, review redirect targets, and inspect health history. Nothing is overwritten automatically.",
+ "按需抓取网页元数据、核对重定向目标并查看健康记录,所有修改均需手动确认。",
+ )}
+
- {bookmarks.length} bookmarks
- Manual review gate
+ {tx(`${bookmarks.length} bookmarks`, `${bookmarks.length} 个书签`)}
+ {tx("Manual review gate", "人工复核模式")}
@@ -308,8 +361,8 @@ export function BookmarkMaintenance({ bookmarks, onChanged }: Props) {
type="search"
value={query}
onChange={(event) => setQuery(event.target.value)}
- placeholder="Search title or URL…"
- aria-label="Search Metadata and Health bookmarks"
+ placeholder={tx("Search title or URL…", "搜索标题或网址…")}
+ aria-label={tx("Search Metadata and Health bookmarks", "搜索元数据与健康检查书签")}
/>
{visibleBookmarks.length} / {bookmarks.length}
@@ -325,29 +378,46 @@ export function BookmarkMaintenance({ bookmarks, onChanged }: Props) {
{bookmark.title}
{bookmark.url}
- {healthLabels[bookmark.healthStatus]}
+ {statusLabels[bookmark.healthStatus]}
))}
- {!bookmarks.length && No bookmarks yet. Add a bookmark before running metadata or health maintenance.
}
- {bookmarks.length > 0 && !visibleBookmarks.length && No matches. Try another title or URL.
}
+ {!bookmarks.length && (
+
+ {tx("No bookmarks yet.", "暂无书签。")}
+ {tx("Add a bookmark before running metadata or health maintenance.", "添加书签后即可执行元数据与健康检查。")}
+
+ )}
+ {bookmarks.length > 0 && !visibleBookmarks.length && (
+
+ {tx("No matches.", "无匹配结果。")}
+ {tx("Try another title or URL.", "请尝试其他标题或网址。")}
+
+ )}
{!selected ? (
-
Select a bookmark to inspect.
+
{tx("Select a bookmark to inspect.", "请从左侧选择一个书签进行查看。")}
) : (
<>
-
-
SELECTED BOOKMARK
-
{selected.title}
-
{selected.url}
+
- {selected.healthPolicy}
- {healthLabels[selected.healthStatus]}
+ {policyLabels[selected.healthPolicy]}
+ {statusLabels[selected.healthStatus]}
@@ -355,11 +425,17 @@ export function BookmarkMaintenance({ bookmarks, onChanged }: Props) {
-
Page metadata
+
{tx("Page metadata", "页面元数据")}
{selected.healthPolicy === "local-only"
- ? "Local/private page metadata is never fetched by the Worker. Local health checks stay in the browser extension instead."
- : "Server fetches are limited to public HTTP(S) pages, follow at most five redirects and read at most 512 KiB of HTML. Canonical URL comes only from the page's rel=canonical tag; HTTP redirects are shown separately as Resolved URL."}
+ ? tx(
+ "Local/private page metadata is never fetched by the Worker. Use local health checks in the extension instead.",
+ "Worker 不会抓取本地/内网页面元数据;本地检查请在浏览器扩展中运行。",
+ )
+ : tx(
+ "Fetches public HTTP(S) pages (max 5 redirects, 512 KiB HTML). Canonical URL comes only from rel=canonical; HTTP redirects appear as Resolved URL.",
+ "仅抓取公网 HTTP(S) 页面(最多 5 次重定向、512 KiB HTML)。规范链接取自 rel=canonical,HTTP 跳转单独显示为最终跳转地址。",
+ )}
void fetchMetadata()}
>
- {selected.healthPolicy === "local-only" ? "Server metadata disabled" : metadataBusy ? "Fetching…" : metadata ? "Refresh metadata" : "Fetch metadata"}
+ {selected.healthPolicy === "local-only"
+ ? tx("Server metadata disabled", "服务端抓取已禁用")
+ : metadataBusy
+ ? tx("Fetching…", "抓取中…")
+ : metadata
+ ? tx("Refresh metadata", "刷新元数据")
+ : tx("Fetch metadata", "抓取元数据")}
- {loading ? Loading…
: metadata ? (
+ {loading ? (
+ {tx("Loading…", "加载中…")}
+ ) : metadata ? (
- Title {metadataTitle ?? "Not provided"}
- {metadataTitle && metadataTitle !== selected.title && void applyUpdate({ title: metadataTitle }, "Metadata title applied.")}>Use title }
+ {tx("Title", "标题")} {metadataTitle ?? tx("Not provided", "未提供")}
+ {metadataTitle && metadataTitle !== selected.title && (
+ void applyUpdate({ title: metadataTitle }, tx("Metadata title applied.", "已应用抓取的标题。"))}
+ >
+ {tx("Use title", "采用标题")}
+
+ )}
- Description {metadataDescription ?? "Not provided"}
- {metadataDescription && metadataDescription !== selected.description && void applyUpdate({ description: metadataDescription }, "Metadata description applied.")}>Use description }
+ {tx("Description", "描述")} {metadataDescription ?? tx("Not provided", "未提供")}
+ {metadataDescription && metadataDescription !== selected.description && (
+ void applyUpdate({ description: metadataDescription }, tx("Metadata description applied.", "已应用抓取的描述。"))}
+ >
+ {tx("Use description", "采用描述")}
+
+ )}
- Canonical URL {metadataCanonicalUrl ?? "Not provided"}
- {metadataCanonicalUrl && metadataCanonicalUrl !== selected.url && void applyUpdate({ url: metadataCanonicalUrl }, "Canonical URL applied. Fetch metadata again for the new URL.", true)}>Use canonical }
+ {tx("Canonical URL", "规范链接")} {metadataCanonicalUrl ?? tx("Not provided", "未提供")}
+ {metadataCanonicalUrl && metadataCanonicalUrl !== selected.url && (
+ void applyUpdate(
+ { url: metadataCanonicalUrl },
+ tx("Canonical URL applied. Fetch metadata again for the new URL.", "已应用规范链接,可按需重新抓取新地址的元数据。"),
+ true,
+ )}
+ >
+ {tx("Use canonical", "采用规范链接")}
+
+ )}
- Icon {metadataIconUrl ?? "Not provided"}
- {metadataIconUrl && metadataIconUrl !== selected.iconUrl && void applyUpdate({ iconUrl: metadataIconUrl }, "Metadata icon applied.")}>Use icon }
+ {tx("Icon", "图标")} {metadataIconUrl ?? tx("Not provided", "未提供")}
+ {metadataIconUrl && metadataIconUrl !== selected.iconUrl && (
+ void applyUpdate({ iconUrl: metadataIconUrl }, tx("Metadata icon applied.", "已应用抓取的图标。"))}
+ >
+ {tx("Use icon", "采用图标")}
+
+ )}
- {metadata.imageUrl &&
Open Graph image {metadata.imageUrl}
}
+ {metadata.imageUrl && (
+
+ {tx("Open Graph image", "Open Graph 封面图")} {metadata.imageUrl}
+
+ )}
{metadataResolvedUrl && (
- Resolved URL {metadataResolvedUrl}
- {resolvedUrlSuggestion && void applyUpdate({ url: resolvedUrlSuggestion }, "Resolved URL applied. Metadata was invalidated for the new URL.", true)}>Use resolved URL }
+ {tx("Resolved URL", "最终跳转地址")} {metadataResolvedUrl}
+ {resolvedUrlSuggestion && (
+ void applyUpdate(
+ { url: resolvedUrlSuggestion },
+ tx("Resolved URL applied. Metadata was invalidated for the new URL.", "已更新为最终跳转地址,旧元数据已清除。"),
+ true,
+ )}
+ >
+ {tx("Use resolved URL", "采用跳转地址")}
+
+ )}
)}
-
Fetched {displayTime(metadata.fetchedAt)}. Suggestions remain separate until you apply them.
+
+ {tx(
+ `Fetched ${displayTime(metadata.fetchedAt, locale)}. Suggestions remain separate until applied.`,
+ `抓取时间:${displayTime(metadata.fetchedAt, locale)}。建议不会自动覆盖书签内容。`,
+ )}
+
) : (
{selected.healthPolicy === "local-only"
- ? "No server metadata is fetched for this local/private bookmark."
- : "No stored metadata. Fetching does not change the bookmark by itself."}
+ ? tx("No server metadata is fetched for this local/private bookmark.", "本地/内网书签不执行服务端元数据抓取。")
+ : tx("No stored metadata. Fetching does not change the bookmark by itself.", "暂无缓存元数据;点击抓取不会自动改动书签。")}
)}
@@ -411,17 +552,23 @@ export function BookmarkMaintenance({ bookmarks, onChanged }: Props) {
-
Health history
+
{tx("Health history", "健康检查历史")}
{selected.healthPolicy === "local-only"
- ? "Local/private checks run only in the paired browser extension after you explicitly allow the exact hostname."
- : "Server checks remain disabled for ignored bookmarks. Manual-policy bookmarks can still be checked explicitly."}
+ ? tx(
+ "Local/private checks run only in the paired browser extension after you explicitly allow the exact hostname.",
+ "本地/内网检查仅在已配对的浏览器扩展中运行,且需逐个授权主机名。",
+ )
+ : tx(
+ "Server checks stay disabled for ignored bookmarks. Manual-policy bookmarks can still be checked explicitly.",
+ "已忽略的书签不会运行服务端检查;手动策略书签仍可点击立即检查。",
+ )}
{selected.healthPolicy === "local-only" ? (
void runLocalHealthCheck()}>
- {healthBusy ? "Checking locally…" : "Check locally"}
+ {healthBusy ? tx("Checking locally…", "本地检查中…") : tx("Check locally", "本地检查")}
) : (
void runHealthCheck()}
>
- {healthBusy ? "Checking…" : selected.healthPolicy === "ignore" ? "Ignored" : "Check now"}
+ {healthBusy
+ ? tx("Checking…", "检查中…")
+ : selected.healthPolicy === "ignore"
+ ? policyLabels.ignore
+ : tx("Check now", "立即检查")}
)}
@@ -444,23 +595,36 @@ export function BookmarkMaintenance({ bookmarks, onChanged }: Props) {
{redirectedUrl && (
- Redirect target {redirectedUrl}
- void applyUpdate({ url: redirectedUrl }, "Redirect target applied. Metadata was invalidated for the new URL.", true)}>Use final URL
+ {tx("Redirect target", "重定向目标")} {redirectedUrl}
+ void applyUpdate(
+ { url: redirectedUrl },
+ tx("Redirect target applied. Metadata was invalidated for the new URL.", "已更新为重定向目标地址,旧元数据已清除。"),
+ true,
+ )}
+ >
+ {tx("Use final URL", "采用最终地址")}
+
)}
{checks.slice(0, 10).map((check) => (
- {healthLabels[check.status]}
- {check.source === "extension" ? "Browser" : "Server"}
+ {statusLabels[check.status]}
+
+ {check.source === "extension" ? tx("Browser", "浏览器") : tx("Server", "服务端")}
+
{check.httpStatus ?? "—"}
{check.responseMs == null ? "—" : `${check.responseMs} ms`}
{check.finalUrl ?? selected.url}
- {displayTime(check.checkedAt)}
+ {displayTime(check.checkedAt, locale)}
))}
- {!checks.length &&
No health checks recorded yet.
}
+ {!checks.length &&
{tx("No health checks recorded yet.", "暂无健康检查记录。")}
}
>
@@ -471,9 +635,13 @@ export function BookmarkMaintenance({ bookmarks, onChanged }: Props) {
-
CLEANUP REVIEW
-
Delete only what you reviewed.
-
Only normal-policy bookmarks whose latest status is DNS error, TLS error or unavailable appear here. Ignored, local-only, manual, timeout, auth, rate-limit and redirect results are excluded.
+
{tx("Cleanup review", "失效书签清理复核")}
+
+ {tx(
+ "Only normal-policy bookmarks whose latest check returned DNS error, TLS error, or unavailable appear here. Ignored, local-only, manual, timeout, auth, rate-limit, and redirect items are excluded.",
+ "仅列出策略为「常规」且最近一次结果为 DNS 错误、TLS 错误或不可访问的书签。已忽略、仅本地、手动、超时、鉴权、限流与重定向项均已自动排除。",
+ )}
+
setCleanupSelection(allCleanupSelected ? new Set() : new Set(cleanupCandidates.map((bookmark) => bookmark.id)))}
>
- {allCleanupSelected ? "Clear selection" : "Select candidates"}
+ {allCleanupSelected ? tx("Clear selection", "取消全选") : tx("Select candidates", "选择候选项")}
void deleteCleanupSelection()}>
- {cleanupBusy ? "Deleting…" : `Delete selected (${cleanupSelection.size})`}
+ {cleanupBusy
+ ? tx("Deleting…", "删除中…")
+ : tx(`Delete selected (${cleanupSelection.size})`, `删除已选 (${cleanupSelection.size})`)}
@@ -498,10 +668,12 @@ export function BookmarkMaintenance({ bookmarks, onChanged }: Props) {
{bookmark.title}
{bookmark.url}
- {healthLabels[bookmark.healthStatus]}
+ {statusLabels[bookmark.healthStatus]}
))}
- {!cleanupCandidates.length && No conservative cleanup candidates right now.
}
+ {!cleanupCandidates.length && (
+ {tx("No conservative cleanup candidates right now.", "当前没有待清理的失效书签。")}
+ )}
diff --git a/apps/web/src/BookmarkManager.tsx b/apps/web/src/BookmarkManager.tsx
index daf791f..845f996 100644
--- a/apps/web/src/BookmarkManager.tsx
+++ b/apps/web/src/BookmarkManager.tsx
@@ -1,9 +1,17 @@
+/**
+ * [INPUT]: depends on Bookmark, Category from @dockmark/core; useI18n from ./i18n; subviews from ./BookmarkManagerLegacy, ./LibraryBulkOrganizer, ./AiOrganizationSettings, ./LibraryBulkMaintenance, ./BookmarkMaintenance, ./ChangeJournal
+ * [OUTPUT]: exports BookmarkManager tabbed hub component
+ * [POS]: top-level Bookmarks route workspace switcher hosting Library, Organize, Health, and History views
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
+
import { useMemo, useState } from "react";
import type { Bookmark, Category } from "@dockmark/core";
import { AiOrganizationSettings } from "./AiOrganizationSettings";
import { BookmarkMaintenance } from "./BookmarkMaintenance";
import { BookmarkManager as ExistingBookmarkManager } from "./BookmarkManagerLegacy";
import { ChangeJournal } from "./ChangeJournal";
+import { useI18n } from "./i18n";
import { LibraryBulkMaintenance } from "./LibraryBulkMaintenance";
import { LibraryBulkOrganizer } from "./LibraryBulkOrganizer";
@@ -17,14 +25,8 @@ interface Props {
type LibraryView = "library" | "organize" | "health" | "history";
-const views: Array<{ id: LibraryView; label: string; detail: string }> = [
- { id: "library", label: "Library", detail: "Create, edit, categorize and reorder bookmarks." },
- { id: "organize", label: "Organize", detail: "Bulk moves, tags and AI-assisted organization." },
- { id: "health", label: "Health", detail: "Metadata, health checks, cleanup and archive review." },
- { id: "history", label: "History", detail: "Review recent library changes." },
-];
-
export function BookmarkManager({ bookmarks, categories, bookmarkTags, loading, onChanged }: Props) {
+ const { tx } = useI18n();
const [view, setView] = useState
("library");
const [journalRevision, setJournalRevision] = useState(0);
const categoryNameById = useMemo(
@@ -32,6 +34,29 @@ export function BookmarkManager({ bookmarks, categories, bookmarkTags, loading,
[categories],
);
+ const views = useMemo>(() => [
+ {
+ id: "library",
+ label: tx("Library", "书签库"),
+ detail: tx("Create, edit, categorize, and reorder bookmarks.", "创建、编辑、分类与排序书签。"),
+ },
+ {
+ id: "organize",
+ label: tx("Organize", "批量与 AI 整理"),
+ detail: tx("Bulk moves, tags, and AI-assisted organization.", "批量分类、标签整理与 AI 辅助整理。"),
+ },
+ {
+ id: "health",
+ label: tx("Health", "元数据与健康"),
+ detail: tx("Metadata, health checks, cleanup, and archive review.", "元数据抓取、健康检查、清理与归档复核。"),
+ },
+ {
+ id: "history",
+ label: tx("History", "变更记录"),
+ detail: tx("Review recent library changes and recovery snapshots.", "查看近期书签库批量变更与恢复快照。"),
+ },
+ ], [tx]);
+
async function onBulkChanged() {
await onChanged();
setJournalRevision((current) => current + 1);
@@ -39,7 +64,7 @@ export function BookmarkManager({ bookmarks, categories, bookmarkTags, loading,
return (
-
+
{views.map((item) => (
Promise;
}
-type DraftPolicy = HealthPolicy | "auto";
-
-interface BookmarkDraft {
- title: string;
- url: string;
- description: string;
- categoryId: string;
- healthPolicy: DraftPolicy;
- tagsText: string;
-}
-
interface BookmarkGroup {
categoryId: string | null;
name: string;
bookmarks: Bookmark[];
}
-const emptyDraft: BookmarkDraft = {
- title: "",
- url: "",
- description: "",
- categoryId: "",
- healthPolicy: "auto",
- tagsText: "",
-};
-
-const healthLabels: Record = {
- unknown: "Unchecked",
- healthy: "Healthy",
- redirected: "Redirected",
- "auth-required": "Auth required",
- forbidden: "Forbidden",
- "rate-limited": "Rate limited",
- timeout: "Timeout",
- "dns-error": "DNS error",
- "tls-error": "TLS error",
- unavailable: "Unavailable",
- "local-only": "Local only",
- ignored: "Ignored",
-};
-
-function messageFrom(error: unknown) {
- return error instanceof Error ? error.message : "Something went wrong.";
+function messageFrom(error: unknown, fallback: string) {
+ return error instanceof Error ? error.message : fallback;
}
-function tagValidationMessage(value: string) {
+function tagValidationMessage(value: string, fallback: string) {
try {
parseBookmarkTags(value);
return null;
} catch (error) {
- return messageFrom(error);
+ return messageFrom(error, fallback);
}
}
@@ -111,98 +87,8 @@ function moveByOffset(ids: string[], id: string, offset: -1 | 1) {
return next;
}
-function HealthBadge({ bookmark }: { bookmark: Bookmark }) {
- const status = bookmark.healthPolicy === "local-only"
- ? "local-only"
- : bookmark.healthPolicy === "ignore"
- ? "ignored"
- : bookmark.healthStatus;
-
- return (
-
- {bookmark.healthPolicy === "manual" && status === "unknown" ? "Manual" : healthLabels[status]}
-
- );
-}
-
-function BookmarkFields({
- draft,
- categories,
- onChange,
- allowAuto,
- idPrefix,
- urlError,
- tagsError,
-}: {
- draft: BookmarkDraft;
- categories: Category[];
- onChange: (draft: BookmarkDraft) => void;
- allowAuto: boolean;
- idPrefix: string;
- urlError?: string | null;
- tagsError?: string | null;
-}) {
- const tagsHelpId = `${idPrefix}-tags-help`;
- const tagsErrorId = `${idPrefix}-tags-error`;
- const urlErrorId = `${idPrefix}-url-error`;
-
- return (
-
-
- Title
- onChange({ ...draft, title: event.target.value })} placeholder="GitHub" />
-
-
- URL
- onChange({ ...draft, url: event.target.value })}
- placeholder="github.com"
- inputMode="url"
- aria-invalid={Boolean(urlError)}
- aria-describedby={urlError ? urlErrorId : undefined}
- />
- {urlError && {urlError} }
-
-
- Category
- onChange({ ...draft, categoryId: event.target.value })}>
- Uncategorized
- {categories.map((category) => {category.name} )}
-
-
-
- Health policy
- onChange({ ...draft, healthPolicy: event.target.value as DraftPolicy })}>
- {allowAuto && Auto detect }
- Normal
- Local only
- Ignore
- Manual
-
-
-
- Description
-
-
- Tags
- onChange({ ...draft, tagsText: event.target.value })}
- placeholder="dev, docs, self-hosted"
- aria-invalid={Boolean(tagsError)}
- aria-describedby={`${tagsHelpId}${tagsError ? ` ${tagsErrorId}` : ""}`}
- />
- Comma, semicolon or newline separated · up to 12 tags · 40 characters each. Invalid input is rejected instead of truncated.
- {tagsError && {tagsError} }
-
-
- );
-}
-
export function BookmarkManager({ bookmarks, categories, bookmarkTags, loading, onChanged }: Props) {
+ const { tx } = useI18n();
const [draft, setDraft] = useState(emptyDraft);
const [editingId, setEditingId] = useState(null);
const [editDraft, setEditDraft] = useState(emptyDraft);
@@ -228,8 +114,11 @@ export function BookmarkManager({ bookmarks, categories, bookmarkTags, loading,
const [draggedCategoryId, setDraggedCategoryId] = useState(null);
const [draggedBookmark, setDraggedBookmark] = useState<{ id: string; categoryId: string | null } | null>(null);
- const createTagError = useMemo(() => tagValidationMessage(draft.tagsText), [draft.tagsText]);
- const editTagError = useMemo(() => tagValidationMessage(editDraft.tagsText), [editDraft.tagsText]);
+ const genericError = tx("Something went wrong.", "操作失败,请重试。");
+ const uncategorizedLabel = tx("Uncategorized", "未分类");
+
+ const createTagError = useMemo(() => tagValidationMessage(draft.tagsText, genericError), [draft.tagsText, genericError]);
+ const editTagError = useMemo(() => tagValidationMessage(editDraft.tagsText, genericError), [editDraft.tagsText, genericError]);
const categoryNameById = useMemo(
() => new Map(categories.map((category) => [category.id, category.name])),
@@ -256,9 +145,9 @@ export function BookmarkManager({ bookmarks, categories, bookmarkTags, loading,
const filteredBookmarks = useMemo(() => bookmarks.filter((bookmark) => {
const tags = bookmarkTags[bookmark.id] ?? [];
if (activeTag && !tags.some((tag) => tag.toLocaleLowerCase() === activeTag.toLocaleLowerCase())) return false;
- const categoryName = bookmark.categoryId ? categoryNameById.get(bookmark.categoryId) ?? "" : "Uncategorized";
+ const categoryName = bookmark.categoryId ? categoryNameById.get(bookmark.categoryId) ?? "" : uncategorizedLabel;
return bookmarkMatchesQuery(bookmark, categoryName, tags, query);
- }), [activeTag, bookmarkTags, bookmarks, categoryNameById, query]);
+ }), [activeTag, bookmarkTags, bookmarks, categoryNameById, query, uncategorizedLabel]);
const filtering = Boolean(query.trim() || activeTag);
@@ -272,13 +161,13 @@ export function BookmarkManager({ bookmarks, categories, bookmarkTags, loading,
}));
groups.push({
categoryId: null,
- name: "Uncategorized",
+ name: uncategorizedLabel,
bookmarks: filteredBookmarks
.filter((bookmark) => !bookmark.categoryId)
.sort((a, b) => a.position - b.position || a.title.localeCompare(b.title)),
});
return groups.filter((group) => group.bookmarks.length > 0);
- }, [filteredBookmarks, categories]);
+ }, [filteredBookmarks, categories, uncategorizedLabel]);
async function refreshAfter(action: () => Promise) {
setBusy(true);
@@ -289,12 +178,12 @@ export function BookmarkManager({ bookmarks, categories, bookmarkTags, loading,
await action();
} catch (caught) {
actionError = caught;
- setError(messageFrom(caught));
+ setError(messageFrom(caught, genericError));
}
try {
await onChanged();
} catch (caught) {
- if (!actionError) setError(messageFrom(caught));
+ if (!actionError) setError(messageFrom(caught, genericError));
} finally {
setBusy(false);
}
@@ -307,9 +196,9 @@ export function BookmarkManager({ bookmarks, categories, bookmarkTags, loading,
try {
await reorderCategories(ids);
await onChanged();
- setNotice("Category order saved.");
+ setNotice(tx("Category order saved.", "已保存分类顺序。"));
} catch (caught) {
- setError(messageFrom(caught));
+ setError(messageFrom(caught, genericError));
await onChanged();
} finally {
setReordering(false);
@@ -324,9 +213,9 @@ export function BookmarkManager({ bookmarks, categories, bookmarkTags, loading,
try {
await reorderBookmarks(categoryId, ids);
await onChanged();
- setNotice("Bookmark order saved.");
+ setNotice(tx("Bookmark order saved.", "已保存书签顺序。"));
} catch (caught) {
- setError(messageFrom(caught));
+ setError(messageFrom(caught, genericError));
await onChanged();
} finally {
setReordering(false);
@@ -370,7 +259,7 @@ export function BookmarkManager({ bookmarks, categories, bookmarkTags, loading,
await checkBookmarkHealth(bookmark.id);
await onChanged();
} catch (caught) {
- setError(messageFrom(caught));
+ setError(messageFrom(caught, genericError));
} finally {
setCheckingIds((current) => {
const next = new Set(current);
@@ -402,9 +291,12 @@ export function BookmarkManager({ bookmarks, categories, bookmarkTags, loading,
});
}
await onChanged();
- setNotice(`Checked ${checked} bookmark${checked === 1 ? "" : "s"}${failed ? `; ${failed} failed to check` : ""}.`);
+ setNotice(tx(
+ `Checked ${checked} bookmark${checked === 1 ? "" : "s"}${failed ? `; ${failed} failed to check` : ""}.`,
+ `已完成 ${checked} 个书签健康检查${failed ? `;${failed} 个检查失败` : ""}。`,
+ ));
} catch (caught) {
- setError(messageFrom(caught));
+ setError(messageFrom(caught, genericError));
} finally {
setCheckingIds(new Set());
setBulkChecking(false);
@@ -433,16 +325,19 @@ export function BookmarkManager({ bookmarks, categories, bookmarkTags, loading,
const result = await createBookmarkWithTags(input, tags);
setDraft(emptyDraft);
setCreateUrlError(null);
- setCreateStatus(`Saved “${result.bookmark.title}”.`);
+ setCreateStatus(tx(`Saved “${result.bookmark.title}”.`, `已保存「${result.bookmark.title}」。`));
try {
await onChanged();
} catch (refreshError) {
- setCreateSubmitError(`Saved, but the library could not refresh: ${messageFrom(refreshError)}`);
+ setCreateSubmitError(tx(
+ `Saved, but the library could not refresh: ${messageFrom(refreshError, genericError)}`,
+ `已保存,但书签库刷新失败:${messageFrom(refreshError, genericError)}`,
+ ));
}
} catch (caught) {
const urlMessage = duplicateUrlMessage(caught);
if (urlMessage) setCreateUrlError(urlMessage);
- else setCreateSubmitError(messageFrom(caught));
+ else setCreateSubmitError(messageFrom(caught, genericError));
} finally {
setCreatingBookmark(false);
}
@@ -474,12 +369,15 @@ export function BookmarkManager({ bookmarks, categories, bookmarkTags, loading,
try {
await onChanged();
} catch (refreshError) {
- setError(`Bookmark was saved, but the library could not refresh: ${messageFrom(refreshError)}`);
+ setError(tx(
+ `Bookmark was saved, but the library could not refresh: ${messageFrom(refreshError, genericError)}`,
+ `书签已保存,但书签库刷新失败:${messageFrom(refreshError, genericError)}`,
+ ));
}
} catch (caught) {
const urlMessage = duplicateUrlMessage(caught);
if (urlMessage) setEditUrlError(urlMessage);
- else setEditSubmitError(messageFrom(caught));
+ else setEditSubmitError(messageFrom(caught, genericError));
} finally {
setSavingEditId(null);
}
@@ -523,16 +421,27 @@ export function BookmarkManager({ bookmarks, categories, bookmarkTags, loading,
}
return (
-
-
+
+
-
BOOKMARK LIBRARY
-
Keep the useful parts of your browser portable.
+
{tx("Bookmark Library", "书签库")}
+
+ {tx("Add, categorize, tag, and reorder bookmarks synced across your browsers.", "添加、分类、标记并排序你的全部书签。")}
+
- {bookmarks.length} bookmarks · {tagSummary.length} tags
- void checkEligible()}>
- {bulkChecking ? "Checking…" : `Check ${eligibleForAutomaticCheck.length} eligible`}
+
+ {tx(`${bookmarks.length} bookmarks · ${tagSummary.length} tags`, `${bookmarks.length} 个书签 · ${tagSummary.length} 个标签`)}
+
+ void checkEligible()}
+ >
+ {bulkChecking
+ ? tx("Checking…", "检查中…")
+ : tx(`Check ${eligibleForAutomaticCheck.length} eligible`, `检查 ${eligibleForAutomaticCheck.length} 个可检书签`)}
@@ -541,89 +450,89 @@ export function BookmarkManager({ bookmarks, categories, bookmarkTags, loading,
{notice && {notice}
}
-
+
{ setEditingCategoryId(category.id); setEditingCategoryName(category.name); }}
+ onCancelEditCategory={() => setEditingCategoryId(null)}
+ onEditingCategoryNameChange={setEditingCategoryName}
+ onSubmitCategoryEdit={submitCategoryEdit}
+ onDeleteCategory={(category) => {
+ if (window.confirm(tx(
+ `Delete category “${category.name}”? Its bookmarks will become uncategorized.`,
+ `删除分类「${category.name}」?其中的书签将变为未分类。`,
+ ))) {
+ void refreshAfter(() => deleteCategory(category.id));
+ }
+ }}
+ onDragStartCategory={setDraggedCategoryId}
+ onDragEndCategory={() => setDraggedCategoryId(null)}
+ onDropCategory={categoryDrop}
+ onMoveCategory={(id, offset) => void persistCategoryOrder(moveByOffset(categories.map((item) => item.id), id, offset))}
+ onSelectTag={setActiveTag}
+ />
-
Find bookmarks {filteredBookmarks.length} of {bookmarks.length}
- {filtering &&
{ setQuery(""); setActiveTag(null); }}>Clear filters }
+
+ {tx("Find bookmarks", "查找书签")}
+ {tx(`${filteredBookmarks.length} of ${bookmarks.length}`, `${filteredBookmarks.length} / ${bookmarks.length}`)}
+
+ {filtering && (
+
{ setQuery(""); setActiveTag(null); }}>
+ {tx("Clear filters", "清除筛选")}
+
+ )}
- ⌕
- setQuery(event.target.value)} placeholder="Search title, URL, description, category or #tag…" aria-label="Search bookmark library" />
+ ⌕
+ setQuery(event.target.value)}
+ placeholder={tx("Search title, URL, description, category, or #tag…", "搜索标题、网址、描述、分类或 #标签…")}
+ aria-label={tx("Search bookmark library", "搜索书签库")}
+ />
-
Space-separated terms use AND matching across Library, Launcher and New Tab. Example: github #dev. Reordering is paused while a filter is active.
+
+ {tx(
+ "Space-separated terms use AND matching across Library, Launcher, and New Tab (e.g. ",
+ "空格分隔的关键词按 AND 匹配,并同步用于书签库、启动台与新标签页(例如 ",
+ )}
+ github #dev
+ {tx("). Reordering pauses while filtered.", ")。筛选期间暂停拖拽排序。")}
+
) : (
<>
⋮⋮
-
{bookmark.title.slice(0, 1).toUpperCase()}
+
{bookmark.title}
- {savedBookmarkId === bookmark.id &&
Saved }
+ {savedBookmarkId === bookmark.id && (
+
{tx("Saved", "已保存")}
+ )}
-
{bookmark.url}
+
{bookmark.url}
{bookmark.description &&
{bookmark.description}
}
{group.name}
@@ -716,15 +639,48 @@ export function BookmarkManager({ bookmarks, categories, bookmarkTags, loading,
- void persistBookmarkOrder(group.categoryId, moveByOffset(ids, bookmark.id, -1))}>↑
- void persistBookmarkOrder(group.categoryId, moveByOffset(ids, bookmark.id, 1))}>↓
+ void persistBookmarkOrder(group.categoryId, moveByOffset(ids, bookmark.id, -1))}
+ >
+ ↑
+
+ void persistBookmarkOrder(group.categoryId, moveByOffset(ids, bookmark.id, 1))}
+ >
+ ↓
+
{(bookmark.healthPolicy === "normal" || bookmark.healthPolicy === "manual") && (
- void checkOne(bookmark)}>
- {checkingIds.has(bookmark.id) ? "Checking…" : "Check"}
+ void checkOne(bookmark)}
+ >
+ {checkingIds.has(bookmark.id) ? tx("Checking…", "检查中…") : tx("Check", "检查")}
)}
- beginEdit(bookmark)}>Edit
- { if (window.confirm(`Delete “${bookmark.title}”?`)) void refreshAfter(() => deleteBookmark(bookmark.id)); }}>Delete
+ beginEdit(bookmark)}>
+ {tx("Edit", "编辑")}
+
+ {
+ if (window.confirm(tx(`Delete “${bookmark.title}”?`, `确认删除「${bookmark.title}」?`))) {
+ void refreshAfter(() => deleteBookmark(bookmark.id));
+ }
+ }}
+ >
+ {tx("Delete", "删除")}
+
>
)}
@@ -737,10 +693,16 @@ export function BookmarkManager({ bookmarks, categories, bookmarkTags, loading,
})}
{!loading && !bookmarks.length && (
-
No bookmarks yet. Add the first URL above or import a browser bookmark file.
+
+ {tx("No bookmarks yet.", "暂无书签。")}
+ {tx("Add your first URL above or import a browser bookmark file.", "在上方添加首个书签,或前往导入导出页导入浏览器书签。")}
+
)}
{!loading && bookmarks.length > 0 && !filteredBookmarks.length && (
-
No bookmarks match this filter. Try another term, remove the active tag, or clear filters.
+
+ {tx("No bookmarks match this filter.", "没有符合筛选条件的书签。")}
+ {tx("Try another keyword, remove the active tag, or clear filters.", "尝试其他关键词、取消当前标签或清除筛选。")}
+
)}
diff --git a/apps/web/src/BrowserExtensionManager.tsx b/apps/web/src/BrowserExtensionManager.tsx
index 3eb40d8..990f645 100644
--- a/apps/web/src/BrowserExtensionManager.tsx
+++ b/apps/web/src/BrowserExtensionManager.tsx
@@ -1,3 +1,9 @@
+/**
+ * [INPUT]: depends on browser-bridge diagnostics from ./browser-bridge, release constants/version comparison from ./extension-distribution, BrowserSettingsManager, useI18n from ./i18n, and ./extension.css
+ * [OUTPUT]: exports BrowserExtensionManager hub with profile downloads, manual install guide, BrowserSettingsManager, and live bridge diagnostics
+ * [POS]: Mounted inside App.tsx for /app/extension. Presents Chromium New Tab, Chromium Standard, and Firefox MV3 packages alongside live capability checks.
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
import { useCallback, useEffect, useMemo, useState } from "react";
import {
BRIDGE_PROTOCOL_VERSION,
@@ -16,26 +22,15 @@ import {
compareExtensionVersions,
} from "./extension-distribution";
import { BrowserSettingsManager } from "./BrowserSettingsManager";
+import { useI18n } from "./i18n";
import "./extension.css";
-const capabilityLabels: Array<[keyof BrowserBridgeStatus["capabilities"], string]> = [
- ["openTabs", "Open tabs"],
- ["activateTabs", "Switch to existing tabs"],
- ["workspaceReuse", "Workspace reuse"],
- ["workspacePinned", "Pinned workspace tabs"],
- ["sessionRestore", "Session restore"],
- ["sessionPinned", "Pinned session restore"],
- ["nativeBookmarks", "Native bookmarks"],
- ["nativeBookmarkSync", "Native bookmark mapping sync"],
- ["nativeBookmarkWriteback", "Manual bookmark writeback"],
- ["localHealth", "Local URL health checks"],
-];
-
function external(url: string) {
window.open(url, "_blank", "noopener,noreferrer");
}
export function BrowserExtensionManager() {
+ const { tx } = useI18n();
const [status, setStatus] = useState(null);
const [checking, setChecking] = useState(true);
const [error, setError] = useState(null);
@@ -43,6 +38,22 @@ export function BrowserExtensionManager() {
const webStoreUrl = CHROME_WEB_STORE_URL;
const newTabWebStoreUrl = CHROME_NEW_TAB_WEB_STORE_URL;
+ const capabilityLabels = useMemo>(
+ () => [
+ ["openTabs", tx("Open tabs", "打开的标签页")],
+ ["activateTabs", tx("Switch to existing tabs", "切换到已有标签页")],
+ ["workspaceReuse", tx("Workspace reuse", "工作区标签复用")],
+ ["workspacePinned", tx("Pinned workspace tabs", "工作区固定标签页")],
+ ["sessionRestore", tx("Session restore", "会话恢复")],
+ ["sessionPinned", tx("Pinned session restore", "固定会话标签恢复")],
+ ["nativeBookmarks", tx("Native bookmarks", "原生书签读取")],
+ ["nativeBookmarkSync", tx("Native bookmark mapping sync", "原生书签映射同步")],
+ ["nativeBookmarkWriteback", tx("Manual bookmark writeback", "手动书签回写")],
+ ["localHealth", tx("Local URL health checks", "本地内网链接健康检查")],
+ ],
+ [tx],
+ );
+
const refresh = useCallback(async () => {
setChecking(true);
setError(null);
@@ -50,11 +61,11 @@ export function BrowserExtensionManager() {
setStatus(await getRawBridgeStatus());
} catch (caught) {
setStatus(null);
- setError(caught instanceof Error ? caught.message : "Dockmark browser extension was not detected.");
+ setError(caught instanceof Error ? caught.message : tx("Dockmark browser extension was not detected.", "未检测到 Dockmark 浏览器扩展。"));
} finally {
setChecking(false);
}
- }, []);
+ }, [tx]);
useEffect(() => {
const unsubscribe = onBridgeEvent((event) => {
@@ -78,20 +89,25 @@ export function BrowserExtensionManager() {
const nativeBookmarksGranted = Boolean(status?.permissions?.nativeBookmarks);
const state = useMemo(() => {
- if (checking) return { label: "Checking", tone: "neutral" } as const;
- if (!status) return { label: "Not connected", tone: "warning" } as const;
- if (!protocolCompatible) return { label: "Update required", tone: "danger" } as const;
- if (updateAvailable) return { label: "Update available", tone: "warning" } as const;
- if (!nativeBookmarksGranted) return { label: "Connected · bookmarks off", tone: "warning" } as const;
- return { label: "Connected", tone: "success" } as const;
- }, [checking, nativeBookmarksGranted, protocolCompatible, status, updateAvailable]);
+ if (checking) return { label: tx("Checking", "检测中"), tone: "neutral" } as const;
+ if (!status) return { label: tx("Not connected", "未连接"), tone: "warning" } as const;
+ if (!protocolCompatible) return { label: tx("Update required", "需要更新"), tone: "danger" } as const;
+ if (updateAvailable) return { label: tx("Update available", "有可用更新"), tone: "warning" } as const;
+ if (!nativeBookmarksGranted) return { label: tx("Connected · bookmarks off", "已连接 · 未开启书签权限"), tone: "warning" } as const;
+ return { label: tx("Connected", "已连接"), tone: "success" } as const;
+ }, [checking, nativeBookmarksGranted, protocolCompatible, status, tx, updateAvailable]);
return (
-
BROWSER INTEGRATION
-
Choose the Dockmark browser profile you want.
+
{tx("Browser Extension", "浏览器扩展")}
+
+ {tx(
+ "Install the Chromium or Firefox extension for live open tabs, pinned sessions and reviewed bookmark sync.",
+ "安装 Chromium 或 Firefox 扩展,解锁实时标签页切换、固定会话恢复与人工确认书签同步。",
+ )}
+
{state.label}
@@ -99,45 +115,74 @@ export function BrowserExtensionManager() {
Chromium + Firefox · v{EXTENSION_RELEASE_VERSION}
-
{status ? `Extension ${status.extensionVersion} detected` : "One Browser Bridge, explicit browser profiles"}
+
+ {status
+ ? tx(`Extension v${status.extensionVersion} detected`, `已检测到扩展 v${status.extensionVersion}`)
+ : tx("Choose a browser profile", "选择适合你的扩展版本")}
+
- Chromium keeps the Standard and local-first New Tab profiles. Firefox joins v1.0 with a Standard MV3 preview using the same reviewed Browser Bridge, native-bookmark permission model and local-health safety boundaries.
+ {tx(
+ "Chromium provides both a local-first New Tab profile and a Standard profile. Firefox provides a Standard MV3 package with the same reviewed Browser Bridge and safety boundaries.",
+ "Chromium 提供本地优先的「新标签页版」与「标准版」;Firefox 提供标准 MV3 预览版,共享同一浏览器桥接与安全边界。",
+ )}
{status && protocolCompatible && !nativeBookmarksGranted && (
- Native bookmarks are not enabled.
- Open the Dockmark extension popup and choose Enable bookmark access . This permission is used for reviewed import/sync and explicit manual writeback; Dockmark never writes browser bookmarks in the background.
+ {tx("Native bookmarks permission is off.", "原生书签权限尚未开启。")}
+
+ {tx(
+ "Open the Dockmark extension popup and enable bookmark access for reviewed import, sync and manual writeback. Dockmark never writes browser bookmarks in the background.",
+ "打开 Dockmark 扩展弹窗并开启「书签访问权限」,即可使用受审导入、同步与手动回写。Dockmark 绝不在后台静默写入浏览器书签。",
+ )}
+
)}
- setGuideOpen((open) => !open)}>Installation Guide
+ setGuideOpen((open) => !open)}>
+ {guideOpen ? tx("Hide installation guide", "收起安装指南") : tx("Installation guide", "安装指南")}
+
void refresh()}>
- {checking ? "Checking…" : "Refresh diagnostics"}
+ {checking ? tx("Checking…", "检测中…") : tx("Refresh diagnostics", "刷新诊断")}
D·
-
+
- CHROMIUM · RECOMMENDED
+ {tx("CHROMIUM · RECOMMENDED", "CHROMIUM · 推荐")}
Dockmark New Tab
-
LOCAL FIRST
+
{tx("LOCAL FIRST", "本地优先")}
- Make every new tab an instant local Dockmark launcher. Cached bookmarks, Workspaces, search engines and open tabs appear before the network is needed; cloud data refreshes quietly in the background.
+
+ {tx(
+ "Turn every new tab into an instant local Dockmark launcher. Cached bookmarks, Workspaces, search engines and open tabs appear before the network responds.",
+ "将每个新标签页变为毫秒级本地启动台。缓存书签、工作区、搜索引擎与打开标签页即刻呈现,云端数据在后台静默刷新。",
+ )}
+
- Fast extension-local startup — no redirect to your Workers URL.
- Last-known-good cache keeps search and launch available offline.
- Same Bridge, Sessions and bookmark sync/writeback features as Standard.
+ {tx("Instant extension-local startup — no redirect to your Workers URL.", "本地极速启动,无需跳转等待 Workers 响应。")}
+ {tx("Last-known-good cache keeps search and launch working offline.", "本地快照缓存确保离线也可检索与启动。")}
+ {tx("Includes all Browser Bridge, Session and reviewed bookmark sync features.", "包含完整的浏览器桥接、会话恢复与书签同步能力。")}
- {newTabWebStoreUrl && external(newTabWebStoreUrl)}>Add Dockmark New Tab }
- external(NEW_TAB_EXTENSION_DOWNLOAD_URL)}>
- {updateAvailable ? `Download New Tab v${EXTENSION_RELEASE_VERSION}` : "Download New Tab"}
+ {newTabWebStoreUrl && (
+ external(newTabWebStoreUrl)}>
+ {tx("Add Dockmark New Tab", "前往商店安装 New Tab")}
+
+ )}
+ external(NEW_TAB_EXTENSION_DOWNLOAD_URL)}
+ >
+ {updateAvailable
+ ? tx(`Download New Tab v${EXTENSION_RELEASE_VERSION}`, `下载 New Tab v${EXTENSION_RELEASE_VERSION}`)
+ : tx("Download New Tab", "下载 New Tab 版")}
@@ -145,21 +190,36 @@ export function BrowserExtensionManager() {
- CHROMIUM · STANDARD
+ {tx("CHROMIUM · STANDARD", "CHROMIUM · 标准版")}
Dockmark Extension
-
NEW TAB UNCHANGED
+
{tx("NEW TAB UNCHANGED", "保留默认新标签页")}
- Keep your browser's existing New Tab page while adding Dockmark's Browser Bridge and reviewed bookmark integration.
+
+ {tx(
+ "Keep your browser's existing New Tab page while adding Dockmark's Browser Bridge and reviewed bookmark integration.",
+ "保留浏览器原有新标签页,仅接入 Dockmark 浏览器桥接、弹窗收录与原生书签同步能力。",
+ )}
+
- Never declares a browser New Tab override.
- Open tabs, Workspace reuse, Sessions and native bookmark mapping.
- Manual Dockmark → Browser title/URL writeback only when you choose it.
+ {tx("Never declares a browser New Tab override.", "不接管浏览器新标签页。")}
+ {tx("Open tabs, Workspace reuse, Sessions and native bookmark mapping.", "支持实时标签页、工作区复用、会话恢复与书签映射。")}
+ {tx("Manual Dockmark → Browser writeback only when explicitly triggered.", "仅在手动触发并确认时将变更回写到浏览器书签。")}
- {webStoreUrl && external(webStoreUrl)}>Add Standard Extension }
- external(EXTENSION_DOWNLOAD_URL)}>
- {updateAvailable || (!protocolCompatible && Boolean(status)) ? `Download Standard v${EXTENSION_RELEASE_VERSION}` : "Download Standard"}
+ {webStoreUrl && (
+ external(webStoreUrl)}>
+ {tx("Add Standard Extension", "前往商店安装标准版")}
+
+ )}
+ external(EXTENSION_DOWNLOAD_URL)}
+ >
+ {updateAvailable || (!protocolCompatible && Boolean(status))
+ ? tx(`Download Standard v${EXTENSION_RELEASE_VERSION}`, `下载标准版 v${EXTENSION_RELEASE_VERSION}`)
+ : tx("Download Standard", "下载标准版")}
@@ -167,52 +227,106 @@ export function BrowserExtensionManager() {
- FIREFOX · PREVIEW
-
Dockmark Extension for Firefox
+ {tx("FIREFOX · PREVIEW", "FIREFOX · 预览版")}
+ {tx("Dockmark Extension for Firefox", "Dockmark Firefox 扩展")}
-
MV3 STANDARD
+
{tx("MV3 STANDARD", "MV3 标准版")}
- The Firefox package intentionally starts with the Standard profile. It targets Manifest V3 so Dockmark can keep the same dynamic, explicitly authorized bridge registration model instead of falling back to a broader MV2 permission surface.
+
+ {tx(
+ "Targets Manifest V3 with dynamic per-origin authorization, preserving the same explicit permission model as Chromium Standard.",
+ "基于 Manifest V3 构建,按站点显式授权桥接与可选权限,保持与 Chromium 标准版一致的安全模型。",
+ )}
+
- Same open-tab, Workspace, Session and reviewed native-bookmark capabilities.
- Bookmark access stays optional; local/private health access stays per-host and explicit.
- No New Tab override yet — Firefox New Tab parity waits for real-browser validation.
+ {tx("Same open-tab, Workspace, Session and reviewed native-bookmark capabilities.", "完整支持标签页切换、工作区、会话与受审原生书签同步。")}
+ {tx("Bookmark access stays optional; local-health host access stays explicit.", "原生书签权限按需开启,本地内网健康检查按主机单独授权。")}
+ {tx("Standard profile only — does not override Firefox New Tab.", "当前为标准版,不覆盖 Firefox 默认新标签页。")}
external(FIREFOX_EXTENSION_DOWNLOAD_URL)}>
- Download Firefox v{EXTENSION_RELEASE_VERSION}
+ {tx(`Download Firefox v${EXTENSION_RELEASE_VERSION}`, `下载 Firefox 版 v${EXTENSION_RELEASE_VERSION}`)}
- Install one Chromium profile only . For an existing unpacked Chromium installation, replace the files in the same extension folder and click Reload in chrome://extensions; keeping the same folder preserves the extension ID, mappings and New Tab cache. The Firefox GitHub ZIP is an unsigned validation build and is intended for temporary loading through about:debugging until signed distribution is configured.
+ {tx(
+ "Install one Chromium profile only. When updating an unpacked build, replace files inside the same folder and click Reload in ",
+ "Chromium 浏览器请仅安装其中一个版本。更新本地解压版时,请覆盖原目录文件并在 ",
+ )}
+ chrome://extensions
+ {tx(
+ " to keep extension ID, mappings and cache. The Firefox ZIP is an unsigned validation build for temporary loading via ",
+ " 中点击「重新加载」,以保留扩展 ID、映射关系与本地缓存。Firefox ZIP 为未签名验证包,可通过 ",
+ )}
+ about:debugging
+ {tx(".", " 临时加载。")}
{(guideOpen || !status) && (
-
Manual installation Release ZIP installation for Chromium and Firefox validation.
-
Release page ↗
+
+
{tx("Manual installation", "手动安装步骤")}
+
{tx("Load the release ZIP in Chromium or Firefox.", "使用 GitHub Release ZIP 在 Chromium 或 Firefox 中加载。")}
+
+
+ {tx("Release page ↗", "发布页 ↗")}
+
Chromium
- Choose either dockmark-newtab-chrome-v{EXTENSION_RELEASE_VERSION}.zip or dockmark-chrome-v{EXTENSION_RELEASE_VERSION}.zip, then unzip it.
- Open chrome://extensions (or the equivalent extensions page in your Chromium browser).
- Enable Developer mode , choose Load unpacked , then select the folder containing manifest.json.
- Open the Dockmark popup, set this site as the server, grant site access, then separately enable bookmark access if you need reviewed browser bookmark sync/writeback.
+
+ {tx("Download and unzip ", "下载并解压 ")}
+ dockmark-newtab-chrome-v{EXTENSION_RELEASE_VERSION}.zip
+ {tx(" or ", " 或 ")}
+ dockmark-chrome-v{EXTENSION_RELEASE_VERSION}.zip.
+
+
+ {tx("Open ", "打开 ")}
+ chrome://extensions
+ {tx(" in your browser.", " 扩展管理页面。")}
+
+
+ {tx("Enable Developer mode, click Load unpacked, and select the folder containing ", "开启「开发者模式」,点击「加载已解压的扩展程序」,选择包含 ")}
+ manifest.json
+ {tx(".", " 的文件夹。")}
+
+
+ {tx(
+ "Open the Dockmark popup, connect this origin, enter a pairing code, and optionally enable bookmark access.",
+ "打开 Dockmark 扩展弹窗,连接当前站点并填入配对码,按需开启书签访问权限。",
+ )}
+
-
Firefox preview
+
{tx("Firefox preview", "Firefox 预览版")}
- Download dockmark-firefox-v{EXTENSION_RELEASE_VERSION}.zip and unzip it.
- Open about:debugging#/runtime/this-firefox and choose Load Temporary Add-on… .
- Select the extracted manifest.json. The temporary add-on is removed when Firefox restarts.
- Configure the Dockmark origin in the popup, approve only that site, then test bookmark access and local-health host permission separately.
+
+ {tx("Download and unzip ", "下载并解压 ")}
+ dockmark-firefox-v{EXTENSION_RELEASE_VERSION}.zip.
+
+
+ {tx("Open ", "打开 ")}
+ about:debugging#/runtime/this-firefox
+ {tx(" and click Load Temporary Add-on…", " 并点击「临时载入附加组件…」。")}
+
+
+ {tx("Select the extracted ", "选择解压后的 ")}
+ manifest.json
+ {tx(". Temporary add-ons reset when Firefox restarts.", "(Firefox 重启后需重新加载)。")}
+
+
+ {tx(
+ "Set this Dockmark origin in the popup, approve site access, and enable optional permissions as needed.",
+ "在弹窗中配置当前 Dockmark 地址、批准站点访问并按需开启可选权限。",
+ )}
+
@@ -223,23 +337,67 @@ export function BrowserExtensionManager() {
- Connection Live handshake between this Dockmark origin and the browser extension.
+
+
+
{tx("Connection", "连接诊断")}
+
{tx("Live handshake between this Dockmark origin and the extension.", "当前页面与浏览器扩展之间的实时握手状态。")}
+
+
-
Current Dockmark origin {window.location.origin}
-
Extension {status ? `v${status.extensionVersion}` : "Not detected"}
-
Bridge protocol {status ? `${status.protocolVersion} / Web ${BRIDGE_PROTOCOL_VERSION}` : `Web ${BRIDGE_PROTOCOL_VERSION}`}
-
Compatibility {status ? protocolCompatible ? "Compatible" : "Update required" : "Waiting for extension"}
-
Native bookmark permission {status?.permissions?.nativeBookmarks ? "Granted" : status ? "Not granted" : "Unavailable"}
+
+
{tx("Current Dockmark origin", "当前站点来源")}
+ {window.location.origin}
+
+
+
{tx("Extension", "扩展版本")}
+ {status ? `v${status.extensionVersion}` : tx("Not detected", "未检测到")}
+
+
+
{tx("Bridge protocol", "桥接协议")}
+ {status ? `${status.protocolVersion} / Web ${BRIDGE_PROTOCOL_VERSION}` : `Web ${BRIDGE_PROTOCOL_VERSION}`}
+
+
+
{tx("Compatibility", "兼容性")}
+
+ {status
+ ? protocolCompatible
+ ? tx("Compatible", "兼容")
+ : tx("Update required", "需要更新")
+ : tx("Waiting for extension", "等待扩展连接")}
+
+
+
+
{tx("Native bookmark permission", "原生书签权限")}
+
+ {status?.permissions?.nativeBookmarks
+ ? tx("Granted", "已授权")
+ : status
+ ? tx("Not granted", "未授权")
+ : tx("Unavailable", "不可用")}
+
+
{error && {error}
}
- Capabilities Capabilities are reported by the connected extension, not assumed by the Web app.
+
+
+
{tx("Capabilities", "可用能力")}
+
{tx("Reported directly by the connected extension.", "由已连接的扩展实时上报的能力清单。")}
+
+
{capabilityLabels.map(([key, label]) => {
const enabled = Boolean(status?.capabilities[key]);
- return
{label} {enabled ? "Available" : status ? "Not available" : "—"}
;
+ return (
+
+ {label}
+
+ {enabled ? tx("Available", "可用") : status ? tx("Not available", "不可用") : "—"}
+
+
+ );
})}
diff --git a/apps/web/src/BrowserSettingsManager.tsx b/apps/web/src/BrowserSettingsManager.tsx
index 0892865..95e4c45 100644
--- a/apps/web/src/BrowserSettingsManager.tsx
+++ b/apps/web/src/BrowserSettingsManager.tsx
@@ -1,3 +1,9 @@
+/**
+ * [INPUT]: depends on DEFAULT_BROWSER_SETTINGS, normalizeBrowserSettings, BrowserSettings, SearchEngine from @dockmark/core; useI18n from ./i18n; and ./settings.css
+ * [OUTPUT]: exports BrowserSettingsManager panel for local-first and cloud-synced New Tab and bookmark conflict policies
+ * [POS]: Shared between SettingsPage (/app/settings/browser) and BrowserExtensionManager (/app/extension). Persists settings to localStorage and PATCH /api/settings/browser.
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
import { useEffect, useMemo, useState } from "react";
import {
DEFAULT_BROWSER_SETTINGS,
@@ -5,6 +11,7 @@ import {
type BrowserSettings,
type SearchEngine,
} from "@dockmark/core";
+import { useI18n } from "./i18n";
import "./settings.css";
const LOCAL_SETTINGS_KEY = "dockmarkBrowserSettingsV1";
@@ -62,13 +69,16 @@ async function saveCloudSettings(settings: BrowserSettings) {
return normalizeBrowserSettings(payload.settings);
}
-function dateLabel(value: string | null) {
- if (!value) return "Not synced yet";
+function dateLabel(value: string | null, locale: string, tx: (en: string, zh: string) => string) {
+ if (!value) return tx("Not synced yet", "尚未同步");
const date = new Date(value);
- return Number.isNaN(date.getTime()) ? "Synced" : `Cloud synced ${date.toLocaleString()}`;
+ if (Number.isNaN(date.getTime())) return tx("Synced", "已同步");
+ const formatted = new Intl.DateTimeFormat(locale, { dateStyle: "medium", timeStyle: "short" }).format(date);
+ return tx(`Cloud synced ${formatted}`, `云端同步于 ${formatted}`);
}
export function BrowserSettingsManager() {
+ const { locale, tx } = useI18n();
const [settings, setSettings] = useState
(() => readLocalSettings());
const [engines, setEngines] = useState([]);
const [loading, setLoading] = useState(true);
@@ -89,7 +99,8 @@ export function BrowserSettingsManager() {
})
.catch((error) => {
if (cancelled) return;
- setMessage(`${error instanceof Error ? error.message : "Could not load cloud settings."} Using local settings.`);
+ const reason = error instanceof Error ? error.message : tx("Could not load cloud settings.", "无法加载云端配置。");
+ setMessage(tx(`${reason} Using local settings.`, `${reason} 当前使用本地配置。`));
})
.finally(() => {
if (!cancelled) setLoading(false);
@@ -97,7 +108,7 @@ export function BrowserSettingsManager() {
return () => {
cancelled = true;
};
- }, []);
+ }, [tx]);
const orderedEngines = useMemo(
() => [...engines].sort((a, b) => a.position - b.position),
@@ -108,7 +119,7 @@ export function BrowserSettingsManager() {
setSettings(next);
writeLocalSettings(next);
setDirty(true);
- setMessage("Saved locally. Sync to cloud to share this policy with Dockmark New Tab.");
+ setMessage(tx("Saved locally. Sync to cloud to share this policy with Dockmark New Tab.", "已在本地保存,点击同步后将推送到云端及 Dockmark New Tab。"));
}
function patchNewTab(
@@ -132,9 +143,9 @@ export function BrowserSettingsManager() {
setSettings(saved);
writeLocalSettings(saved);
setDirty(false);
- setMessage("Settings synced. New Tab will pick them up on its next refresh.");
+ setMessage(tx("Settings synced. New Tab will pick them up on its next refresh.", "设置已同步,新标签页将在下次刷新时生效。"));
} catch (error) {
- setMessage(error instanceof Error ? error.message : "Could not save settings.");
+ setMessage(error instanceof Error ? error.message : tx("Could not save settings.", "保存设置失败。"));
} finally {
setSaving(false);
}
@@ -143,20 +154,24 @@ export function BrowserSettingsManager() {
function resetLocal() {
const defaults = normalizeBrowserSettings(DEFAULT_BROWSER_SETTINGS);
update(defaults);
- setMessage("Defaults restored locally. Sync to cloud to make them authoritative.");
+ setMessage(tx("Defaults restored locally. Sync to cloud to make them authoritative.", "已在本地恢复默认设置,点击同步以覆盖云端配置。"));
}
return (
-
BROWSER / NEW TAB SETTINGS
-
Local first, cloud synced.
-
Changes are written to this browser immediately. Sync them to D1 so the New Tab profile and future devices use the same policy.
+
{tx("Browser & New Tab", "浏览器与新标签页")}
+
+ {tx(
+ "Changes apply locally right away. Sync to D1 so Dockmark New Tab and other browsers share the same defaults.",
+ "修改会立即保存在本地;同步到 D1 后,Dockmark 新标签页与其他浏览器将共享同一策略。",
+ )}
+
- {dirty ? "Local changes" : "In sync"}
- {loading ? "Loading cloud settings…" : dateLabel(settings.updatedAt)}
+ {dirty ? tx("Local changes", "有未同步修改") : tx("In sync", "已同步")}
+ {loading ? tx("Loading cloud settings…", "正在加载云端配置…") : dateLabel(settings.updatedAt, locale, tx)}
@@ -164,15 +179,20 @@ export function BrowserSettingsManager() {
-
Bookmark conflict preference
-
This guides reviewed conflict resolution. Prefer Browser / Prefer Dockmark highlights the matching action and can batch one-sided Dockmark changes after you explicitly confirm.
+
{tx("Bookmark conflict preference", "书签冲突处理偏好")}
+
+ {tx(
+ "Guides reviewed conflict resolution. Prefer Browser / Prefer Dockmark highlights the matching action and enables confirmed one-sided batch apply.",
+ "用于引导书签同步审查。「优先浏览器 / 优先 Dockmark」会高亮推荐动作,并在你明确确认后支持单边变更批量应用。",
+ )}
+
-
+
{([
- ["ask", "Ask every time"],
- ["browser", "Prefer Browser"],
- ["dockmark", "Prefer Dockmark"],
+ ["ask", tx("Ask every time", "每次询问")],
+ ["browser", tx("Prefer Browser", "优先浏览器")],
+ ["dockmark", tx("Prefer Dockmark", "优先 Dockmark")],
] as const).map(([value, label]) => (
))}
-
This policy never enables background bookmark writes. True two-sided REVIEW conflicts still require an individual decision.
+
+ {tx(
+ "Never enables background bookmark writes. Two-sided conflicts always require an individual decision.",
+ "该偏好不会开启后台自动写入;双边冲突始终需要逐项确认。",
+ )}
+
-
New Tab search
-
Choose the engine used by the local launcher when no bang/keyword is entered.
+
{tx("New Tab search", "新标签页默认搜索")}
+
{tx("Engine used by the local launcher when no bang shortcut is entered.", "未输入快捷搜索词(如 !g)时,新标签页启动台使用的默认引擎。")}
- Default search engine
+ {tx("Default search engine", "默认搜索引擎")}
patchNewTab("defaultSearchEngineId", event.target.value || null)}
>
- Follow Dockmark default
+ {tx("Follow Dockmark default", "跟随 Dockmark 默认引擎")}
{orderedEngines.map((engine) => (
- {engine.name}{engine.isDefault ? " · default" : ""}
+
+ {engine.name}
+ {engine.isDefault ? tx(" · default", " · 默认") : ""}
+
))}
@@ -211,13 +239,16 @@ export function BrowserSettingsManager() {
-
Local launcher
-
Tune what Dockmark New Tab renders from its last-known-good local snapshot.
+
{tx("Local launcher", "本地启动台")}
+
{tx("Control what Dockmark New Tab displays from its cached local snapshot.", "配置 Dockmark 新标签页从本地快照渲染的内容与数量。")}
- Show open tabs Include live browser tabs in command search.
+
+ {tx("Show open tabs", "显示打开的标签页")}
+ {tx("Include live browser tabs in command search.", "在命令搜索中包含当前已打开的标签页。")}
+
- Background refresh Refresh cloud data quietly whenever a New Tab opens online.
+
+ {tx("Background refresh", "静默后台刷新")}
+ {tx("Refresh cloud data quietly whenever a New Tab opens online.", "在线打开新标签页时在后台自动更新云端快照。")}
+
- Bookmark cards
+ {tx("Bookmark cards", "书签卡片数量")}
- Workspace cards
+ {tx("Workspace cards", "工作区卡片数量")}
{message &&
{message}
}
-
New Tab cache status, manual refresh and cache clearing are available directly in the local launcher so they still work when the Dockmark server is offline.
+
+ {tx(
+ "Cache status, manual refresh and cache clearing stay inside the local New Tab page so they work even offline.",
+ "本地快照状态、手动刷新与清除缓存位于新标签页内部,离线时也可正常操作。",
+ )}
+
- Reset defaults
+
+ {tx("Reset defaults", "恢复默认")}
+
void save()} disabled={saving || !dirty}>
- {saving ? "Syncing…" : "Sync settings"}
+ {saving ? tx("Syncing…", "同步中…") : tx("Sync settings", "同步设置")}
diff --git a/apps/web/src/ChangeJournal.tsx b/apps/web/src/ChangeJournal.tsx
index 2623d7e..917bba7 100644
--- a/apps/web/src/ChangeJournal.tsx
+++ b/apps/web/src/ChangeJournal.tsx
@@ -1,51 +1,95 @@
+/**
+ * [INPUT]: depends on HEALTH_POLICY_LABELS, HEALTH_STATUS_LABELS, HealthPolicy, HealthStatus from @dockmark/core; listChangeJournal, ChangeJournalEntry, ChangeJournalSnapshot from ./change-journal-api; useI18n from ./i18n
+ * [OUTPUT]: exports ChangeJournal component
+ * [POS]: History tab view inside BookmarkManager displaying transaction-recorded before/after snapshots for manual audit and recovery
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
+
import { useEffect, useState } from "react";
+import {
+ HEALTH_POLICY_LABELS,
+ HEALTH_STATUS_LABELS,
+ type HealthPolicy,
+ type HealthStatus,
+ type ResolvedLocale,
+} from "@dockmark/core";
import {
listChangeJournal,
type ChangeJournalEntry,
type ChangeJournalSnapshot,
} from "./change-journal-api";
+import { useI18n } from "./i18n";
import "./change-journal.css";
interface Props {
revision: string;
}
-function messageFrom(error: unknown) {
- return error instanceof Error ? error.message : "Could not load the change journal.";
+function messageFrom(error: unknown, fallback: string) {
+ return error instanceof Error ? error.message : fallback;
}
-function displayTime(value: string) {
+function displayTime(value: string, locale: ResolvedLocale) {
const date = new Date(value);
- return Number.isNaN(date.valueOf()) ? value : date.toLocaleString();
+ if (Number.isNaN(date.valueOf())) return value;
+ return new Intl.DateTimeFormat(locale, {
+ dateStyle: "medium",
+ timeStyle: "short",
+ }).format(date);
+}
+
+function formatHealthPolicy(value: string, locale: ResolvedLocale) {
+ const map = HEALTH_POLICY_LABELS[locale] as Record;
+ return map[value as HealthPolicy] ?? value;
}
-function stateLabel(snapshot: ChangeJournalSnapshot | null) {
- if (!snapshot) return "Deleted";
- return [
- snapshot.archived ? "Archived" : "Active",
- snapshot.inbox ? "Inbox" : "Filed",
- snapshot.published ? "Public" : "Private",
- ].join(" · ");
+function formatHealthStatus(value: string, locale: ResolvedLocale) {
+ const map = HEALTH_STATUS_LABELS[locale] as Record;
+ return map[value as HealthStatus] ?? value;
}
function Snapshot({ label, value }: { label: string; value: ChangeJournalSnapshot | null }) {
+ const { locale, tx } = useI18n();
+
+ const stateText = !value
+ ? tx("Deleted", "已删除")
+ : [
+ value.archived ? tx("Archived", "已归档") : tx("Active", "活跃"),
+ value.inbox ? tx("Inbox", "收件箱") : tx("Filed", "已归类"),
+ value.published ? tx("Public", "公开") : tx("Private", "私密"),
+ ].join(" · ");
+
return (
{label}
- {!value ? No bookmark record : <>
- Category: {value.categoryName ?? (value.categoryId ? value.categoryId : "Uncategorized")}
- Tags: {value.tags.length ? value.tags.map((tag) => `#${tag}`).join(" ") : "None"}
- Health: {value.healthPolicy} / {value.healthStatus}
- State: {stateLabel(value)}
- Position: {value.position}
- {value.description && Description: {value.description} }
- {value.iconUrl && Icon: {value.iconUrl} }
- >}
+ {!value ? (
+ {tx("No bookmark record", "无书签记录")}
+ ) : (
+ <>
+
+ {tx("Category:", "分类:")}{" "}
+ {value.categoryName ?? (value.categoryId ? value.categoryId : tx("Uncategorized", "未分类"))}
+
+
+ {tx("Tags:", "标签:")}{" "}
+ {value.tags.length ? value.tags.map((tag) => `#${tag}`).join(" ") : tx("None", "无")}
+
+
+ {tx("Health:", "健康:")}{" "}
+ {formatHealthPolicy(value.healthPolicy, locale)} / {formatHealthStatus(value.healthStatus, locale)}
+
+ {tx("State:", "状态:")} {stateText}
+ {tx("Position:", "排序位置:")} {value.position}
+ {value.description && {tx("Description:", "描述:")} {value.description} }
+ {value.iconUrl && {tx("Icon:", "图标:")} {value.iconUrl} }
+ >
+ )}
);
}
export function ChangeJournal({ revision }: Props) {
+ const { locale, tx } = useI18n();
const [entries, setEntries] = useState([]);
const [loading, setLoading] = useState(true);
const [error, setError] = useState(null);
@@ -57,7 +101,7 @@ export function ChangeJournal({ revision }: Props) {
try {
setEntries(await listChangeJournal(30));
} catch (caught) {
- setError(messageFrom(caught));
+ setError(messageFrom(caught, tx("Could not load the change journal.", "无法加载变更记录。")));
} finally {
setLoading(false);
}
@@ -73,24 +117,35 @@ export function ChangeJournal({ revision }: Props) {
setCopiedId(entry.id);
window.setTimeout(() => setCopiedId((current) => current === entry.id ? null : current), 1800);
} catch {
- setError("Could not copy recovery JSON. Expand Raw recovery JSON and copy it manually.");
+ setError(tx(
+ "Could not copy recovery JSON. Expand Raw recovery JSON and copy it manually.",
+ "复制恢复 JSON 失败,请展开下方原始 JSON 后手动复制。",
+ ));
}
}
return (
-
+
-
V5 · RECOVERY CONTEXT
-
Change journal
-
High-impact reviewed batches record before/after context in the same D1 transaction. This is an audit and manual-recovery surface, not automatic undo.
+
{tx("Change journal", "变更记录")}
+
+ {tx(
+ "High-impact reviewed batches record before/after snapshots in the same transaction for audit and manual recovery.",
+ "高影响批量操作会在同一事务中记录变更前后快照,供审计与手动恢复使用。",
+ )}
+
-
void refresh()}>{loading ? "Refreshing…" : "Refresh"}
+
void refresh()}>
+ {loading ? tx("Refreshing…", "刷新中…") : tx("Refresh", "刷新")}
+
{error &&
{error}
}
- {!loading && !entries.length &&
No high-impact bulk changes have been journaled yet.
}
+ {!loading && !entries.length && (
+
{tx("No high-impact bulk changes have been recorded yet.", "暂无批量变更记录。")}
+ )}
{entries.map((entry) => (
@@ -98,13 +153,23 @@ export function ChangeJournal({ revision }: Props) {
{entry.summary}
- {displayTime(entry.createdAt)} · {entry.operation} · {entry.itemCount} item{entry.itemCount === 1 ? "" : "s"}
+
+ {displayTime(entry.createdAt, locale)} · {entry.operation} ·{" "}
+ {tx(`${entry.itemCount} item${entry.itemCount === 1 ? "" : "s"}`, `${entry.itemCount} 项`)}
+
- Use the recorded values to manually restore or verify a later repair.
- void copyEntry(entry)}>{copiedId === entry.id ? "Copied" : "Copy recovery JSON"}
+
+ {tx(
+ "Use the recorded values to manually restore or verify a repair.",
+ "可参考记录的变更前后字段进行人工核对或恢复。",
+ )}
+
+ void copyEntry(entry)}>
+ {copiedId === entry.id ? tx("Copied", "已复制") : tx("Copy recovery JSON", "复制恢复 JSON")}
+
{entry.items.map((item) => (
@@ -114,14 +179,14 @@ export function ChangeJournal({ revision }: Props) {
{item.url}
-
-
+
+
))}
- Raw recovery JSON
+ {tx("Raw recovery JSON", "原始恢复 JSON")}
{JSON.stringify(entry, null, 2)}
diff --git a/apps/web/src/DuplicateReviewPage.tsx b/apps/web/src/DuplicateReviewPage.tsx
index 08fd247..4c59eb5 100644
--- a/apps/web/src/DuplicateReviewPage.tsx
+++ b/apps/web/src/DuplicateReviewPage.tsx
@@ -1,29 +1,88 @@
+/**
+ * [INPUT]: depends on useEffect, useMemo, useState from react; HEALTH_POLICY_LABELS, HEALTH_STATUS_LABELS, ResolvedLocale from @dockmark/core; getDuplicateReview, DuplicateCandidateKind, DuplicateReviewCandidate, DuplicateReviewMember, DuplicateReviewResult from ./duplicate-review-api; useI18n from ./i18n; BookmarkFavicon, safeDomainLabel from ./BookmarkFavicon; ./duplicate-review.css
+ * [OUTPUT]: exports DuplicateReviewPage component for read-only side-by-side inspection of conservative duplicate bookmark pairs
+ * [POS]: top-level /app/duplicates workspace; displays URL/metadata evidence without mutating bookmarks
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
+
import { useEffect, useMemo, useState } from "react";
+import {
+ HEALTH_POLICY_LABELS,
+ HEALTH_STATUS_LABELS,
+ type ResolvedLocale,
+} from "@dockmark/core";
+import { BookmarkFavicon, safeDomainLabel } from "./BookmarkFavicon";
import {
getDuplicateReview,
type DuplicateCandidateKind,
type DuplicateReviewCandidate,
+ type DuplicateReviewMember,
type DuplicateReviewResult,
} from "./duplicate-review-api";
+import { useI18n } from "./i18n";
import "./duplicate-review.css";
-const kindLabels: Record
= {
- canonical: "Canonical target",
- resolved: "Resolved target",
- normalized: "URL variant",
-};
+type TxFn = (en: string, zh: string) => string;
-const kindDescriptions: Record = {
- canonical: "Strong metadata evidence",
- resolved: "Redirect / final-URL evidence",
- normalized: "Conservative URL normalization",
+const KNOWN_REASON_ZH: Record = {
+ "Saved page metadata points these bookmarks at the same canonical target.":
+ "已保存的页面元数据显示这两条书签指向同一个规范链接目标。",
+ "Saved metadata shows these bookmarks resolving to the same final target.":
+ "已保存的页面元数据显示这两条书签最终跳转到同一个目标地址。",
+ "The URLs become equivalent after ignoring protocol/www, fragments, trailing slashes and known tracking parameters.":
+ "忽略协议/www、锚点片段、末尾斜杠及常见追踪参数后,两条链接等价。",
};
-function messageFrom(error: unknown) {
- return error instanceof Error ? error.message : "Could not load duplicate review.";
+function kindLabel(kind: DuplicateCandidateKind, tx: TxFn): string {
+ switch (kind) {
+ case "canonical":
+ return tx("Canonical target", "规范链接");
+ case "resolved":
+ return tx("Resolved target", "跳转目标");
+ case "normalized":
+ return tx("URL variant", "URL 变体");
+ }
+}
+
+function kindDescription(kind: DuplicateCandidateKind, tx: TxFn): string {
+ switch (kind) {
+ case "canonical":
+ return tx("Strong metadata evidence", "强元数据依据");
+ case "resolved":
+ return tx("Redirect / final-URL evidence", "重定向 / 最终地址依据");
+ case "normalized":
+ return tx("Conservative URL normalization", "保守 URL 归一化");
+ }
+}
+
+function localizedReason(candidate: DuplicateReviewCandidate, isZh: boolean): string {
+ if (!isZh) return candidate.reason;
+ return KNOWN_REASON_ZH[candidate.reason] ?? candidate.reason;
+}
+
+function healthPolicyLabel(policy: string, locale: ResolvedLocale): string {
+ const labels = HEALTH_POLICY_LABELS[locale] as Record;
+ return labels[policy] ?? policy;
+}
+
+function healthStatusLabel(status: string, locale: ResolvedLocale): string {
+ const labels = HEALTH_STATUS_LABELS[locale] as Record;
+ return labels[status] ?? status;
+}
+
+function formatFetchedDate(value: string, locale: ResolvedLocale): string {
+ const date = new Date(value);
+ if (Number.isNaN(date.getTime())) return value;
+ return new Intl.DateTimeFormat(locale, {
+ year: "numeric",
+ month: "short",
+ day: "numeric",
+ hour: "2-digit",
+ minute: "2-digit",
+ }).format(date);
}
-function matches(candidate: DuplicateReviewCandidate, query: string) {
+function matches(candidate: DuplicateReviewCandidate, query: string): boolean {
const normalized = query.trim().toLocaleLowerCase();
if (!normalized) return true;
const haystack = [
@@ -34,33 +93,81 @@ function matches(candidate: DuplicateReviewCandidate, query: string) {
candidate.right.url,
candidate.right.categoryName ?? "",
candidate.evidenceUrl ?? "",
- ].join("\n").toLocaleLowerCase();
+ ]
+ .join("\n")
+ .toLocaleLowerCase();
return normalized.split(/\s+/).every((token) => haystack.includes(token));
}
-function MemberCard({ side, candidate }: { side: "left" | "right"; candidate: DuplicateReviewCandidate }) {
- const bookmark = candidate[side];
+function MemberCard({
+ side,
+ candidate,
+ locale,
+ tx,
+}: {
+ side: "left" | "right";
+ candidate: DuplicateReviewCandidate;
+ locale: ResolvedLocale;
+ tx: TxFn;
+}) {
+ const bookmark = candidate[side] as DuplicateReviewMember & { iconUrl?: string | null };
return (
-
{side === "left" ? "A" : "B"}
-
-
{bookmark.title}
-
{bookmark.categoryName ?? "Uncategorized"} · {bookmark.healthPolicy} · {bookmark.healthStatus}
+
+
+
+ {side === "left" ? "A" : "B"}
+ {bookmark.title}
+
+
+ {safeDomainLabel(bookmark.url)} · {bookmark.categoryName ?? tx("Uncategorized", "未分类")} ·{" "}
+ {healthPolicyLabel(bookmark.healthPolicy, locale)} ·{" "}
+ {healthStatusLabel(bookmark.healthStatus, locale)}
+
-
{bookmark.url}
+
+
+ {bookmark.url}
+
{bookmark.description &&
{bookmark.description}
}
-
- {bookmark.canonicalUrl &&
Canonical {bookmark.canonicalUrl}
}
- {bookmark.finalUrl &&
Resolved {bookmark.finalUrl}
}
- {bookmark.metadataFetchedAt &&
Metadata fetched {new Date(bookmark.metadataFetchedAt).toLocaleString()} }
-
+
+ {(bookmark.canonicalUrl || bookmark.finalUrl || bookmark.metadataFetchedAt) && (
+
+ {bookmark.canonicalUrl && (
+
+ {tx("Canonical", "规范链接")}
+ {bookmark.canonicalUrl}
+
+ )}
+ {bookmark.finalUrl && (
+
+ {tx("Resolved", "最终跳转")}
+ {bookmark.finalUrl}
+
+ )}
+ {bookmark.metadataFetchedAt && (
+
+ {tx(
+ `Metadata fetched ${formatFetchedDate(bookmark.metadataFetchedAt, locale)}`,
+ `元数据抓取于 ${formatFetchedDate(bookmark.metadataFetchedAt, locale)}`,
+ )}
+
+ )}
+
+ )}
);
}
export function DuplicateReviewPage() {
+ const { locale, isZh, tx } = useI18n();
const [result, setResult] = useState
(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState(null);
@@ -75,19 +182,30 @@ export function DuplicateReviewPage() {
setResult(await getDuplicateReview());
setHiddenIds(new Set());
} catch (caught) {
- setError(messageFrom(caught));
+ setError(
+ caught instanceof Error
+ ? caught.message
+ : tx("Could not load duplicate review.", "无法加载重复项审查。"),
+ );
} finally {
setLoading(false);
}
}
- useEffect(() => { void refresh(); }, []);
+ useEffect(() => {
+ void refresh();
+ }, []);
- const visible = useMemo(() => (result?.candidates ?? []).filter((candidate) =>
- !hiddenIds.has(candidate.id) &&
- (kind === "all" || candidate.kind === kind) &&
- matches(candidate, query),
- ), [hiddenIds, kind, query, result]);
+ const visible = useMemo(
+ () =>
+ (result?.candidates ?? []).filter(
+ (candidate) =>
+ !hiddenIds.has(candidate.id) &&
+ (kind === "all" || candidate.kind === kind) &&
+ matches(candidate, query),
+ ),
+ [hiddenIds, kind, query, result],
+ );
function hide(id: string) {
setHiddenIds((current) => new Set(current).add(id));
@@ -97,84 +215,190 @@ export function DuplicateReviewPage() {
return (
-
-
-
V5 · DUPLICATE REVIEW
-
Evidence first. No silent cleanup.
-
Dockmark compares saved URLs with metadata canonical and resolved targets, then surfaces conservative duplicate candidates for human review. This workspace never merges, edits or deletes bookmarks.
+
+
+
{tx("Duplicate Review", "重复项审查")}
+
+ {tx(
+ "Compare saved URLs with canonical and resolved metadata evidence. Read-only — Dockmark never merges, edits, or deletes bookmarks automatically.",
+ "结合规范链接与跳转目标元数据识别候选重复书签。仅提供审查建议,不会自动合并、修改或删除书签。",
+ )}
+
- void refresh()}>{loading ? "Analyzing…" : "Refresh review"}
-
+
+
+ {stats?.totalCandidates ?? 0}
+ {tx("pairs", "组候选")}
+
+ void refresh()}
+ >
+ {loading ? tx("Analyzing…", "分析中…") : tx("Refresh review", "重新分析")}
+
+
+
{error &&
{error}
}
-
- {stats?.totalCandidates ?? 0} candidate pairs
- {stats?.canonicalCandidates ?? 0} canonical
- {stats?.resolvedCandidates ?? 0} resolved
- {stats?.normalizedCandidates ?? 0} URL variants
- {stats?.metadataBookmarks ?? 0}/{stats?.analyzedBookmarks ?? 0} with metadata
+
+
+ {stats?.totalCandidates ?? 0}
+ {tx("Candidate pairs", "候选重复组")}
+
+
+ {stats?.canonicalCandidates ?? 0}
+ {tx("Canonical", "规范链接")}
+
+
+ {stats?.resolvedCandidates ?? 0}
+ {tx("Resolved", "跳转目标")}
+
+
+ {stats?.normalizedCandidates ?? 0}
+ {tx("URL variants", "URL 变体")}
+
+
+
+ {stats?.metadataBookmarks ?? 0}/{stats?.analyzedBookmarks ?? 0}
+
+ {tx("With metadata", "已含元数据")}
+
{(stats?.bookmarkAnalysisTruncated || stats?.candidateListTruncated) && (
-
- {stats.bookmarkAnalysisTruncated && <>Analysis is limited to the most recently updated {stats.analyzedBookmarks} bookmarks. >}
- {stats.candidateListTruncated && <>Showing the first {result?.candidates.length ?? 0} of {stats.totalCandidates} candidate pairs.>}
+
+ {stats.bookmarkAnalysisTruncated && (
+
+ {tx(
+ `Analysis is limited to the most recently updated ${stats.analyzedBookmarks} bookmarks. `,
+ `本次分析仅覆盖最近更新的 ${stats.analyzedBookmarks} 条书签。`,
+ )}
+
+ )}
+ {stats.candidateListTruncated && (
+
+ {tx(
+ `Showing the first ${result?.candidates.length ?? 0} of ${stats.totalCandidates} candidate pairs.`,
+ `当前显示前 ${result?.candidates.length ?? 0} 组,共检测到 ${stats.totalCandidates} 组候选重复。`,
+ )}
+
+ )}
)}
- Search review queue
- setQuery(event.target.value)} placeholder="Title, URL, category or evidence target…" />
+ {tx("Search review queue", "搜索审查列表")}
+ setQuery(event.target.value)}
+ placeholder={tx("Title, URL, category, or evidence target…", "按标题、链接、分类或依据地址搜索…")}
+ />
- Evidence
- setKind(event.target.value as "all" | DuplicateCandidateKind)}>
- All evidence
- Canonical target
- Resolved target
- URL variant
+ {tx("Evidence", "依据类型")}
+ setKind(event.target.value as "all" | DuplicateCandidateKind)}
+ >
+ {tx("All evidence", "全部依据")}
+ {tx("Canonical target", "规范链接")}
+ {tx("Resolved target", "跳转目标")}
+ {tx("URL variant", "URL 变体")}
- {visible.length} visible
- {hiddenIds.size > 0 && setHiddenIds(new Set())}>Restore {hiddenIds.size} hidden }
+ {tx(`${visible.length} visible`, `显示 ${visible.length} 组`)}
+ {hiddenIds.size > 0 && (
+ setHiddenIds(new Set())}
+ >
+ {tx(`Restore ${hiddenIds.size} hidden`, `恢复 ${hiddenIds.size} 组已隐藏`)}
+
+ )}
- {loading && !result ? Analyzing saved bookmark and metadata evidence…
: visible.map((candidate) => (
-
-
-
-
-
{kindLabels[candidate.kind]}
-
{kindDescriptions[candidate.kind]}
+ {loading && !result ? (
+
+ {tx("Analyzing saved bookmark and metadata evidence…", "正在分析书签与页面元数据依据…")}
+
+ ) : (
+ visible.map((candidate) => (
+
+
+
+
+ {kindLabel(candidate.kind, tx)}
+ {kindDescription(candidate.kind, tx)}
+
+
{localizedReason(candidate, isZh)}
+ {candidate.evidenceUrl && (
+
{candidate.evidenceUrl}
+ )}
- {candidate.reason}
- {candidate.evidenceUrl && {candidate.evidenceUrl}}
-
-
hide(candidate.id)}>Hide for now
-
-
-
- Recommendation only — decide in Library / Metadata & Health before changing anything.
-
-
Open A
-
Open B
+
hide(candidate.id)}
+ >
+ {tx("Hide for now", "暂时隐藏")}
+
+
+
+
-
-
- ))}
+
+
+
+ {tx(
+ "Recommendation only — review in Bookmarks or Metadata & Health before editing or deleting.",
+ "仅供参考 — 请在「书签库」或「元数据与健康」中确认后再编辑或删除。",
+ )}
+
+
+
+
+ ))
+ )}
+
{!loading && result && visible.length === 0 && (
- {result.stats.totalCandidates ? "No candidates match this view." : "No duplicate candidates found."}
- {result.stats.metadataBookmarks < result.stats.analyzedBookmarks ? "Fetching metadata for public bookmarks can reveal additional canonical or resolved-target evidence." : "Current URL and metadata evidence does not suggest duplicate pairs."}
+
+ {result.stats.totalCandidates
+ ? tx("No candidates match this filter.", "当前筛选条件下没有匹配的候选重复项。")
+ : tx("No duplicate candidates found.", "未发现重复项候选。")}
+
+
+ {result.stats.metadataBookmarks < result.stats.analyzedBookmarks
+ ? tx(
+ "Fetching metadata for public bookmarks can reveal additional canonical or resolved-target evidence.",
+ "为公开书签抓取页面元数据可发现更多规范链接或跳转目标依据。",
+ )
+ : tx(
+ "Current URL and metadata evidence does not suggest duplicate pairs.",
+ "根据当前链接与页面元数据,未检测到疑似重复的书签组合。",
+ )}
+
)}
diff --git a/apps/web/src/InboxPage.tsx b/apps/web/src/InboxPage.tsx
index 1b2430a..175f2ec 100644
--- a/apps/web/src/InboxPage.tsx
+++ b/apps/web/src/InboxPage.tsx
@@ -1,3 +1,10 @@
+/**
+ * [INPUT]: depends on useEffect, useMemo, useState from react; Category from @dockmark/core; listCategories, refreshBookmarkMetadata, updateBookmark, BookmarkMetadata from ./api; generateAiOrganizationSuggestions, getAiProviderStatus, loadAiProviderSettings, AiOrganizationSuggestion from ./ai-organization; listInbox, resolveInboxBookmark, reviewInboxBatch, InboxBookmark, InboxReviewPatch from ./inbox-api; listBookmarkTags from ./tag-api; useI18n from ./i18n; BookmarkFavicon from ./BookmarkFavicon; InboxReviewCard and metadata helpers from ./InboxReviewCard
+ * [OUTPUT]: exports InboxPage component for reviewing, enriching, AI-triaging, and filing captured Inbox bookmarks
+ * [POS]: top-level /app/inbox triage view; coordinates batch AI preview and delegates per-bookmark review cards to InboxReviewCard
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
+
import { useEffect, useMemo, useState } from "react";
import type { Category } from "@dockmark/core";
import {
@@ -12,6 +19,8 @@ import {
loadAiProviderSettings,
type AiOrganizationSuggestion,
} from "./ai-organization";
+import { BookmarkFavicon } from "./BookmarkFavicon";
+import { useI18n } from "./i18n";
import {
listInbox,
resolveInboxBookmark,
@@ -19,54 +28,27 @@ import {
type InboxBookmark,
type InboxReviewPatch,
} from "./inbox-api";
+import {
+ InboxReviewCard,
+ emptyMetadataSelection,
+ selectionCount,
+ type MetadataField,
+ type MetadataSelection,
+} from "./InboxReviewCard";
import { listBookmarkTags } from "./tag-api";
-type MetadataField = "title" | "description" | "canonicalUrl" | "iconUrl";
-type MetadataSelection = Record
;
-
-function emptyMetadataSelection(): MetadataSelection {
- return {
- title: false,
- description: false,
- canonicalUrl: false,
- iconUrl: false,
- };
-}
-
-function hostLabel(url: string) {
- try {
- return new URL(url).host;
- } catch {
- return url;
- }
-}
-
-function dateLabel(value: string) {
- const date = new Date(value);
- if (Number.isNaN(date.getTime())) return value;
- return new Intl.DateTimeFormat(undefined, {
- month: "short",
- day: "numeric",
- hour: "2-digit",
- minute: "2-digit",
- }).format(date);
-}
-
-function selectionCount(selection: MetadataSelection | undefined) {
- return selection ? Object.values(selection).filter(Boolean).length : 0;
-}
-
-function sameTags(left: string[], right: string[]) {
+function sameTags(left: string[], right: string[]): boolean {
const a = left.map((tag) => tag.toLocaleLowerCase()).sort();
const b = right.map((tag) => tag.toLocaleLowerCase()).sort();
return a.length === b.length && a.every((tag, index) => tag === b[index]);
}
-function messageFrom(error: unknown) {
- return error instanceof Error ? error.message : "Something went wrong.";
+function messageFrom(error: unknown, fallback: string): string {
+ return error instanceof Error ? error.message : fallback;
}
export function InboxPage() {
+ const { locale, tx } = useI18n();
const [bookmarks, setBookmarks] = useState([]);
const [categories, setCategories] = useState([]);
const [bookmarkTags, setBookmarkTags] = useState>({});
@@ -110,6 +92,10 @@ export function InboxPage() {
() => aiEligible.filter((bookmark) => aiGeneratedIds.has(bookmark.id)).length,
[aiEligible, aiGeneratedIds],
);
+ const aiPreviewIds = useMemo(
+ () => new Set(aiSuggestions.map((suggestion) => suggestion.bookmarkId)),
+ [aiSuggestions],
+ );
async function refresh() {
setLoading(true);
@@ -136,7 +122,7 @@ export function InboxPage() {
return next;
});
} catch (caught) {
- setError(caught instanceof Error ? caught.message : "Could not load Inbox.");
+ setError(messageFrom(caught, tx("Could not load Inbox.", "无法加载收件箱。")));
} finally {
setLoading(false);
}
@@ -165,9 +151,14 @@ export function InboxPage() {
const metadata = await refreshBookmarkMetadata(bookmark.id);
setMetadataById((current) => ({ ...current, [bookmark.id]: metadata }));
setMetadataSelections((current) => ({ ...current, [bookmark.id]: emptyMetadataSelection() }));
- setNotice(`Metadata refreshed for “${bookmark.title}”. Nothing was applied automatically.`);
+ setNotice(
+ tx(
+ `Metadata refreshed for “${bookmark.title}”. Nothing was applied automatically.`,
+ `已刷新「${bookmark.title}」的页面元数据,尚未自动写入。`,
+ ),
+ );
} catch (caught) {
- setError(caught instanceof Error ? caught.message : "Could not fetch bookmark metadata.");
+ setError(messageFrom(caught, tx("Could not fetch bookmark metadata.", "无法抓取书签元数据。")));
} finally {
setMetadataBusyId(null);
}
@@ -214,7 +205,12 @@ export function InboxPage() {
if (selection.title && metadata?.title && metadata.title !== bookmark.title) {
if (metadata.title.length > 200) {
- throw new Error("The suggested metadata title is longer than Dockmark's 200-character bookmark title limit.");
+ throw new Error(
+ tx(
+ "The suggested metadata title is longer than Dockmark's 200-character bookmark title limit.",
+ "建议的元数据标题超过了 Dockmark 的 200 字符书签标题上限。",
+ ),
+ );
}
input.title = metadata.title;
}
@@ -236,21 +232,29 @@ export function InboxPage() {
removeLocalState(removed);
setAiSuggestions((current) => current.filter((suggestion) => !removed.has(suggestion.bookmarkId)));
setAiAcceptedIds((current) => new Set(Array.from(current).filter((id) => !removed.has(id))));
- const categoryName = categoryId ? categoryById.get(categoryId) ?? "selected category" : "Uncategorized";
+ const categoryName = categoryId
+ ? categoryById.get(categoryId) ?? tx("selected category", "所选分类")
+ : tx("Uncategorized", "未分类");
const applied = Object.keys(input).length;
setNotice(
applied
- ? `Reviewed “${bookmark.title}” with ${applied} metadata suggestion${applied === 1 ? "" : "s"} → ${categoryName}.`
- : `Reviewed “${bookmark.title}” → ${categoryName}.`,
+ ? tx(
+ `Reviewed “${bookmark.title}” with ${applied} metadata suggestion${applied === 1 ? "" : "s"} → ${categoryName}.`,
+ `已归档「${bookmark.title}」(应用 ${applied} 项元数据建议)→ ${categoryName}。`,
+ )
+ : tx(
+ `Reviewed “${bookmark.title}” → ${categoryName}.`,
+ `已归档「${bookmark.title}」→ ${categoryName}。`,
+ ),
);
} catch (caught) {
- setError(caught instanceof Error ? caught.message : "Could not review Inbox bookmark.");
+ setError(messageFrom(caught, tx("Could not review Inbox bookmark.", "无法归档收件箱书签。")));
} finally {
setBusyId(null);
}
}
- function nextAiIds(progress = aiGeneratedIds, source = bookmarks) {
+ function nextAiIds(progress = aiGeneratedIds, source = bookmarks): string[] {
return source
.filter((bookmark) => bookmark.healthPolicy === "normal" && !progress.has(bookmark.id))
.filter((bookmark) => selectionCount(metadataSelections[bookmark.id]) === 0)
@@ -266,7 +270,9 @@ export function InboxPage() {
}
function toggleAiBookmark(bookmark: InboxBookmark) {
- if (bookmark.healthPolicy !== "normal" || selectionCount(metadataSelections[bookmark.id]) > 0 || aiSuggestions.length) return;
+ if (bookmark.healthPolicy !== "normal" || selectionCount(metadataSelections[bookmark.id]) > 0 || aiSuggestions.length) {
+ return;
+ }
setAiSelectedIds((current) => {
const next = new Set(current);
if (next.has(bookmark.id)) next.delete(bookmark.id);
@@ -277,7 +283,12 @@ export function InboxPage() {
async function generateAiTriage() {
if (aiSuggestions.length) {
- setError("Apply or discard the current Inbox AI preview before generating another batch.");
+ setError(
+ tx(
+ "Apply or discard the current Inbox AI preview before generating another batch.",
+ "生成下一批之前,请先应用或放弃当前的收件箱 AI 预览。",
+ ),
+ );
return;
}
const selected = bookmarks.filter((bookmark) => aiSelectedIds.has(bookmark.id) && bookmark.healthPolicy === "normal");
@@ -287,7 +298,11 @@ export function InboxPage() {
setNotice(null);
try {
const provider = loadAiProviderSettings();
- const next = await generateAiOrganizationSuggestions(provider, selected.map((bookmark) => bookmark.id));
+ const next = await generateAiOrganizationSuggestions(
+ provider,
+ selected.map((bookmark) => bookmark.id),
+ locale,
+ );
const generatedAfter = new Set(aiGeneratedIds);
next.forEach((suggestion) => generatedAfter.add(suggestion.bookmarkId));
setAiGeneratedIds(generatedAfter);
@@ -296,11 +311,13 @@ export function InboxPage() {
const nextBatch = nextAiIds(generatedAfter);
setAiSelectedIds(new Set(nextBatch));
setNotice(
- `Generated ${next.length} reviewed Inbox suggestion${next.length === 1 ? "" : "s"}. ` +
- `${nextBatch.length} next pending item${nextBatch.length === 1 ? " is" : "s are"} queued; nothing has been filed yet.`,
+ tx(
+ `Generated ${next.length} reviewed Inbox suggestion${next.length === 1 ? "" : "s"}. ${nextBatch.length} next pending item${nextBatch.length === 1 ? " is" : "s are"} queued; nothing has been filed yet.`,
+ `已生成 ${next.length} 条收件箱整理建议,已预选下批 ${nextBatch.length} 项待处理书签;当前尚未归档。`,
+ ),
);
} catch (caught) {
- setError(messageFrom(caught));
+ setError(messageFrom(caught, tx("Could not generate AI suggestions.", "无法生成 AI 整理建议。")));
} finally {
setAiGenerating(false);
}
@@ -319,7 +336,12 @@ export function InboxPage() {
setAiSuggestions([]);
setAiAcceptedIds(new Set());
setError(null);
- setNotice("Inbox AI preview discarded. Generated markers and queued selection were kept; no bookmark data changed.");
+ setNotice(
+ tx(
+ "Inbox AI preview discarded. Generated markers and queued selection were kept; no bookmark data changed.",
+ "已放弃收件箱 AI 预览。已保留生成标记与待选队列,书签数据未发生更改。",
+ ),
+ );
}
async function applyAiTriage() {
@@ -332,19 +354,29 @@ export function InboxPage() {
const patches: InboxReviewPatch[] = accepted.map((suggestion) => {
const bookmark = bookmarkById.get(suggestion.bookmarkId);
if (!bookmark || bookmark.healthPolicy !== "normal") {
- throw new Error("One or more Inbox bookmarks changed eligibility. Refresh and regenerate before filing.");
+ throw new Error(
+ tx(
+ "One or more Inbox bookmarks changed eligibility. Refresh and regenerate before filing.",
+ "部分收件箱书签的健康检查策略已变化,请刷新后重新生成再归档。",
+ ),
+ );
}
const categoryId = suggestion.categoryName
? categoryByName.get(suggestion.categoryName.toLocaleLowerCase())
: null;
if (suggestion.categoryName && !categoryId) {
- throw new Error(`Suggested category “${suggestion.categoryName}” no longer exists. Refresh and regenerate before filing.`);
+ throw new Error(
+ tx(
+ `Suggested category “${suggestion.categoryName}” no longer exists. Refresh and regenerate before filing.`,
+ `建议分类「${suggestion.categoryName}」已不存在,请刷新后重新生成再归档。`,
+ ),
+ );
}
return {
bookmarkId: bookmark.id,
title: suggestion.title || bookmark.title,
description: suggestion.description || null,
- categoryId,
+ categoryId: categoryId ?? null,
tags: suggestion.tags,
};
});
@@ -362,11 +394,13 @@ export function InboxPage() {
setAiSuggestions((current) => current.filter((suggestion) => !appliedIds.has(suggestion.bookmarkId)));
setAiAcceptedIds((current) => new Set(Array.from(current).filter((id) => !appliedIds.has(id))));
setNotice(
- `Applied and filed ${result.applied} reviewed Inbox AI suggestion${result.applied === 1 ? "" : "s"} in one atomic D1 batch. ` +
- "URL, favicon, HealthPolicy and HealthStatus were untouched.",
+ tx(
+ `Applied and filed ${result.applied} reviewed Inbox AI suggestion${result.applied === 1 ? "" : "s"} in one batch. URL, favicon, and health fields stayed untouched.`,
+ `已一次性应用并归档 ${result.applied} 条 AI 整理建议,链接、图标与健康检查字段均保持不变。`,
+ ),
);
} catch (caught) {
- setError(messageFrom(caught));
+ setError(messageFrom(caught, tx("Could not apply Inbox AI suggestions.", "无法应用收件箱 AI 整理建议。")));
} finally {
setAiApplying(false);
}
@@ -374,76 +408,191 @@ export function InboxPage() {
return (
-
-
-
QUICK CAPTURE
-
Inbox
-
Tabs saved from the Dockmark extension land here as a review state, not as a special category. Public pages can optionally fetch metadata suggestions, or you can run reviewed AI triage across up to 20 Inbox items before filing.
+
+
+
{tx("Inbox", "收件箱")}
+
+ {tx(
+ "Review tabs captured from the Dockmark extension, fetch optional page metadata, or run reviewed AI triage before filing into your library.",
+ "审核来自 Dockmark 扩展的收录页面,按需抓取页面元数据或批量运行 AI 整理后再归档到书签库。",
+ )}
+
-
-
{bookmarks.length}
-
waiting
+
+
+ {bookmarks.length}
+ {tx("waiting", "待归档")}
+
+
+ {aiEligible.length}
+ {tx("AI eligible", "可 AI 整理")}
+
-
+
- {(notice || error) &&
{error ?? notice}
}
+ {(notice || error) && (
+
+ {error ?? notice}
+
+ )}
-
+
-
AI TRIAGE · REVIEWED
-
Organize a capture batch, then file it once.
-
Uses the same browser-local provider/model/timeout from Settings. Only normal Inbox bookmarks are eligible. AI can suggest title, description, an existing category and tags; URL, favicon and health fields stay outside this batch write surface.
+
{tx("AI Triage (Reviewed)", "AI 批量整理(审核后归档)")}
+
+ {tx(
+ "Uses your Settings AI provider for up to 20 normal bookmarks per batch. Suggests title, description, existing category, and tags while leaving URL, favicon, and health fields untouched.",
+ "使用设置中的 AI 模型,单批最多处理 20 条常规书签;仅建议标题、描述、已有分类和标签,不改动链接、图标及健康检查字段。",
+ )}
+
- {aiSelectedIds.size}/20 selected
- {generatedInInbox} generated this session · {aiPending.length} pending
+
+ {aiSelectedIds.size}/20 {tx("selected", "已选")}
+
+
+ {tx(
+ `${generatedInInbox} generated · ${aiPending.length} pending`,
+ `本轮已生成 ${generatedInInbox} · 待处理 ${aiPending.length}`,
+ )}
+
+
-
0 || !aiPending.length} onClick={selectNextAi}>Select next {Math.min(20, aiPending.length)}
-
0} onClick={() => setAiSelectedIds(new Set())}>Clear selection
-
0} onClick={() => void generateAiTriage()}>
- {aiGenerating ? "Generating…" : aiSuggestions.length ? "Review current preview first" : `Generate Inbox suggestions ${aiSelectedIds.size}`}
+ 0 || !aiPending.length}
+ onClick={selectNextAi}
+ >
+ {tx(`Select next ${Math.min(20, aiPending.length)}`, `选中下批 ${Math.min(20, aiPending.length)} 项`)}
+
+ 0}
+ onClick={() => setAiSelectedIds(new Set())}
+ >
+ {tx("Clear selection", "清空选择")}
+
+ 0}
+ onClick={() => void generateAiTriage()}
+ >
+ {aiGenerating
+ ? tx("Generating…", "生成中…")
+ : aiSuggestions.length
+ ? tx("Review current preview first", "请先处理当前预览")
+ : tx(`Generate suggestions (${aiSelectedIds.size})`, `生成整理建议(${aiSelectedIds.size})`)}
- {aiApiReady === false && Configure AI provider → }
- {aiApiReady === null && void refreshAiStatus()}>Refresh AI status }
+ {aiApiReady === false && (
+
+ {tx("Configure AI provider →", "前往配置 AI 提供商 →")}
+
+ )}
+ {aiApiReady === null && (
+ void refreshAiStatus()}>
+ {tx("Refresh AI status", "刷新 AI 状态")}
+
+ )}
- Items with page-metadata fields already selected are excluded from AI selection so the two reviewed filing paths cannot silently override each other.
+
+ {tx(
+ "Items with page-metadata fields checked are excluded from AI selection so the two review paths cannot conflict.",
+ "已勾选页面元数据字段的书签会自动排除在 AI 选择之外,避免两条归档路径互相覆盖。",
+ )}
+
{aiSuggestions.length > 0 && (
-
AI preview · nothing filed yet Accept whole reviewed suggestions. Unchecked rows remain in Inbox.
- setAiAcceptedIds(new Set(aiSuggestions.map((suggestion) => suggestion.bookmarkId)))}>Select all
- setAiAcceptedIds(new Set())}>Clear
- Discard preview
- void applyAiTriage()}>{aiApplying ? "Applying & filing…" : `Apply & file ${aiAcceptedIds.size}`}
+ {tx("AI preview · nothing filed yet", "AI 整理预览 · 尚未归档")}
+
+ {tx(
+ "Check suggestions to apply and file. Unchecked items remain in Inbox.",
+ "勾选需要应用并归档的建议;未勾选项将保留在收件箱。",
+ )}
+
+
+
+ setAiAcceptedIds(new Set(aiSuggestions.map((suggestion) => suggestion.bookmarkId)))}
+ >
+ {tx("Select all", "全选")}
+
+ setAiAcceptedIds(new Set())}
+ >
+ {tx("Clear", "清空")}
+
+
+ {tx("Discard preview", "放弃预览")}
+
+ void applyAiTriage()}
+ >
+ {aiApplying
+ ? tx("Applying & filing…", "应用并归档中…")
+ : tx(`Apply & file (${aiAcceptedIds.size})`, `应用并归档(${aiAcceptedIds.size})`)}
+
{aiSuggestions.map((suggestion) => {
const bookmark = bookmarkById.get(suggestion.bookmarkId);
if (!bookmark) return null;
- const currentCategory = bookmark.categoryId ? categoryById.get(bookmark.categoryId) ?? "Unknown category" : "Uncategorized";
- const nextCategory = suggestion.categoryName ?? "Uncategorized";
+ const currentCategory = bookmark.categoryId
+ ? categoryById.get(bookmark.categoryId) ?? tx("Unknown category", "未知分类")
+ : tx("Uncategorized", "未分类");
+ const nextCategory = suggestion.categoryName ?? tx("Uncategorized", "未分类");
const currentTags = bookmarkTags[bookmark.id] ?? [];
const changes = [
- suggestion.title !== bookmark.title && "TITLE",
- suggestion.description !== (bookmark.description ?? "") && "DESCRIPTION",
- nextCategory !== currentCategory && "CATEGORY",
- !sameTags(suggestion.tags, currentTags) && "TAGS",
+ suggestion.title !== bookmark.title && tx("TITLE", "标题"),
+ suggestion.description !== (bookmark.description ?? "") && tx("DESCRIPTION", "描述"),
+ nextCategory !== currentCategory && tx("CATEGORY", "分类"),
+ !sameTags(suggestion.tags, currentTags) && tx("TAGS", "标签"),
].filter(Boolean);
return (
- toggleAiSuggestion(suggestion.bookmarkId)} />
+ toggleAiSuggestion(suggestion.bookmarkId)}
+ />
+
{suggestion.title || bookmark.title}
- {nextCategory} · {suggestion.tags.length ? suggestion.tags.map((tag) => `#${tag}`).join(" ") : "no tags"}
- {suggestion.description || "No suggested description"}
+
+ {nextCategory} ·{" "}
+ {suggestion.tags.length
+ ? suggestion.tags.map((tag) => `#${tag}`).join(" ")
+ : tx("no tags", "无标签")}
+
+ {suggestion.description || tx("No suggested description", "无建议描述")}
- {changes.join(" · ") || "NO FIELD CHANGE"}
+ {changes.join(" · ") || tx("NO CHANGE", "无字段变更")}
);
})}
@@ -454,138 +603,74 @@ export function InboxPage() {
-
Captured bookmarks Exact URL duplicates are rejected before a second bookmark is created. Metadata stays behind the same review gate.
-
void refresh()}>Refresh
+
+ {tx("Captured bookmarks", "待审核书签")}
+
+ {tx(
+ "Exact URL duplicates are blocked on capture; metadata updates stay behind your review.",
+ "收录时已自动拦截完全重复的链接;元数据仅在审核确认后写入。",
+ )}
+
+
+
void refresh()}
+ >
+ {tx("Refresh", "刷新")}
+
{loading ? (
- Loading Inbox…
+ {tx("Loading Inbox…", "正在加载收件箱…")}
) : bookmarks.length ? (
- {bookmarks.map((bookmark) => {
- const metadata = metadataById[bookmark.id] ?? null;
- const selection = metadataSelections[bookmark.id] ?? emptyMetadataSelection();
- const selectedMetadataCount = selectionCount(selection);
- const metadataBusy = metadataBusyId === bookmark.id;
- const titleAvailable = Boolean(metadata?.title && metadata.title !== bookmark.title && metadata.title.length <= 200);
- const descriptionAvailable = Boolean(metadata?.description && metadata.description !== bookmark.description);
- const canonicalAvailable = Boolean(metadata?.canonicalUrl && metadata.canonicalUrl !== bookmark.url);
- const iconAvailable = Boolean(metadata?.iconUrl && metadata.iconUrl !== bookmark.iconUrl);
- const aiSelectable = bookmark.healthPolicy === "normal" && !selectedMetadataCount && !aiSuggestions.length;
-
- return (
-
-
-
-
- = 20)}
- onChange={() => toggleAiBookmark(bookmark)}
- aria-label={`Select ${bookmark.title} for AI triage`}
- />
- AI
-
-
{bookmark.title}
-
{bookmark.healthPolicy === "local-only" ? "Local only" : "Captured"}
-
-
- {hostLabel(bookmark.url)}
- Captured {dateLabel(bookmark.inboxAt)}
- {bookmark.categoryId && Currently {bookmark.categoryName ?? categoryById.get(bookmark.categoryId) ?? "categorized"} }
- {(bookmarkTags[bookmark.id] ?? []).slice(0, 4).map((tag) => #{tag} )}
-
- {bookmark.description &&
{bookmark.description}
}
-
-
-
-
- File to
- setCategoryDrafts((current) => ({ ...current, [bookmark.id]: event.target.value }))}
- >
- Uncategorized
- {categories.map((category) => {category.name} )}
-
-
- void review(bookmark)}>
- {busyId === bookmark.id
- ? "Filing…"
- : selectedMetadataCount
- ? `Apply ${selectedMetadataCount} + file`
- : "Review & file"}
-
-
-
-
-
-
- Page metadata suggestions
-
- {bookmark.healthPolicy === "local-only"
- ? "Local/private metadata stays disabled on the server."
- : "Fetch is read-only for the bookmark. Select individual fields to apply only when you file this Inbox item."}
-
-
-
suggestion.bookmarkId === bookmark.id)}
- onClick={() => void fetchMetadata(bookmark)}
- >
- {bookmark.healthPolicy === "local-only"
- ? "Server metadata disabled"
- : metadataBusy
- ? "Fetching…"
- : metadata
- ? "Refresh metadata"
- : "Fetch metadata"}
-
-
-
- {metadata && (
-
- )}
-
-
- );
- })}
+ {bookmarks.map((bookmark) => (
+
= 20}
+ aiPreviewOpen={aiSuggestions.length > 0}
+ inAiPreview={aiPreviewIds.has(bookmark.id)}
+ busy={busyId === bookmark.id}
+ anyBusy={busyId !== null}
+ metadataBusy={metadataBusyId === bookmark.id}
+ anyMetadataBusy={metadataBusyId !== null}
+ aiGenerating={aiGenerating}
+ aiApplying={aiApplying}
+ locale={locale}
+ tx={tx}
+ onToggleAi={toggleAiBookmark}
+ onCategoryChange={(bookmarkId, categoryId) =>
+ setCategoryDrafts((current) => ({ ...current, [bookmarkId]: categoryId }))
+ }
+ onReview={(item) => void review(item)}
+ onFetchMetadata={(item) => void fetchMetadata(item)}
+ onToggleMetadata={toggleMetadata}
+ />
+ ))}
) : (
- Inbox is clear.
- Use the paired Dockmark extension → Save current tab or Reviewed multi-tab capture to collect the next pages.
+ {tx("Inbox is clear.", "收件箱已清空。")}
+
+ {tx(
+ "Use the paired Dockmark extension to save the current tab or capture multiple tabs for review.",
+ "使用已配对的 Dockmark 浏览器扩展收录当前标签页或批量收录多个标签页。",
+ )}
+
)}
diff --git a/apps/web/src/InboxReviewCard.tsx b/apps/web/src/InboxReviewCard.tsx
new file mode 100644
index 0000000..c94f4b4
--- /dev/null
+++ b/apps/web/src/InboxReviewCard.tsx
@@ -0,0 +1,359 @@
+/**
+ * [INPUT]: depends on Category, HEALTH_POLICY_LABELS, ResolvedLocale, formatRelativeTime from @dockmark/core; BookmarkMetadata from ./api; InboxBookmark from ./inbox-api; BookmarkFavicon and safeDomainLabel from ./BookmarkFavicon
+ * [OUTPUT]: exports InboxReviewCard component, MetadataField, MetadataSelection, emptyMetadataSelection, and selectionCount helpers
+ * [POS]: single-item review card inside apps/web/src/InboxPage.tsx for filing, AI triage selection, and opt-in page metadata inspection
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
+
+import {
+ HEALTH_POLICY_LABELS,
+ formatRelativeTime,
+ type Category,
+ type ResolvedLocale,
+} from "@dockmark/core";
+import type { BookmarkMetadata } from "./api";
+import { BookmarkFavicon, safeDomainLabel } from "./BookmarkFavicon";
+import type { InboxBookmark } from "./inbox-api";
+
+export type MetadataField = "title" | "description" | "canonicalUrl" | "iconUrl";
+export type MetadataSelection = Record
;
+
+export function emptyMetadataSelection(): MetadataSelection {
+ return {
+ title: false,
+ description: false,
+ canonicalUrl: false,
+ iconUrl: false,
+ };
+}
+
+export function selectionCount(selection: MetadataSelection | undefined): number {
+ return selection ? Object.values(selection).filter(Boolean).length : 0;
+}
+
+function formatInboxDate(value: string, locale: ResolvedLocale): string {
+ const date = new Date(value);
+ if (Number.isNaN(date.getTime())) return value;
+ return new Intl.DateTimeFormat(locale, {
+ month: "short",
+ day: "numeric",
+ hour: "2-digit",
+ minute: "2-digit",
+ }).format(date);
+}
+
+interface InboxReviewCardProps {
+ bookmark: InboxBookmark;
+ categories: Category[];
+ categoryName: string | null;
+ tags: string[];
+ categoryDraft: string;
+ metadata: BookmarkMetadata | null;
+ selection: MetadataSelection;
+ aiSelected: boolean;
+ aiSelectionLimitReached: boolean;
+ aiPreviewOpen: boolean;
+ inAiPreview: boolean;
+ busy: boolean;
+ anyBusy: boolean;
+ metadataBusy: boolean;
+ anyMetadataBusy: boolean;
+ aiGenerating: boolean;
+ aiApplying: boolean;
+ locale: ResolvedLocale;
+ tx: (en: string, zh: string) => string;
+ onToggleAi: (bookmark: InboxBookmark) => void;
+ onCategoryChange: (bookmarkId: string, categoryId: string) => void;
+ onReview: (bookmark: InboxBookmark) => void;
+ onFetchMetadata: (bookmark: InboxBookmark) => void;
+ onToggleMetadata: (bookmarkId: string, field: MetadataField) => void;
+}
+
+export function InboxReviewCard({
+ bookmark,
+ categories,
+ categoryName,
+ tags,
+ categoryDraft,
+ metadata,
+ selection,
+ aiSelected,
+ aiSelectionLimitReached,
+ aiPreviewOpen,
+ inAiPreview,
+ busy,
+ anyBusy,
+ metadataBusy,
+ anyMetadataBusy,
+ aiGenerating,
+ aiApplying,
+ locale,
+ tx,
+ onToggleAi,
+ onCategoryChange,
+ onReview,
+ onFetchMetadata,
+ onToggleMetadata,
+}: InboxReviewCardProps) {
+ const selectedMetadataCount = selectionCount(selection);
+ const titleAvailable = Boolean(
+ metadata?.title && metadata.title !== bookmark.title && metadata.title.length <= 200,
+ );
+ const descriptionAvailable = Boolean(
+ metadata?.description && metadata.description !== bookmark.description,
+ );
+ const canonicalAvailable = Boolean(
+ metadata?.canonicalUrl && metadata.canonicalUrl !== bookmark.url,
+ );
+ const iconAvailable = Boolean(
+ metadata?.iconUrl && metadata.iconUrl !== bookmark.iconUrl,
+ );
+ const aiSelectable =
+ bookmark.healthPolicy === "normal" && !selectedMetadataCount && !aiPreviewOpen;
+ const policyLabel = HEALTH_POLICY_LABELS[locale][bookmark.healthPolicy];
+
+ const aiTooltip = selectedMetadataCount
+ ? tx(
+ "Clear selected metadata fields before adding this item to AI triage.",
+ "加入 AI 整理前,请先取消勾选页面元数据字段。",
+ )
+ : bookmark.healthPolicy !== "normal"
+ ? tx(
+ `AI excludes ${policyLabel} bookmarks.`,
+ `AI 整理会跳过「${policyLabel}」策略的书签。`,
+ )
+ : tx(
+ "Select for reviewed Inbox AI triage.",
+ "勾选以加入收件箱 AI 审核整理。",
+ );
+
+ const capturedRelative = formatRelativeTime(bookmark.inboxAt, locale);
+ const capturedExact = formatInboxDate(bookmark.inboxAt, locale);
+
+ return (
+
+
+
+
+ onToggleAi(bookmark)}
+ aria-label={tx(
+ `Select ${bookmark.title} for AI triage`,
+ `选择「${bookmark.title}」用于 AI 整理`,
+ )}
+ />
+ AI
+
+
+
+ {bookmark.title}
+
+
+ {bookmark.healthPolicy === "normal" ? tx("Captured", "已收录") : policyLabel}
+
+
+
+
+ {safeDomainLabel(bookmark.url)}
+
+ {tx(`Captured ${capturedRelative}`, `收录于 ${capturedRelative}`)}
+
+ {categoryName && (
+ {tx(`Currently ${categoryName}`, `当前分类:${categoryName}`)}
+ )}
+ {tags.slice(0, 4).map((tag) => (
+
+ #{tag}
+
+ ))}
+
+
+ {bookmark.description &&
{bookmark.description}
}
+
+
+
+
+ {tx("File to", "归档到分类")}
+ onCategoryChange(bookmark.id, event.target.value)}
+ >
+ {tx("Uncategorized", "未分类")}
+ {categories.map((category) => (
+
+ {category.name}
+
+ ))}
+
+
+ onReview(bookmark)}
+ >
+ {busy
+ ? tx("Filing…", "归档中…")
+ : selectedMetadataCount
+ ? tx(`Apply ${selectedMetadataCount} + file`, `应用 ${selectedMetadataCount} 项并归档`)
+ : tx("Review & file", "审核并归档")}
+
+
+
+
+
+
+ {tx("Page metadata suggestions", "页面元数据建议")}
+
+ {bookmark.healthPolicy === "local-only"
+ ? tx(
+ "Local/private metadata stays disabled on the server.",
+ "本地或内网书签已禁用服务端元数据抓取。",
+ )
+ : tx(
+ "Read-only fetch. Checked fields apply only when you file this item.",
+ "抓取不会自动写入;勾选的字段仅在点击归档时应用。",
+ )}
+
+
+
onFetchMetadata(bookmark)}
+ >
+ {bookmark.healthPolicy === "local-only"
+ ? tx("Metadata disabled", "已禁用抓取")
+ : metadataBusy
+ ? tx("Fetching…", "抓取中…")
+ : metadata
+ ? tx("Refresh metadata", "重新抓取")
+ : tx("Fetch metadata", "抓取元数据")}
+
+
+
+ {metadata && (
+
+
+ onToggleMetadata(bookmark.id, "title")}
+ />
+
+ {tx("Title", "标题")}
+ {metadata.title ?? tx("Not provided", "未提供")}
+
+
+ {metadata.title && metadata.title.length > 200
+ ? tx("Too long to apply", "超出长度限制")
+ : titleAvailable
+ ? tx("Apply on file", "归档时应用")
+ : tx("Matches / unavailable", "已一致或不可用")}
+
+
+
+
+ onToggleMetadata(bookmark.id, "description")}
+ />
+
+ {tx("Description", "描述")}
+ {metadata.description ?? tx("Not provided", "未提供")}
+
+
+ {descriptionAvailable
+ ? tx("Apply on file", "归档时应用")
+ : tx("Matches / unavailable", "已一致或不可用")}
+
+
+
+
+ onToggleMetadata(bookmark.id, "canonicalUrl")}
+ />
+
+ {tx("Canonical URL", "规范链接")}
+ {metadata.canonicalUrl ?? tx("Not provided", "未提供")}
+
+
+ {canonicalAvailable
+ ? tx("Replace URL on file", "归档时替换链接")
+ : tx("Matches / unavailable", "已一致或不可用")}
+
+
+
+
+ onToggleMetadata(bookmark.id, "iconUrl")}
+ />
+
+ {tx("Favicon", "网站图标")}
+ {metadata.iconUrl ?? tx("Not provided", "未提供")}
+
+
+ {iconAvailable
+ ? tx("Apply on file", "归档时应用")
+ : tx("Matches / unavailable", "已一致或不可用")}
+
+
+
+ {metadata.finalUrl && metadata.finalUrl !== bookmark.url && (
+
+
+ {tx("Resolved URL", "最终跳转链接")}
+ {metadata.finalUrl}
+
+
+ {tx(
+ "Info only · redirects are not canonical",
+ "仅供参考 · 重定向不视为规范链接",
+ )}
+
+
+ )}
+
+
+ {tx(
+ `Fetched ${formatInboxDate(metadata.fetchedAt, locale)} · suggestions stay separate until Review & file.`,
+ `抓取于 ${formatInboxDate(metadata.fetchedAt, locale)} · 在点击「审核并归档」前不会写入书签。`,
+ )}
+
+
+ )}
+
+
+ );
+}
diff --git a/apps/web/src/LauncherDashboard.tsx b/apps/web/src/LauncherDashboard.tsx
new file mode 100644
index 0000000..4475778
--- /dev/null
+++ b/apps/web/src/LauncherDashboard.tsx
@@ -0,0 +1,670 @@
+/**
+ * [INPUT]: depends on @dockmark/core ranking/bang/i18n helpers; BridgeTab from ./browser-bridge; bookmarkMatchesQuery from ./bookmark-search; matchesSmartCollection/smartCollectionFilterLabels from ./smart-collection-match; SmartCollection from ./smart-collections-api; useI18n from ./i18n
+ * [OUTPUT]: exports safeHttpUrl, hostLabel, SafeFavicon, buildLauncherResults, LauncherCommandPanel, and LauncherDashboard
+ * [POS]: Launcher UI and command-ranking module used by App.tsx. Provides the interactive empty-query dashboard, keyboard-navigable command results panel, and shared favicon renderer.
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
+import { useMemo, useState, type MouseEvent } from "react";
+import {
+ buildSearchUrl,
+ launcherTextScore,
+ matchingBangEngines,
+ parseBangQuery,
+ rankCommands,
+ SOURCE_LABELS,
+ type Bookmark,
+ type Category,
+ type CommandResult,
+ type ResolvedLocale,
+ type SearchEngine,
+ type SessionWithItems,
+ type WorkspaceWithItems,
+} from "@dockmark/core";
+import { bookmarkMatchesQuery } from "./bookmark-search";
+import type { BridgeTab } from "./browser-bridge";
+import { useI18n } from "./i18n";
+import { matchesSmartCollection, smartCollectionFilterLabels } from "./smart-collection-match";
+import type { SmartCollection } from "./smart-collections-api";
+
+export function safeHttpUrl(value: string | null | undefined): string | null {
+ if (!value) return null;
+ try {
+ const parsed = new URL(value);
+ return parsed.protocol === "http:" || parsed.protocol === "https:" ? parsed.toString() : null;
+ } catch {
+ return null;
+ }
+}
+
+export function hostLabel(url: string): string {
+ try {
+ return new URL(url).host.replace(/^www\./i, "");
+ } catch {
+ return url;
+ }
+}
+
+export function SafeFavicon({
+ iconUrl,
+ title,
+ url,
+ className = "launcher-card-icon",
+}: {
+ iconUrl?: string | null | undefined;
+ title: string;
+ url?: string | undefined;
+ className?: string | undefined;
+}) {
+ const [failed, setFailed] = useState(false);
+ const validIcon = failed ? null : safeHttpUrl(iconUrl);
+ const fallbackChar = (title.trim() || (url ? hostLabel(url) : "D")).slice(0, 1).toUpperCase();
+
+ return (
+
+ {validIcon ? (
+ setFailed(true)}
+ />
+ ) : (
+ fallbackChar
+ )}
+
+ );
+}
+
+export interface BuildLauncherResultsInput {
+ query: string;
+ bookmarks: Bookmark[];
+ bookmarkTags: Record;
+ categoryById: Map;
+ smartCollections: SmartCollection[];
+ inboxIds: Set;
+ workspaces: WorkspaceWithItems[];
+ sessions: SessionWithItems[];
+ searchEngines: SearchEngine[];
+ defaultEngine: SearchEngine | null;
+ openTabs: BridgeTab[];
+ bridgeConnected: boolean;
+ tx: (en: string, zh: string) => string;
+}
+
+export function buildLauncherResults({
+ query,
+ bookmarks,
+ bookmarkTags,
+ categoryById,
+ smartCollections,
+ inboxIds,
+ workspaces,
+ sessions,
+ searchEngines,
+ defaultEngine,
+ openTabs,
+ bridgeConnected,
+ tx,
+}: BuildLauncherResultsInput): CommandResult[] {
+ const trimmed = query.trim();
+ const normalized = trimmed.toLocaleLowerCase();
+ const bang = parseBangQuery(trimmed, searchEngines);
+
+ if (bang) {
+ const canRun = Boolean(bang.query);
+ return [{
+ id: `search-run:${bang.engine.id}`,
+ source: "search",
+ title: canRun
+ ? tx(`Search ${bang.engine.name} for “${bang.query}”`, `使用 ${bang.engine.name} 搜索“${bang.query}”`)
+ : tx(`Search with ${bang.engine.name}`, `使用 ${bang.engine.name} 搜索`),
+ subtitle: `!${bang.engine.keyword ?? ""} · ${bang.engine.searchUrl}`,
+ ...(canRun ? { url: buildSearchUrl(bang.engine, bang.query) } : {}),
+ score: 100,
+ }];
+ }
+
+ const bangSuggestions = matchingBangEngines(trimmed, searchEngines);
+ if (bangSuggestions.length) {
+ return bangSuggestions.slice(0, 8).map((engine) => ({
+ id: `search-shortcut:${engine.id}`,
+ source: "search",
+ title: engine.name,
+ subtitle: tx(`!${engine.keyword} · type a query`, `!${engine.keyword} · 输入搜索词`),
+ score: 100,
+ }));
+ }
+
+ if (trimmed.startsWith("@")) {
+ const needle = trimmed.slice(1).trim();
+ return smartCollections
+ .flatMap((collection) => {
+ const labels = smartCollectionFilterLabels(collection.filters, categoryById);
+ const count = bookmarks.filter((bookmark) =>
+ matchesSmartCollection(bookmark, collection.filters, bookmarkTags[bookmark.id] ?? [], inboxIds),
+ ).length;
+ const subtitle = tx(
+ `${count} bookmark${count === 1 ? "" : "s"}${labels.length ? ` · ${labels.slice(0, 4).join(" · ")}` : " · All bookmarks"}`,
+ `${count} 条书签${labels.length ? ` · ${labels.slice(0, 4).join(" · ")}` : " · 全部书签"}`,
+ );
+ const score = needle ? launcherTextScore(needle, collection.name, [subtitle, ...labels], 60) : 60;
+ if (needle && score < 0) return [];
+ return [{
+ id: `navigation:collection:${collection.id}`,
+ source: "collection" as const,
+ title: collection.name,
+ subtitle,
+ score,
+ }];
+ })
+ .sort((a, b) => b.score - a.score)
+ .slice(0, 10);
+ }
+
+ const tabCandidates = normalized ? openTabs : openTabs.slice(0, 4);
+ const tabResults: CommandResult[] = tabCandidates.flatMap((tab) => {
+ const subtitle = `${hostLabel(tab.url)}${tab.pinned ? tx(" · Pinned", " · 已固定") : ""}${tab.active ? tx(" · Active", " · 当前") : ""}`;
+ const score = launcherTextScore(trimmed, tab.title, [tab.url, subtitle], 40 + (tab.pinned ? 4 : 0) + (tab.active ? 2 : 0));
+ if (normalized && score < 0) return [];
+ return [{
+ id: `tab:${tab.id}`,
+ source: "tab",
+ title: tab.title,
+ subtitle,
+ url: tab.url,
+ score,
+ }];
+ });
+ const workspaceResults: CommandResult[] = workspaces.flatMap((workspace) => {
+ const subtitle = tx(
+ `Open workspace · ${workspace.items.length} tabs`,
+ `打开工作区 · ${workspace.items.length} 个标签`,
+ );
+ const itemText = workspace.items.flatMap((item) => [item.title, item.url]);
+ const score = launcherTextScore(trimmed, workspace.name, [workspace.description ?? "", subtitle, ...itemText], 30);
+ if (normalized && score < 0) return [];
+ return [{
+ id: workspace.id,
+ source: "workspace",
+ title: workspace.name,
+ subtitle,
+ score,
+ }];
+ });
+ const sessionResults: CommandResult[] = sessions.flatMap((session, index) => {
+ const subtitle = tx(
+ `Restore session · ${session.items.length} tabs${session.sourceDevice ? ` · ${session.sourceDevice}` : ""}`,
+ `恢复会话 · ${session.items.length} 个标签${session.sourceDevice ? ` · ${session.sourceDevice}` : ""}`,
+ );
+ const itemText = session.items.flatMap((item) => [item.title, item.url]);
+ const score = launcherTextScore(trimmed, session.name, [session.sourceDevice ?? "", subtitle, ...itemText], Math.max(0, 30 - index));
+ if (normalized && score < 0) return [];
+ return [{
+ id: session.id,
+ source: "session",
+ title: session.name,
+ subtitle,
+ score,
+ }];
+ });
+ const collectionResults: CommandResult[] = smartCollections.flatMap((collection) => {
+ const labels = smartCollectionFilterLabels(collection.filters, categoryById);
+ const count = bookmarks.filter((bookmark) =>
+ matchesSmartCollection(bookmark, collection.filters, bookmarkTags[bookmark.id] ?? [], inboxIds),
+ ).length;
+ const subtitle = tx(
+ `${count} bookmark${count === 1 ? "" : "s"}${labels.length ? ` · ${labels.slice(0, 4).join(" · ")}` : " · All bookmarks"}`,
+ `${count} 条书签${labels.length ? ` · ${labels.slice(0, 4).join(" · ")}` : " · 全部书签"}`,
+ );
+ const score = launcherTextScore(trimmed, collection.name, [subtitle, ...labels], 30);
+ if (normalized && score < 0) return [];
+ return [{
+ id: `navigation:collection:${collection.id}`,
+ source: "collection",
+ title: collection.name,
+ subtitle,
+ score,
+ }];
+ });
+ const bookmarkResults: CommandResult[] = bookmarks.flatMap((bookmark) => {
+ const tags = bookmarkTags[bookmark.id] ?? [];
+ const category = bookmark.categoryId ? categoryById.get(bookmark.categoryId) ?? "" : tx("Uncategorized", "未分类");
+ const tagTokens = tags.map((tag) => `#${tag}`);
+ if (normalized && !bookmarkMatchesQuery(bookmark, category, tags, trimmed)) return [];
+ const subtitleParts = [hostLabel(bookmark.url)];
+ if (category) subtitleParts.push(category);
+ if (tagTokens.length) subtitleParts.push(tagTokens.slice(0, 3).join(" "));
+ const score = launcherTextScore(trimmed, bookmark.title, [bookmark.url, bookmark.description ?? "", category, ...tags, ...tagTokens], 30);
+ if (normalized && score < 0) return [];
+ return [{
+ id: bookmark.id,
+ source: "bookmark",
+ title: bookmark.title,
+ subtitle: subtitleParts.join(" · "),
+ url: bookmark.url,
+ score,
+ }];
+ });
+ const navigationTitle = bridgeConnected
+ ? tx("Browser extension", "浏览器扩展")
+ : tx("Install browser extension", "安装浏览器扩展");
+ const navigationSubtitle = bridgeConnected
+ ? tx("Diagnostics, version and capabilities", "连接诊断、版本与能力状态")
+ : tx("Enable open tabs, Session restore and native bookmark import", "解锁打开的标签页、会话恢复与原生书签同步");
+ const navigationScore = launcherTextScore(trimmed, navigationTitle, [navigationSubtitle], 20);
+ const navigationResults: CommandResult[] = normalized && navigationScore < 0 ? [] : [{
+ id: "navigation:extension",
+ source: "navigation",
+ title: navigationTitle,
+ subtitle: navigationSubtitle,
+ score: navigationScore,
+ }];
+
+ const localResults = rankCommands([
+ ...tabResults,
+ ...workspaceResults,
+ ...sessionResults,
+ ...collectionResults,
+ ...bookmarkResults,
+ ...navigationResults,
+ ]).slice(0, trimmed && defaultEngine ? 8 : 9);
+
+ if (trimmed && defaultEngine) {
+ localResults.push({
+ id: `search-run:${defaultEngine.id}`,
+ source: "search",
+ title: tx(`Search ${defaultEngine.name} for “${trimmed}”`, `使用 ${defaultEngine.name} 搜索“${trimmed}”`),
+ subtitle: defaultEngine.keyword
+ ? tx(`Default · !${defaultEngine.keyword}`, `默认引擎 · !${defaultEngine.keyword}`)
+ : tx("Default search engine", "默认搜索引擎"),
+ url: buildSearchUrl(defaultEngine, trimmed),
+ score: 0,
+ });
+ }
+
+ return localResults;
+}
+
+export function LauncherCommandPanel({
+ results,
+ selectedIndex,
+ bookmarkById,
+ bridgeConnected,
+ launcherStatus,
+ loading,
+ locale,
+ onSelectIndex,
+ onExecute,
+}: {
+ results: CommandResult[];
+ selectedIndex: number;
+ bookmarkById: Map;
+ bridgeConnected: boolean;
+ launcherStatus: string;
+ loading: boolean;
+ locale: ResolvedLocale;
+ onSelectIndex: (index: number) => void;
+ onExecute: (item: CommandResult, forceNewTab: boolean) => Promise;
+}) {
+ const { tx } = useI18n();
+ const sourceLabels = SOURCE_LABELS[locale];
+
+ return (
+
+
+ {tx("Command results", "搜索结果")}
+ {launcherStatus}
+
+
+ {results.map((item, index) => {
+ const isCollection = item.source === "collection";
+ const bookmark = item.source === "bookmark" ? bookmarkById.get(item.id) : undefined;
+ return (
+
onSelectIndex(index)}
+ onClick={(event) => void onExecute(item, event.metaKey || event.ctrlKey || event.shiftKey)}
+ >
+ {bookmark ? (
+
+ ) : (
+
+ {isCollection ? "◇" : item.source === "tab" ? "↗" : item.source === "session" ? "↺" : item.source === "search" ? "⌕" : item.source === "navigation" ? "+" : item.title.slice(0, 1).toUpperCase()}
+
+ )}
+
+ {item.title}
+ {item.subtitle}
+
+
+ {item.source === "search" && item.id.startsWith("search-shortcut:")
+ ? {tx("Bang", "快捷搜索")}
+ : sourceLabels[item.source]}
+
+
+ );
+ })}
+ {!loading && !results.length && (
+
+ {tx("No matches. Configure a search engine or try another query.", "暂无匹配项,可尝试其他关键词或配置默认搜索引擎。")}
+
+ )}
+
+
+
+ ↑ ↓ {tx("select", "选择")} Enter {tx("run", "打开")} Tab {tx("accept bang", "补全快捷词")}
+
+
+ Shift /⌘ /Ctrl +Enter {tx("new tab", "新标签页")} / {tx("focus", "聚焦")} Esc {tx("clear", "清空")}
+
+
+
+ );
+}
+
+type FilterKey =
+ | { kind: "all" }
+ | { kind: "collection"; id: string }
+ | { kind: "category"; id: string | null };
+
+interface LauncherDashboardProps {
+ bookmarks: Bookmark[];
+ bookmarkTags: Record;
+ categories: Category[];
+ smartCollections: SmartCollection[];
+ inboxIds: Set;
+ workspaces: WorkspaceWithItems[];
+ openTabs: BridgeTab[];
+ bridgeConnected: boolean;
+ loading: boolean;
+ onLaunchWorkspace: (workspace: WorkspaceWithItems) => Promise;
+ onActivateTab: (tab: BridgeTab, forceNewTab: boolean) => Promise;
+ onOpenView: (view: "workspaces" | "bookmarks") => void;
+}
+
+export function LauncherDashboard({
+ bookmarks,
+ bookmarkTags,
+ categories,
+ smartCollections,
+ inboxIds,
+ workspaces,
+ openTabs,
+ bridgeConnected,
+ loading,
+ onLaunchWorkspace,
+ onActivateTab,
+ onOpenView,
+}: LauncherDashboardProps) {
+ const { tx } = useI18n();
+ const [filter, setFilter] = useState({ kind: "all" });
+ const [launchingId, setLaunchingId] = useState(null);
+
+ const categoryById = useMemo(
+ () => new Map(categories.map((category) => [category.id, category.name])),
+ [categories],
+ );
+
+ const collectionCounts = useMemo(() => {
+ const counts = new Map();
+ for (const collection of smartCollections) {
+ let count = 0;
+ for (const bookmark of bookmarks) {
+ if (matchesSmartCollection(bookmark, collection.filters, bookmarkTags[bookmark.id] ?? [], inboxIds)) {
+ count += 1;
+ }
+ }
+ counts.set(collection.id, count);
+ }
+ return counts;
+ }, [bookmarkTags, bookmarks, inboxIds, smartCollections]);
+
+ const categoryCounts = useMemo(() => {
+ const counts = new Map();
+ let uncategorized = 0;
+ for (const bookmark of bookmarks) {
+ if (!bookmark.categoryId) uncategorized += 1;
+ else counts.set(bookmark.categoryId, (counts.get(bookmark.categoryId) ?? 0) + 1);
+ }
+ return { counts, uncategorized };
+ }, [bookmarks]);
+
+ const activeCollection = useMemo(
+ () => (filter.kind === "collection" ? smartCollections.find((item) => item.id === filter.id) ?? null : null),
+ [filter, smartCollections],
+ );
+
+ const visibleBookmarks = useMemo(() => {
+ if (filter.kind === "all") return bookmarks;
+ if (filter.kind === "collection") {
+ if (!activeCollection) return bookmarks;
+ return bookmarks.filter((bookmark) =>
+ matchesSmartCollection(bookmark, activeCollection.filters, bookmarkTags[bookmark.id] ?? [], inboxIds),
+ );
+ }
+ if (filter.id === null) return bookmarks.filter((bookmark) => !bookmark.categoryId);
+ return bookmarks.filter((bookmark) => bookmark.categoryId === filter.id);
+ }, [activeCollection, bookmarkTags, bookmarks, filter, inboxIds]);
+
+ async function launch(workspace: WorkspaceWithItems) {
+ setLaunchingId(workspace.id);
+ try {
+ await onLaunchWorkspace(workspace);
+ } finally {
+ setLaunchingId(null);
+ }
+ }
+
+ function handleBookmarkClick(event: MouseEvent, url: string) {
+ if (!safeHttpUrl(url)) event.preventDefault();
+ }
+
+ return (
+
+ {bridgeConnected && openTabs.length > 0 && (
+
+
+
{tx("Open tabs", "打开的标签页")}
+ {openTabs.length}
+
+
+ {openTabs.slice(0, 6).map((tab) => (
+ void onActivateTab(tab, event.metaKey || event.ctrlKey || event.shiftKey)}
+ title={`${tab.title} — ${tab.url}`}
+ >
+ {tab.pinned ? "📌" : "↗"}
+ {tab.title}
+ {hostLabel(tab.url)}
+
+ ))}
+
+
+ )}
+
+ {workspaces.length > 0 && (
+
+
+
{tx("Workspaces", "工作区")}
+ {workspaces.length}
+ onOpenView("workspaces")}>
+ {tx("Manage →", "管理 →")}
+
+
+
+ {workspaces.map((workspace) => {
+ const reuseCount = workspace.items.filter((item) => item.openMode === "reuse").length;
+ const pinnedCount = workspace.items.filter((item) => item.openMode === "pinned").length;
+ const isLaunching = launchingId === workspace.id;
+ return (
+
+
+
+ {workspace.icon || workspace.name.slice(0, 1).toUpperCase()}
+
+
+
{workspace.name}
+
+
+ {tx(
+ `${workspace.items.length} tab${workspace.items.length === 1 ? "" : "s"}`,
+ `${workspace.items.length} 个标签`,
+ )}
+
+ {reuseCount > 0 && {tx("reuse", "复用")} }
+ {pinnedCount > 0 && {tx("pinned", "固定")} }
+
+
+
+ void launch(workspace)}
+ >
+ {isLaunching ? tx("Opening…", "启动中…") : tx("Launch", "启动")}
+
+
+ );
+ })}
+
+
+ )}
+
+
+
+
{tx("Bookmarks", "书签")}
+
+ {visibleBookmarks.length === bookmarks.length
+ ? bookmarks.length
+ : `${visibleBookmarks.length} / ${bookmarks.length}`}
+
+ onOpenView("bookmarks")}>
+ {tx("Manage →", "管理 →")}
+
+
+
+
+ setFilter({ kind: "all" })}
+ >
+ {tx("All", "全部")}
+ {bookmarks.length}
+
+
+ {smartCollections.map((collection) => {
+ const active = filter.kind === "collection" && filter.id === collection.id;
+ return (
+ setFilter({ kind: "collection", id: collection.id })}
+ >
+ ◇
+ {collection.name}
+ {collectionCounts.get(collection.id) ?? 0}
+
+ );
+ })}
+
+ {categories.map((category) => {
+ const count = categoryCounts.counts.get(category.id) ?? 0;
+ if (count === 0) return null;
+ const active = filter.kind === "category" && filter.id === category.id;
+ return (
+ setFilter({ kind: "category", id: category.id })}
+ >
+ {category.name}
+ {count}
+
+ );
+ })}
+
+ {categoryCounts.uncategorized > 0 && (
+ setFilter({ kind: "category", id: null })}
+ >
+ {tx("Uncategorized", "未分类")}
+ {categoryCounts.uncategorized}
+
+ )}
+
+
+ {loading && !bookmarks.length ? (
+ {tx("Loading bookmarks…", "正在加载书签…")}
+ ) : visibleBookmarks.length > 0 ? (
+
+ ) : (
+
+ {tx("No bookmarks in this view", "当前筛选下暂无书签")}
+
+ {filter.kind === "all"
+ ? tx("Add bookmarks in Bookmarks or import from your browser.", "可在「书签」页面新增,或从浏览器导入。")
+ : tx("Choose another collection or category pill above.", "可点击上方其他合集或分类标签查看。")}
+
+
+ )}
+
+
+ );
+}
diff --git a/apps/web/src/LibraryBulkMaintenance.tsx b/apps/web/src/LibraryBulkMaintenance.tsx
index 6ee6f58..112eca1 100644
--- a/apps/web/src/LibraryBulkMaintenance.tsx
+++ b/apps/web/src/LibraryBulkMaintenance.tsx
@@ -1,6 +1,14 @@
+/**
+ * [INPUT]: depends on Bookmark, HealthPolicy, HEALTH_POLICY_LABELS from @dockmark/core; bookmarkMatchesQuery from ./bookmark-search; listArchivedBookmarks, maintainLibraryBatch, MAX_LIBRARY_MAINTENANCE_BATCH from ./library-maintenance-api; useI18n from ./i18n
+ * [OUTPUT]: exports LibraryBulkMaintenance component
+ * [POS]: reviewed bulk health-policy, archive, restore, and permanent-delete workflow inside the Health tab
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
+
import { useEffect, useMemo, useState } from "react";
-import type { Bookmark, HealthPolicy } from "@dockmark/core";
+import { HEALTH_POLICY_LABELS, type Bookmark, type HealthPolicy } from "@dockmark/core";
import { bookmarkMatchesQuery } from "./bookmark-search";
+import { useI18n } from "./i18n";
import {
listArchivedBookmarks,
maintainLibraryBatch,
@@ -18,11 +26,16 @@ interface Props {
type Scope = "active" | "archived";
-function messageFrom(error: unknown) {
- return error instanceof Error ? error.message : "Something went wrong.";
+function messageFrom(error: unknown, fallback: string) {
+ return error instanceof Error ? error.message : fallback;
}
export function LibraryBulkMaintenance({ bookmarks, bookmarkTags, categoryNameById, onChanged }: Props) {
+ const { locale, tx } = useI18n();
+ const policyLabels = HEALTH_POLICY_LABELS[locale];
+ const genericError = tx("Something went wrong.", "操作失败,请重试。");
+ const uncategorizedLabel = tx("Uncategorized", "未分类");
+
const [scope, setScope] = useState("active");
const [archived, setArchived] = useState([]);
const [query, setQuery] = useState("");
@@ -40,14 +53,14 @@ export function LibraryBulkMaintenance({ bookmarks, bookmarkTags, categoryNameBy
}
useEffect(() => {
- void refreshArchived().catch((caught) => setError(messageFrom(caught)));
+ void refreshArchived().catch((caught) => setError(messageFrom(caught, genericError)));
}, []);
const source = scope === "active" ? bookmarks : archived;
const candidates = useMemo(() => source.filter((bookmark) => {
- const category = bookmark.categoryId ? categoryNameById.get(bookmark.categoryId) ?? "" : "Uncategorized";
+ const category = bookmark.categoryId ? categoryNameById.get(bookmark.categoryId) ?? "" : uncategorizedLabel;
return bookmarkMatchesQuery(bookmark, category, bookmarkTags[bookmark.id] ?? [], query);
- }), [bookmarkTags, categoryNameById, query, source]);
+ }), [bookmarkTags, categoryNameById, query, source, uncategorizedLabel]);
const selected = useMemo(() => source.filter((bookmark) => selectedIds.has(bookmark.id)), [selectedIds, source]);
useEffect(() => {
@@ -77,9 +90,11 @@ export function LibraryBulkMaintenance({ bookmarks, bookmarkTags, categoryNameBy
function selectMatches() {
setSelectedIds(new Set(candidates.slice(0, MAX_LIBRARY_MAINTENANCE_BATCH).map((bookmark) => bookmark.id)));
- setNotice(candidates.length > MAX_LIBRARY_MAINTENANCE_BATCH
- ? `Selected the first ${MAX_LIBRARY_MAINTENANCE_BATCH} matches.`
- : null);
+ setNotice(
+ candidates.length > MAX_LIBRARY_MAINTENANCE_BATCH
+ ? tx(`Selected the first ${MAX_LIBRARY_MAINTENANCE_BATCH} matches.`, `已选择前 ${MAX_LIBRARY_MAINTENANCE_BATCH} 个匹配项。`)
+ : null,
+ );
}
async function applyReviewed() {
@@ -99,107 +114,213 @@ export function LibraryBulkMaintenance({ bookmarks, bookmarkTags, categoryNameBy
setSelectedIds(new Set());
setReviewing(false);
setDeleteConfirmation("");
- const verb = action === "set-health-policy" ? `Updated HealthPolicy to ${healthPolicy} for`
- : action === "archive" ? "Archived"
- : action === "restore" ? "Restored"
- : "Permanently deleted";
- setNotice(`${verb} ${result.applied} bookmark${result.applied === 1 ? "" : "s"}.`);
+ if (action === "set-health-policy") {
+ setNotice(tx(
+ `Updated health policy to ${policyLabels[healthPolicy]} for ${result.applied} bookmark${result.applied === 1 ? "" : "s"}.`,
+ `已将 ${result.applied} 个书签的健康策略更新为「${policyLabels[healthPolicy]}」。`,
+ ));
+ } else if (action === "archive") {
+ setNotice(tx(`Archived ${result.applied} bookmark${result.applied === 1 ? "" : "s"}.`, `已归档 ${result.applied} 个书签。`));
+ } else if (action === "restore") {
+ setNotice(tx(`Restored ${result.applied} bookmark${result.applied === 1 ? "" : "s"}.`, `已恢复 ${result.applied} 个书签。`));
+ } else {
+ setNotice(tx(`Permanently deleted ${result.applied} bookmark${result.applied === 1 ? "" : "s"}.`, `已永久删除 ${result.applied} 个书签。`));
+ }
} catch (caught) {
- setError(messageFrom(caught));
+ setError(messageFrom(caught, genericError));
} finally {
setApplying(false);
}
}
return (
-
+
-
V5 · REVIEWED MAINTENANCE
-
Bulk maintain
-
HealthPolicy and destructive lifecycle changes stay behind an explicit review gate. Archive is reversible; permanent delete is archive-only.
+
{tx("Bulk maintain", "批量维护与归档")}
+
+ {tx(
+ "Health policy and lifecycle actions require explicit review. Archiving is reversible; permanent deletion is only available from Archive.",
+ "健康策略调整与归档删除均需复核确认。归档可随时恢复;仅已归档书签支持永久删除。",
+ )}
+
- {selectedIds.size} selected
- Select matches
- { setSelectedIds(new Set()); setReviewing(false); }}>Clear
+ {tx(`${selectedIds.size} selected`, `已选 ${selectedIds.size} 项`)}
+
+ {tx("Select matches", "选择匹配项")}
+
+ { setSelectedIds(new Set()); setReviewing(false); }}
+ >
+ {tx("Clear", "清空")}
+
- setScope("active")}>Active ({bookmarks.length})
- setScope("archived")}>Archived ({archived.length})
+ setScope("active")}>
+ {tx(`Active (${bookmarks.length})`, `活跃书签 (${bookmarks.length})`)}
+
+ setScope("archived")}>
+ {tx(`Archived (${archived.length})`, `已归档 (${archived.length})`)}
+
- ⌕
- setQuery(event.target.value)} placeholder={`Filter ${scope} bookmarks…`} />
- {candidates.length} match{candidates.length === 1 ? "" : "es"}
+ ⌕
+ setQuery(event.target.value)}
+ placeholder={scope === "active"
+ ? tx("Filter active bookmarks…", "筛选活跃书签…")
+ : tx("Filter archived bookmarks…", "筛选已归档书签…")}
+ />
+ {tx(`${candidates.length} match${candidates.length === 1 ? "" : "es"}`, `${candidates.length} 个匹配`)}
- Action
- { setAction(event.target.value as LibraryMaintenanceAction); setReviewing(false); setDeleteConfirmation(""); }}>
- {scope === "active" ? <>
- Set HealthPolicy
- Archive
- > : <>
- Restore to Library
- Permanent delete
- >}
+ {tx("Action", "操作")}
+ {
+ setAction(event.target.value as LibraryMaintenanceAction);
+ setReviewing(false);
+ setDeleteConfirmation("");
+ }}
+ >
+ {scope === "active" ? (
+ <>
+ {tx("Set health policy", "设置健康策略")}
+ {tx("Archive", "归档")}
+ >
+ ) : (
+ <>
+ {tx("Restore to Library", "恢复到书签库")}
+ {tx("Permanent delete", "永久删除")}
+ >
+ )}
- {action === "set-health-policy" &&
- HealthPolicy
- setHealthPolicy(event.target.value as HealthPolicy)}>
- Normal
- Ignore
- Local only
- Manual
-
- }
+ {action === "set-health-policy" && (
+
+ {tx("Health policy", "健康检查策略")}
+ setHealthPolicy(event.target.value as HealthPolicy)}
+ >
+ {policyLabels.normal}
+ {policyLabels.ignore}
+ {policyLabels["local-only"]}
+ {policyLabels.manual}
+
+
+ )}
{error &&
{error}
}
{notice &&
{notice}
}
- {!reviewing ?
- setReviewing(true)}>Review {selectedIds.size || ""} maintenance change{selectedIds.size === 1 ? "" : "s"}
- Maximum {MAX_LIBRARY_MAINTENANCE_BATCH} bookmarks per reviewed batch.
-
:
-
-
Review before apply
-
{selectedIds.size} bookmark{selectedIds.size === 1 ? "" : "s"} selected. {action === "archive" ? "Archive removes them from active Library, Inbox and public selection without deleting data." : action === "delete" ? "Permanent delete cannot be undone and is allowed only from Archived." : "The batch is applied atomically after validation."}
-
-
- {action === "set-health-policy" ? `Set HealthPolicy → ${healthPolicy}` : action === "archive" ? "Archive selected bookmarks" : action === "restore" ? "Restore selected bookmarks" : "Permanently delete selected bookmarks"}
-
-
- {selected.slice(0, 8).map((bookmark) => {bookmark.title} )}
- {selected.length > 8 && +{selected.length - 8} more }
-
- {action === "delete" &&
- Type DELETE to confirm permanent deletion
- setDeleteConfirmation(event.target.value)} autoComplete="off" />
- }
+ {!reviewing ? (
- void applyReviewed()}>{applying ? "Applying…" : action === "delete" ? `Delete ${selectedIds.size} permanently` : `Apply to ${selectedIds.size}`}
- setReviewing(false)}>Back
+ setReviewing(true)}>
+ {selectedIds.size
+ ? tx(`Review ${selectedIds.size} maintenance change${selectedIds.size === 1 ? "" : "s"}`, `复核 ${selectedIds.size} 项维护变更`)
+ : tx("Review maintenance changes", "复核维护变更")}
+
+
+ {tx(`Up to ${MAX_LIBRARY_MAINTENANCE_BATCH} bookmarks per reviewed batch.`, `单次最多复核 ${MAX_LIBRARY_MAINTENANCE_BATCH} 个书签。`)}
+
+
+ ) : (
+
+
+
{tx("Review before apply", "应用前确认")}
+
+ {tx(`${selectedIds.size} bookmark${selectedIds.size === 1 ? "" : "s"} selected. `, `已选择 ${selectedIds.size} 个书签。`)}
+ {action === "archive"
+ ? tx("Archiving removes them from active Library, Inbox, and public selection without deleting data.", "归档会将其移出活跃书签库、收件箱和公开主页,不会删除数据。")
+ : action === "delete"
+ ? tx("Permanent deletion cannot be undone and is allowed only from Archive.", "永久删除不可撤销,且仅限对已归档书签执行。")
+ : tx("The batch is applied atomically after validation.", "校验通过后将一次性原子提交。")}
+
+
+
+
+ {action === "set-health-policy"
+ ? tx(`Set health policy → ${policyLabels[healthPolicy]}`, `设置健康策略 → ${policyLabels[healthPolicy]}`)
+ : action === "archive"
+ ? tx("Archive selected bookmarks", "归档所选书签")
+ : action === "restore"
+ ? tx("Restore selected bookmarks", "恢复所选书签")
+ : tx("Permanently delete selected bookmarks", "永久删除所选书签")}
+
+
+
+ {selected.slice(0, 8).map((bookmark) => {bookmark.title} )}
+ {selected.length > 8 && {tx(`+${selected.length - 8} more`, `另有 ${selected.length - 8} 项`)} }
+
+ {action === "delete" && (
+
+ {tx("Type DELETE to confirm permanent deletion", "输入 DELETE 确认永久删除")}
+ setDeleteConfirmation(event.target.value)}
+ placeholder="DELETE"
+ autoComplete="off"
+ />
+
+ )}
+
+ void applyReviewed()}
+ >
+ {applying
+ ? tx("Applying…", "应用中…")
+ : action === "delete"
+ ? tx(`Delete ${selectedIds.size} permanently`, `永久删除 ${selectedIds.size} 项`)
+ : tx(`Apply to ${selectedIds.size}`, `应用到 ${selectedIds.size} 项`)}
+
+ setReviewing(false)}>
+ {tx("Back", "返回")}
+
+
-
}
+ )}
);
diff --git a/apps/web/src/LibraryBulkOrganizer.tsx b/apps/web/src/LibraryBulkOrganizer.tsx
index 979a622..1087b0d 100644
--- a/apps/web/src/LibraryBulkOrganizer.tsx
+++ b/apps/web/src/LibraryBulkOrganizer.tsx
@@ -1,7 +1,15 @@
+/**
+ * [INPUT]: depends on Bookmark, Category from @dockmark/core; parseBookmarkTags from ./bookmark-details-api; bookmarkMatchesQuery from ./bookmark-search; MAX_LIBRARY_BATCH, organizeLibraryBatch from ./library-batch-api; useI18n from ./i18n
+ * [OUTPUT]: exports LibraryBulkOrganizer component
+ * [POS]: reviewed multi-select category and tag batch organizer used in BookmarkManager and SmartCollectionsPage
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
+
import { useMemo, useState } from "react";
import type { Bookmark, Category } from "@dockmark/core";
import { parseBookmarkTags } from "./bookmark-details-api";
import { bookmarkMatchesQuery } from "./bookmark-search";
+import { useI18n } from "./i18n";
import { MAX_LIBRARY_BATCH, organizeLibraryBatch } from "./library-batch-api";
import "./library-bulk.css";
@@ -16,16 +24,16 @@ interface Props {
const KEEP_CATEGORY = "__keep__";
-function messageFrom(error: unknown) {
- return error instanceof Error ? error.message : "Something went wrong.";
+function messageFrom(error: unknown, fallback: string) {
+ return error instanceof Error ? error.message : fallback;
}
-function tagInputError(value: string) {
+function tagInputError(value: string, fallback: string) {
try {
parseBookmarkTags(value);
return null;
} catch (error) {
- return messageFrom(error);
+ return messageFrom(error, fallback);
}
}
@@ -37,6 +45,10 @@ export function LibraryBulkOrganizer({
contextLabel,
preselectMatches = false,
}: Props) {
+ const { tx } = useI18n();
+ const genericError = tx("Something went wrong.", "操作失败,请重试。");
+ const uncategorizedLabel = tx("Uncategorized", "未分类");
+
const [query, setQuery] = useState("");
const [selectedIds, setSelectedIds] = useState>(
() => new Set(preselectMatches ? bookmarks.slice(0, MAX_LIBRARY_BATCH).map((bookmark) => bookmark.id) : []),
@@ -49,7 +61,10 @@ export function LibraryBulkOrganizer({
const [error, setError] = useState(null);
const [notice, setNotice] = useState(
() => preselectMatches && bookmarks.length > MAX_LIBRARY_BATCH
- ? `Selected the first ${MAX_LIBRARY_BATCH} of ${bookmarks.length} handed-off matches.`
+ ? tx(
+ `Selected the first ${MAX_LIBRARY_BATCH} of ${bookmarks.length} handed-off matches.`,
+ `已预选前 ${MAX_LIBRARY_BATCH} 个匹配书签(共 ${bookmarks.length} 个)。`,
+ )
: null,
);
@@ -59,10 +74,10 @@ export function LibraryBulkOrganizer({
);
const candidates = useMemo(
() => bookmarks.filter((bookmark) => {
- const category = bookmark.categoryId ? categoryNameById.get(bookmark.categoryId) ?? "" : "Uncategorized";
+ const category = bookmark.categoryId ? categoryNameById.get(bookmark.categoryId) ?? "" : uncategorizedLabel;
return bookmarkMatchesQuery(bookmark, category, bookmarkTags[bookmark.id] ?? [], query);
}),
- [bookmarkTags, bookmarks, categoryNameById, query],
+ [bookmarkTags, bookmarks, categoryNameById, query, uncategorizedLabel],
);
const visibleIds = useMemo(() => new Set(candidates.map((bookmark) => bookmark.id)), [candidates]);
const selectedBookmarks = useMemo(
@@ -74,15 +89,20 @@ export function LibraryBulkOrganizer({
[selectedIds, visibleIds],
);
- const addTagsError = useMemo(() => tagInputError(addTagsText), [addTagsText]);
- const removeTagsError = useMemo(() => tagInputError(removeTagsText), [removeTagsText]);
+ const addTagsError = useMemo(() => tagInputError(addTagsText, genericError), [addTagsText, genericError]);
+ const removeTagsError = useMemo(() => tagInputError(removeTagsText, genericError), [removeTagsText, genericError]);
const overlapError = useMemo(() => {
if (addTagsError || removeTagsError) return null;
const addTags = parseBookmarkTags(addTagsText);
const removeKeys = new Set(parseBookmarkTags(removeTagsText).map((tag) => tag.toLocaleLowerCase()));
const overlap = addTags.find((tag) => removeKeys.has(tag.toLocaleLowerCase()));
- return overlap ? `Tag “${overlap}” cannot be added and removed in the same review.` : null;
- }, [addTagsError, addTagsText, removeTagsError, removeTagsText]);
+ return overlap
+ ? tx(
+ `Tag “${overlap}” cannot be added and removed in the same review.`,
+ `标签「${overlap}」不能在同一批次中同时添加和移除。`,
+ )
+ : null;
+ }, [addTagsError, addTagsText, removeTagsError, removeTagsText, tx]);
const hasChanges = categoryChoice !== KEEP_CATEGORY || Boolean(addTagsText.trim()) || Boolean(removeTagsText.trim());
const validationError = addTagsError || removeTagsError || overlapError;
@@ -109,7 +129,11 @@ export function LibraryBulkOrganizer({
function selectVisible() {
if (reviewing || applying) return;
setSelectedIds(new Set(candidates.slice(0, MAX_LIBRARY_BATCH).map((bookmark) => bookmark.id)));
- setNotice(candidates.length > MAX_LIBRARY_BATCH ? `Selected the first ${MAX_LIBRARY_BATCH} matching bookmarks.` : null);
+ setNotice(
+ candidates.length > MAX_LIBRARY_BATCH
+ ? tx(`Selected the first ${MAX_LIBRARY_BATCH} matching bookmarks.`, `已选择前 ${MAX_LIBRARY_BATCH} 个匹配书签。`)
+ : null,
+ );
setError(null);
}
@@ -122,9 +146,10 @@ export function LibraryBulkOrganizer({
}
function categoryLabel() {
- if (categoryChoice === KEEP_CATEGORY) return "Keep current categories";
- if (categoryChoice === "") return "Move to Uncategorized";
- return `Move to ${categories.find((category) => category.id === categoryChoice)?.name ?? "selected category"}`;
+ if (categoryChoice === KEEP_CATEGORY) return tx("Keep current categories", "保持当前分类");
+ if (categoryChoice === "") return tx("Move to Uncategorized", "移至未分类");
+ const targetName = categories.find((category) => category.id === categoryChoice)?.name ?? tx("selected category", "所选分类");
+ return tx(`Move to ${targetName}`, `移至「${targetName}」`);
}
async function applyReviewedChanges() {
@@ -147,9 +172,12 @@ export function LibraryBulkOrganizer({
setAddTagsText("");
setRemoveTagsText("");
setReviewing(false);
- setNotice(`Applied reviewed organization to ${result.applied} bookmark${result.applied === 1 ? "" : "s"}.`);
+ setNotice(tx(
+ `Applied reviewed organization to ${result.applied} bookmark${result.applied === 1 ? "" : "s"}.`,
+ `已批量整理 ${result.applied} 个书签。`,
+ ));
} catch (caught) {
- setError(messageFrom(caught));
+ setError(messageFrom(caught, genericError));
} finally {
setApplying(false);
}
@@ -159,48 +187,60 @@ export function LibraryBulkOrganizer({
const removeTags = !removeTagsError ? parseBookmarkTags(removeTagsText) : [];
return (
-
+
-
V5 · POWER LIBRARY
-
Bulk organize
+
{tx("Bulk organize", "批量整理")}
- {contextLabel
- ? <>Scoped from {contextLabel} . Review category and tag changes first, then commit the batch atomically.>
- : "Explicit multi-select organization: review category and tag changes first, then commit the batch atomically."}
+ {contextLabel ? (
+ <>
+ {tx("Scoped from ", "当前范围来自 ")}
+ {contextLabel}
+ {tx(". Review category and tag changes before committing atomically.", "。核对分类和标签变更后再一次性原子提交。")}
+ >
+ ) : (
+ tx("Select bookmarks, preview category and tag edits, then commit the batch atomically.", "多选书签并预览分类与标签修改,确认后一次性原子提交。")
+ )}
- {selectedIds.size} selected
+ {tx(`${selectedIds.size} selected`, `已选 ${selectedIds.size} 项`)}
- {candidates.length > MAX_LIBRARY_BATCH ? `Select first ${MAX_LIBRARY_BATCH}` : "Select matches"}
+ {candidates.length > MAX_LIBRARY_BATCH
+ ? tx(`Select first ${MAX_LIBRARY_BATCH}`, `全选前 ${MAX_LIBRARY_BATCH} 项`)
+ : tx("Select matches", "选择匹配项")}
+
+
+ {tx("Clear", "清空")}
- Clear
- ⌕
+ ⌕
setQuery(event.target.value)}
placeholder={contextLabel
- ? "Narrow the handed-off collection by title, URL, description, category or #tag…"
- : "Filter bulk candidates by title, URL, description, category or #tag…"}
- aria-label="Filter bookmarks for bulk organization"
+ ? tx("Narrow collection by title, URL, description, category, or #tag…", "按标题、网址、描述、分类或 #标签进一步筛选…")
+ : tx("Filter bulk candidates by title, URL, description, category, or #tag…", "按标题、网址、描述、分类或 #标签筛选书签…")}
+ aria-label={tx("Filter bookmarks for bulk organization", "筛选待批量整理的书签")}
/>
- {candidates.length} match{candidates.length === 1 ? "" : "es"}
+ {tx(`${candidates.length} match${candidates.length === 1 ? "" : "es"}`, `${candidates.length} 个匹配`)}
{hiddenSelectedCount > 0 && (
- {hiddenSelectedCount} selected bookmark{hiddenSelectedCount === 1 ? " is" : "s are"} outside the current bulk filter. Clear selection if you want this review to stay filter-only.
+ {tx(
+ `${hiddenSelectedCount} selected bookmark${hiddenSelectedCount === 1 ? " is" : "s are"} outside the current filter. Clear selection to keep this review filter-only.`,
+ `有 ${hiddenSelectedCount} 个已选书签不在当前筛选结果中。如需仅处理当前结果,请先清空选择。`,
+ )}
)}
-
+
{candidates.slice(0, 100).map((bookmark) => (
{bookmark.title} {bookmark.url}
))}
- {!candidates.length &&
No bookmarks match this bulk filter.
}
- {candidates.length > 100 &&
Showing the first 100 matches in the picker. Narrow the filter to target another set.
}
+ {!candidates.length &&
{tx("No bookmarks match this filter.", "没有符合当前筛选条件的书签。")}
}
+ {candidates.length > 100 && (
+
+ {tx("Showing the first 100 matches. Narrow the filter to target another set.", "仅展示前 100 个匹配项,请缩小筛选范围以定位其他书签。")}
+
+ )}
- Category
+ {tx("Category", "分类")}
{ setCategoryChoice(event.target.value); resetReview(); }}>
- Keep current categories
- Move to Uncategorized
- {categories.map((category) => Move to {category.name} )}
+ {tx("Keep current categories", "保持当前分类")}
+ {tx("Move to Uncategorized", "移至未分类")}
+ {categories.map((category) => (
+ {tx(`Move to ${category.name}`, `移至「${category.name}」`)}
+ ))}
- Add tags
+ {tx("Add tags", "添加标签")}
{ setAddTagsText(event.target.value); resetReview(); }}
- placeholder="dev, docs"
+ placeholder={tx("dev, docs", "dev, docs")}
aria-invalid={Boolean(addTagsError)}
/>
{addTagsError && {addTagsError} }
- Remove tags
+ {tx("Remove tags", "移除标签")}
{ setRemoveTagsText(event.target.value); resetReview(); }}
- placeholder="old, later"
+ placeholder={tx("old, later", "old, 待看")}
aria-invalid={Boolean(removeTagsError)}
/>
{removeTagsError && {removeTagsError} }
@@ -256,30 +302,46 @@ export function LibraryBulkOrganizer({
{!reviewing ? (
setReviewing(true)}>
- Review {selectedIds.size || ""} change{selectedIds.size === 1 ? "" : "s"}
+ {selectedIds.size
+ ? tx(`Review ${selectedIds.size} change${selectedIds.size === 1 ? "" : "s"}`, `复核 ${selectedIds.size} 项变更`)
+ : tx("Review changes", "复核变更")}
- Maximum {MAX_LIBRARY_BATCH} bookmarks per reviewed batch. Titles, URLs, descriptions and HealthPolicy are never changed here.
+
+ {tx(
+ `Up to ${MAX_LIBRARY_BATCH} bookmarks per batch. Titles, URLs, descriptions, and health policies are never modified here.`,
+ `单次最多处理 ${MAX_LIBRARY_BATCH} 个书签。不会改动标题、网址、描述或健康策略。`,
+ )}
+
) : (
-
Review before apply
-
{selectedIds.size} bookmark{selectedIds.size === 1 ? "" : "s"} will be updated in one D1 batch. If validation fails, none are changed.
+
{tx("Review before apply", "应用前确认")}
+
+ {tx(
+ `${selectedIds.size} bookmark${selectedIds.size === 1 ? "" : "s"} will be updated in one transaction. If validation fails, nothing changes.`,
+ `将在单次事务中更新 ${selectedIds.size} 个书签;若校验失败,不会产生部分修改。`,
+ )}
+
{categoryLabel()}
- {addTags.length > 0 && Add {addTags.map((tag) => `#${tag}`).join(" ")} }
- {removeTags.length > 0 && Remove {removeTags.map((tag) => `#${tag}`).join(" ")} }
+ {addTags.length > 0 && {tx("Add", "添加")} {addTags.map((tag) => `#${tag}`).join(" ")} }
+ {removeTags.length > 0 && {tx("Remove", "移除")} {removeTags.map((tag) => `#${tag}`).join(" ")} }
{selectedBookmarks.slice(0, 8).map((bookmark) => {bookmark.title} )}
- {selectedIds.size > 8 && +{selectedIds.size - 8} more }
+ {selectedIds.size > 8 && {tx(`+${selectedIds.size - 8} more`, `另有 ${selectedIds.size - 8} 项`)} }
void applyReviewedChanges()}>
- {applying ? "Applying…" : `Apply to ${selectedIds.size}`}
+ {applying
+ ? tx("Applying…", "应用中…")
+ : tx(`Apply to ${selectedIds.size}`, `应用到 ${selectedIds.size} 项`)}
+
+ setReviewing(false)}>
+ {tx("Back", "返回")}
- setReviewing(false)}>Back
)}
diff --git a/apps/web/src/NativeBookmarkImport.tsx b/apps/web/src/NativeBookmarkImport.tsx
index 6427096..6395b8a 100644
--- a/apps/web/src/NativeBookmarkImport.tsx
+++ b/apps/web/src/NativeBookmarkImport.tsx
@@ -1,3 +1,10 @@
+/**
+ * [INPUT]: depends on DEFAULT_BROWSER_SETTINGS, normalizeBookmarkUrl, normalizeBrowserSettings, Bookmark, BookmarkConflictPreference, Category from @dockmark/core; bookmark/bridge/transfer/sync modules; NativeMappingPreviewPanel, NativeImportTreePanel from ./NativeBookmarkSyncPanels; useI18n from ./i18n
+ * [OUTPUT]: exports NativeBookmarkImport component
+ * [POS]: browser-native bookmark reader, mapping conflict resolver, and safe incremental sync controller embedded in TransferManager
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
+
import { useEffect, useMemo, useState } from "react";
import {
DEFAULT_BROWSER_SETTINGS,
@@ -19,15 +26,21 @@ import {
type NativeBookmarkSnapshot,
type NativeBrowserBookmark,
} from "./browser-bridge";
-import { buildImportPreview, type ImportCandidate, type ParsedBookmark } from "./bookmark-transfer";
+import { buildImportPreview, type ParsedBookmark } from "./bookmark-transfer";
+import { useI18n } from "./i18n";
import {
acceptNativeMappingBaseline,
buildNativeMappingRows,
- nativeMappingReviewDescription,
- nativeMappingStateLabel,
removeNativeMappingBaseline,
type NativeMappingRow,
} from "./native-bookmark-sync";
+import {
+ conflictPreferenceLabel,
+ folderCategory,
+ NativeImportTreePanel,
+ NativeMappingPreviewPanel,
+ type NativeImportCandidate,
+} from "./NativeBookmarkSyncPanels";
interface Props {
bookmarks: Bookmark[];
@@ -36,13 +49,6 @@ interface Props {
onOpenExtension: () => void;
}
-interface NativeImportCandidate extends ImportCandidate {
- browserBookmarkId: string;
- folderPath: string[];
- existingBookmarkId?: string;
- mappedDockmarkBookmarkId?: string | undefined;
-}
-
const LOCAL_SETTINGS_KEY = "dockmarkBrowserSettingsV1";
function readConflictPreference(): BookmarkConflictPreference {
@@ -54,30 +60,17 @@ function readConflictPreference(): BookmarkConflictPreference {
}
}
-function conflictPreferenceLabel(preference: BookmarkConflictPreference) {
- if (preference === "browser") return "Prefer Browser";
- if (preference === "dockmark") return "Prefer Dockmark";
- return "Ask every time";
-}
-
function categoryKey(value: string) {
return value.trim().toLocaleLowerCase();
}
-function folderCategory(path: string[]) {
- const cleaned = path.map((part) => part.trim()).filter(Boolean);
- if (!cleaned.length) return undefined;
- const joined = cleaned.join(" / ");
- return joined.length <= 80 ? joined : `…${joined.slice(-79)}`;
-}
-
function existingByUrl(bookmarks: Bookmark[]) {
const map = new Map();
for (const bookmark of bookmarks) {
try {
map.set(normalizeBookmarkUrl(bookmark.url), bookmark);
} catch {
- // Existing Dockmark data should already be normalized; ignore malformed legacy rows.
+ // Ignore malformed legacy rows.
}
}
return map;
@@ -87,6 +80,7 @@ function buildNativePreview(
nativeBookmarks: NativeBrowserBookmark[],
mappings: NativeBookmarkMapping[],
cloudBookmarks: Bookmark[],
+ changedErrorMessage: string,
) {
const parsed: ParsedBookmark[] = nativeBookmarks.map((bookmark) => {
const categoryName = folderCategory(bookmark.folderPath);
@@ -102,7 +96,7 @@ function buildNativePreview(
return base.map((candidate, index): NativeImportCandidate => {
const native = nativeBookmarks[index];
- if (!native) throw new Error("Browser bookmark snapshot changed while building the preview.");
+ if (!native) throw new Error(changedErrorMessage);
const existing = candidate.normalizedUrl ? cloudByUrl.get(candidate.normalizedUrl) : undefined;
const mapping = mappingByNativeId.get(native.id);
@@ -118,6 +112,7 @@ function buildNativePreview(
}
export function NativeBookmarkImport({ bookmarks, categories, onChanged, onOpenExtension }: Props) {
+ const { locale, tx } = useI18n();
const [items, setItems] = useState([]);
const [snapshot, setSnapshot] = useState(null);
const [loaded, setLoaded] = useState(false);
@@ -130,11 +125,19 @@ export function NativeBookmarkImport({ bookmarks, categories, onChanged, onOpenE
const [message, setMessage] = useState(null);
const [relinkTargets, setRelinkTargets] = useState>({});
+ const snapshotChangedError = tx(
+ "Browser bookmark snapshot changed while building the preview.",
+ "生成预览时浏览器书签快照发生变化,请重新读取。",
+ );
+
useEffect(() => onBridgeEvent((event) => {
if (event === "bookmarks-changed" && loaded && !busy) {
- setMessage("Browser bookmark state changed. Refresh the snapshot to preview the latest mapping differences.");
+ setMessage(tx(
+ "Browser bookmark state changed. Refresh the snapshot to preview the latest mapping differences.",
+ "检测到浏览器书签变动,请刷新快照以预览最新映射差异。",
+ ));
}
- }), [busy, loaded]);
+ }), [busy, loaded, tx]);
useEffect(() => {
const onStorage = (event: StorageEvent) => {
@@ -190,6 +193,13 @@ export function NativeBookmarkImport({ bookmarks, categories, onChanged, onOpenE
missing: mappingRows.filter((row) => row.state === "native-missing" || row.state === "cloud-missing").length,
}), [mappingRows]);
+ async function refreshMappingSnapshot() {
+ const nextSnapshot = await getNativeBookmarksWithBridge();
+ setSnapshot(nextSnapshot);
+ setItems(buildNativePreview(nextSnapshot.bookmarks, nextSnapshot.mappings, bookmarks, snapshotChangedError));
+ return nextSnapshot;
+ }
+
async function loadNativeBookmarks() {
setBusy(true);
setError(null);
@@ -198,24 +208,33 @@ export function NativeBookmarkImport({ bookmarks, categories, onChanged, onOpenE
try {
const bridge = await getBridgeStatus();
if (!bridge.capabilities.nativeBookmarks) {
- throw new Error("This Dockmark extension is too old for native bookmark import. Update it and reconnect.");
+ throw new Error(tx(
+ "This Dockmark extension is too old for native bookmark import. Update it and reconnect.",
+ "当前浏览器扩展版本过旧,不支持读取原生书签。请更新扩展并重新连接。",
+ ));
}
if (!bridge.permissions?.nativeBookmarks) {
- throw new Error("Open the Dockmark extension popup and enable Native bookmarks, then try again.");
+ throw new Error(tx(
+ "Open the Dockmark extension popup and enable Native bookmarks, then try again.",
+ "请先在 Dockmark 浏览器扩展弹窗中启用「原生书签」权限后再重试。",
+ ));
}
const nextSnapshot = await getNativeBookmarksWithBridge();
setSyncCapable(Boolean(bridge.capabilities.nativeBookmarkSync));
setWritebackCapable(Boolean(bridge.capabilities.nativeBookmarkWriteback));
setSnapshot(nextSnapshot);
- setItems(buildNativePreview(nextSnapshot.bookmarks, nextSnapshot.mappings, bookmarks));
+ setItems(buildNativePreview(nextSnapshot.bookmarks, nextSnapshot.mappings, bookmarks, snapshotChangedError));
setLoaded(true);
- setMessage(`Read ${nextSnapshot.bookmarks.length} browser bookmarks and ${nextSnapshot.mappings.length} local mapping${nextSnapshot.mappings.length === 1 ? "" : "s"}. Nothing has been changed yet.`);
+ setMessage(tx(
+ `Read ${nextSnapshot.bookmarks.length} browser bookmarks and ${nextSnapshot.mappings.length} local mapping${nextSnapshot.mappings.length === 1 ? "" : "s"}. Nothing has been changed yet.`,
+ `已读取 ${nextSnapshot.bookmarks.length} 个浏览器书签及 ${nextSnapshot.mappings.length} 条本地映射,尚未改动任何数据。`,
+ ));
} catch (caught) {
setLoaded(false);
setSnapshot(null);
setItems([]);
- setError(caught instanceof Error ? caught.message : "Could not read browser bookmarks.");
+ setError(caught instanceof Error ? caught.message : tx("Could not read browser bookmarks.", "无法读取浏览器书签。"));
} finally {
setBusy(false);
}
@@ -314,16 +333,13 @@ export function NativeBookmarkImport({ bookmarks, categories, onChanged, onOpenE
if (successfulMappings.length) await saveNativeBookmarkMappingsWithBridge(successfulMappings);
await onChanged();
- const nextSnapshot = await getNativeBookmarksWithBridge();
- setSnapshot(nextSnapshot);
- setItems(buildNativePreview(nextSnapshot.bookmarks, nextSnapshot.mappings, bookmarks));
- setMessage(
- `Mapped ${successfulMappings.length} browser bookmark${successfulMappings.length === 1 ? "" : "s"}: ` +
- `${created} new Dockmark bookmark${created === 1 ? "" : "s"}, ${linkedExisting} existing URL${linkedExisting === 1 ? "" : "s"}` +
- `${failedGroups ? `; ${failedGroups} URL group${failedGroups === 1 ? "" : "s"} failed` : ""}.`,
- );
+ await refreshMappingSnapshot();
+ setMessage(tx(
+ `Mapped ${successfulMappings.length} browser bookmark${successfulMappings.length === 1 ? "" : "s"}: ${created} new, ${linkedExisting} linked to existing URLs${failedGroups ? `; ${failedGroups} failed` : ""}.`,
+ `已映射 ${successfulMappings.length} 个浏览器书签:新增 ${created} 项、关联已有 ${linkedExisting} 项${failedGroups ? `,${failedGroups} 组失败` : ""}。`,
+ ));
} catch (caught) {
- setError(caught instanceof Error ? caught.message : "Native bookmark import failed.");
+ setError(caught instanceof Error ? caught.message : tx("Native bookmark import failed.", "原生书签导入失败。"));
} finally {
setBusy(false);
}
@@ -344,37 +360,33 @@ export function NativeBookmarkImport({ bookmarks, categories, onChanged, onOpenE
? { ...item, mappedDockmarkBookmarkId: undefined, selected: item.status !== "invalid" }
: item,
));
- setMessage("Mapping unlinked. Neither the browser bookmark nor the Dockmark bookmark was deleted.");
+ setMessage(tx(
+ "Mapping unlinked. Neither the browser bookmark nor the Dockmark bookmark was deleted.",
+ "已解除映射,浏览器书签与 Dockmark 书签均未被删除。",
+ ));
} catch (caught) {
- setError(caught instanceof Error ? caught.message : "Could not unlink mapping.");
+ setError(caught instanceof Error ? caught.message : tx("Could not unlink mapping.", "无法解除映射。"));
} finally {
setBusy(false);
}
}
- async function refreshMappingSnapshot() {
- const nextSnapshot = await getNativeBookmarksWithBridge();
- setSnapshot(nextSnapshot);
- setItems(buildNativePreview(nextSnapshot.bookmarks, nextSnapshot.mappings, bookmarks));
- return nextSnapshot;
- }
-
async function keepDockmark(row: NativeMappingRow) {
if (!row.native || !row.cloud) return;
setBusy(true);
setError(null);
setMessage(null);
try {
- const mapping: NativeBookmarkMapping = {
- ...row.mapping,
- url: row.native.url,
- };
+ const mapping: NativeBookmarkMapping = { ...row.mapping, url: row.native.url };
await saveNativeBookmarkMappingsWithBridge([mapping]);
acceptNativeMappingBaseline(mapping, row.native, row.cloud);
await refreshMappingSnapshot();
- setMessage("Kept the Dockmark version and accepted the current Browser ↔ Dockmark difference as the new mapping baseline. No browser data was changed.");
+ setMessage(tx(
+ "Kept the Dockmark version and accepted the current difference as the new baseline. No browser data was changed.",
+ "已保留 Dockmark 版本并将当前差异设为新基线,未改动浏览器书签。",
+ ));
} catch (caught) {
- setError(caught instanceof Error ? caught.message : "Could not keep the Dockmark version.");
+ setError(caught instanceof Error ? caught.message : tx("Could not keep the Dockmark version.", "无法保留 Dockmark 版本。"));
} finally {
setBusy(false);
}
@@ -393,17 +405,17 @@ export function NativeBookmarkImport({ bookmarks, categories, onChanged, onOpenE
url: row.cloud.url,
});
- const mapping: NativeBookmarkMapping = {
- ...row.mapping,
- url: row.cloud.url,
- };
+ const mapping: NativeBookmarkMapping = { ...row.mapping, url: row.cloud.url };
await saveNativeBookmarkMappingsWithBridge([mapping]);
const nextSnapshot = await refreshMappingSnapshot();
const nextNative = nextSnapshot.bookmarks.find((bookmark) => bookmark.id === row.mapping.browserBookmarkId);
if (nextNative) acceptNativeMappingBaseline(mapping, nextNative, row.cloud);
- setMessage(`Wrote Dockmark title and URL to the mapped browser bookmark “${row.cloud.title}”. The browser folder was not moved, and no other browser bookmarks were changed.`);
+ setMessage(tx(
+ `Wrote Dockmark title and URL to the mapped browser bookmark “${row.cloud.title}”. No folders were moved.`,
+ `已将「${row.cloud.title}」的标题与网址写回对应浏览器书签,未移动浏览器文件夹。`,
+ ));
} catch (caught) {
- setError(caught instanceof Error ? caught.message : "Could not write this Dockmark bookmark back to the browser.");
+ setError(caught instanceof Error ? caught.message : tx("Could not write this Dockmark bookmark back to the browser.", "无法写回浏览器书签。"));
} finally {
setBusy(false);
}
@@ -432,9 +444,12 @@ export function NativeBookmarkImport({ bookmarks, categories, onChanged, onOpenE
return next;
});
await refreshMappingSnapshot();
- setMessage(`Re-linked the browser bookmark to “${target.title}”. Neither bookmark was modified.`);
+ setMessage(tx(
+ `Re-linked the browser bookmark to “${target.title}”. Neither bookmark was modified.`,
+ `已将该浏览器书签重新关联到「${target.title}」,两侧书签内容未改动。`,
+ ));
} catch (caught) {
- setError(caught instanceof Error ? caught.message : "Could not re-link this mapping.");
+ setError(caught instanceof Error ? caught.message : tx("Could not re-link this mapping.", "无法重新关联此映射。"));
} finally {
setBusy(false);
}
@@ -497,9 +512,12 @@ export function NativeBookmarkImport({ bookmarks, categories, onChanged, onOpenE
acceptNativeMappingBaseline(mapping, native, target);
await onChanged();
await refreshMappingSnapshot();
- setMessage(`Resolved review using Browser as the source. Dockmark now follows “${native.title || native.url}”; the native browser bookmark was not modified.`);
+ setMessage(tx(
+ `Resolved review using Browser as source. Dockmark now follows “${native.title || native.url}”.`,
+ `已采用浏览器版本,Dockmark 已更新为「${native.title || native.url}」。`,
+ ));
} catch (caught) {
- setError(caught instanceof Error ? caught.message : "Could not resolve this mapping using the browser version.");
+ setError(caught instanceof Error ? caught.message : tx("Could not resolve this mapping using the browser version.", "无法采用浏览器版本解决此冲突。"));
} finally {
setBusy(false);
}
@@ -512,22 +530,16 @@ export function NativeBookmarkImport({ bookmarks, categories, onChanged, onOpenE
setMessage(null);
try {
for (const row of preferredReviewRows) {
- if (conflictPreference === "browser") {
- await useBrowser(row);
- } else if (writebackCapable) {
- await writeDockmarkToBrowser(row);
- } else {
- await keepDockmark(row);
- }
+ if (conflictPreference === "browser") await useBrowser(row);
+ else if (writebackCapable) await writeDockmarkToBrowser(row);
+ else await keepDockmark(row);
}
- setMessage(
- `Applied ${conflictPreferenceLabel(conflictPreference)} to ${preferredReviewRows.length} one-sided Dockmark change${preferredReviewRows.length === 1 ? "" : "s"}. ` +
- (conflictPreference === "dockmark" && writebackCapable
- ? "Each affected browser bookmark was explicitly written by this action; folders were not moved."
- : "No background browser writes were enabled."),
- );
+ setMessage(tx(
+ `Applied ${conflictPreferenceLabel(conflictPreference, locale)} to ${preferredReviewRows.length} one-sided Dockmark change${preferredReviewRows.length === 1 ? "" : "s"}.`,
+ `已按「${conflictPreferenceLabel(conflictPreference, locale)}」处理 ${preferredReviewRows.length} 条单侧 Dockmark 变更。`,
+ ));
} catch (caught) {
- setError(caught instanceof Error ? caught.message : "Could not apply the preferred review policy.");
+ setError(caught instanceof Error ? caught.message : tx("Could not apply the preferred review policy.", "无法应用偏好策略。"));
} finally {
setPolicyApplying(false);
}
@@ -634,214 +646,116 @@ export function NativeBookmarkImport({ bookmarks, categories, onChanged, onOpenE
if (toSave.length) await saveNativeBookmarkMappingsWithBridge(toSave);
if (toRemove.length) await removeNativeBookmarkMappingsWithBridge(toRemove);
await onChanged();
- const nextSnapshot = await getNativeBookmarksWithBridge();
- setSnapshot(nextSnapshot);
- setItems(buildNativePreview(nextSnapshot.bookmarks, nextSnapshot.mappings, bookmarks));
- setMessage(`Applied ${toSave.length + toRemove.length} safe mapping change${toSave.length + toRemove.length === 1 ? "" : "s"}: ${updated} updated/remapped, ${recreated} recreated, ${unlinked} stale mapping${unlinked === 1 ? "" : "s"} unlinked. Native browser bookmarks were not modified.`);
+ await refreshMappingSnapshot();
+ const total = toSave.length + toRemove.length;
+ setMessage(tx(
+ `Applied ${total} safe mapping change${total === 1 ? "" : "s"}: ${updated} updated, ${recreated} recreated, ${unlinked} unlinked. Browser bookmarks were not modified.`,
+ `已应用 ${total} 项安全映射变更:更新 ${updated} 项、重建 ${recreated} 项、解除过期映射 ${unlinked} 项,未改动浏览器书签。`,
+ ));
} catch (caught) {
- setError(caught instanceof Error ? caught.message : "Could not apply mapping changes.");
+ setError(caught instanceof Error ? caught.message : tx("Could not apply mapping changes.", "无法应用映射变更。"));
} finally {
setBusy(false);
}
}
- function statusLabel(item: NativeImportCandidate) {
- if (item.mappedDockmarkBookmarkId) return "MAPPED";
- if (item.status === "invalid") return "INVALID";
- if (item.existingBookmarkId) return "LINK";
- if (item.status === "duplicate") return "DEDUP";
- if (item.healthPolicy === "local-only") return "LOCAL ONLY";
- return "NEW";
- }
-
return (
<>
-
Browser bookmarks
-
Read the connected browser directly, review imports, and maintain the local native↔Dockmark mapping.
+
{tx("Browser bookmarks", "浏览器原生书签")}
+
+ {tx(
+ "Read bookmarks from the connected browser, review imports, and maintain local native ↔ Dockmark mappings.",
+ "直接读取已连接浏览器的书签树,预览导入并维护本地原生 ↔ Dockmark 映射。",
+ )}
+
-
NO AUTO BROWSER WRITES
+
{tx("No auto browser writes", "无自动写回")}
void loadNativeBookmarks()}>
- {busy && !loaded ? "Reading…" : loaded ? "Refresh browser snapshot" : "Read browser bookmarks"}
+ {busy && !loaded
+ ? tx("Reading…", "读取中…")
+ : loaded
+ ? tx("Refresh browser snapshot", "刷新浏览器快照")
+ : tx("Read browser bookmarks", "读取浏览器书签")}
+
+
+ {tx(
+ "Automatic sync never edits browser bookmarks. Extension 0.4+ writes title + URL only after an explicit review click.",
+ "自动同步绝不改动浏览器书签;扩展 0.4+ 仅在你手动点击复核写回时更新标题与网址。",
+ )}
+
+
+ {tx("Extension / install →", "扩展与安装 →")}
- Automatic sync never edits browser bookmarks. Extension 0.4+ can write title + URL only after an explicit Review action.
- Extension / install →
{error && (
- {error} Open extension diagnostics →
+ {error}{" "}
+
+ {tx("Open extension diagnostics →", "打开扩展诊断 →")}
+
)}
{message && {message}
}
{loaded && !syncCapable && (
- This extension can import browser bookmarks but cannot preserve mapping drift for incremental sync. Update to Dockmark Extension 0.3.0 or newer. Update extension →
+ {tx(
+ "This extension can import browser bookmarks but cannot track mapping drift for incremental sync. Update to Dockmark Extension 0.3.0+.",
+ "当前扩展仅支持导入,暂不支持增量同步映射检测。请更新至 Dockmark 扩展 0.3.0 或更高版本。",
+ )}{" "}
+
+ {tx("Update extension →", "更新扩展 →")}
+
)}
{loaded && syncCapable && mappingRows.length > 0 && (
-
-
-
-
MAPPING HEALTH · {conflictPreferenceLabel(conflictPreference).toUpperCase()}
-
Native ↔ Dockmark mappings
-
-
- {conflictPreference !== "ask" && (
- void applyPreferredReviewChanges()} disabled={busy || policyApplying || !preferredReviewRows.length}>
- {policyApplying ? "Applying policy…" : `Apply preferred ${preferredReviewRows.length}`}
-
- )}
- void applySafeMappingChanges()} disabled={busy || policyApplying || !mappingStats.safe}>
- {busy ? "Applying…" : `Apply safe changes ${mappingStats.safe}`}
-
-
-
-
- {mappingStats.total} Mapped
- {mappingStats.synced} Synced
- {mappingStats.safe} Safe changes
- {mappingStats.conflicts} Review
- {mappingStats.missing} Missing side
-
- {conflictPreference !== "ask" && (
-
- {conflictPreferenceLabel(conflictPreference)} recommends a source for Review rows. “Apply preferred” is still an explicit action and only batches one-sided DOCKMARK CHANGED rows; true REVIEW conflicts remain individual decisions.
-
- )}
-
- {mappingRows.slice(0, 500).map((row) => {
- const needsReview = row.state === "cloud-changed" || row.state === "conflict";
- const selectedTarget = relinkTargets[row.mapping.browserBookmarkId] ?? "";
- const recommendedAction = !needsReview || conflictPreference === "ask"
- ? null
- : conflictPreference === "browser"
- ? "browser"
- : writebackCapable
- ? "writeback"
- : "keep";
- return (
-
-
-
- {row.native?.title ?? row.cloud?.title ?? row.mapping.url}
- Browser · {row.native?.url ?? "bookmark removed"}
- Dockmark · {row.cloud?.url ?? "bookmark missing"}
-
- {nativeMappingStateLabel(row.state)}
- {!needsReview && (
- void unlinkMapping(row.mapping.browserBookmarkId)}>Unlink
- )}
-
-
- {needsReview && row.native && row.cloud && (
-
-
{nativeMappingReviewDescription(row.state)}
- {recommendedAction && (
-
Policy recommendation: {recommendedAction === "browser" ? "Use Browser" : recommendedAction === "writeback" ? "Write Dockmark → Browser" : "Keep Dockmark"}. This is guidance only until you click an action.
- )}
-
-
- Browser
- {row.native.title || row.native.url}
- {row.native.url}
- {folderCategory(row.native.folderPath) ?? "Uncategorized"}
-
-
- Dockmark
- {row.cloud.title}
- {row.cloud.url}
- {row.cloud.categoryId ? categoryNames.get(row.cloud.categoryId) ?? "Unknown category" : "Uncategorized"}
-
-
-
-
void useBrowser(row)}>Use Browser
-
void keepDockmark(row)}>Keep Dockmark
- {writebackCapable && (
-
void writeDockmarkToBrowser(row)}>Write Dockmark → Browser
- )}
-
- setRelinkTargets((current) => ({ ...current, [row.mapping.browserBookmarkId]: event.target.value }))}
- >
- Choose Dockmark bookmark…
- {relinkOptions.filter((bookmark) => bookmark.id !== row.cloud?.id).map((bookmark) => (
- {bookmark.title} — {bookmark.url}
- ))}
-
- void relinkMapping(row)}>Re-link
-
-
void unlinkMapping(row.mapping.browserBookmarkId)}>Unlink
-
-
Use Browser may update Dockmark title, URL and category. Keep Dockmark accepts the current difference as intentional. Write Dockmark → Browser explicitly changes only the mapped browser bookmark title + URL; it never moves the browser folder. Re-link only changes the local mapping.
-
- )}
-
- );
- })}
-
- Safe Apply remains browser → Dockmark only. Browser deletions unlink the mapping but keep the Dockmark bookmark. Preferred policy actions still require a click; no background browser mutation is enabled.
-
+ void applyPreferredReviewChanges()}
+ onApplySafe={() => void applySafeMappingChanges()}
+ onUseBrowser={(row) => void useBrowser(row)}
+ onKeepDockmark={(row) => void keepDockmark(row)}
+ onWriteDockmarkToBrowser={(row) => void writeDockmarkToBrowser(row)}
+ onRelinkTargetChange={(id, value) => setRelinkTargets((current) => ({ ...current, [id]: value }))}
+ onRelinkMapping={(row) => void relinkMapping(row)}
+ onUnlinkMapping={(id) => void unlinkMapping(id)}
+ />
)}
{loaded && items.length > 0 && (
-
-
-
BROWSER IMPORT PREVIEW
Native bookmark tree
-
- selectAll(true)}>Select unmapped
- selectAll(false)}>Clear
- void importSelected()} disabled={busy || policyApplying || !stats.selected}>
- {busy ? "Importing…" : `Import / map ${stats.selected}`}
-
-
-
-
-
- {stats.total} Total
- {stats.newCloud} New URLs
- {stats.linkExisting} Link URLs
- {stats.mapped} Mapped
- {stats.local} Local only
- {stats.invalid} Invalid
-
-
-
- {items.slice(0, 500).map((item) => (
-
- toggle(item.browserBookmarkId)}
- />
-
- {item.title}
- {item.normalizedUrl ?? item.url}
- {item.categoryName ?? "Uncategorized"}
-
- {statusLabel(item)}
-
- ))}
-
- {items.length > 500 && Showing the first 500 of {items.length} browser entries; selected hidden entries are still included.
}
-
+ void importSelected()}
+ onToggleItem={toggle}
+ />
)}
- {loaded && !items.length && No HTTP/HTTPS browser bookmarks were found.
}
+ {loaded && !items.length && (
+
+ {tx("No HTTP/HTTPS browser bookmarks were found.", "未在浏览器中找到 HTTP/HTTPS 书签。")}
+
+ )}
>
);
}
diff --git a/apps/web/src/NativeBookmarkSyncPanels.tsx b/apps/web/src/NativeBookmarkSyncPanels.tsx
new file mode 100644
index 0000000..e72d8bf
--- /dev/null
+++ b/apps/web/src/NativeBookmarkSyncPanels.tsx
@@ -0,0 +1,424 @@
+/**
+ * [INPUT]: depends on Bookmark, BookmarkConflictPreference, ResolvedLocale from @dockmark/core; ImportCandidate from ./bookmark-transfer; NativeMappingRow, NativeMappingState from ./native-bookmark-sync; useI18n from ./i18n
+ * [OUTPUT]: exports NativeImportCandidate, folderCategory, conflictPreferenceLabel, NativeMappingPreviewPanel, and NativeImportTreePanel
+ * [POS]: presentation panels extracted from NativeBookmarkImport.tsx to keep both files well under 800 lines
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
+
+import type { Bookmark, BookmarkConflictPreference, ResolvedLocale } from "@dockmark/core";
+import type { ImportCandidate } from "./bookmark-transfer";
+import { useI18n } from "./i18n";
+import type { NativeMappingRow, NativeMappingState } from "./native-bookmark-sync";
+
+export interface NativeImportCandidate extends ImportCandidate {
+ browserBookmarkId: string;
+ folderPath: string[];
+ existingBookmarkId?: string;
+ mappedDockmarkBookmarkId?: string | undefined;
+}
+
+export function folderCategory(path: string[]) {
+ const cleaned = path.map((part) => part.trim()).filter(Boolean);
+ if (!cleaned.length) return undefined;
+ const joined = cleaned.join(" / ");
+ return joined.length <= 80 ? joined : `…${joined.slice(-79)}`;
+}
+
+export function conflictPreferenceLabel(preference: BookmarkConflictPreference, locale: ResolvedLocale) {
+ if (preference === "browser") return locale === "zh-CN" ? "优先浏览器" : "Prefer Browser";
+ if (preference === "dockmark") return locale === "zh-CN" ? "优先 Dockmark" : "Prefer Dockmark";
+ return locale === "zh-CN" ? "每次询问" : "Ask every time";
+}
+
+function localizedMappingStateLabel(state: NativeMappingState, locale: ResolvedLocale) {
+ if (locale === "zh-CN") {
+ switch (state) {
+ case "synced": return "已同步";
+ case "native-changed": return "浏览器已更新";
+ case "native-missing": return "浏览器已移除";
+ case "cloud-missing": return "Dockmark 缺失";
+ case "mapping-stale": return "映射过期";
+ case "cloud-changed": return "Dockmark 已更新";
+ case "conflict": return "待复核";
+ }
+ }
+ switch (state) {
+ case "synced": return "Synced";
+ case "native-changed": return "Browser changed";
+ case "native-missing": return "Browser missing";
+ case "cloud-missing": return "Dockmark missing";
+ case "mapping-stale": return "Mapping stale";
+ case "cloud-changed": return "Dockmark changed";
+ case "conflict": return "Review";
+ }
+}
+
+function localizedReviewDescription(state: NativeMappingState, locale: ResolvedLocale) {
+ if (locale === "zh-CN") {
+ switch (state) {
+ case "cloud-missing":
+ return "映射指向的 Dockmark 书签不在活跃书签库中(可能已归档或已删除),因此安全应用不会自动重建。请在书签库恢复,或解除该过期映射后重新导入。";
+ case "cloud-changed":
+ return "自建立映射基线后 Dockmark 端发生了变化。可保留 Dockmark 版本、采用浏览器版本,或重新关联到其他书签。";
+ case "conflict":
+ return "双方均有改动,或浏览器文件夹与 Dockmark 分类不一致。请选择以此映射的哪一侧为准。";
+ default:
+ return "此映射无需人工冲突复核。";
+ }
+ }
+ switch (state) {
+ case "cloud-missing":
+ return "The mapped Dockmark bookmark is not in the active Library. It may be archived or deleted, so Safe Apply will not recreate it. Restore it in Library or unlink this stale mapping.";
+ case "cloud-changed":
+ return "Dockmark changed after this mapping baseline. Keep Dockmark, use the browser version, or re-link the browser bookmark.";
+ case "conflict":
+ return "Both sides changed, or the browser folder and Dockmark category diverged. Choose which state should become authoritative.";
+ default:
+ return "This mapping does not require manual conflict review.";
+ }
+}
+
+interface MappingPanelProps {
+ conflictPreference: BookmarkConflictPreference;
+ mappingRows: NativeMappingRow[];
+ preferredReviewCount: number;
+ mappingStats: {
+ total: number;
+ synced: number;
+ safe: number;
+ conflicts: number;
+ missing: number;
+ };
+ categoryNames: Map;
+ relinkOptions: Bookmark[];
+ relinkTargets: Record;
+ writebackCapable: boolean;
+ busy: boolean;
+ policyApplying: boolean;
+ onApplyPreferred: () => void;
+ onApplySafe: () => void;
+ onUseBrowser: (row: NativeMappingRow) => void;
+ onKeepDockmark: (row: NativeMappingRow) => void;
+ onWriteDockmarkToBrowser: (row: NativeMappingRow) => void;
+ onRelinkTargetChange: (browserBookmarkId: string, value: string) => void;
+ onRelinkMapping: (row: NativeMappingRow) => void;
+ onUnlinkMapping: (browserBookmarkId: string) => void;
+}
+
+export function NativeMappingPreviewPanel({
+ conflictPreference,
+ mappingRows,
+ preferredReviewCount,
+ mappingStats,
+ categoryNames,
+ relinkOptions,
+ relinkTargets,
+ writebackCapable,
+ busy,
+ policyApplying,
+ onApplyPreferred,
+ onApplySafe,
+ onUseBrowser,
+ onKeepDockmark,
+ onWriteDockmarkToBrowser,
+ onRelinkTargetChange,
+ onRelinkMapping,
+ onUnlinkMapping,
+}: MappingPanelProps) {
+ const { locale, tx } = useI18n();
+ const uncategorized = tx("Uncategorized", "未分类");
+
+ return (
+
+
+
+
{tx("Native ↔ Dockmark mappings", "浏览器 ↔ Dockmark 书签映射")}
+
+ {tx("Conflict policy:", "冲突偏好:")} {conflictPreferenceLabel(conflictPreference, locale)}
+
+
+
+ {conflictPreference !== "ask" && (
+
+ {policyApplying
+ ? tx("Applying policy…", "应用策略中…")
+ : tx(`Apply preferred (${preferredReviewCount})`, `按偏好应用 (${preferredReviewCount})`)}
+
+ )}
+
+ {busy
+ ? tx("Applying…", "应用中…")
+ : tx(`Apply safe changes (${mappingStats.safe})`, `应用安全变更 (${mappingStats.safe})`)}
+
+
+
+
+
+ {mappingStats.total} {tx("Mapped", "已映射")}
+ {mappingStats.synced} {tx("Synced", "已同步")}
+ {mappingStats.safe} {tx("Safe changes", "安全变更")}
+ {mappingStats.conflicts} {tx("Review", "待复核")}
+ {mappingStats.missing} {tx("Missing side", "单侧缺失")}
+
+
+ {conflictPreference !== "ask" && (
+
+ {tx(
+ `${conflictPreferenceLabel(conflictPreference, locale)} highlights a suggested action for Review rows. “Apply preferred” remains explicit and only batches one-sided Dockmark changes; two-sided conflicts stay individual decisions.`,
+ `当前「${conflictPreferenceLabel(conflictPreference, locale)}」仅作复核建议。「按偏好应用」仍需手动触发且仅批量处理单侧 Dockmark 变更;双向冲突需逐项确认。`,
+ )}
+
+ )}
+
+
+ {mappingRows.slice(0, 500).map((row) => {
+ const needsReview = row.state === "cloud-changed" || row.state === "conflict";
+ const selectedTarget = relinkTargets[row.mapping.browserBookmarkId] ?? "";
+ const recommendedAction = !needsReview || conflictPreference === "ask"
+ ? null
+ : conflictPreference === "browser"
+ ? "browser"
+ : writebackCapable
+ ? "writeback"
+ : "keep";
+
+ return (
+
+
+
+ {row.native?.title ?? row.cloud?.title ?? row.mapping.url}
+ {tx("Browser", "浏览器")} · {row.native?.url ?? tx("bookmark removed", "书签已移除")}
+ Dockmark · {row.cloud?.url ?? tx("bookmark missing", "书签缺失")}
+
+
+ {localizedMappingStateLabel(row.state, locale)}
+
+ {!needsReview && (
+ onUnlinkMapping(row.mapping.browserBookmarkId)}
+ >
+ {tx("Unlink", "解除映射")}
+
+ )}
+
+
+ {needsReview && row.native && row.cloud && (
+
+
{localizedReviewDescription(row.state, locale)}
+ {recommendedAction && (
+
+ {tx("Policy recommendation:", "策略推荐:")}{" "}
+ {recommendedAction === "browser"
+ ? tx("Use Browser", "采用浏览器版本")
+ : recommendedAction === "writeback"
+ ? tx("Write Dockmark → Browser", "将 Dockmark 写回浏览器")
+ : tx("Keep Dockmark", "保留 Dockmark 版本")}
+ {tx(". Nothing runs until you click.", "。点击按钮后才会执行。")}
+
+ )}
+
+
+ {tx("Browser", "浏览器")}
+ {row.native.title || row.native.url}
+ {row.native.url}
+ {folderCategory(row.native.folderPath) ?? uncategorized}
+
+
+ Dockmark
+ {row.cloud.title}
+ {row.cloud.url}
+ {row.cloud.categoryId ? categoryNames.get(row.cloud.categoryId) ?? tx("Unknown category", "未知分类") : uncategorized}
+
+
+
+
onUseBrowser(row)}
+ >
+ {tx("Use Browser", "采用浏览器")}
+
+
onKeepDockmark(row)}
+ >
+ {tx("Keep Dockmark", "保留 Dockmark")}
+
+ {writebackCapable && (
+
onWriteDockmarkToBrowser(row)}
+ >
+ {tx("Write Dockmark → Browser", "写回浏览器")}
+
+ )}
+
+ onRelinkTargetChange(row.mapping.browserBookmarkId, event.target.value)}
+ >
+ {tx("Choose Dockmark bookmark…", "选择目标 Dockmark 书签…")}
+ {relinkOptions.filter((bookmark) => bookmark.id !== row.cloud?.id).map((bookmark) => (
+ {bookmark.title} — {bookmark.url}
+ ))}
+
+ onRelinkMapping(row)}
+ >
+ {tx("Re-link", "重新关联")}
+
+
+
onUnlinkMapping(row.mapping.browserBookmarkId)}
+ >
+ {tx("Unlink", "解除映射")}
+
+
+
+ {tx(
+ "Use Browser updates Dockmark title, URL, and category. Keep Dockmark accepts the difference. Write Dockmark → Browser updates only the mapped browser title + URL without moving folders. Re-link updates only the local mapping.",
+ "「采用浏览器」会更新 Dockmark 的标题、网址与分类;「保留 Dockmark」将当前差异设为新基线;「写回浏览器」仅更新该浏览器书签的标题与网址,不移动文件夹;「重新关联」仅变更本地映射关系。",
+ )}
+
+
+ )}
+
+ );
+ })}
+
+
+ {tx(
+ "Safe Apply remains browser → Dockmark only. Browser deletions unlink the mapping while keeping the Dockmark bookmark.",
+ "安全应用仅支持「浏览器 → Dockmark」单向同步;浏览器端删除书签只会解除映射,不会删除 Dockmark 中的书签。",
+ )}
+
+
+ );
+}
+
+interface ImportTreePanelProps {
+ items: NativeImportCandidate[];
+ stats: {
+ total: number;
+ selected: number;
+ newCloud: number;
+ linkExisting: number;
+ mapped: number;
+ local: number;
+ invalid: number;
+ };
+ busy: boolean;
+ policyApplying: boolean;
+ onSelectAll: (selected: boolean) => void;
+ onImportSelected: () => void;
+ onToggleItem: (browserBookmarkId: string) => void;
+}
+
+export function NativeImportTreePanel({
+ items,
+ stats,
+ busy,
+ policyApplying,
+ onSelectAll,
+ onImportSelected,
+ onToggleItem,
+}: ImportTreePanelProps) {
+ const { tx } = useI18n();
+
+ function statusLabel(item: NativeImportCandidate) {
+ if (item.mappedDockmarkBookmarkId) return tx("Mapped", "已映射");
+ if (item.status === "invalid") return tx("Invalid", "无效");
+ if (item.existingBookmarkId) return tx("Link", "关联已有");
+ if (item.status === "duplicate") return tx("Dedup", "去重");
+ if (item.healthPolicy === "local-only") return tx("Local only", "仅本地");
+ return tx("New", "新增");
+ }
+
+ return (
+
+
+
+
{tx("Native bookmark tree", "浏览器书签树预览")}
+
+
+ onSelectAll(true)}>
+ {tx("Select unmapped", "选择未映射项")}
+
+ onSelectAll(false)}>
+ {tx("Clear", "清空")}
+
+
+ {busy
+ ? tx("Importing…", "导入中…")
+ : tx(`Import / map (${stats.selected})`, `导入 / 映射 (${stats.selected})`)}
+
+
+
+
+
+ {stats.total} {tx("Total", "总计")}
+ {stats.newCloud} {tx("New URLs", "新增网址")}
+ {stats.linkExisting} {tx("Link URLs", "关联已有")}
+ {stats.mapped} {tx("Mapped", "已映射")}
+ {stats.local} {tx("Local only", "仅本地")}
+ {stats.invalid} {tx("Invalid", "无效")}
+
+
+
+ {items.slice(0, 500).map((item) => (
+
+ onToggleItem(item.browserBookmarkId)}
+ />
+
+ {item.title}
+ {item.normalizedUrl ?? item.url}
+ {item.categoryName ?? tx("Uncategorized", "未分类")}
+
+ {statusLabel(item)}
+
+ ))}
+
+ {items.length > 500 && (
+
+ {tx(
+ `Showing the first 500 of ${items.length} browser entries; selected hidden entries are still included.`,
+ `仅显示前 500 条浏览器书签(共 ${items.length} 条);未展示的已选项仍会一并处理。`,
+ )}
+
+ )}
+
+ );
+}
diff --git a/apps/web/src/PrivateRoot.tsx b/apps/web/src/PrivateRoot.tsx
index c4085fa..8d78896 100644
--- a/apps/web/src/PrivateRoot.tsx
+++ b/apps/web/src/PrivateRoot.tsx
@@ -1,4 +1,11 @@
+/**
+ * [INPUT]: depends on App, SettingsPage, InboxPage, SmartCollectionsPage, DuplicateReviewPage, auth-client, inbox-api, ./theme, and ./i18n
+ * [OUTPUT]: exports PrivateRoot auth gate, private utility navigation shell, and 1-click theme/locale quick-toggles
+ * [POS]: Top-level controller for /app* routes. Enforces session authentication and renders the sticky 46px private utility bar above active views.
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
import { useCallback, useEffect, useState, type FormEvent, type ReactNode } from "react";
+import type { AppearancePreference } from "@dockmark/core";
import { App } from "./App";
import { DuplicateReviewPage } from "./DuplicateReviewPage";
import { InboxPage } from "./InboxPage";
@@ -6,8 +13,12 @@ import { SettingsPage } from "./SettingsPage";
import { SmartCollectionsPage } from "./SmartCollectionsPage";
import { getAuthStatus, login, logout, type AuthStatus } from "./auth-client";
import { getInboxCount, INBOX_CHANGED_EVENT } from "./inbox-api";
+import { saveAppearanceAndLocale, useI18n } from "./i18n";
+import { APPEARANCE_STORAGE_KEY, applyAppearance, localAppearance } from "./theme";
import "./security.css";
+const THEME_CYCLE: AppearancePreference[] = ["system", "light", "dark"];
+
function targetView() {
if (window.location.pathname.startsWith("/app/settings")) return "settings";
if (window.location.pathname.startsWith("/app/inbox")) return "inbox";
@@ -29,7 +40,81 @@ function isWorkspacePath(pathname: string) {
!pathname.startsWith("/app/duplicates");
}
+function useAppearancePreference(): [AppearancePreference, (next: AppearancePreference, syncCloud: boolean) => void] {
+ const [preference, setPreference] = useState(() => localAppearance());
+
+ useEffect(() => {
+ const syncFromDom = () => setPreference(localAppearance());
+ const onAppearance = (event: Event) => {
+ const detail = (event as CustomEvent<{ preference?: AppearancePreference }>).detail;
+ setPreference(detail?.preference ?? localAppearance());
+ };
+ const onStorage = (event: StorageEvent) => {
+ if (event.key === APPEARANCE_STORAGE_KEY) syncFromDom();
+ };
+ window.addEventListener("dockmark:appearance", onAppearance);
+ window.addEventListener("storage", onStorage);
+ return () => {
+ window.removeEventListener("dockmark:appearance", onAppearance);
+ window.removeEventListener("storage", onStorage);
+ };
+ }, []);
+
+ const choose = useCallback((next: AppearancePreference, syncCloud: boolean) => {
+ setPreference(next);
+ applyAppearance(next, true);
+ if (syncCloud) {
+ void saveAppearanceAndLocale({ preference: next }).catch(() => undefined);
+ }
+ }, []);
+
+ return [preference, choose];
+}
+
+function QuickPreferenceToggles({ syncCloud, className = "" }: { syncCloud: boolean; className?: string }) {
+ const { isZh, tx, setLocalePreference } = useI18n();
+ const [appearance, setAppearance] = useAppearancePreference();
+
+ const nextAppearance = THEME_CYCLE[(THEME_CYCLE.indexOf(appearance) + 1) % THEME_CYCLE.length] ?? "system";
+ const themeIcon = appearance === "light" ? "☀" : appearance === "dark" ? "☾" : "◐";
+ const themeShortLabel = appearance === "light"
+ ? tx("Light", "浅色")
+ : appearance === "dark"
+ ? tx("Dark", "深色")
+ : tx("System", "跟随系统");
+ const nextThemeLabel = nextAppearance === "light"
+ ? tx("Light", "浅色")
+ : nextAppearance === "dark"
+ ? tx("Dark", "深色")
+ : tx("System", "跟随系统");
+
+ return (
+
+ setAppearance(nextAppearance, syncCloud)}
+ >
+ {themeIcon}
+ {themeShortLabel}
+
+ void setLocalePreference(isZh ? "en" : "zh-CN", { syncCloud }).catch(() => undefined)}
+ >
+ {isZh ? "EN" : "中文"}
+
+
+ );
+}
+
function PrivateNavigation({ children, onLogout }: { children: ReactNode; onLogout: () => Promise }) {
+ const { tx } = useI18n();
const [path, setPath] = useState(window.location.pathname);
const [inboxCount, setInboxCount] = useState(null);
@@ -37,7 +122,7 @@ function PrivateNavigation({ children, onLogout }: { children: ReactNode; onLogo
try {
setInboxCount(await getInboxCount());
} catch {
- // The badge is a convenience signal. Keep the last known count when a refresh fails.
+ // Keep the last known badge count when a background refresh fails.
}
}, []);
@@ -69,30 +154,43 @@ function PrivateNavigation({ children, onLogout }: { children: ReactNode; onLogo
}, [refreshInboxCount]);
const inboxLabel = inboxCount && inboxCount > 0
- ? `Inbox, ${inboxCount} bookmark${inboxCount === 1 ? "" : "s"} waiting for review`
- : "Inbox";
+ ? tx(
+ `Inbox, ${inboxCount} bookmark${inboxCount === 1 ? "" : "s"} waiting for review`,
+ `收件箱,有 ${inboxCount} 条书签待整理`,
+ )
+ : tx("Inbox", "收件箱");
return (
<>
-
D· Public page
-
- navigate("/app")}>Workspace
+ D· {tx("Public page", "公开主页")}
+
+ navigate("/app")}>
+ {tx("Workspace", "工作台")}
+
navigate("/app/inbox")}
>
- Inbox
+ {tx("Inbox", "收件箱")}
{inboxCount !== null && inboxCount > 0 && (
{inboxCount > 99 ? "99+" : inboxCount}
)}
- navigate("/app/collections")}>Collections
- navigate("/app/duplicates")}>Duplicates
- navigate("/app/settings")}>Settings
- void onLogout()}>Sign out
+ navigate("/app/collections")}>
+ {tx("Collections", "智能合集")}
+
+ navigate("/app/duplicates")}>
+ {tx("Duplicates", "重复项")}
+
+ navigate("/app/settings")}>
+ {tx("Settings", "设置")}
+
+
+
+ void onLogout()}>{tx("Sign out", "退出")}
{children}
@@ -101,6 +199,7 @@ function PrivateNavigation({ children, onLogout }: { children: ReactNode; onLogo
}
function LoginCard({ onAuthenticated }: { onAuthenticated: () => Promise }) {
+ const { tx } = useI18n();
const [password, setPassword] = useState("");
const [busy, setBusy] = useState(false);
const [error, setError] = useState(null);
@@ -114,7 +213,7 @@ function LoginCard({ onAuthenticated }: { onAuthenticated: () => Promise }
setPassword("");
await onAuthenticated();
} catch (caught) {
- setError(caught instanceof Error ? caught.message : "Could not sign in.");
+ setError(caught instanceof Error ? caught.message : tx("Could not sign in.", "登录失败,请检查密码后重试。"));
} finally {
setBusy(false);
}
@@ -123,13 +222,21 @@ function LoginCard({ onAuthenticated }: { onAuthenticated: () => Promise }
return (
D· Dockmark
+
+
+
- PRIVATE WORKSPACE
- Sign in to manage Dockmark.
- The public homepage exposes only your curated list. Everything else is protected by this Web session.
+ {tx("PRIVATE WORKSPACE", "私有工作台")}
+ {tx("Sign in to Dockmark", "登录 Dockmark")}
+
+ {tx(
+ "The public homepage exposes only your curated list. Everything else is protected by this Web session.",
+ "公开主页仅展示精选发布的书签;其余书签、工作区与会话均受当前 Web 会话保护。",
+ )}
+
{error && {error}
}
- ← Back to public page
+ {tx("← Back to public page", "← 返回公开主页")}
);
}
function SetupRequired({ onRetry }: { onRetry: () => Promise }) {
+ const { tx } = useI18n();
+
return (
D· Dockmark
+
+
+
- SECURITY REQUIRED
- Private APIs are locked.
- Set the Worker secret DOCKMARK_ADMIN_PASSWORD to a strong value of at least 12 characters, then redeploy or restart the Worker binding. Dockmark deliberately fails closed while this secret is missing.
+ {tx("SECURITY REQUIRED", "需要安全配置")}
+ {tx("Private APIs are locked", "私有接口已锁定")}
+
+ {tx(
+ "Set the Worker secret ",
+ "请将 Worker 密钥 ",
+ )}
+ DOCKMARK_ADMIN_PASSWORD
+ {tx(
+ " to a strong value of at least 12 characters, then redeploy or restart the Worker binding. Dockmark deliberately fails closed while this secret is missing.",
+ " 设置为至少 12 位的强密码,然后重新部署或重启 Worker。缺少该密钥时 Dockmark 会默认拒绝访问以保障安全。",
+ )}
+
npx wrangler secret put DOCKMARK_ADMIN_PASSWORD
- or add the same secret in Cloudflare Workers → Settings → Variables and Secrets.
+
+ {tx(
+ "or add the same secret in Cloudflare Workers → Settings → Variables and Secrets.",
+ "或在 Cloudflare Workers → Settings → Variables and Secrets 中添加同名密钥。",
+ )}
+
- void onRetry()}>Retry security check
- ← Public page remains available
+ void onRetry()}>
+ {tx("Retry security check", "重新检查安全状态")}
+
+ {tx("← Public page remains available", "← 公开主页仍可访问")}
);
}
export function PrivateRoot() {
+ const { tx } = useI18n();
const [status, setStatus] = useState(null);
const [loading, setLoading] = useState(true);
const [path, setPath] = useState(window.location.pathname);
const [error, setError] = useState(null);
- async function refreshStatus() {
+ const refreshStatus = useCallback(async () => {
setLoading(true);
setError(null);
try {
setStatus(await getAuthStatus());
} catch (caught) {
- setError(caught instanceof Error ? caught.message : "Could not reach Dockmark security service.");
+ setError(
+ caught instanceof Error
+ ? caught.message
+ : tx("Could not reach Dockmark security service.", "无法连接 Dockmark 安全服务。"),
+ );
} finally {
setLoading(false);
}
- }
+ }, [tx]);
useEffect(() => {
void refreshStatus();
const onPopState = () => setPath(window.location.pathname);
window.addEventListener("popstate", onPopState);
return () => window.removeEventListener("popstate", onPopState);
- }, []);
+ }, [refreshStatus]);
async function signOut() {
try {
await logout();
} finally {
- setStatus((current) => current ? { ...current, authenticated: false, kind: null } : current);
+ setStatus((current) => (current ? { ...current, authenticated: false, kind: null } : current));
navigate("/app");
}
}
if (loading) {
- return Checking private workspace…
;
+ return (
+
+ {tx("Checking private workspace…", "正在检查私有工作台…")}
+
+ );
}
if (error) {
return (
- Security check failed. {error}
void refreshStatus()}>Retry
+
+
+
+
+
+ {tx("Security check failed", "安全检查失败")}
+ {error}
+ void refreshStatus()}>
+ {tx("Retry", "重试")}
+
+
+
);
}
if (!status?.configured) return ;
@@ -222,6 +373,7 @@ export function PrivateRoot() {
: path.startsWith("/app/duplicates")
? "duplicates"
: targetView();
+
return (
{view === "settings"
diff --git a/apps/web/src/PublicPage.tsx b/apps/web/src/PublicPage.tsx
index 35226eb..ca57cae 100644
--- a/apps/web/src/PublicPage.tsx
+++ b/apps/web/src/PublicPage.tsx
@@ -1,4 +1,14 @@
+/**
+ * [INPUT]: depends on usePublicI18n from ./i18n, applyAppearance/localAppearance from ./theme, SafeFavicon/hostLabel/safeHttpUrl from ./LauncherDashboard, and ./public-page.css
+ * [OUTPUT]: exports PublicPage read-only curated bookmarks directory with visitor-local theme and locale toggles
+ * [POS]: Public root route (/) rendered by main.tsx for unauthenticated visitors. Never mutates owner D1 preferences.
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
import { useEffect, useMemo, useState } from "react";
+import type { AppearancePreference } from "@dockmark/core";
+import { usePublicI18n } from "./i18n";
+import { hostLabel, SafeFavicon, safeHttpUrl } from "./LauncherDashboard";
+import { APPEARANCE_STORAGE_KEY, applyAppearance, localAppearance } from "./theme";
import "./public-page.css";
type PublicBookmark = {
@@ -12,20 +22,33 @@ type PublicBookmark = {
publishedAt: string;
};
-function hostLabel(url: string) {
- try {
- return new URL(url).host;
- } catch {
- return url;
- }
-}
+const THEME_CYCLE: AppearancePreference[] = ["system", "light", "dark"];
export function PublicPage() {
+ const { isZh, tx, setLocalePreference } = usePublicI18n();
+ const [appearance, setAppearance] = useState(() => localAppearance());
const [bookmarks, setBookmarks] = useState([]);
const [query, setQuery] = useState("");
const [loading, setLoading] = useState(true);
const [error, setError] = useState(null);
+ useEffect(() => {
+ const sync = () => setAppearance(localAppearance());
+ const onAppearance = (event: Event) => {
+ const detail = (event as CustomEvent<{ preference?: AppearancePreference }>).detail;
+ setAppearance(detail?.preference ?? localAppearance());
+ };
+ const onStorage = (event: StorageEvent) => {
+ if (event.key === APPEARANCE_STORAGE_KEY) sync();
+ };
+ window.addEventListener("dockmark:appearance", onAppearance);
+ window.addEventListener("storage", onStorage);
+ return () => {
+ window.removeEventListener("dockmark:appearance", onAppearance);
+ window.removeEventListener("storage", onStorage);
+ };
+ }, []);
+
useEffect(() => {
let cancelled = false;
void fetch("/api/public/bookmarks", { cache: "no-store" })
@@ -38,7 +61,7 @@ export function PublicPage() {
if (!cancelled) setBookmarks(items);
})
.catch((caught) => {
- if (!cancelled) setError(caught instanceof Error ? caught.message : "Could not load public bookmarks.");
+ if (!cancelled) setError(caught instanceof Error ? caught.message : tx("Could not load public bookmarks.", "无法加载公开书签。"));
})
.finally(() => {
if (!cancelled) setLoading(false);
@@ -46,7 +69,7 @@ export function PublicPage() {
return () => {
cancelled = true;
};
- }, []);
+ }, [tx]);
const filtered = useMemo(() => {
const needle = query.trim().toLocaleLowerCase();
@@ -63,7 +86,7 @@ export function PublicPage() {
for (const bookmark of filtered) {
const key = bookmark.category?.id ?? "uncategorized";
const current = map.get(key) ?? {
- name: bookmark.category?.name ?? "Elsewhere",
+ name: bookmark.category?.name ?? tx("Uncategorized", "未分类"),
...(bookmark.category?.icon ? { icon: bookmark.category.icon } : {}),
items: [],
};
@@ -71,27 +94,81 @@ export function PublicPage() {
map.set(key, current);
}
return Array.from(map.values());
- }, [filtered]);
+ }, [filtered, tx]);
+
+ const nextAppearance = THEME_CYCLE[(THEME_CYCLE.indexOf(appearance) + 1) % THEME_CYCLE.length] ?? "system";
+ const themeIcon = appearance === "light" ? "☀" : appearance === "dark" ? "☾" : "◐";
+ const themeLabel = appearance === "light"
+ ? tx("Light", "浅色")
+ : appearance === "dark"
+ ? tx("Dark", "深色")
+ : tx("System", "跟随系统");
+
+ function cycleTheme() {
+ setAppearance(nextAppearance);
+ applyAppearance(nextAppearance, true);
+ }
return (
- CURATED LINKS
- A smaller web, worth returning to.
- A deliberately public slice of this Dockmark. Private bookmarks, Workspaces, Sessions and browser controls stay behind sign-in.
+
+
+
{tx("Curated links", "精选书签")}
+
+ {tx(
+ "A public slice of this Dockmark library. Private bookmarks, Workspaces and Sessions stay behind sign-in.",
+ "来自 Dockmark 的公开精选列表;私有书签、工作区与会话仅在登录后可见。",
+ )}
+
+
+ {!loading && !error && (
+
+ {tx(`${bookmarks.length} link${bookmarks.length === 1 ? "" : "s"}`, `${bookmarks.length} 条链接`)}
+
+ )}
+
- ⌕
- setQuery(event.target.value)} placeholder="Filter this public list…" autoFocus />
+ ⌕
+ setQuery(event.target.value)}
+ placeholder={tx("Filter public links by title, host or category…", "按标题、域名或分类筛选公开书签…")}
+ autoFocus
+ />
- {error && {error}
}
- {!error && loading && Loading curated links…
}
+ {error && {error}
}
+ {!error && loading && {tx("Loading curated links…", "正在加载公开书签…")}
}
{!loading && !error && groups.length > 0 && (
@@ -104,13 +181,24 @@ export function PublicPage() {
@@ -121,12 +209,19 @@ export function PublicPage() {
{!loading && !error && !groups.length && (
- {query ? "No public links match that filter." : "Nothing is public yet."}
- {query ? "Try another term." : "The owner can publish selected bookmarks from Settings."}
+ {query ? tx("No public links match that filter.", "没有匹配的公开链接。") : tx("Nothing is public yet.", "暂未发布公开链接。")}
+
+ {query
+ ? tx("Try another keyword.", "请尝试其他关键词。")
+ : tx("The owner can publish selected bookmarks from Settings.", "站点所有者可在「设置 → 公开主页」中选择发布书签。")}
+
)}
-
+
);
}
diff --git a/apps/web/src/PublicPageSettings.tsx b/apps/web/src/PublicPageSettings.tsx
index ae07135..fd8b7de 100644
--- a/apps/web/src/PublicPageSettings.tsx
+++ b/apps/web/src/PublicPageSettings.tsx
@@ -1,6 +1,13 @@
+/**
+ * [INPUT]: depends on Bookmark, Category from @dockmark/core; textMatchesQuery from ./bookmark-search; reorderBookmarks/reorderCategories from ./reorder-api; useI18n from ./i18n
+ * [OUTPUT]: exports PublicPageSettings panel for publishing/unpublishing bookmarks (single & batch) and ordering public groups
+ * [POS]: Mounted in SettingsPage under /app/settings/public. Manages /api/public/bookmarks/* selection and shares canonical Library ordering.
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
import { useEffect, useMemo, useRef, useState } from "react";
import type { Bookmark, Category } from "@dockmark/core";
import { textMatchesQuery } from "./bookmark-search";
+import { useI18n } from "./i18n";
import { reorderBookmarks, reorderCategories } from "./reorder-api";
interface Props {
@@ -37,6 +44,7 @@ function swapIds(ids: string[], leftId: string, rightId: string) {
}
export function PublicPageSettings({ bookmarks, categories, onChanged }: Props) {
+ const { tx } = useI18n();
const [published, setPublishedIds] = useState
>(() => new Set());
const [loading, setLoading] = useState(true);
const [busyId, setBusyId] = useState(null);
@@ -56,7 +64,7 @@ export function PublicPageSettings({ bookmarks, categories, onChanged }: Props)
if (!cancelled) setPublishedIds(ids);
})
.catch((caught) => {
- if (!cancelled) setError(caught instanceof Error ? caught.message : "Could not load public page settings.");
+ if (!cancelled) setError(caught instanceof Error ? caught.message : tx("Could not load public page settings.", "无法加载公开主页配置。"));
})
.finally(() => {
if (!cancelled) setLoading(false);
@@ -64,7 +72,7 @@ export function PublicPageSettings({ bookmarks, categories, onChanged }: Props)
return () => {
cancelled = true;
};
- }, []);
+ }, [tx]);
useEffect(() => {
const activeIds = new Set(bookmarks.map((bookmark) => bookmark.id));
@@ -96,16 +104,16 @@ export function PublicPageSettings({ bookmarks, categories, onChanged }: Props)
const uncategorized = (bookmarksByCategory.get("") ?? []).filter((bookmark) => published.has(bookmark.id));
return [
...categoryGroups.filter((group) => group.bookmarks.length),
- ...(uncategorized.length ? [{ id: "", name: "Elsewhere", bookmarks: uncategorized }] : []),
+ ...(uncategorized.length ? [{ id: "", name: tx("Uncategorized", "未分类"), bookmarks: uncategorized }] : []),
];
- }, [bookmarksByCategory, categories, published]);
+ }, [bookmarksByCategory, categories, published, tx]);
const filteredBookmarks = useMemo(
() => bookmarks.filter((bookmark) => {
const isPublished = published.has(bookmark.id);
if (filter === "published" && !isPublished) return false;
if (filter === "unpublished" && isPublished) return false;
- const categoryName = bookmark.categoryId ? categoryNameById.get(bookmark.categoryId) ?? "" : "Uncategorized";
+ const categoryName = bookmark.categoryId ? categoryNameById.get(bookmark.categoryId) ?? "" : tx("Uncategorized", "未分类");
return textMatchesQuery(query, [
bookmark.title,
bookmark.url,
@@ -113,7 +121,7 @@ export function PublicPageSettings({ bookmarks, categories, onChanged }: Props)
categoryName,
]);
}),
- [bookmarks, categoryNameById, filter, published, query],
+ [bookmarks, categoryNameById, filter, published, query, tx],
);
const publishedCount = published.size;
@@ -145,9 +153,13 @@ export function PublicPageSettings({ bookmarks, categories, onChanged }: Props)
next.delete(bookmark.id);
return next;
});
- setNotice(`${nextPublished ? "Published" : "Unpublished"} “${bookmark.title}”.`);
+ setNotice(
+ nextPublished
+ ? tx(`Published “${bookmark.title}”.`, `已公开“${bookmark.title}”。`)
+ : tx(`Unpublished “${bookmark.title}”.`, `已取消公开“${bookmark.title}”。`),
+ );
} catch (caught) {
- setError(caught instanceof Error ? caught.message : "Could not update this bookmark.");
+ setError(caught instanceof Error ? caught.message : tx("Could not update this bookmark.", "更新该书签状态失败。"));
} finally {
setBusyId(null);
}
@@ -179,7 +191,11 @@ export function PublicPageSettings({ bookmarks, categories, onChanged }: Props)
const idsToUpdate = selected.filter((id) => published.has(id) !== nextPublished);
if (!idsToUpdate.length) {
setSelectedIds(new Set());
- setNotice(nextPublished ? "Every selected bookmark is already published." : "Every selected bookmark is already unpublished.");
+ setNotice(
+ nextPublished
+ ? tx("Every selected bookmark is already published.", "所选书签均已处于公开状态。")
+ : tx("Every selected bookmark is already unpublished.", "所选书签均已处于未公开状态。"),
+ );
return;
}
@@ -214,9 +230,18 @@ export function PublicPageSettings({ bookmarks, categories, onChanged }: Props)
setSelectedIds(failedIds);
if (failedIds.size) {
- setError(`${updated} bookmark${updated === 1 ? "" : "s"} updated; ${failedIds.size} failed and remain selected for retry.`);
+ setError(
+ tx(
+ `${updated} bookmark${updated === 1 ? "" : "s"} updated; ${failedIds.size} failed and remain selected for retry.`,
+ `已更新 ${updated} 条书签;${failedIds.size} 条失败,已保留选中状态以便重试。`,
+ ),
+ );
} else {
- setNotice(`${nextPublished ? "Published" : "Unpublished"} ${updated} bookmark${updated === 1 ? "" : "s"}.`);
+ setNotice(
+ nextPublished
+ ? tx(`Published ${updated} bookmark${updated === 1 ? "" : "s"}.`, `已公开 ${updated} 条书签。`)
+ : tx(`Unpublished ${updated} bookmark${updated === 1 ? "" : "s"}.`, `已取消公开 ${updated} 条书签。`),
+ );
}
} finally {
setBatchBusy(null);
@@ -237,7 +262,7 @@ export function PublicPageSettings({ bookmarks, categories, onChanged }: Props)
await reorderCategories(swapIds(allIds, groupId, targetId));
await onChanged();
} catch (caught) {
- setError(caught instanceof Error ? caught.message : "Could not reorder public categories.");
+ setError(caught instanceof Error ? caught.message : tx("Could not reorder public categories.", "调整分类顺序失败。"));
} finally {
setSorting(false);
}
@@ -259,7 +284,7 @@ export function PublicPageSettings({ bookmarks, categories, onChanged }: Props)
await reorderBookmarks(bookmark.categoryId ?? null, swapIds(allIds, bookmark.id, targetId));
await onChanged();
} catch (caught) {
- setError(caught instanceof Error ? caught.message : "Could not reorder public bookmarks.");
+ setError(caught instanceof Error ? caught.message : tx("Could not reorder public bookmarks.", "调整书签顺序失败。"));
} finally {
setSorting(false);
}
@@ -271,13 +296,19 @@ export function PublicPageSettings({ bookmarks, categories, onChanged }: Props)
-
PUBLIC PAGE
-
Publish and arrange the curated view.
-
Public groups reuse the canonical Library category and bookmark order. Reordering here updates that shared order, so Web, New Tab and the public page stay consistent instead of drifting into separate layouts.
+
{tx("Public Page Curation", "公开主页管理")}
+
+ {tx(
+ "Public groups reuse your canonical Library order so Web, New Tab and the public page always stay aligned.",
+ "公开分组直接复用书签库的统一排序,确保网页工作台、新标签页与公开主页展示顺序一致。",
+ )}
+
@@ -288,10 +319,10 @@ export function PublicPageSettings({ bookmarks, categories, onChanged }: Props)
-
Public layout
-
Move published categories and links without leaving Settings.
+
{tx("Public layout", "公开列表预览与排序")}
+
{tx("Reorder published categories and links directly here.", "直接上下调整已公开分类与链接顺序。")}
-
{groups.length} groups
+
{tx(`${groups.length} groups`, `${groups.length} 个分组`)}
@@ -300,12 +331,26 @@ export function PublicPageSettings({ bookmarks, categories, onChanged }: Props)
{group.name}
- {group.bookmarks.length} links
+ {tx(`${group.bookmarks.length} links`, `${group.bookmarks.length} 条链接`)}
{group.id && (
- void moveCategory(group.id, -1)}>↑ Group
- void moveCategory(group.id, 1)}>↓ Group
+ void moveCategory(group.id, -1)}
+ >
+ {tx("↑ Group", "↑ 上移分组")}
+
+ void moveCategory(group.id, 1)}
+ >
+ {tx("↓ Group", "↓ 下移分组")}
+
)}
@@ -319,27 +364,54 @@ export function PublicPageSettings({ bookmarks, categories, onChanged }: Props)
{bookmark.url}
- void moveBookmark(bookmark, -1)}>↑
- void moveBookmark(bookmark, 1)}>↓
- void toggle(bookmark)}>Unpublish
+ void moveBookmark(bookmark, -1)}
+ >
+ ↑
+
+ void moveBookmark(bookmark, 1)}
+ >
+ ↓
+
+ void toggle(bookmark)}
+ >
+ {tx("Unpublish", "取消公开")}
+
))}
))}
- {!loading && !groups.length &&
Nothing is public yet. Publish bookmarks from the manager beside this preview.
}
- {loading &&
Loading public selection…
}
+ {!loading && !groups.length && (
+
+ {tx("Nothing is public yet. Publish bookmarks from the list beside this preview.", "暂未公开任何书签,可在右侧列表中挑选并发布。")}
+
+ )}
+ {loading &&
{tx("Loading public selection…", "正在加载公开书签…")}
}
-
Add to public page
-
Search the full library, filter by publication state, then update one bookmark or a selected batch.
+
{tx("Select bookmarks", "挑选公开书签")}
+
{tx("Filter your library and publish individually or in bulk.", "检索全部书签,按状态筛选并单条或批量发布。")}
-
{filteredBookmarks.length} shown
+
{tx(`${filteredBookmarks.length} shown`, `显示 ${filteredBookmarks.length} 条`)}
@@ -349,14 +421,20 @@ export function PublicPageSettings({ bookmarks, categories, onChanged }: Props)
type="search"
value={query}
onChange={(event) => setQuery(event.target.value)}
- placeholder="Filter title, URL, description or category…"
- aria-label="Filter public page bookmarks"
+ placeholder={tx("Filter title, URL, description or category…", "按标题、网址、描述或分类筛选…")}
+ aria-label={tx("Filter public page bookmarks", "筛选书签")}
/>
-
-
setFilter("all")}>All · {bookmarks.length}
-
setFilter("published")}>Published · {publishedCount}
-
setFilter("unpublished")}>Unpublished · {unpublishedCount}
+
+ setFilter("all")}>
+ {tx(`All · ${bookmarks.length}`, `全部 · ${bookmarks.length}`)}
+
+ setFilter("published")}>
+ {tx(`Published · ${publishedCount}`, `已公开 · ${publishedCount}`)}
+
+ setFilter("unpublished")}>
+ {tx(`Unpublished · ${unpublishedCount}`, `未公开 · ${unpublishedCount}`)}
+
@@ -369,24 +447,28 @@ export function PublicPageSettings({ bookmarks, categories, onChanged }: Props)
disabled={!filteredBookmarks.length || mutationBusy}
onChange={toggleVisibleSelection}
/>
-
{allVisibleSelected ? "Clear visible" : "Select visible"}
+
{allVisibleSelected ? tx("Clear visible", "取消全选") : tx("Select visible", "全选当前")}
-
{selectedIds.size} selected
+
{tx(`${selectedIds.size} selected`, `已选 ${selectedIds.size} 条`)}
void updateSelection(true)}>
- {batchBusy === "publish" ? "Publishing…" : "Publish"}
+ {batchBusy === "publish" ? tx("Publishing…", "发布中…") : tx("Publish", "公开")}
void updateSelection(false)}>
- {batchBusy === "unpublish" ? "Unpublishing…" : "Unpublish"}
+ {batchBusy === "unpublish" ? tx("Unpublishing…", "取消中…") : tx("Unpublish", "取消公开")}
+
+ setSelectedIds(new Set())}>
+ {tx("Clear", "清空")}
- setSelectedIds(new Set())}>Clear
{filteredBookmarks.map((bookmark) => {
const isPublished = published.has(bookmark.id);
- const categoryName = bookmark.categoryId ? categoryNameById.get(bookmark.categoryId) ?? "Uncategorized" : "Uncategorized";
+ const categoryName = bookmark.categoryId
+ ? categoryNameById.get(bookmark.categoryId) ?? tx("Uncategorized", "未分类")
+ : tx("Uncategorized", "未分类");
return (
@@ -401,22 +483,30 @@ export function PublicPageSettings({ bookmarks, categories, onChanged }: Props)
{categoryName} · {bookmark.url}
- {isPublished ? "PUBLISHED" : "PRIVATE"}
+ {isPublished ? tx("PUBLISHED", "已公开") : tx("PRIVATE", "私有")}
void toggle(bookmark)}
>
- {busyId === bookmark.id ? "Saving…" : isPublished ? "Unpublish" : "Publish"}
+ {busyId === bookmark.id
+ ? tx("Saving…", "保存中…")
+ : isPublished
+ ? tx("Unpublish", "取消公开")
+ : tx("Publish", "公开")}
);
})}
{!loading && !filteredBookmarks.length && (
-
{query.trim() ? "No bookmarks match this filter." : "No bookmarks match this publication state."}
+
+ {query.trim()
+ ? tx("No bookmarks match this filter.", "没有匹配的书签。")
+ : tx("No bookmarks match this publication state.", "当前状态下暂无书签。")}
+
)}
- {loading &&
Loading public selection…
}
+ {loading &&
{tx("Loading public selection…", "正在加载公开书签…")}
}
diff --git a/apps/web/src/SearchEngineManager.tsx b/apps/web/src/SearchEngineManager.tsx
index 61877f4..db91387 100644
--- a/apps/web/src/SearchEngineManager.tsx
+++ b/apps/web/src/SearchEngineManager.tsx
@@ -1,3 +1,10 @@
+/**
+ * [INPUT]: depends on SearchEngine from @dockmark/core; search engine CRUD from ./api; BookmarkFavicon and safeDomainLabel from ./BookmarkFavicon; useI18n from ./i18n
+ * [OUTPUT]: exports SearchEngineManager component for configuring Launcher web search engines and bang shortcuts
+ * [POS]: search engine settings surface in apps/web/src, paired with search-engines.css
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
+
import { useMemo, useState, type FormEvent } from "react";
import type { SearchEngine } from "@dockmark/core";
import {
@@ -5,6 +12,8 @@ import {
deleteSearchEngine,
updateSearchEngine,
} from "./api";
+import { BookmarkFavicon, safeDomainLabel } from "./BookmarkFavicon";
+import { useI18n } from "./i18n";
interface Props {
engines: SearchEngine[];
@@ -24,11 +33,8 @@ const emptyDraft: Draft = {
searchUrl: "https://example.com/search?q=%s",
};
-function messageFrom(error: unknown) {
- return error instanceof Error ? error.message : "Something went wrong.";
-}
-
export function SearchEngineManager({ engines, loading, onChanged }: Props) {
+ const { isZh, tx } = useI18n();
const [newDraft, setNewDraft] = useState
(emptyDraft);
const [editingId, setEditingId] = useState(null);
const [editDraft, setEditDraft] = useState(emptyDraft);
@@ -40,6 +46,15 @@ export function SearchEngineManager({ engines, loading, onChanged }: Props) {
[engines],
);
+ const defaultEngine = useMemo(
+ () => ordered.find((engine) => engine.isDefault) ?? null,
+ [ordered],
+ );
+
+ function messageFrom(caught: unknown) {
+ return caught instanceof Error ? caught.message : tx("Something went wrong.", "操作失败,请稍后重试。");
+ }
+
async function run(action: () => Promise) {
setBusy(true);
setError(null);
@@ -99,13 +114,22 @@ export function SearchEngineManager({ engines, loading, onChanged }: Props) {
return (
-
-
-
SEARCH ENGINES
-
Choose where a command should search the web.
+
+
+ {defaultEngine && (
+
+ {tx(`Default: ${defaultEngine.name}`, `默认:${defaultEngine.name}`)}
+
+ )}
+
+ {tx(`${engines.length} engine${engines.length === 1 ? "" : "s"}`, `${engines.length} 个搜索引擎`)}
+
+
+
{error &&
{error}
}
@@ -113,56 +137,195 @@ export function SearchEngineManager({ engines, loading, onChanged }: Props) {
- {ordered.map((engine, index) => (
-
- {editingId === engine.id ? (
-
- ) : (
- <>
-
-
{engine.name.slice(0, 1).toUpperCase()}
-
-
{engine.name} {engine.isDefault && Default }
-
{engine.keyword ? `!${engine.keyword}` : "No bang shortcut"} · {engine.searchUrl}
+ {ordered.map((engine, index) => {
+ const sampleUrl = engine.searchUrl.replace("%s", "query");
+ return (
+
+ {editingId === engine.id ? (
+
-
- void move(engine, -1)}>↑
- void move(engine, 1)}>↓
- {!engine.isDefault && void run(async () => { await updateSearchEngine(engine.id, { isDefault: true }); })}>Make default }
- beginEdit(engine)}>Edit
- { if (window.confirm(`Delete search engine “${engine.name}”?`)) void run(() => deleteSearchEngine(engine.id)); }}>Delete
-
- >
- )}
-
- ))}
- {!loading && !ordered.length &&
No search engine configured. Apply migrations or create one above.
}
+
+ ) : (
+ <>
+
+
+
+
+ {engine.name}
+ {engine.isDefault && {tx("Default", "默认")} }
+ {engine.keyword && !{engine.keyword} }
+ {safeDomainLabel(sampleUrl)}
+
+
+ {engine.keyword ? `!${engine.keyword}` : tx("No bang shortcut", "无快捷词")} · {engine.searchUrl}
+
+
+
+
+ void move(engine, -1)}
+ >
+ ↑
+
+ void move(engine, 1)}
+ >
+ ↓
+
+ {!engine.isDefault && (
+
+ void run(async () => {
+ await updateSearchEngine(engine.id, { isDefault: true });
+ })
+ }
+ >
+ {tx("Make default", "设为默认")}
+
+ )}
+ beginEdit(engine)}>
+ {tx("Edit", "编辑")}
+
+ {
+ if (
+ window.confirm(
+ tx(`Delete search engine “${engine.name}”?`, `确定删除搜索引擎“${engine.name}”吗?`),
+ )
+ ) {
+ void run(() => deleteSearchEngine(engine.id));
+ }
+ }}
+ >
+ {tx("Delete", "删除")}
+
+
+ >
+ )}
+
+ );
+ })}
+ {!loading && !ordered.length && (
+
+ {tx("No search engine configured.", "尚未配置搜索引擎。")}
+ {tx("Apply migrations or create one above.", "请执行数据迁移或在左侧添加一个搜索引擎。")}
+
+ )}
-
Bang shortcuts
-
Type a shortcut followed by a query in the Launcher, for example !gh dockmark . Type only ! to discover configured shortcuts. Without a bang, Dockmark offers the default engine for the current query.
+
{tx("Bang shortcuts", "快捷词说明")}
+
+ {isZh ? (
+ <>
+ 在启动器中输入快捷词与关键词即可定向搜索,例如 !gh dockmark 。仅输入 ! {" "}
+ 可查看所有已配置的快捷词。未输入快捷词时,Dockmark 会使用默认搜索引擎。
+ >
+ ) : (
+ <>
+ Type a shortcut followed by a query in the Launcher, for example !gh dockmark . Type only{" "}
+ ! to discover configured shortcuts. Without a bang, Dockmark offers the default engine for the
+ current query.
+ >
+ )}
+
);
diff --git a/apps/web/src/SecuritySettings.tsx b/apps/web/src/SecuritySettings.tsx
index de496b1..30dc409 100644
--- a/apps/web/src/SecuritySettings.tsx
+++ b/apps/web/src/SecuritySettings.tsx
@@ -1,29 +1,38 @@
-import { useEffect, useState } from "react";
+/**
+ * [INPUT]: depends on createPairCode, listDevices, revokeDevice, PairedDevice from ./auth-client and useI18n from ./i18n
+ * [OUTPUT]: exports SecuritySettings panel for generating one-time pairing codes and managing paired browser extensions
+ * [POS]: Mounted in SettingsPage under /app/settings/security. Manages revocable per-device extension bearer tokens.
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
+import { useCallback, useEffect, useState } from "react";
import { createPairCode, listDevices, revokeDevice, type PairedDevice } from "./auth-client";
+import { useI18n } from "./i18n";
-function timeLabel(value: string) {
+function timeLabel(value: string, locale: string) {
const date = new Date(value);
- return Number.isNaN(date.getTime()) ? value : date.toLocaleString();
+ if (Number.isNaN(date.getTime())) return value;
+ return new Intl.DateTimeFormat(locale, { dateStyle: "medium", timeStyle: "short" }).format(date);
}
export function SecuritySettings() {
+ const { locale, tx } = useI18n();
const [devices, setDevices] = useState
([]);
const [pairCode, setPairCode] = useState<{ code: string; expiresAt: string } | null>(null);
const [busy, setBusy] = useState(false);
const [message, setMessage] = useState(null);
const [error, setError] = useState(null);
- async function refreshDevices() {
+ const refreshDevices = useCallback(async () => {
try {
setDevices(await listDevices());
} catch (caught) {
- setError(caught instanceof Error ? caught.message : "Could not load paired devices.");
+ setError(caught instanceof Error ? caught.message : tx("Could not load paired devices.", "无法加载已配对设备列表。"));
}
- }
+ }, [tx]);
useEffect(() => {
void refreshDevices();
- }, []);
+ }, [refreshDevices]);
async function generatePairCode() {
setBusy(true);
@@ -32,9 +41,9 @@ export function SecuritySettings() {
try {
const result = await createPairCode();
setPairCode(result);
- setMessage("Pairing code created. Enter it in the Dockmark extension popup within 10 minutes.");
+ setMessage(tx("Pairing code created. Enter it in the Dockmark extension popup within 10 minutes.", "配对码已生成,请在 10 分钟内填入 Dockmark 扩展弹窗。"));
} catch (caught) {
- setError(caught instanceof Error ? caught.message : "Could not create a pairing code.");
+ setError(caught instanceof Error ? caught.message : tx("Could not create a pairing code.", "生成配对码失败。"));
} finally {
setBusy(false);
}
@@ -44,23 +53,27 @@ export function SecuritySettings() {
if (!pairCode) return;
try {
await navigator.clipboard.writeText(pairCode.code);
- setMessage("Pairing code copied.");
+ setMessage(tx("Pairing code copied.", "已复制配对码。"));
} catch {
- setMessage("Copy is unavailable in this browser. Select the code manually.");
+ setMessage(tx("Copy is unavailable in this browser. Select the code manually.", "当前浏览器不支持剪贴板写入,请手动选中复制。"));
}
}
async function revoke(device: PairedDevice) {
- if (!window.confirm(`Revoke “${device.name}”? Its extension token will stop working immediately.`)) return;
+ const prompt = tx(
+ `Revoke “${device.name}”? Its extension token will stop working immediately.`,
+ `确定吊销“${device.name}”吗?该扩展令牌将立即失效。`,
+ );
+ if (!window.confirm(prompt)) return;
setBusy(true);
setError(null);
setMessage(null);
try {
await revokeDevice(device.id);
await refreshDevices();
- setMessage(`Revoked “${device.name}”.`);
+ setMessage(tx(`Revoked “${device.name}”.`, `已吊销“${device.name}”。`));
} catch (caught) {
- setError(caught instanceof Error ? caught.message : "Could not revoke this device.");
+ setError(caught instanceof Error ? caught.message : tx("Could not revoke this device.", "吊销设备失败。"));
} finally {
setBusy(false);
}
@@ -73,13 +86,22 @@ export function SecuritySettings() {
-
SECURITY
-
Web sessions and paired extensions.
-
Your Web session uses an HttpOnly cookie. Extensions use revocable per-device bearer tokens created from short-lived one-time pairing codes.
+
{tx("Security & Paired Devices", "安全与已配对设备")}
+
+ {tx(
+ "Web sessions use HttpOnly cookies; extensions use revocable per-device tokens issued via one-time pairing codes.",
+ "网页端使用 HttpOnly Cookie 会话;浏览器扩展通过一次性配对码获取可独立吊销的设备令牌。",
+ )}
+
- {activeDevices.length} active device{activeDevices.length === 1 ? "" : "s"}
- Browser writes still require explicit review.
+
+ {tx(
+ `${activeDevices.length} active device${activeDevices.length === 1 ? "" : "s"}`,
+ `${activeDevices.length} 台活跃设备`,
+ )}
+
+ {tx("Browser writes require review", "浏览器书签写入始终需人工确认")}
@@ -90,22 +112,31 @@ export function SecuritySettings() {
-
Pair a browser extension
-
Create a one-time code only from this signed-in Web session. The code expires after 10 minutes and can be used once.
+
{tx("Pair a browser extension", "配对浏览器扩展")}
+
+ {tx(
+ "Create a one-time code from this signed-in session. Expires in 10 minutes and works once.",
+ "仅可在当前已登录会话中生成一次性配对码,10 分钟内有效且仅可使用一次。",
+ )}
+
{pairCode ? (
{pairCode.code}
-
Expires {timeLabel(pairCode.expiresAt)}
+
{tx(`Expires ${timeLabel(pairCode.expiresAt, locale)}`, `过期时间:${timeLabel(pairCode.expiresAt, locale)}`)}
- void copyPairCode()}>Copy code
- void generatePairCode()}>New code
+ void copyPairCode()}>
+ {tx("Copy code", "复制配对码")}
+
+ void generatePairCode()}>
+ {tx("New code", "重新生成")}
+
) : (
void generatePairCode()}>
- {busy ? "Creating…" : "Create pairing code"}
+ {busy ? tx("Creating…", "生成中…") : tx("Create pairing code", "生成配对码")}
)}
@@ -113,29 +144,57 @@ export function SecuritySettings() {
-
Paired devices
-
Each extension has its own token. Revoking one device does not sign out your Web session or other browsers.
+
{tx("Paired devices", "已配对设备")}
+
+ {tx(
+ "Each extension keeps its own token. Revoking one device never signs out your Web session or other browsers.",
+ "每个扩展拥有独立令牌;吊销单台设备不会影响当前网页会话或其他浏览器。",
+ )}
+
-
void refreshDevices()}>Refresh
+
void refreshDevices()}>
+ {tx("Refresh", "刷新")}
+
{activeDevices.map((device) => (
{device.name}
- Paired {timeLabel(device.createdAt)} · last seen {timeLabel(device.lastSeenAt)}
+
+ {tx(
+ `Paired ${timeLabel(device.createdAt, locale)} · last seen ${timeLabel(device.lastSeenAt, locale)}`,
+ `配对于 ${timeLabel(device.createdAt, locale)} · 最近活跃 ${timeLabel(device.lastSeenAt, locale)}`,
+ )}
+
- void revoke(device)}>Revoke
+ void revoke(device)}>
+ {tx("Revoke", "吊销")}
+
))}
- {!activeDevices.length &&
No active paired extensions yet.
}
+ {!activeDevices.length && (
+
{tx("No active paired extensions yet.", "暂无活跃的已配对扩展。")}
+ )}
{revokedDevices.length > 0 && (
- {revokedDevices.length} revoked device{revokedDevices.length === 1 ? "" : "s"}
+
+ {tx(
+ `${revokedDevices.length} revoked device${revokedDevices.length === 1 ? "" : "s"}`,
+ `${revokedDevices.length} 台已吊销设备`,
+ )}
+
{revokedDevices.map((device) => (
- {device.name} Revoked {device.revokedAt ? timeLabel(device.revokedAt) : ""}
+
+ {device.name}
+
+ {device.revokedAt
+ ? tx(`Revoked ${timeLabel(device.revokedAt, locale)}`, `吊销于 ${timeLabel(device.revokedAt, locale)}`)
+ : ""}
+
+
))}
diff --git a/apps/web/src/SessionManager.tsx b/apps/web/src/SessionManager.tsx
index aaf0908..35a285b 100644
--- a/apps/web/src/SessionManager.tsx
+++ b/apps/web/src/SessionManager.tsx
@@ -1,7 +1,16 @@
+/**
+ * [INPUT]: depends on SessionWithItems, SessionItem, CreateSessionItemInput, ResolvedLocale, normalizeBookmarkUrl, formatRelativeTime from @dockmark/core; session CRUD from ./api; bridge restore from ./browser-bridge; BookmarkFavicon and safeDomainLabel from ./BookmarkFavicon; useI18n from ./i18n
+ * [OUTPUT]: exports SessionManager component for saving, editing, and restoring browser tab snapshots
+ * [POS]: session management tool surface in apps/web/src, paired with session.css
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
+
import { useEffect, useMemo, useState, type FormEvent } from "react";
import {
+ formatRelativeTime,
normalizeBookmarkUrl,
type CreateSessionItemInput,
+ type ResolvedLocale,
type SessionItem,
type SessionWithItems,
} from "@dockmark/core";
@@ -13,7 +22,9 @@ import {
updateSession,
updateSessionItem,
} from "./api";
+import { BookmarkFavicon, safeDomainLabel } from "./BookmarkFavicon";
import { getBridgeStatus, restoreSessionWithBridge } from "./browser-bridge";
+import { useI18n } from "./i18n";
interface Props {
sessions: SessionWithItems[];
@@ -31,10 +42,6 @@ interface ItemDraft {
const emptyItemDraft: ItemDraft = { title: "", url: "", pinned: false };
-function messageFrom(error: unknown) {
- return error instanceof Error ? error.message : "Something went wrong.";
-}
-
function deriveTitle(url: string) {
try {
const parsed = new URL(url);
@@ -63,10 +70,10 @@ function parseQuickLines(value: string): CreateSessionItemInput[] {
});
}
-function formatSessionDate(value: string) {
+function formatSessionDate(value: string, locale: ResolvedLocale) {
const date = new Date(value);
if (Number.isNaN(date.getTime())) return value;
- return new Intl.DateTimeFormat(undefined, {
+ return new Intl.DateTimeFormat(locale, {
month: "short",
day: "numeric",
hour: "2-digit",
@@ -81,8 +88,9 @@ export function SessionManager({
onSelectedChange,
onChanged,
}: Props) {
+ const { locale, isZh, tx } = useI18n();
const [newName, setNewName] = useState("");
- const [newSource, setNewSource] = useState("Web");
+ const [newSource, setNewSource] = useState(() => (isZh ? "网页端" : "Web"));
const [quickUrls, setQuickUrls] = useState("");
const [editingMeta, setEditingMeta] = useState(false);
const [metaName, setMetaName] = useState("");
@@ -98,6 +106,16 @@ export function SessionManager({
[selectedSessionId, sessions],
);
+ const totalTabs = useMemo(
+ () => sessions.reduce((sum, session) => sum + session.items.length, 0),
+ [sessions],
+ );
+
+ const orderedItems = useMemo(
+ () => (selected ? [...selected.items].sort((a, b) => a.position - b.position) : []),
+ [selected],
+ );
+
useEffect(() => {
if (!selectedSessionId && sessions[0]) onSelectedChange(sessions[0].id);
if (selectedSessionId && !sessions.some((session) => session.id === selectedSessionId)) {
@@ -105,6 +123,10 @@ export function SessionManager({
}
}, [onSelectedChange, selectedSessionId, sessions]);
+ function messageFrom(caught: unknown) {
+ return caught instanceof Error ? caught.message : tx("Something went wrong.", "操作失败,请稍后重试。");
+ }
+
async function run(action: () => Promise) {
setBusy(true);
setError(null);
@@ -232,13 +254,20 @@ export function SessionManager({
return (
-
-
-
SESSIONS
-
Save where you are. Resume anywhere.
+
+
+
+ {tx(`${sessions.length} session${sessions.length === 1 ? "" : "s"}`, `${sessions.length} 个会话`)}
+
+
+ {tx(`${totalTabs} tab${totalTabs === 1 ? "" : "s"}`, `${totalTabs} 个标签页`)}
+
+
+
{error &&
{error}
}
@@ -246,33 +275,67 @@ export function SessionManager({
-
New session Paste one URL per line, or use “Title | URL”.
+
+
{tx("New session", "新建会话")}
+
{tx("Paste one URL per line, or use “Title | URL”.", "每行粘贴一个链接,或使用“标题 | 链接”格式。")}
+
-
Recent sessions {sessions.length}
+
+
{tx("Recent sessions", "最近会话")}
+ {sessions.length}
+
{sessions.map((session) => (
onSelectedChange(session.id)}
>
{session.items.length}
{session.name}
- {formatSessionDate(session.createdAt)}{session.sourceDevice ? ` · ${session.sourceDevice}` : ""}
+
+ {formatSessionDate(session.createdAt, locale)}
+ {session.sourceDevice ? ` · ${session.sourceDevice}` : ""}
+
))}
- {!loading && !sessions.length &&
No saved sessions yet.
}
+ {!loading && !sessions.length && (
+
{tx("No saved sessions yet.", "暂无已保存的会话。")}
+ )}
@@ -282,37 +345,71 @@ export function SessionManager({
{editingMeta ? (
- setMetaName(event.target.value)} maxLength={120} />
- setMetaSource(event.target.value)} maxLength={160} placeholder="Source device" />
+ setMetaName(event.target.value)}
+ placeholder={tx("Session name", "会话名称")}
+ maxLength={120}
+ />
+ setMetaSource(event.target.value)}
+ maxLength={160}
+ placeholder={tx("Source device", "来源设备")}
+ />
- Save
- setEditingMeta(false)}>Cancel
+ {tx("Save", "保存")}
+ setEditingMeta(false)}>
+ {tx("Cancel", "取消")}
+
) : (
-
-
↺
{selected.name}
+
+
+ ↺
+
{selected.name}
+
- {selected.items.length} tabs · saved {formatSessionDate(selected.createdAt)}
+ {tx(
+ `${selected.items.length} tab${selected.items.length === 1 ? "" : "s"} · saved ${formatSessionDate(selected.createdAt, locale)} (${formatRelativeTime(selected.createdAt, locale)})`,
+ `${selected.items.length} 个标签页 · 保存于 ${formatSessionDate(selected.createdAt, locale)}(${formatRelativeTime(selected.createdAt, locale)})`,
+ )}
{selected.sourceDevice ? ` · ${selected.sourceDevice}` : ""}
- void restoreSession()}>Restore · {selected.items.length}
- Edit
+ void restoreSession()}
+ >
+ {tx(`Restore · ${selected.items.length}`, `恢复 · ${selected.items.length}`)}
+
+
+ {tx("Edit", "编辑")}
+
{
- if (window.confirm(`Delete session “${selected.name}”?`)) {
+ if (
+ window.confirm(
+ tx(`Delete session “${selected.name}”?`, `确定删除会话“${selected.name}”吗?`),
+ )
+ ) {
void run(async () => {
await deleteSession(selected.id);
onSelectedChange(null);
});
}
}}
- >Delete
+ >
+ {tx("Delete", "删除")}
+
)}
@@ -320,51 +417,166 @@ export function SessionManager({
-
Add tab Sessions are snapshots, but you can repair or extend them later.
+
+
{tx("Add tab", "添加标签页")}
+
{tx("Sessions are snapshots, and you can repair or extend them later.", "会话是标签页快照,仍可随时补充或修正。")}
+
- setNewItem({ ...newItem, title: event.target.value })} placeholder="Title" />
- setNewItem({ ...newItem, url: event.target.value })} placeholder="https://example.com" inputMode="url" />
- setNewItem({ ...newItem, pinned: event.target.checked })} /> Pinned
- Add tab
+ setNewItem({ ...newItem, title: event.target.value })}
+ placeholder={tx("Title", "标题")}
+ />
+ setNewItem({ ...newItem, url: event.target.value })}
+ placeholder="https://example.com"
+ inputMode="url"
+ />
+
+ setNewItem({ ...newItem, pinned: event.target.checked })}
+ />{" "}
+ {tx("Pinned", "固定")}
+
+
+ {tx("Add tab", "添加标签页")}
+
- {[...selected.items].sort((a, b) => a.position - b.position).map((item, index, ordered) => (
+ {orderedItems.map((item, index) => (
{editingItemId === item.id ? (
saveItem(event, item.id)}>
- setItemDraft({ ...itemDraft, title: event.target.value })} />
- setItemDraft({ ...itemDraft, url: event.target.value })} inputMode="url" />
- setItemDraft({ ...itemDraft, pinned: event.target.checked })} /> Pinned
- Save setEditingItemId(null)}>Cancel
+ setItemDraft({ ...itemDraft, title: event.target.value })}
+ placeholder={tx("Title", "标题")}
+ />
+ setItemDraft({ ...itemDraft, url: event.target.value })}
+ placeholder="https://example.com"
+ inputMode="url"
+ />
+
+ setItemDraft({ ...itemDraft, pinned: event.target.checked })}
+ />{" "}
+ {tx("Pinned", "固定")}
+
+
+ {tx("Save", "保存")}
+ setEditingItemId(null)}>
+ {tx("Cancel", "取消")}
+
+
) : (
<>
{String(index + 1).padStart(2, "0")}
+
{item.title}
-
{item.url}
-
{item.pinned && Pinned }Snapshot tab
+
{item.url}
+
+ {safeDomainLabel(item.url)}
+ {item.pinned && {tx("Pinned", "已固定")} }
+ {tx("Snapshot tab", "快照标签页")}
+
- void moveItem(item, -1)}>↑
- void moveItem(item, 1)}>↓
- beginItemEdit(item)}>Edit
- { if (window.confirm(`Remove “${item.title}” from this session?`)) void run(() => deleteSessionItem(selected.id, item.id)); }}>Remove
+ void moveItem(item, -1)}
+ >
+ ↑
+
+ void moveItem(item, 1)}
+ >
+ ↓
+
+ beginItemEdit(item)}>
+ {tx("Edit", "编辑")}
+
+ {
+ if (
+ window.confirm(
+ tx(
+ `Remove “${item.title}” from this session?`,
+ `确定从当前会话移除“${item.title}”吗?`,
+ ),
+ )
+ ) {
+ void run(() => deleteSessionItem(selected.id, item.id));
+ }
+ }}
+ >
+ {tx("Remove", "移除")}
+
>
)}
))}
- {!selected.items.length &&
This session has no tabs. Add URLs above or save a browser window from the extension.
}
+ {!orderedItems.length && (
+
+ {tx("This session has no tabs.", "该会话暂无标签页。")}
+
+ {tx(
+ "Add URLs above or save a browser window from the extension.",
+ "请在上方添加链接,或通过浏览器扩展保存当前窗口。",
+ )}
+
+
+ )}
-
Web-only restore opens normal tabs. When the browser bridge is connected, pinned state is restored by the extension.
+
+ {tx(
+ "Web-only restore opens normal tabs. When the Browser Bridge is connected, pinned state is restored by the extension.",
+ "纯网页恢复会以普通标签页打开;连接浏览器桥接后,扩展会自动还原标签页的固定状态。",
+ )}
+
>
) : (
-
No session selected. Save a temporary browsing state so it can be resumed elsewhere.
+
+ {tx("No session selected.", "未选择会话。")}
+
+ {tx(
+ "Save a temporary browsing state so it can be resumed elsewhere.",
+ "保存当前浏览状态,以便稍后在其他设备继续。",
+ )}
+
+
)}
diff --git a/apps/web/src/SettingsPage.tsx b/apps/web/src/SettingsPage.tsx
index 5436a95..66c9dd2 100644
--- a/apps/web/src/SettingsPage.tsx
+++ b/apps/web/src/SettingsPage.tsx
@@ -1,8 +1,15 @@
+/**
+ * [INPUT]: depends on listBookmarks/listCategories from ./api, useI18n from ./i18n, AppearanceSettings, BrowserSettingsManager, SecuritySettings, PublicPageSettings, and settings/security CSS
+ * [OUTPUT]: exports SettingsPage shell and client-side /app/settings/* sub-router
+ * [POS]: Mounted by PrivateRoot for /app/settings/*. Coordinates four configuration panels without mixing library editing.
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
import { useCallback, useEffect, useMemo, useState } from "react";
import type { Bookmark, Category } from "@dockmark/core";
import { listBookmarks, listCategories } from "./api";
import { AppearanceSettings } from "./AppearanceSettings";
import { BrowserSettingsManager } from "./BrowserSettingsManager";
+import { useI18n } from "./i18n";
import { PublicPageSettings } from "./PublicPageSettings";
import { SecuritySettings } from "./SecuritySettings";
import "./settings.css";
@@ -10,13 +17,6 @@ import "./security.css";
type SettingsView = "appearance" | "browser" | "security" | "public";
-const sections: Array<{ id: SettingsView; label: string; detail: string }> = [
- { id: "appearance", label: "Appearance", detail: "Theme and visual preferences." },
- { id: "browser", label: "Browser", detail: "New Tab and sync behavior." },
- { id: "security", label: "Security", detail: "Pairing and trusted devices." },
- { id: "public", label: "Public Page", detail: "Publish and arrange curated links." },
-];
-
function settingsView(pathname: string): SettingsView {
const segment = pathname.split("/").filter(Boolean).at(-1);
return segment === "browser" || segment === "security" || segment === "public" || segment === "appearance"
@@ -30,6 +30,7 @@ function navigate(view: SettingsView) {
}
export function SettingsPage() {
+ const { tx } = useI18n();
const [path, setPath] = useState(window.location.pathname);
const [bookmarks, setBookmarks] = useState
([]);
const [categories, setCategories] = useState([]);
@@ -37,6 +38,32 @@ export function SettingsPage() {
const [error, setError] = useState(null);
const view = useMemo(() => settingsView(path), [path]);
+ const sections = useMemo>(
+ () => [
+ {
+ id: "appearance",
+ label: tx("Appearance & Language", "外观与语言"),
+ detail: tx("Theme mode and interface language.", "主题模式与界面显示语言。"),
+ },
+ {
+ id: "browser",
+ label: tx("Browser", "浏览器与新标签页"),
+ detail: tx("New Tab launcher and sync preferences.", "新标签页启动台与同步偏好。"),
+ },
+ {
+ id: "security",
+ label: tx("Security", "安全与设备"),
+ detail: tx("Pairing codes and trusted extensions.", "配对码与已配对扩展管理。"),
+ },
+ {
+ id: "public",
+ label: tx("Public Page", "公开主页"),
+ detail: tx("Publish and order curated links.", "发布与排序精选公开链接。"),
+ },
+ ],
+ [tx],
+ );
+
useEffect(() => {
const onPopState = () => setPath(window.location.pathname);
window.addEventListener("popstate", onPopState);
@@ -51,10 +78,10 @@ export function SettingsPage() {
setCategories(nextCategories);
setPublicDataLoaded(true);
} catch (caught) {
- setError(caught instanceof Error ? caught.message : "Could not load public-page data.");
+ setError(caught instanceof Error ? caught.message : tx("Could not load public-page data.", "无法加载公开主页数据。"));
throw caught;
}
- }, []);
+ }, [tx]);
useEffect(() => {
if (view === "public" && !publicDataLoaded) {
@@ -68,13 +95,12 @@ export function SettingsPage() {
-
DOCKMARK SETTINGS
-
Policies and preferences, without the library clutter.
-
{active.detail} Bookmark editing, organization, health and change history now live together under Workspace → Bookmarks.
+
{tx("Settings", "设置")}
+
{active.detail}
-
+
{sections.map((section) => (
- : Loading public-page library…
+ : {tx("Loading public-page library…", "正在加载书签列表…")}
)}
);
diff --git a/apps/web/src/SmartCollectionsPage.tsx b/apps/web/src/SmartCollectionsPage.tsx
index 5de57dc..6663e36 100644
--- a/apps/web/src/SmartCollectionsPage.tsx
+++ b/apps/web/src/SmartCollectionsPage.tsx
@@ -1,10 +1,24 @@
+/**
+ * [INPUT]: depends on useEffect, useMemo, useState, FormEvent from react; HEALTH_STATUS_LABELS, Bookmark, Category, HealthStatus, ResolvedLocale from @dockmark/core; listBookmarks, listCategories from ./api; listInbox from ./inbox-api; LibraryBulkOrganizer from ./LibraryBulkOrganizer; MAX_LIBRARY_BATCH from ./library-batch-api; listBookmarkTags from ./tag-api; matchesSmartCollection from ./smart-collection-match; createSmartCollection, deleteSmartCollection, listSmartCollections, updateSmartCollection, SmartCollection, SmartCollectionFilters from ./smart-collections-api; useI18n from ./i18n; BookmarkFavicon, safeDomainLabel from ./BookmarkFavicon; ./smart-collections.css
+ * [OUTPUT]: exports SmartCollectionsPage component for authoring, previewing, and handing off live Smart Collection views
+ * [POS]: top-level /app/collections workspace; evaluates saved filter rules client-side and hands matched sets into LibraryBulkOrganizer
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
+
import { useEffect, useMemo, useState, type FormEvent } from "react";
-import type { Bookmark, Category, HealthStatus } from "@dockmark/core";
+import {
+ HEALTH_STATUS_LABELS,
+ type Bookmark,
+ type Category,
+ type HealthStatus,
+ type ResolvedLocale,
+} from "@dockmark/core";
import { listBookmarks, listCategories } from "./api";
+import { BookmarkFavicon, safeDomainLabel } from "./BookmarkFavicon";
+import { useI18n } from "./i18n";
import { listInbox } from "./inbox-api";
import { LibraryBulkOrganizer } from "./LibraryBulkOrganizer";
import { MAX_LIBRARY_BATCH } from "./library-batch-api";
-import { listBookmarkTags } from "./tag-api";
import { matchesSmartCollection } from "./smart-collection-match";
import {
createSmartCollection,
@@ -14,27 +28,27 @@ import {
type SmartCollection,
type SmartCollectionFilters,
} from "./smart-collections-api";
+import { listBookmarkTags } from "./tag-api";
import "./smart-collections.css";
-const healthLabels: Record = {
- unknown: "Unchecked",
- healthy: "Healthy",
- redirected: "Redirected",
- "auth-required": "Auth required",
- forbidden: "Forbidden",
- "rate-limited": "Rate limited",
- timeout: "Timeout",
- "dns-error": "DNS error",
- "tls-error": "TLS error",
- unavailable: "Unavailable",
- "local-only": "Local only",
- ignored: "Ignored",
-};
-
-const healthStatuses = Object.keys(healthLabels) as HealthStatus[];
+const HEALTH_STATUSES: HealthStatus[] = [
+ "unknown",
+ "healthy",
+ "redirected",
+ "auth-required",
+ "forbidden",
+ "rate-limited",
+ "timeout",
+ "dns-error",
+ "tls-error",
+ "unavailable",
+ "local-only",
+ "ignored",
+];
type CategoryDraft = "any" | "uncategorized" | string;
type InboxDraft = "any" | "inbox" | "library";
+type TxFn = (en: string, zh: string) => string;
interface Draft {
name: string;
@@ -54,35 +68,51 @@ const emptyDraft: Draft = {
inbox: "any",
};
-function tagsFromText(value: string) {
+function tagsFromText(value: string, tx: TxFn): string[] {
const tags: string[] = [];
const seen = new Set();
for (const raw of value.split(/[;,\n]/)) {
const tag = raw.trim().replace(/\s+/g, " ");
if (!tag) continue;
- if (tag.length > 40) throw new Error("Each Smart Collection tag must be 40 characters or fewer.");
+ if (tag.length > 40) {
+ throw new Error(
+ tx(
+ "Each Smart Collection tag must be 40 characters or fewer.",
+ "智能合集的单个标签长度不能超过 40 个字符。",
+ ),
+ );
+ }
const key = tag.toLocaleLowerCase();
if (seen.has(key)) continue;
seen.add(key);
tags.push(tag);
}
- if (tags.length > 8) throw new Error("A Smart Collection can require at most 8 tags.");
+ if (tags.length > 8) {
+ throw new Error(
+ tx(
+ "A Smart Collection can require at most 8 tags.",
+ "每个智能合集最多支持 8 个必选标签。",
+ ),
+ );
+ }
return tags;
}
-function filtersFromDraft(draft: Draft): SmartCollectionFilters {
+function filtersFromDraft(draft: Draft, tx: TxFn): SmartCollectionFilters {
const filters: SmartCollectionFilters = {};
if (draft.category === "uncategorized") filters.categoryId = null;
else if (draft.category !== "any") filters.categoryId = draft.category;
- const tags = tagsFromText(draft.tagsText);
+ const tags = tagsFromText(draft.tagsText, tx);
if (tags.length) filters.tags = tags;
- if (draft.domain.trim()) filters.domain = draft.domain.trim().toLocaleLowerCase().replace(/^\.+|\.+$/g, "");
+ if (draft.domain.trim()) {
+ filters.domain = draft.domain.trim().toLocaleLowerCase().replace(/^\.+|\.+$/g, "");
+ }
if (draft.healthStatus !== "any") filters.healthStatus = draft.healthStatus;
if (draft.inbox !== "any") filters.inbox = draft.inbox;
return filters;
}
-function filterSignature(filters: SmartCollectionFilters) {
+function filterSignature(filters: SmartCollectionFilters): string {
return JSON.stringify({
category: Object.prototype.hasOwnProperty.call(filters, "categoryId") ? filters.categoryId : "__any__",
tags: filters.tags ?? [],
@@ -97,7 +127,9 @@ function draftFromCollection(collection: SmartCollection): Draft {
return {
name: collection.name,
category: Object.prototype.hasOwnProperty.call(filters, "categoryId")
- ? filters.categoryId === null ? "uncategorized" : filters.categoryId ?? "any"
+ ? filters.categoryId === null
+ ? "uncategorized"
+ : filters.categoryId ?? "any"
: "any",
tagsText: (filters.tags ?? []).join(", "),
domain: filters.domain ?? "",
@@ -106,11 +138,31 @@ function draftFromCollection(collection: SmartCollection): Draft {
};
}
-function hostLabel(url: string) {
- try { return new URL(url).hostname; } catch { return url; }
+function formatCollectionFilterLabels(
+ filters: SmartCollectionFilters,
+ categoryById: Map,
+ locale: ResolvedLocale,
+ tx: TxFn,
+): string[] {
+ const labels: string[] = [];
+ if (Object.prototype.hasOwnProperty.call(filters, "categoryId")) {
+ labels.push(
+ filters.categoryId === null
+ ? tx("Uncategorized", "未分类")
+ : categoryById.get(filters.categoryId ?? "") ?? tx("Unknown category", "未知分类"),
+ );
+ }
+ for (const tag of filters.tags ?? []) labels.push(`#${tag}`);
+ if (filters.domain) labels.push(filters.domain);
+ if (filters.healthStatus) {
+ labels.push(HEALTH_STATUS_LABELS[locale][filters.healthStatus]);
+ }
+ if (filters.inbox === "inbox") labels.push(tx("Inbox only", "仅收件箱"));
+ if (filters.inbox === "library") labels.push(tx("Filed library", "已归档书签库"));
+ return labels;
}
-function selectedCollectionFromLocation() {
+function selectedCollectionFromLocation(): string | null {
const value = new URLSearchParams(window.location.search).get("collection");
return value?.trim() || null;
}
@@ -123,6 +175,7 @@ function syncCollectionLocation(id: string | null) {
}
export function SmartCollectionsPage() {
+ const { locale, tx } = useI18n();
const [bookmarks, setBookmarks] = useState([]);
const [categories, setCategories] = useState([]);
const [bookmarkTags, setBookmarkTags] = useState>({});
@@ -136,12 +189,27 @@ export function SmartCollectionsPage() {
const [error, setError] = useState(null);
const [notice, setNotice] = useState(null);
- const categoryById = useMemo(() => new Map(categories.map((category) => [category.id, category.name])), [categories]);
- const selected = useMemo(() => collections.find((collection) => collection.id === selectedId) ?? null, [collections, selectedId]);
+ const categoryById = useMemo(
+ () => new Map(categories.map((category) => [category.id, category.name])),
+ [categories],
+ );
+ const selected = useMemo(
+ () => collections.find((collection) => collection.id === selectedId) ?? null,
+ [collections, selectedId],
+ );
const draftFilters = useMemo(() => {
- try { return filtersFromDraft(draft); } catch { return {} as SmartCollectionFilters; }
- }, [draft]);
+ try {
+ return filtersFromDraft(draft, tx);
+ } catch {
+ return {} as SmartCollectionFilters;
+ }
+ }, [draft, tx]);
+
+ const draftFilterChips = useMemo(
+ () => formatCollectionFilterLabels(draftFilters, categoryById, locale, tx),
+ [categoryById, draftFilters, locale, tx],
+ );
const preview = useMemo(
() => bookmarks.filter((bookmark) => matchesSmartCollection(bookmark, draftFilters, bookmarkTags[bookmark.id] ?? [], inboxIds)),
@@ -158,23 +226,35 @@ export function SmartCollectionsPage() {
const draftMatchesSaved = useMemo(() => {
if (!selected || draft.name.trim() !== selected.name) return false;
try {
- return filterSignature(filtersFromDraft(draft)) === filterSignature(selected.filters);
+ return filterSignature(filtersFromDraft(draft, tx)) === filterSignature(selected.filters);
} catch {
return false;
}
- }, [draft, selected]);
-
- const counts = useMemo(() => new Map(collections.map((collection) => [
- collection.id,
- bookmarks.filter((bookmark) => matchesSmartCollection(bookmark, collection.filters, bookmarkTags[bookmark.id] ?? [], inboxIds)).length,
- ])), [bookmarkTags, bookmarks, collections, inboxIds]);
+ }, [draft, selected, tx]);
+
+ const counts = useMemo(
+ () =>
+ new Map(
+ collections.map((collection) => [
+ collection.id,
+ bookmarks.filter((bookmark) =>
+ matchesSmartCollection(bookmark, collection.filters, bookmarkTags[bookmark.id] ?? [], inboxIds),
+ ).length,
+ ]),
+ ),
+ [bookmarkTags, bookmarks, collections, inboxIds],
+ );
async function refresh() {
setLoading(true);
setError(null);
try {
const [nextBookmarks, nextCategories, nextTags, nextInbox, nextCollections] = await Promise.all([
- listBookmarks(), listCategories(), listBookmarkTags(), listInbox(), listSmartCollections(),
+ listBookmarks(),
+ listCategories(),
+ listBookmarkTags(),
+ listInbox(),
+ listSmartCollections(),
]);
setBookmarks(nextBookmarks);
setCategories(nextCategories);
@@ -192,13 +272,19 @@ export function SmartCollectionsPage() {
}
}
} catch (caught) {
- setError(caught instanceof Error ? caught.message : "Could not load Smart Collections.");
+ setError(
+ caught instanceof Error
+ ? caught.message
+ : tx("Could not load Smart Collections.", "无法加载智能合集。"),
+ );
} finally {
setLoading(false);
}
}
- useEffect(() => { void refresh(); }, []);
+ useEffect(() => {
+ void refresh();
+ }, []);
useEffect(() => {
if (showBulkOrganizer && !draftMatchesSaved) setShowBulkOrganizer(false);
@@ -227,11 +313,16 @@ export function SmartCollectionsPage() {
setError(null);
setNotice(null);
let filters: SmartCollectionFilters;
- try { filters = filtersFromDraft(draft); } catch (caught) {
- setError(caught instanceof Error ? caught.message : "Invalid filters.");
+ try {
+ filters = filtersFromDraft(draft, tx);
+ } catch (caught) {
+ setError(caught instanceof Error ? caught.message : tx("Invalid filters.", "筛选条件无效。"));
+ return;
+ }
+ if (!draft.name.trim()) {
+ setError(tx("Choose a Smart Collection name.", "请输入智能合集名称。"));
return;
}
- if (!draft.name.trim()) { setError("Choose a Smart Collection name."); return; }
setBusy(true);
try {
const saved = selected
@@ -242,16 +333,34 @@ export function SmartCollectionsPage() {
setDraft(draftFromCollection(saved));
setShowBulkOrganizer(false);
syncCollectionLocation(saved.id);
- setNotice(selected ? "Smart Collection updated." : "Smart Collection saved.");
+ setNotice(
+ selected
+ ? tx("Smart Collection updated.", "智能合集已更新。")
+ : tx("Smart Collection saved.", "智能合集已保存。"),
+ );
} catch (caught) {
- setError(caught instanceof Error ? caught.message : "Could not save Smart Collection.");
+ setError(
+ caught instanceof Error
+ ? caught.message
+ : tx("Could not save Smart Collection.", "无法保存智能合集。"),
+ );
} finally {
setBusy(false);
}
}
async function remove() {
- if (!selected || !window.confirm(`Delete Smart Collection “${selected.name}”? Bookmarks are not deleted.`)) return;
+ if (
+ !selected ||
+ !window.confirm(
+ tx(
+ `Delete Smart Collection “${selected.name}”? Bookmarks are not deleted.`,
+ `确定删除智能合集「${selected.name}」吗?其中的书签不会被删除。`,
+ ),
+ )
+ ) {
+ return;
+ }
setBusy(true);
setError(null);
setNotice(null);
@@ -262,83 +371,298 @@ export function SmartCollectionsPage() {
setShowBulkOrganizer(false);
syncCollectionLocation(null);
await refresh();
- setNotice("Smart Collection deleted. Bookmarks were untouched.");
+ setNotice(tx("Smart Collection deleted. Bookmarks were untouched.", "智能合集已删除,书签未受影响。"));
} catch (caught) {
- setError(caught instanceof Error ? caught.message : "Could not delete Smart Collection.");
+ setError(
+ caught instanceof Error
+ ? caught.message
+ : tx("Could not delete Smart Collection.", "无法删除智能合集。"),
+ );
} finally {
setBusy(false);
}
}
const bulkButtonLabel = !selected
- ? "Bulk organize matches"
+ ? tx("Bulk organize matches", "批量整理匹配项")
: !draftMatchesSaved
- ? "Save changes before bulk organize"
+ ? tx("Save changes to bulk organize", "保存更改后可批量整理")
: showBulkOrganizer
- ? "Close bulk organizer"
+ ? tx("Close bulk organizer", "收起批量整理")
: selectedMatches.length > MAX_LIBRARY_BATCH
- ? `Bulk organize first ${MAX_LIBRARY_BATCH}`
- : `Bulk organize ${selectedMatches.length} match${selectedMatches.length === 1 ? "" : "es"}`;
+ ? tx(`Bulk organize first ${MAX_LIBRARY_BATCH}`, `批量整理前 ${MAX_LIBRARY_BATCH} 项`)
+ : tx(
+ `Bulk organize ${selectedMatches.length} match${selectedMatches.length === 1 ? "" : "es"}`,
+ `批量整理 ${selectedMatches.length} 项匹配`,
+ );
return (
-
- SMART LIBRARY
Saved filters, live results. Smart Collections are reusable views over your existing bookmarks. They never move, duplicate or mutate a bookmark.
- {collections.length} saved collections
-
+
+
+
{tx("Smart Collections", "智能合集")}
+
+ {tx(
+ "Reusable live filter views over your bookmark library. Collections never move, duplicate, or mutate bookmarks.",
+ "基于现有书签库的实时筛选视图,不会移动、复制或修改任何书签。",
+ )}
+
+
+
+
+ {collections.length}
+ {tx("collections", "个智能合集")}
+
+
+ {bookmarks.length}
+ {tx("bookmarks", "条书签")}
+
+
+
{error && {error}
}
{notice && {notice}
}
- Collections Counts update from current library state.
New
- {loading ? Loading…
: collections.length ? collections.map((collection) => (
- choose(collection)}>
- {collection.name} {Object.keys(collection.filters).length ? "Filtered view" : "All bookmarks"} {counts.get(collection.id) ?? 0}
+
+
+ {tx("Collections", "合集列表")}
+ {tx("Counts reflect live library state.", "数量随书签库实时更新。")}
+
+
+ {tx("New", "新建")}
- )) :
No Smart Collections yet.
}
+
+ {loading ? (
+ {tx("Loading…", "加载中…")}
+ ) : collections.length ? (
+ collections.map((collection) => {
+ const labels = formatCollectionFilterLabels(collection.filters, categoryById, locale, tx);
+ return (
+ choose(collection)}
+ >
+
+ {collection.name}
+
+ {labels.length ? labels.join(" · ") : tx("All bookmarks", "全部书签")}
+
+
+ {counts.get(collection.id) ?? 0}
+
+ );
+ })
+ ) : (
+
+ {tx("No Smart Collections yet.", "还没有智能合集。")}
+
+ )}
- {selected ? "EDIT COLLECTION" : "NEW COLLECTION"}
{selected ? selected.name : "Build a saved view"} {selected && void remove()}>Delete }{busy ? "Saving…" : selected ? "Save changes" : "Save collection"}
+
+
+
{selected ? selected.name : tx("New Smart Collection", "新建智能合集")}
+
+ {selected
+ ? tx("Edit filters and preview live matches.", "调整筛选条件并实时预览匹配书签。")
+ : tx("Combine rules to build a reusable view.", "组合筛选条件创建可复用的实时视图。")}
+
+
+
+ {selected && (
+ void remove()}
+ >
+ {tx("Delete", "删除")}
+
+ )}
+
+ {busy
+ ? tx("Saving…", "保存中…")
+ : selected
+ ? tx("Save changes", "保存更改")
+ : tx("Save collection", "保存合集")}
+
+
+
+
- Name setDraft({ ...draft, name: event.target.value })} placeholder="Dev docs" />
- Category setDraft({ ...draft, category: event.target.value })}>Any category Uncategorized {categories.map((category) => {category.name} )}
- Required tags setDraft({ ...draft, tagsText: event.target.value })} placeholder="dev, docs" />All listed tags must match.
- Domain setDraft({ ...draft, domain: event.target.value })} placeholder="github.com" />Includes matching subdomains.
- Health setDraft({ ...draft, healthStatus: event.target.value as Draft["healthStatus"] })}>Any health status {healthStatuses.map((status) => {healthLabels[status]} )}
- Inbox state setDraft({ ...draft, inbox: event.target.value as InboxDraft })}>Inbox + Library Inbox only Filed library only
+
+ {tx("Name", "名称")}
+ setDraft({ ...draft, name: event.target.value })}
+ placeholder={tx("Dev docs", "开发文档")}
+ />
+
+
+
+ {tx("Category", "分类")}
+ setDraft({ ...draft, category: event.target.value })}
+ >
+ {tx("Any category", "全部分类")}
+ {tx("Uncategorized", "未分类")}
+ {categories.map((category) => (
+
+ {category.name}
+
+ ))}
+
+
+
+
+ {tx("Required tags", "必选标签")}
+ setDraft({ ...draft, tagsText: event.target.value })}
+ placeholder={tx("dev, docs", "dev, 文档")}
+ />
+ {tx("All listed tags must match.", "需同时包含列出的全部标签。")}
+
+
+
+ {tx("Domain", "域名")}
+ setDraft({ ...draft, domain: event.target.value })}
+ placeholder="github.com"
+ />
+ {tx("Includes matching subdomains.", "同时匹配该域名的子域名。")}
+
+
+
+ {tx("Health", "健康检查")}
+ setDraft({ ...draft, healthStatus: event.target.value as Draft["healthStatus"] })}
+ >
+ {tx("Any health status", "全部健康状态")}
+ {HEALTH_STATUSES.map((status) => (
+
+ {HEALTH_STATUS_LABELS[locale][status]}
+
+ ))}
+
+
+
+
+ {tx("Inbox state", "收件箱状态")}
+ setDraft({ ...draft, inbox: event.target.value as InboxDraft })}
+ >
+ {tx("Inbox + Library", "收件箱与书签库")}
+ {tx("Inbox only", "仅收件箱")}
+ {tx("Filed library", "已归档书签库")}
+
+
-
Live preview {preview.length} of {bookmarks.length} bookmarks
+
+ {tx("Live preview", "实时预览")}
+
+ {tx(
+ `${preview.length} of ${bookmarks.length} bookmarks`,
+ `共 ${bookmarks.length} 条书签中匹配 ${preview.length} 条`,
+ )}
+
+
{selected && (
setShowBulkOrganizer((current) => !current)}
>
{bulkButtonLabel}
)}
- void refresh()}>Refresh data
+ void refresh()}>
+ {tx("Refresh data", "刷新数据")}
+
+
+
+ {draftFilterChips.length ? (
+ draftFilterChips.map((chip) => (
+
+ {chip}
+
+ ))
+ ) : (
+ {tx("All bookmarks", "全部书签")}
+ )}
+
+
{preview.slice(0, 100).map((bookmark) => (
- {bookmark.title} {hostLabel(bookmark.url)} · {bookmark.categoryId ? categoryById.get(bookmark.categoryId) ?? "Unknown category" : "Uncategorized"} {bookmark.description &&
{bookmark.description}
}
- {healthLabels[bookmark.healthStatus]} {inboxIds.has(bookmark.id) && Inbox }{(bookmarkTags[bookmark.id] ?? []).slice(0, 4).map((tag) => #{tag} )}
+
+
+
+
+ {bookmark.title}
+
+
+ {safeDomainLabel(bookmark.url)} ·{" "}
+ {bookmark.categoryId
+ ? categoryById.get(bookmark.categoryId) ?? tx("Unknown category", "未知分类")
+ : tx("Uncategorized", "未分类")}
+
+ {bookmark.description &&
{bookmark.description}
}
+
+
+
+ {HEALTH_STATUS_LABELS[locale][bookmark.healthStatus]}
+ {inboxIds.has(bookmark.id) && {tx("Inbox", "收件箱")} }
+ {(bookmarkTags[bookmark.id] ?? []).slice(0, 4).map((tag) => (
+ #{tag}
+ ))}
+
))}
- {!preview.length &&
No bookmarks match this filter combination.
}
- {preview.length > 100 &&
Showing the first 100 of {preview.length} matches.
}
+ {!preview.length && (
+
+ {tx("No bookmarks match this filter combination.", "没有书签匹配当前的筛选条件。")}
+
+ )}
+ {preview.length > 100 && (
+
+ {tx(
+ `Showing the first 100 of ${preview.length} matches.`,
+ `已显示前 100 条,共匹配 ${preview.length} 条。`,
+ )}
+
+ )}
@@ -347,10 +671,14 @@ export function SmartCollectionsPage() {
-
COLLECTION → BULK REVIEW
-
{selected.name}
+
{tx(`Bulk organize · ${selected.name}`, `批量整理 · ${selected.name}`)}
-
{selectedMatches.length} live match{selectedMatches.length === 1 ? "" : "es"} · up to {MAX_LIBRARY_BATCH} selected per batch
+
+ {tx(
+ `${selectedMatches.length} live match${selectedMatches.length === 1 ? "" : "es"} · up to ${MAX_LIBRARY_BATCH} per batch`,
+ `实时匹配 ${selectedMatches.length} 项 · 单批最多选择 ${MAX_LIBRARY_BATCH} 项`,
+ )}
+
diff --git a/apps/web/src/TransferManager.tsx b/apps/web/src/TransferManager.tsx
index f0d7fed..67183a2 100644
--- a/apps/web/src/TransferManager.tsx
+++ b/apps/web/src/TransferManager.tsx
@@ -1,6 +1,14 @@
+/**
+ * [INPUT]: depends on Bookmark, Category, HEALTH_POLICY_LABELS from @dockmark/core; bookmark/category/tag CRUD from ./api and ./tag-api; parser/exporter from ./bookmark-transfer; NativeBookmarkImport from ./NativeBookmarkImport; BookmarkFavicon and safeDomainLabel from ./BookmarkFavicon; useI18n from ./i18n
+ * [OUTPUT]: exports TransferManager component for file-based import/export and native browser bookmark sync hosting
+ * [POS]: import and export tool surface in apps/web/src, paired with transfer.css and NativeBookmarkImport
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
+
import { useMemo, useState, type ChangeEvent } from "react";
-import type { Bookmark, Category } from "@dockmark/core";
+import { HEALTH_POLICY_LABELS, type Bookmark, type Category } from "@dockmark/core";
import { createBookmark, createCategory } from "./api";
+import { BookmarkFavicon, safeDomainLabel } from "./BookmarkFavicon";
import {
buildImportPreview,
downloadTextFile,
@@ -9,6 +17,7 @@ import {
parseBookmarkFile,
type ImportCandidate,
} from "./bookmark-transfer";
+import { useI18n } from "./i18n";
import { NativeBookmarkImport } from "./NativeBookmarkImport";
import { listBookmarkTags, replaceBookmarkTags } from "./tag-api";
import "./transfer.css";
@@ -29,6 +38,7 @@ function categoryKey(value: string) {
}
export function TransferManager({ bookmarks, categories, onChanged, onOpenExtension }: Props) {
+ const { locale, tx } = useI18n();
const [items, setItems] = useState([]);
const [fileName, setFileName] = useState(null);
const [error, setError] = useState(null);
@@ -44,6 +54,15 @@ export function TransferManager({ bookmarks, categories, onChanged, onOpenExtens
selected: items.filter((item) => item.status === "new" && item.selected).length,
}), [items]);
+ function candidateStatusLabel(item: ImportCandidate) {
+ if (item.status === "new" && item.healthPolicy === "local-only") {
+ return HEALTH_POLICY_LABELS[locale]["local-only"];
+ }
+ if (item.status === "new") return tx("New", "新增");
+ if (item.status === "duplicate") return tx("Duplicate", "重复");
+ return tx("Invalid", "无效");
+ }
+
async function loadFile(event: ChangeEvent) {
const file = event.target.files?.[0];
event.target.value = "";
@@ -54,26 +73,32 @@ export function TransferManager({ bookmarks, categories, onChanged, onOpenExtens
try {
const text = await file.text();
const parsed = parseBookmarkFile(file.name, text);
- if (!parsed.length) throw new Error("No bookmarks were found in this file.");
+ if (!parsed.length) throw new Error(tx("No bookmarks were found in this file.", "该文件中未找到可导入的书签。"));
setItems(buildImportPreview(parsed, bookmarks));
setFileName(file.name);
} catch (caught) {
setItems([]);
setFileName(file.name);
- setError(caught instanceof Error ? caught.message : "Could not read this bookmark file.");
+ setError(
+ caught instanceof Error
+ ? caught.message
+ : tx("Could not read this bookmark file.", "无法读取该书签文件。"),
+ );
}
}
function toggle(id: string) {
- setItems((current) => current.map((item) =>
- item.id === id && item.status === "new" ? { ...item, selected: !item.selected } : item,
- ));
+ setItems((current) =>
+ current.map((item) =>
+ item.id === id && item.status === "new" ? { ...item, selected: !item.selected } : item,
+ ),
+ );
}
function selectAll(selected: boolean) {
- setItems((current) => current.map((item) =>
- item.status === "new" ? { ...item, selected } : item,
- ));
+ setItems((current) =>
+ current.map((item) => (item.status === "new" ? { ...item, selected } : item)),
+ );
}
async function importSelected() {
@@ -85,9 +110,11 @@ export function TransferManager({ bookmarks, categories, onChanged, onOpenExtens
setMessage(null);
try {
const categoryMap = new Map(categories.map((category) => [categoryKey(category.name), category.id]));
- const requiredCategories = Array.from(new Set(
- selected.map((item) => item.categoryName?.trim()).filter((name): name is string => Boolean(name)),
- ));
+ const requiredCategories = Array.from(
+ new Set(
+ selected.map((item) => item.categoryName?.trim()).filter((name): name is string => Boolean(name)),
+ ),
+ );
for (const name of requiredCategories) {
const key = categoryKey(name);
@@ -105,25 +132,27 @@ export function TransferManager({ bookmarks, categories, onChanged, onOpenExtens
for (let offset = 0; offset < selected.length; offset += chunkSize) {
const chunk = selected.slice(offset, offset + chunkSize);
- const results = await Promise.allSettled(chunk.map(async (item) => {
- const bookmark = await createBookmark({
- title: item.title.slice(0, 200),
- url: item.normalizedUrl ?? item.url,
- categoryId: item.categoryName ? categoryMap.get(categoryKey(item.categoryName)) ?? null : null,
- ...(item.description ? { description: item.description.slice(0, 2000) } : {}),
- ...(item.iconUrl ? { iconUrl: item.iconUrl.slice(0, 4096) } : {}),
- ...(item.healthPolicy ? { healthPolicy: item.healthPolicy } : {}),
- });
- let tagsStored = true;
- if (item.tags?.length) {
- try {
- await replaceBookmarkTags(bookmark.id, item.tags);
- } catch {
- tagsStored = false;
+ const results = await Promise.allSettled(
+ chunk.map(async (item) => {
+ const bookmark = await createBookmark({
+ title: item.title.slice(0, 200),
+ url: item.normalizedUrl ?? item.url,
+ categoryId: item.categoryName ? categoryMap.get(categoryKey(item.categoryName)) ?? null : null,
+ ...(item.description ? { description: item.description.slice(0, 2000) } : {}),
+ ...(item.iconUrl ? { iconUrl: item.iconUrl.slice(0, 4096) } : {}),
+ ...(item.healthPolicy ? { healthPolicy: item.healthPolicy } : {}),
+ });
+ let tagsStored = true;
+ if (item.tags?.length) {
+ try {
+ await replaceBookmarkTags(bookmark.id, item.tags);
+ } catch {
+ tagsStored = false;
+ }
}
- }
- return { bookmark, tagsStored };
- }));
+ return { bookmark, tagsStored };
+ }),
+ );
results.forEach((result, index) => {
const item = chunk[index];
@@ -140,9 +169,14 @@ export function TransferManager({ bookmarks, categories, onChanged, onOpenExtens
await onChanged();
setMessage(
- `Imported ${imported} bookmark${imported === 1 ? "" : "s"}` +
- `${failed ? `; ${failed} failed` : ""}` +
- `${tagFailed ? `; ${tagFailed} imported but their tags could not be restored` : ""}.`,
+ tx(
+ `Imported ${imported} bookmark${imported === 1 ? "" : "s"}` +
+ `${failed ? `; ${failed} failed` : ""}` +
+ `${tagFailed ? `; ${tagFailed} imported but their tags could not be restored` : ""}.`,
+ `已导入 ${imported} 条书签` +
+ `${failed ? `;${failed} 条失败` : ""}` +
+ `${tagFailed ? `;其中 ${tagFailed} 条的标签未能恢复` : ""}。`,
+ ),
);
if (failed) {
setItems((current) => current.filter((item) => failedIds.has(item.id) || item.status !== "new"));
@@ -151,7 +185,7 @@ export function TransferManager({ bookmarks, categories, onChanged, onOpenExtens
setFileName(null);
}
} catch (caught) {
- setError(caught instanceof Error ? caught.message : "Import failed.");
+ setError(caught instanceof Error ? caught.message : tx("Import failed.", "导入失败,请稍后重试。"));
} finally {
setBusy(false);
}
@@ -168,7 +202,11 @@ export function TransferManager({ bookmarks, categories, onChanged, onOpenExtens
"application/json",
);
} catch (caught) {
- setError(caught instanceof Error ? caught.message : "Could not export Dockmark JSON.");
+ setError(
+ caught instanceof Error
+ ? caught.message
+ : tx("Could not export Dockmark JSON.", "无法导出 Dockmark JSON 文件。"),
+ );
} finally {
setBusy(false);
}
@@ -180,31 +218,80 @@ export function TransferManager({ bookmarks, categories, onChanged, onOpenExtens
return (
-
-
-
MOVE WITHOUT LOCK-IN
-
Bring bookmarks in. Take them anywhere.
+
+
+
+ {tx(`${bookmarks.length} stored`, `已保存 ${bookmarks.length} 条`)}
+
+
+ {tx(
+ `${categories.length} categor${categories.length === 1 ? "y" : "ies"}`,
+ `${categories.length} 个分类`,
+ )}
+
+
+
-
+
- Import file Chrome, Edge, Firefox Netscape HTML or Dockmark / simple JSON.
+
+
+
{tx("Import file", "从文件导入")}
+
+ {tx(
+ "Chrome, Edge, Firefox Netscape HTML or Dockmark / simple JSON.",
+ "支持 Chrome、Edge、Firefox 导出的 Netscape HTML,以及 Dockmark / 通用 JSON。",
+ )}
+
+
+
- Choose bookmark file
- Nothing is written until you review and confirm.
+ {tx("Choose bookmark file", "选择书签文件")}
+ {tx("Nothing is written until you review and confirm.", "在预览并确认前不会写入任何数据。")}
- Export JSON preserves Dockmark metadata and tags; HTML imports into conventional browsers.
+
+
+
{tx("Export", "导出书签库")}
+
+ {tx(
+ "JSON preserves Dockmark metadata and tags; HTML imports into conventional browsers.",
+ "JSON 完整保留 Dockmark 元数据与标签;HTML 可直接导入常见浏览器。",
+ )}
+
+
+
- void exportJson()} disabled={busy || !bookmarks.length}>{busy ? "Preparing…" : "Export JSON"}
- Export HTML
+ void exportJson()}
+ disabled={busy || !bookmarks.length}
+ >
+ {busy ? tx("Preparing…", "正在生成…") : tx("Export JSON", "导出 JSON")}
+
+
+ {tx("Export HTML", "导出 HTML")}
+
@@ -215,36 +302,78 @@ export function TransferManager({ bookmarks, categories, onChanged, onOpenExtens
{items.length > 0 && (
-
FILE IMPORT PREVIEW
{fileName}
+
+
{tx("File import preview", "文件导入预览")}
+
{fileName}
+
- selectAll(true)}>Select new
- selectAll(false)}>Clear
- void importSelected()} disabled={busy || !stats.selected}>{busy ? "Importing…" : `Import ${stats.selected}`}
+ selectAll(true)}>
+ {tx("Select new", "全选新增")}
+
+ selectAll(false)}>
+ {tx("Clear", "清空选择")}
+
+ void importSelected()}
+ disabled={busy || !stats.selected}
+ >
+ {busy ? tx("Importing…", "导入中…") : tx(`Import ${stats.selected}`, `导入 ${stats.selected} 条`)}
+
- {stats.total} Total
- {stats.fresh} New
- {stats.duplicate} Duplicate
- {stats.local} Local only
- {stats.invalid} Invalid
+ {stats.total} {tx("Total", "总计")}
+ {stats.fresh} {tx("New", "新增")}
+ {stats.duplicate} {tx("Duplicate", "重复")}
+ {stats.local} {HEALTH_POLICY_LABELS[locale]["local-only"]}
+ {stats.invalid} {tx("Invalid", "无效")}
- {items.slice(0, 500).map((item) => (
-
- toggle(item.id)} />
-
- {item.title}
- {item.normalizedUrl ?? item.url}
- {item.categoryName ?? "Uncategorized"}{item.tags?.length ? ` · Tags: ${item.tags.join(", ")}` : ""}
-
- {item.status === "new" && item.healthPolicy === "local-only" ? "LOCAL ONLY" : item.status.toUpperCase()}
-
- ))}
+ {items.slice(0, 500).map((item) => {
+ const targetUrl = item.normalizedUrl ?? item.url;
+ return (
+
+ toggle(item.id)}
+ />
+
+
+ {item.title}
+ {safeDomainLabel(targetUrl)} · {targetUrl}
+
+ {item.categoryName ?? tx("Uncategorized", "未分类")}
+ {item.tags?.length
+ ? tx(` · Tags: ${item.tags.join(", ")}`, ` · 标签:${item.tags.join("、")}`)
+ : ""}
+
+
+
+ {candidateStatusLabel(item)}
+
+
+ );
+ })}
- {items.length > 500 && Showing the first 500 of {items.length} entries; all selected entries will still import.
}
+ {items.length > 500 && (
+
+ {tx(
+ `Showing the first 500 of ${items.length} entries; all selected entries will still import.`,
+ `仅展示前 500 条(共 ${items.length} 条);其余已选条目仍会一并导入。`,
+ )}
+
+ )}
)}
diff --git a/apps/web/src/WorkspaceManager.tsx b/apps/web/src/WorkspaceManager.tsx
index 68250fc..6544fae 100644
--- a/apps/web/src/WorkspaceManager.tsx
+++ b/apps/web/src/WorkspaceManager.tsx
@@ -1,9 +1,17 @@
+/**
+ * [INPUT]: depends on WorkspaceWithItems, WorkspaceItem, WorkspaceOpenMode, Bookmark, HEALTH_POLICY_LABELS from @dockmark/core; workspace CRUD from ./api; bridge launcher from ./browser-bridge; BookmarkFavicon and safeDomainLabel from ./BookmarkFavicon; useI18n from ./i18n
+ * [OUTPUT]: exports WorkspaceManager component for managing reusable cross-browser tab sets
+ * [POS]: workspace management tool surface in apps/web/src, paired with workspaces.css
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
+
import { useEffect, useMemo, useState, type FormEvent } from "react";
-import type {
- Bookmark,
- WorkspaceItem,
- WorkspaceOpenMode,
- WorkspaceWithItems,
+import {
+ HEALTH_POLICY_LABELS,
+ type Bookmark,
+ type WorkspaceItem,
+ type WorkspaceOpenMode,
+ type WorkspaceWithItems,
} from "@dockmark/core";
import {
createWorkspace,
@@ -13,7 +21,9 @@ import {
updateWorkspace,
updateWorkspaceItem,
} from "./api";
+import { BookmarkFavicon, safeDomainLabel } from "./BookmarkFavicon";
import { getBridgeStatus, openWorkspaceWithBridge } from "./browser-bridge";
+import { useI18n } from "./i18n";
interface Props {
workspaces: WorkspaceWithItems[];
@@ -32,16 +42,6 @@ interface ItemDraft {
const emptyItemDraft: ItemDraft = { title: "", url: "", openMode: "reuse" };
-function messageFrom(error: unknown) {
- return error instanceof Error ? error.message : "Something went wrong.";
-}
-
-function openModeLabel(mode: WorkspaceOpenMode) {
- if (mode === "new-tab") return "New tab";
- if (mode === "pinned") return "Pinned · extension";
- return "Reuse if possible";
-}
-
export function WorkspaceManager({
workspaces,
bookmarks,
@@ -50,6 +50,7 @@ export function WorkspaceManager({
onSelectedChange,
onChanged,
}: Props) {
+ const { locale, tx } = useI18n();
const [newName, setNewName] = useState("");
const [newDescription, setNewDescription] = useState("");
const [editingMeta, setEditingMeta] = useState(false);
@@ -68,6 +69,16 @@ export function WorkspaceManager({
[selectedWorkspaceId, workspaces],
);
+ const bookmarkById = useMemo(
+ () => new Map(bookmarks.map((bookmark) => [bookmark.id, bookmark])),
+ [bookmarks],
+ );
+
+ const totalTabs = useMemo(
+ () => workspaces.reduce((sum, workspace) => sum + workspace.items.length, 0),
+ [workspaces],
+ );
+
useEffect(() => {
if (!selectedWorkspaceId && workspaces[0]) onSelectedChange(workspaces[0].id);
if (selectedWorkspaceId && !workspaces.some((workspace) => workspace.id === selectedWorkspaceId)) {
@@ -75,6 +86,16 @@ export function WorkspaceManager({
}
}, [onSelectedChange, selectedWorkspaceId, workspaces]);
+ function messageFrom(caught: unknown) {
+ return caught instanceof Error ? caught.message : tx("Something went wrong.", "操作失败,请稍后重试。");
+ }
+
+ function openModeLabel(mode: WorkspaceOpenMode) {
+ if (mode === "new-tab") return tx("New tab", "新建标签页");
+ if (mode === "pinned") return tx("Pinned · extension", "固定 · 扩展");
+ return tx("Reuse if possible", "尽量复用");
+ }
+
async function run(action: () => Promise
) {
setBusy(true);
setError(null);
@@ -200,31 +221,61 @@ export function WorkspaceManager({
}
}
+ const orderedItems = useMemo(
+ () => (selected ? [...selected.items].sort((a, b) => a.position - b.position) : []),
+ [selected],
+ );
+
return (
-
-
-
WORKSPACES
-
Open the same working set from any browser.
+
+
+
+ {tx(
+ `${workspaces.length} workspace${workspaces.length === 1 ? "" : "s"}`,
+ `${workspaces.length} 个工作区`,
+ )}
+
+
+ {tx(`${totalTabs} tab${totalTabs === 1 ? "" : "s"}`, `${totalTabs} 个标签页`)}
+
+
+
{error &&
{error}
}
-
Your workspaces {workspaces.length}
+
+
{tx("Your workspaces", "我的工作区")}
+ {workspaces.length}
+
{workspaces.map((workspace) => (
onSelectedChange(workspace.id)}
>
{workspace.icon ?? workspace.name.slice(0, 1).toUpperCase()}
- {workspace.name} {workspace.items.length} tabs
+
+ {workspace.name}
+
+ {tx(
+ `${workspace.items.length} tab${workspace.items.length === 1 ? "" : "s"}`,
+ `${workspace.items.length} 个标签页`,
+ )}
+
+
))}
- {!loading && !workspaces.length &&
Create your first workspace above.
}
+ {!loading && !workspaces.length && (
+
{tx("Create your first workspace above.", "请在上方创建你的第一个工作区。")}
+ )}
@@ -246,34 +307,76 @@ export function WorkspaceManager({
{editingMeta ? (
- setMetaName(event.target.value)} maxLength={100} />
- setMetaDescription(event.target.value)} maxLength={1000} placeholder="Description" />
+ setMetaName(event.target.value)}
+ placeholder={tx("Workspace name", "工作区名称")}
+ maxLength={100}
+ />
+ setMetaDescription(event.target.value)}
+ maxLength={1000}
+ placeholder={tx("Description", "描述")}
+ />
- Save
- setEditingMeta(false)}>Cancel
+ {tx("Save", "保存")}
+ setEditingMeta(false)}>
+ {tx("Cancel", "取消")}
+
) : (
-
-
{selected.icon ?? selected.name.slice(0, 1).toUpperCase()}
{selected.name}
-
{selected.description ?? "A reusable set of links that stays portable across browsers."}
+
+
+
+ {selected.icon ?? selected.name.slice(0, 1).toUpperCase()}
+
+
{selected.name}
+
+
+ {selected.description ??
+ tx(
+ "A reusable set of links that stays portable across browsers.",
+ "可在不同浏览器间随时打开的固定链接集合。",
+ )}
+
- void openAll()}>Open all · {selected.items.length}
- Edit
+ void openAll()}
+ >
+ {tx(`Open all · ${selected.items.length}`, `全部打开 · ${selected.items.length}`)}
+
+
+ {tx("Edit", "编辑")}
+
{
- if (window.confirm(`Delete workspace “${selected.name}” and its items?`)) {
+ if (
+ window.confirm(
+ tx(
+ `Delete workspace “${selected.name}” and its items?`,
+ `确定删除工作区“${selected.name}”及其全部条目吗?`,
+ ),
+ )
+ ) {
void run(async () => {
await deleteWorkspace(selected.id);
onSelectedChange(null);
});
}
}}
- >Delete
+ >
+ {tx("Delete", "删除")}
+
)}
@@ -281,75 +384,196 @@ export function WorkspaceManager({
- Add saved bookmark Keep the item linked to an existing Dockmark bookmark.
- setBookmarkId(event.target.value)}>
- Select bookmark…
- {bookmarks.map((bookmark) => {bookmark.title} · {bookmark.url} )}
+
+
+
{tx("Add saved bookmark", "添加已保存书签")}
+
{tx("Link an existing Dockmark bookmark to this workspace.", "将书签库中的已有书签加入当前工作区。")}
+
+
+ setBookmarkId(event.target.value)}
+ aria-label={tx("Select bookmark", "选择书签")}
+ >
+ {tx("Select bookmark…", "选择书签…")}
+ {bookmarks.map((bookmark) => (
+
+ {bookmark.title} · {bookmark.url}
+
+ ))}
- setBookmarkMode(event.target.value as WorkspaceOpenMode)}>
- Reuse if possible
- Always new tab
- Pinned when extension is available
+ setBookmarkMode(event.target.value as WorkspaceOpenMode)}
+ aria-label={tx("Open mode", "打开方式")}
+ >
+ {tx("Reuse if possible", "尽量复用已有标签页")}
+ {tx("Always new tab", "始终新建标签页")}
+ {tx("Pinned when extension is available", "扩展可用时固定标签页")}
- Add bookmark
+
+ {tx("Add bookmark", "添加书签")}
+
- Add custom URL Useful for URLs you do not want in the main bookmark library.
- setCustomDraft({ ...customDraft, title: event.target.value })} placeholder="Local dashboard" />
- setCustomDraft({ ...customDraft, url: event.target.value })} placeholder="localhost:3000" inputMode="url" />
- setCustomDraft({ ...customDraft, openMode: event.target.value as WorkspaceOpenMode })}>
- Reuse if possible
- Always new tab
- Pinned when extension is available
+
+
+
{tx("Add custom URL", "添加自定义链接")}
+
{tx("Useful for URLs you do not want in the main bookmark library.", "适合不需要放进主书签库的临时或本地链接。")}
+
+
+ setCustomDraft({ ...customDraft, title: event.target.value })}
+ placeholder={tx("Local dashboard", "本地控制台")}
+ />
+ setCustomDraft({ ...customDraft, url: event.target.value })}
+ placeholder="localhost:3000"
+ inputMode="url"
+ />
+ setCustomDraft({ ...customDraft, openMode: event.target.value as WorkspaceOpenMode })}
+ aria-label={tx("Open mode", "打开方式")}
+ >
+ {tx("Reuse if possible", "尽量复用已有标签页")}
+ {tx("Always new tab", "始终新建标签页")}
+ {tx("Pinned when extension is available", "扩展可用时固定标签页")}
- Add URL
+
+ {tx("Add URL", "添加链接")}
+
- {[...selected.items].sort((a, b) => a.position - b.position).map((item, index, ordered) => (
-
- {editingItemId === item.id ? (
- saveItem(event, item.id)}>
- setItemDraft({ ...itemDraft, title: event.target.value })} />
- setItemDraft({ ...itemDraft, url: event.target.value })} inputMode="url" />
- setItemDraft({ ...itemDraft, openMode: event.target.value as WorkspaceOpenMode })}>
- Reuse if possible
- Always new tab
- Pinned when extension is available
-
- Save setEditingItemId(null)}>Cancel
-
- ) : (
- <>
- {String(index + 1).padStart(2, "0")}
-
-
{item.title}
-
{item.url}
-
-
{openModeLabel(item.openMode)}
-
{item.bookmarkId ? "Saved bookmark" : "Custom URL"}
- {item.healthPolicy === "local-only" &&
Local only }
+ {orderedItems.map((item, index) => {
+ const linkedBookmark = item.bookmarkId ? bookmarkById.get(item.bookmarkId) : undefined;
+ return (
+
+ {editingItemId === item.id ? (
+ saveItem(event, item.id)}>
+ setItemDraft({ ...itemDraft, title: event.target.value })}
+ placeholder={tx("Title", "标题")}
+ />
+ setItemDraft({ ...itemDraft, url: event.target.value })}
+ placeholder="https://example.com"
+ inputMode="url"
+ />
+ setItemDraft({ ...itemDraft, openMode: event.target.value as WorkspaceOpenMode })}
+ >
+ {tx("Reuse if possible", "尽量复用已有标签页")}
+ {tx("Always new tab", "始终新建标签页")}
+ {tx("Pinned when extension is available", "扩展可用时固定标签页")}
+
+
+ {tx("Save", "保存")}
+ setEditingItemId(null)}>
+ {tx("Cancel", "取消")}
+
-
-
- void moveItem(item, -1)}>↑
- void moveItem(item, 1)}>↓
- beginItemEdit(item)}>Edit
- { if (window.confirm(`Remove “${item.title}” from this workspace?`)) void run(() => deleteWorkspaceItem(selected.id, item.id)); }}>Remove
-
- >
- )}
-
- ))}
+
+ ) : (
+ <>
+
{String(index + 1).padStart(2, "0")}
+
+
+
{item.title}
+
{item.url}
+
+ {safeDomainLabel(item.url)}
+ {openModeLabel(item.openMode)}
+ {item.bookmarkId ? tx("Saved bookmark", "已保存书签") : tx("Custom URL", "自定义链接")}
+ {item.healthPolicy === "local-only" && (
+ {HEALTH_POLICY_LABELS[locale]["local-only"]}
+ )}
+
+
+
+ void moveItem(item, -1)}
+ >
+ ↑
+
+ void moveItem(item, 1)}
+ >
+ ↓
+
+ beginItemEdit(item)}>
+ {tx("Edit", "编辑")}
+
+ {
+ if (
+ window.confirm(
+ tx(
+ `Remove “${item.title}” from this workspace?`,
+ `确定从当前工作区移除“${item.title}”吗?`,
+ ),
+ )
+ ) {
+ void run(() => deleteWorkspaceItem(selected.id, item.id));
+ }
+ }}
+ >
+ {tx("Remove", "移除")}
+
+
+ >
+ )}
+
+ );
+ })}
- {!selected.items.length &&
This workspace is empty. Add a saved bookmark or custom URL above.
}
+ {!orderedItems.length && (
+
+ {tx("This workspace is empty.", "该工作区暂无条目。")}
+ {tx("Add a saved bookmark or custom URL above.", "请在上方添加已保存书签或自定义链接。")}
+
+ )}
- Web mode opens normal tabs. When the browser bridge is connected, “Reuse” and “Pinned” are applied by the extension.
+
+ {tx(
+ "Web mode opens normal tabs. When the Browser Bridge is connected, “Reuse” and “Pinned” are applied by the extension.",
+ "网页模式会以普通标签页打开;连接浏览器桥接后,扩展会自动应用“复用”与“固定”模式。",
+ )}
+
>
) : (
- No workspace selected. Create one to save a reusable group of tabs.
+
+ {tx("No workspace selected.", "未选择工作区。")}
+ {tx("Create one to save a reusable group of tabs.", "创建一个工作区以保存可复用的标签页组。")}
+
)}
diff --git a/apps/web/src/ai-organization.css b/apps/web/src/ai-organization.css
index e4dead9..95c63f6 100644
--- a/apps/web/src/ai-organization.css
+++ b/apps/web/src/ai-organization.css
@@ -1,40 +1,56 @@
-.ai-organization-section { margin-top: 34px; }
-.ai-provider-card, .ai-selection-card { display: grid; align-content: start; gap: 14px; }
+.ai-organization-section { margin-top: 24px; }
+.ai-compact-heading h2 { margin: 0; font-size: 18px; letter-spacing: -0.02em; }
+.ai-compact-heading p { margin: 4px 0 0; }
+.ai-preview-subtitle { margin: 3px 0 0; color: var(--dm-text-muted); font-size: 12px; }
+.ai-provider-card, .ai-selection-card { display: grid; align-content: start; gap: 13px; }
.ai-provider-actions, .ai-selection-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
-.ai-bookmark-search { width: 100%; height: 42px; padding: 0 11px; border: 1px solid var(--dm-border-strong); border-radius: 10px; outline: 0; color: var(--dm-text); background: var(--dm-bg-soft); }
+.ai-provider-actions button,
+.ai-selection-actions button,
+.ai-queue-filters button,
+.ai-generate-button,
+.ai-preview .preview-actions button {
+ white-space: nowrap;
+ flex-shrink: 0;
+}
+.ai-queue-filters button:active,
+.ai-generate-button:active:not(:disabled),
+.ai-preview .preview-actions button:active:not(:disabled) {
+ transform: translateY(1px);
+}
+.ai-bookmark-search { width: 100%; height: 40px; padding: 0 11px; border: 1px solid var(--dm-border-strong); border-radius: 10px; outline: 0; color: var(--dm-text); background: var(--dm-bg-soft); }
.ai-bookmark-search:focus { border-color: var(--dm-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--dm-accent) 15%, transparent); }
-.ai-queue-summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
-.ai-queue-summary > span { color: var(--dm-text-muted); font-size: 10px; }
+.ai-queue-summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
+.ai-queue-summary > span { color: var(--dm-text-muted); font-size: 11px; }
.ai-queue-filters { display: flex; gap: 6px; flex-wrap: wrap; }
-.ai-queue-filters button { min-height: 30px; padding: 0 10px; border: 1px solid var(--dm-border); border-radius: 999px; color: var(--dm-text-muted); background: var(--dm-bg-soft); font-size: 10px; cursor: pointer; }
+.ai-queue-filters button { min-height: 28px; padding: 0 10px; border: 1px solid var(--dm-border); border-radius: 999px; color: var(--dm-text-muted); background: var(--dm-bg-soft); font-size: 11px; cursor: pointer; transition: border-color .14s ease, background .14s ease, color .14s ease; }
.ai-queue-filters button:hover { border-color: var(--dm-border-strong); color: var(--dm-text); }
-.ai-queue-filters button.active { border-color: color-mix(in srgb, var(--dm-accent) 58%, var(--dm-border)); color: var(--dm-accent); background: color-mix(in srgb, var(--dm-accent-bg) 58%, var(--dm-bg-soft)); }
-.ai-selection-warning { margin: -2px 0 0; padding: 9px 10px; border: 1px solid color-mix(in srgb, var(--dm-accent) 38%, var(--dm-border)); border-radius: 9px; color: var(--dm-text-soft); background: color-mix(in srgb, var(--dm-accent-bg) 35%, var(--dm-bg-soft)); font-size: 10px; line-height: 1.45; }
+.ai-queue-filters button.active { border-color: color-mix(in srgb, var(--dm-accent) 58%, var(--dm-border)); color: var(--dm-accent-strong); background: var(--dm-accent-bg); }
+.ai-selection-warning { margin: -2px 0 0; padding: 9px 10px; border: 1px solid color-mix(in srgb, var(--dm-accent) 38%, var(--dm-border)); border-radius: 9px; color: var(--dm-text-soft); background: color-mix(in srgb, var(--dm-accent-bg) 35%, var(--dm-bg-soft)); font-size: 11px; line-height: 1.45; }
.ai-bookmark-list { max-height: 360px; overflow: auto; display: grid; gap: 5px; padding-right: 4px; scrollbar-gutter: stable; }
-.ai-bookmark-row { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 10px; min-height: 56px; padding: 8px 10px; border: 1px solid var(--dm-border); border-radius: 11px; background: var(--dm-bg-soft); cursor: pointer; }
+.ai-bookmark-row { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 10px; min-height: 52px; padding: 8px 10px; border: 1px solid var(--dm-border); border-radius: 11px; background: var(--dm-bg-soft); cursor: pointer; }
.ai-bookmark-row:hover { border-color: var(--dm-border-strong); background: var(--dm-bg-raised); }
-.ai-bookmark-row.is-generated { border-color: color-mix(in srgb, var(--dm-accent) 32%, var(--dm-border)); }
-.ai-bookmark-row.is-generated > em { color: var(--dm-accent); }
+.ai-bookmark-row.is-generated { border-color: color-mix(in srgb, var(--dm-accent) 36%, var(--dm-border)); }
+.ai-bookmark-row.is-generated > em { color: var(--dm-accent-strong); }
.ai-bookmark-row > input, .ai-suggestion-heading > input { accent-color: var(--dm-accent); }
-.ai-bookmark-row > span, .ai-suggestion-heading > span { display: grid; gap: 3px; min-width: 0; }
+.ai-bookmark-row > span, .ai-suggestion-heading > span { display: grid; gap: 2px; min-width: 0; }
.ai-bookmark-row strong, .ai-bookmark-row small, .ai-suggestion-heading strong, .ai-suggestion-heading small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-bookmark-row strong, .ai-suggestion-heading strong { color: var(--dm-text); font-size: 12px; }
-.ai-bookmark-row small, .ai-suggestion-heading small { color: var(--dm-text-muted); font-size: 10px; }
-.ai-bookmark-row em, .ai-suggestion-heading em { max-width: 190px; overflow: hidden; text-overflow: ellipsis; color: var(--dm-text-muted); font-size: 10px; font-style: normal; letter-spacing: .07em; text-transform: uppercase; white-space: nowrap; }
+.ai-bookmark-row small, .ai-suggestion-heading small { color: var(--dm-text-muted); font-size: 11px; }
+.ai-bookmark-row em, .ai-suggestion-heading em { max-width: 190px; overflow: hidden; text-overflow: ellipsis; color: var(--dm-text-muted); font-size: 10px; font-style: normal; white-space: nowrap; }
.ai-bookmark-row.is-protected { opacity: .55; cursor: not-allowed; }
-.ai-queue-empty { margin: 0; padding: 24px 12px; color: var(--dm-text-muted); font-size: 11px; text-align: center; }
+.ai-queue-empty { margin: 0; padding: 24px 12px; color: var(--dm-text-muted); font-size: 12px; text-align: center; }
.ai-generate-button { justify-self: start; }
-.ai-preview { overflow: hidden; border: 1px solid var(--dm-border); border-radius: 18px; background: color-mix(in srgb, var(--dm-bg-card) 86%, transparent); }
+.ai-preview { overflow: hidden; border: 1px solid var(--dm-border); border-radius: 16px; background: var(--dm-bg-card); }
.ai-preview-list { display: grid; gap: 8px; max-height: 720px; overflow: auto; padding: 8px; scrollbar-gutter: stable; }
-.ai-suggestion-row { display: grid; gap: 12px; padding: 13px; border: 1px solid var(--dm-border); border-radius: 13px; background: var(--dm-bg-soft); }
+.ai-suggestion-row { display: grid; gap: 11px; padding: 13px; border: 1px solid var(--dm-border); border-radius: 13px; background: var(--dm-bg-soft); }
.ai-suggestion-heading { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 10px; }
-.ai-suggestion-heading em { color: var(--dm-accent); }
+.ai-suggestion-heading em { color: var(--dm-accent-strong); font-weight: 600; }
.ai-field-diffs { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
-.ai-field-diffs > div { display: grid; grid-template-columns: 72px minmax(0,1fr); gap: 5px 9px; align-items: baseline; min-width: 0; padding: 10px; border: 1px solid var(--dm-border); border-radius: 10px; background: var(--dm-bg-card); }
-.ai-field-diffs > div.is-changed { border-color: color-mix(in srgb, var(--dm-accent) 58%, var(--dm-border)); background: color-mix(in srgb, var(--dm-accent-bg) 55%, var(--dm-bg-card)); }
-.ai-field-diffs > div > span { grid-column: 1 / -1; color: var(--dm-accent); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
-.ai-field-diffs small { color: var(--dm-text-muted); font-size: 10px; text-transform: uppercase; letter-spacing: .05em; }
-.ai-field-diffs strong { min-width: 0; overflow-wrap: anywhere; color: var(--dm-text-soft); font-size: 11px; line-height: 1.45; }
+.ai-field-diffs > div { display: grid; grid-template-columns: 64px minmax(0,1fr); gap: 5px 9px; align-items: baseline; min-width: 0; padding: 10px; border: 1px solid var(--dm-border); border-radius: 10px; background: var(--dm-bg-card); }
+.ai-field-diffs > div.is-changed { border-color: color-mix(in srgb, var(--dm-accent) 56%, var(--dm-border)); background: color-mix(in srgb, var(--dm-accent-bg) 55%, var(--dm-bg-card)); }
+.ai-field-diffs > div > span { grid-column: 1 / -1; color: var(--dm-accent-strong); font-size: 11px; font-weight: 700; }
+.ai-field-diffs small { color: var(--dm-text-muted); font-size: 10px; white-space: nowrap; }
+.ai-field-diffs strong { min-width: 0; overflow-wrap: anywhere; color: var(--dm-text-soft); font-size: 12px; line-height: 1.45; }
.ai-field-diffs .is-changed strong:last-child { color: var(--dm-text); }
@media (max-width: 760px) {
diff --git a/apps/web/src/ai-organization.ts b/apps/web/src/ai-organization.ts
index 178fbaa..b3bd27a 100644
--- a/apps/web/src/ai-organization.ts
+++ b/apps/web/src/ai-organization.ts
@@ -1,3 +1,12 @@
+/**
+ * [INPUT]: depends on ResolvedLocale from @dockmark/core and currentResolvedLocale from ./i18n; calls /api/ai/status, /api/ai/organize, and /api/ai/apply
+ * [OUTPUT]: exports AI provider settings storage helpers, timeout constants, status fetch, locale-aware suggestion generator, and patch applier
+ * [POS]: web client wrapper for AI-assisted bookmark organization in apps/web/src; consumed by AiOrganizationSettings.tsx and InboxPage.tsx
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
+import type { ResolvedLocale } from "@dockmark/core";
+import { currentResolvedLocale } from "./i18n";
+
export interface AiProviderSettings {
endpoint: string;
model: string;
@@ -90,6 +99,7 @@ export function getAiProviderStatus() {
export async function generateAiOrganizationSuggestions(
settings: AiProviderSettings,
bookmarkIds: string[],
+ locale: ResolvedLocale = currentResolvedLocale(),
): Promise
{
if (!settings.endpoint.trim()) throw new Error("Choose an AI provider endpoint before generating suggestions.");
if (!settings.model.trim()) throw new Error("Choose an AI model before generating suggestions.");
@@ -106,6 +116,7 @@ export async function generateAiOrganizationSuggestions(
model: settings.model.trim(),
timeoutSeconds: settings.timeoutSeconds,
bookmarkIds,
+ locale,
}),
});
return Array.isArray(response.suggestions) ? response.suggestions : [];
diff --git a/apps/web/src/bookmark-tags.css b/apps/web/src/bookmark-tags.css
index 6fbf77b..a930090 100644
--- a/apps/web/src/bookmark-tags.css
+++ b/apps/web/src/bookmark-tags.css
@@ -1,10 +1,61 @@
+.bookmark-library-view { padding-top: 32px; }
+.compact-manager-heading {
+ align-items: center;
+ gap: 16px;
+ margin-bottom: 20px;
+}
+.compact-manager-heading h1 {
+ margin: 0;
+ font-size: clamp(22px, 2.5vw, 28px);
+ line-height: 1.2;
+ letter-spacing: -0.025em;
+}
+.manager-subtitle {
+ margin: 5px 0 0;
+ color: var(--dm-text-muted);
+ font-size: 13px;
+ line-height: 1.45;
+}
+
.bookmark-sidebar { display: grid; gap: 14px; }
+.bookmark-icon.has-favicon {
+ padding: 5px;
+ overflow: hidden;
+ background: var(--dm-bg-card);
+}
+.bookmark-icon.has-favicon img {
+ display: block;
+ width: 100%;
+ height: 100%;
+ object-fit: contain;
+ border-radius: 6px;
+}
+
+.bookmark-actions button,
+.row-actions button,
+.management-summary button,
+.management-summary .library-count,
+.bookmark-form .primary,
+.edit-actions button,
+.compact-form button {
+ white-space: nowrap;
+ flex-shrink: 0;
+}
+
+.bookmark-actions button:active:not(:disabled),
+.row-actions button:active:not(:disabled),
+.tag-filter-chip:active,
+.bookmark-tags button:active,
+.active-tag-filter:active {
+ transform: translateY(1px);
+}
+
.bookmark-field-grid .field-span-2 { grid-column: 1 / -1; }
.bookmark-field-grid textarea {
width: 100%;
min-width: 0;
- min-height: 78px;
+ min-height: 76px;
padding: 10px 11px;
resize: vertical;
border: 1px solid var(--dm-border-strong);
@@ -21,10 +72,10 @@
}
.field-help {
color: var(--dm-text-muted);
- font-size: 10px;
+ font-size: 11px;
font-weight: 500;
letter-spacing: 0;
- line-height: 1.4;
+ line-height: 1.45;
text-transform: none;
}
.bookmark-field-grid .field-error > span { color: var(--dm-danger); }
@@ -38,7 +89,7 @@
}
.field-error-message {
color: var(--dm-danger);
- font-size: 10px;
+ font-size: 11px;
font-weight: 600;
letter-spacing: 0;
line-height: 1.45;
@@ -49,7 +100,7 @@
padding: 9px 11px;
border: 1px solid var(--dm-border);
border-radius: 10px;
- font-size: 11px;
+ font-size: 12px;
line-height: 1.5;
}
.inline-form-feedback.error {
@@ -63,15 +114,13 @@
color: var(--dm-accent-strong);
}
.bookmark-save-confirmation {
- padding: 3px 7px;
+ padding: 2px 8px;
border: 1px solid color-mix(in srgb, var(--dm-accent) 42%, var(--dm-border));
border-radius: 999px;
background: var(--dm-accent-bg);
color: var(--dm-accent-strong);
font-size: 10px;
font-weight: 700;
- letter-spacing: .04em;
- text-transform: uppercase;
white-space: nowrap;
}
@@ -86,13 +135,15 @@
background: var(--dm-bg-soft);
color: var(--dm-text-soft);
cursor: pointer;
+ white-space: nowrap;
+ transition: border-color .14s ease, background .14s ease, color .14s ease, transform .1s ease;
}
.tag-filter-chip {
display: inline-flex;
align-items: center;
- gap: 7px;
- min-height: 30px;
- padding: 0 9px;
+ gap: 6px;
+ min-height: 28px;
+ padding: 0 10px;
font-size: 11px;
}
.tag-filter-chip strong { color: var(--dm-text-muted); font-size: 10px; }
@@ -126,7 +177,7 @@
display: flex;
align-items: center;
gap: 9px;
- min-height: 44px;
+ min-height: 42px;
padding: 0 12px;
border: 1px solid var(--dm-border-strong);
border-radius: 11px;
@@ -136,7 +187,7 @@
border-color: var(--dm-accent);
box-shadow: 0 0 0 3px color-mix(in srgb, var(--dm-accent) 10%, transparent);
}
-.bookmark-search-input > span { color: var(--dm-text-muted); font-size: 18px; }
+.bookmark-search-input > span { color: var(--dm-text-muted); font-size: 17px; }
.bookmark-search-input input {
flex: 1;
min-width: 0;
@@ -147,7 +198,7 @@
font: inherit;
}
.bookmark-search-input input::placeholder { color: var(--dm-text-muted); }
-.bookmark-search-help { margin: 0; color: var(--dm-text-muted); font-size: 10px; line-height: 1.5; }
+.bookmark-search-help { margin: 0; color: var(--dm-text-muted); font-size: 11px; line-height: 1.5; }
.bookmark-search-help code { color: var(--dm-text-soft); }
.bookmark-description {
@@ -155,17 +206,17 @@
margin: 2px 0 0;
overflow: hidden;
color: var(--dm-text-muted);
- font-size: 11px;
+ font-size: 12px;
line-height: 1.45;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
}
-.bookmark-meta-line { display: flex; align-items: center; gap: 9px; min-width: 0; flex-wrap: wrap; }
+.bookmark-meta-line { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
.bookmark-tags { display: flex; gap: 5px; min-width: 0; flex-wrap: wrap; }
.bookmark-tags button {
- min-height: 26px;
- padding: 0 9px;
- font-size: 10px;
+ min-height: 24px;
+ padding: 0 8px;
+ font-size: 11px;
}
@media (max-width: 860px) {
diff --git a/apps/web/src/change-journal.css b/apps/web/src/change-journal.css
index 450650c..8e617e6 100644
--- a/apps/web/src/change-journal.css
+++ b/apps/web/src/change-journal.css
@@ -1,5 +1,5 @@
.change-journal {
- margin-top: 1.25rem;
+ padding-top: 32px;
}
.journal-card {
@@ -9,20 +9,25 @@
.journal-list {
display: grid;
- gap: 0.75rem;
+ gap: 0.7rem;
}
.journal-entry {
- border: 1px solid var(--border);
- border-radius: 14px;
- background: color-mix(in srgb, var(--panel) 92%, transparent);
+ border: 1px solid var(--dm-border);
+ border-radius: 13px;
+ background: var(--dm-bg-card);
overflow: hidden;
+ transition: border-color .14s ease;
+}
+
+.journal-entry:hover {
+ border-color: var(--dm-border-strong);
}
.journal-entry > summary {
cursor: pointer;
list-style: none;
- padding: 0.95rem 1rem;
+ padding: 0.9rem 1rem;
}
.journal-entry > summary::-webkit-details-marker {
@@ -34,19 +39,25 @@
gap: 0.25rem;
}
+.journal-entry > summary strong {
+ color: var(--dm-text);
+ font-size: 13px;
+}
+
.journal-entry > summary small,
.journal-item-heading small,
.journal-snapshot span,
.journal-tools span {
- color: var(--muted);
+ color: var(--dm-text-muted);
+ font-size: 12px;
overflow-wrap: anywhere;
}
.journal-entry-body {
display: grid;
- gap: 1rem;
+ gap: 0.9rem;
padding: 0 1rem 1rem;
- border-top: 1px solid var(--border);
+ border-top: 1px solid var(--dm-border);
}
.journal-tools {
@@ -54,20 +65,26 @@
align-items: center;
justify-content: space-between;
gap: 1rem;
- padding-top: 0.9rem;
+ padding-top: 0.85rem;
+}
+
+.journal-tools button {
+ white-space: nowrap;
+ flex-shrink: 0;
}
.journal-items {
display: grid;
- gap: 0.75rem;
+ gap: 0.7rem;
}
.journal-item {
display: grid;
- gap: 0.7rem;
+ gap: 0.65rem;
padding: 0.85rem;
- border: 1px solid var(--border);
- border-radius: 12px;
+ border: 1px solid var(--dm-border);
+ border-radius: 11px;
+ background: var(--dm-bg-soft);
}
.journal-item-heading,
@@ -79,35 +96,45 @@
.journal-snapshot-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
- gap: 0.75rem;
+ gap: 0.7rem;
}
.journal-snapshot {
padding: 0.75rem;
+ border: 1px solid var(--dm-border);
border-radius: 10px;
- background: var(--surface-subtle, var(--panel));
+ background: var(--dm-bg-card);
+}
+
+.journal-snapshot strong {
+ font-size: 12px;
+ color: var(--dm-text);
}
.journal-deleted {
font-weight: 700;
+ color: var(--dm-danger);
}
.journal-raw {
- border-top: 1px solid var(--border);
- padding-top: 0.8rem;
+ border-top: 1px solid var(--dm-border);
+ padding-top: 0.75rem;
}
.journal-raw summary {
cursor: pointer;
- color: var(--muted);
+ color: var(--dm-text-muted);
+ font-size: 12px;
}
.journal-raw pre {
max-height: 28rem;
overflow: auto;
padding: 0.8rem;
+ border: 1px solid var(--dm-border);
border-radius: 10px;
- background: var(--surface-subtle, var(--panel));
+ background: var(--dm-bg-soft);
+ color: var(--dm-text-soft);
font-size: 0.75rem;
white-space: pre-wrap;
overflow-wrap: anywhere;
diff --git a/apps/web/src/duplicate-review.css b/apps/web/src/duplicate-review.css
index 58aa06b..5ebca41 100644
--- a/apps/web/src/duplicate-review.css
+++ b/apps/web/src/duplicate-review.css
@@ -1,63 +1,496 @@
-.duplicate-shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 46px 0 72px; }
-.duplicate-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; margin-bottom: 22px; }
-.duplicate-hero h1 { margin: 6px 0 10px; font-size: clamp(34px, 5vw, 58px); line-height: .95; letter-spacing: -.045em; }
-.duplicate-hero p:not(.eyebrow) { max-width: 760px; margin: 0; color: var(--muted); line-height: 1.65; }
-.duplicate-stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
-.duplicate-stats > div { padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
-.duplicate-stats strong { display: block; font-size: 22px; }
-.duplicate-stats span { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .06em; }
-.duplicate-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) minmax(180px, 260px) auto; gap: 12px; align-items: end; padding: 16px; margin: 16px 0; }
-.duplicate-toolbar label { display: grid; gap: 6px; }
-.duplicate-toolbar label > span { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .07em; }
-.duplicate-toolbar input, .duplicate-toolbar select { width: 100%; min-height: 40px; }
-.duplicate-toolbar-state { display: flex; align-items: center; justify-content: flex-end; gap: 10px; min-height: 40px; }
-.duplicate-list { display: grid; gap: 14px; }
-.duplicate-candidate { overflow: hidden; }
-.duplicate-candidate-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 17px 18px; border-bottom: 1px solid var(--line); }
-.duplicate-candidate-heading p { margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
-.duplicate-kind-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
-.duplicate-kind-row small { color: var(--muted); }
-.duplicate-kind { padding: 4px 8px; border: 1px solid color-mix(in srgb, var(--accent) 38%, var(--line)); border-radius: 999px; background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--text); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
-.duplicate-evidence-url { display: block; margin-top: 8px; color: var(--accent); overflow-wrap: anywhere; font-size: 11px; }
-.duplicate-pair { display: grid; grid-template-columns: minmax(0, 1fr) 34px minmax(0, 1fr); gap: 0; align-items: stretch; }
-.duplicate-member { min-width: 0; padding: 18px; }
-.duplicate-member-heading { display: flex; align-items: flex-start; gap: 10px; }
-.duplicate-member-heading > span { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 8px; background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); font-size: 11px; font-weight: 800; }
-.duplicate-member-heading > div { min-width: 0; display: grid; gap: 3px; }
-.duplicate-member-heading strong { overflow-wrap: anywhere; }
-.duplicate-member-heading small { color: var(--muted); }
-.duplicate-url { display: block; margin-top: 12px; color: var(--text); font-size: 12px; overflow-wrap: anywhere; }
-.duplicate-url:hover { color: var(--accent); }
-.duplicate-member p { margin: 10px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
-.duplicate-member-evidence { display: grid; gap: 7px; margin-top: 12px; }
-.duplicate-member-evidence > div { display: grid; gap: 3px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: color-mix(in srgb, var(--panel) 86%, var(--accent) 4%); }
-.duplicate-member-evidence span { color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
-.duplicate-member-evidence code { color: var(--text); font-size: 10px; overflow-wrap: anywhere; }
-.duplicate-member-evidence > small { color: var(--muted); font-size: 10px; }
-.duplicate-vs { display: grid; place-items: center; color: var(--muted); border-left: 1px solid var(--line); border-right: 1px solid var(--line); font-size: 18px; }
-.duplicate-candidate-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 13px 18px; border-top: 1px solid var(--line); background: color-mix(in srgb, var(--panel) 92%, var(--accent) 3%); }
-.duplicate-candidate-footer > span { color: var(--muted); font-size: 11px; }
-.duplicate-candidate-footer > div { display: flex; gap: 8px; }
-.duplicate-candidate-footer a.secondary { display: inline-flex; align-items: center; min-height: 34px; padding: 0 11px; text-decoration: none; }
-.duplicate-empty { display: grid; gap: 6px; padding: 34px 22px; text-align: center; color: var(--muted); }
-.duplicate-empty strong { color: var(--text); }
-
-[data-theme="light"] .duplicate-member-evidence > div,
-:root[data-theme="light"] .duplicate-member-evidence > div,
-[data-theme="light"] .duplicate-candidate-footer,
-:root[data-theme="light"] .duplicate-candidate-footer { background: #f5f9f6; }
+.duplicate-shell {
+ width: min(1180px, calc(100% - 40px));
+ margin: 0 auto;
+ padding: 28px 0 64px;
+}
+
+.duplicate-hero {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 20px;
+ margin-bottom: 18px;
+}
+
+.duplicate-hero-copy {
+ min-width: 0;
+ display: grid;
+ gap: 4px;
+}
+
+.duplicate-hero h1 {
+ margin: 0;
+ font-size: clamp(22px, 2.4vw, 26px);
+ line-height: 1.2;
+ letter-spacing: -.025em;
+ color: var(--dm-text);
+}
+
+.duplicate-hero p {
+ max-width: 740px;
+ margin: 0;
+ color: var(--dm-text-muted);
+ font-size: 13px;
+ line-height: 1.5;
+}
+
+.duplicate-hero-actions {
+ display: flex;
+ align-items: center;
+ gap: 10px;
+ flex: 0 0 auto;
+}
+
+.duplicate-hero-actions button {
+ white-space: nowrap;
+}
+
+.duplicate-stat-pill {
+ display: inline-flex;
+ align-items: baseline;
+ gap: 6px;
+ padding: 7px 12px;
+ border: 1px solid var(--dm-border);
+ border-radius: 999px;
+ background: var(--dm-bg-card);
+ color: var(--dm-text);
+ white-space: nowrap;
+}
+
+.duplicate-stat-pill strong {
+ font-size: 14px;
+ font-weight: 700;
+ line-height: 1;
+}
+
+.duplicate-stat-pill span {
+ color: var(--dm-text-muted);
+ font-size: 11px;
+}
+
+.duplicate-stats {
+ display: grid;
+ grid-template-columns: repeat(5, minmax(0, 1fr));
+ gap: 10px;
+ margin-bottom: 14px;
+}
+
+.duplicate-stats > div {
+ padding: 12px 14px;
+ border: 1px solid var(--dm-border);
+ border-radius: 13px;
+ background: var(--dm-bg-card);
+}
+
+.duplicate-stats strong {
+ display: block;
+ font-size: 20px;
+ line-height: 1.1;
+ color: var(--dm-text);
+}
+
+.duplicate-stats span {
+ display: block;
+ margin-top: 4px;
+ color: var(--dm-text-muted);
+ font-size: 11px;
+}
+
+.duplicate-truncation-notice {
+ margin: 0 0 14px;
+ padding: 10px 14px;
+ border: 1px solid var(--dm-border);
+ border-radius: 12px;
+ background: var(--dm-bg-soft);
+ color: var(--dm-text-soft);
+ font-size: 12px;
+ line-height: 1.5;
+}
+
+.duplicate-toolbar {
+ max-width: none;
+ display: grid;
+ grid-template-columns: minmax(0, 1fr) minmax(180px, 260px) auto;
+ gap: 12px;
+ align-items: end;
+ padding: 14px 16px;
+ margin: 0 0 14px;
+ border: 1px solid var(--dm-border);
+ border-radius: 14px;
+ background: var(--dm-bg-card);
+}
+
+.duplicate-toolbar label {
+ display: grid;
+ gap: 5px;
+ min-width: 0;
+}
+
+.duplicate-toolbar label > span {
+ color: var(--dm-text-soft);
+ font-size: 12px;
+ font-weight: 560;
+}
+
+.duplicate-toolbar input,
+.duplicate-toolbar select {
+ width: 100%;
+ min-height: 38px;
+ padding: 0 10px;
+ border: 1px solid var(--dm-border-strong);
+ border-radius: 9px;
+ background: var(--dm-input-bg);
+ color: var(--dm-text);
+}
+
+.duplicate-toolbar input::placeholder {
+ color: var(--dm-placeholder);
+ opacity: 1;
+}
+
+.duplicate-toolbar input:hover,
+.duplicate-toolbar select:hover {
+ border-color: color-mix(in srgb, var(--dm-accent) 42%, var(--dm-border-strong));
+ background: var(--dm-input-hover);
+}
+
+.duplicate-toolbar input:focus,
+.duplicate-toolbar select:focus {
+ border-color: var(--dm-accent);
+ background: var(--dm-input-bg);
+ box-shadow: 0 0 0 3px var(--dm-focus-ring);
+ outline: 0;
+}
+
+.duplicate-toolbar-state {
+ display: flex;
+ align-items: center;
+ justify-content: flex-end;
+ gap: 10px;
+ min-height: 38px;
+ white-space: nowrap;
+}
+
+.duplicate-toolbar-state strong {
+ font-size: 12px;
+ color: var(--dm-text-soft);
+}
+
+.duplicate-toolbar-state button {
+ white-space: nowrap;
+}
+
+.duplicate-list {
+ display: grid;
+ gap: 14px;
+}
+
+.duplicate-candidate {
+ max-width: none;
+ margin: 0;
+ overflow: hidden;
+ border: 1px solid var(--dm-border);
+ border-radius: 16px;
+ background: var(--dm-bg-card);
+}
+
+.duplicate-candidate-heading {
+ display: flex;
+ align-items: flex-start;
+ justify-content: space-between;
+ gap: 16px;
+ padding: 14px 18px;
+ border-bottom: 1px solid var(--dm-border);
+}
+
+.duplicate-candidate-copy {
+ min-width: 0;
+}
+
+.duplicate-candidate-heading p {
+ margin: 6px 0 0;
+ color: var(--dm-text-muted);
+ font-size: 12px;
+ line-height: 1.5;
+}
+
+.duplicate-candidate-heading button {
+ flex: 0 0 auto;
+ white-space: nowrap;
+}
+
+.duplicate-kind-row {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ flex-wrap: wrap;
+}
+
+.duplicate-kind-row small {
+ color: var(--dm-text-muted);
+ font-size: 11px;
+}
+
+.duplicate-kind {
+ padding: 3px 9px;
+ border: 1px solid color-mix(in srgb, var(--dm-accent) 42%, var(--dm-border));
+ border-radius: 999px;
+ background: var(--dm-selected-bg);
+ color: var(--dm-accent-strong);
+ font-size: 11px;
+ font-weight: 650;
+ white-space: nowrap;
+}
+
+.duplicate-evidence-url {
+ display: block;
+ margin-top: 6px;
+ color: var(--dm-accent);
+ overflow-wrap: anywhere;
+ font-size: 11px;
+}
+
+.duplicate-pair {
+ display: grid;
+ grid-template-columns: minmax(0, 1fr) 32px minmax(0, 1fr);
+ gap: 0;
+ align-items: stretch;
+}
+
+.duplicate-member {
+ min-width: 0;
+ padding: 16px 18px;
+}
+
+.duplicate-member-heading {
+ display: flex;
+ align-items: flex-start;
+ gap: 11px;
+}
+
+.duplicate-member-icon {
+ display: grid;
+ place-items: center;
+ flex: 0 0 34px;
+ width: 34px;
+ height: 34px;
+ border: 1px solid var(--dm-border);
+ border-radius: 10px;
+ background: var(--dm-accent-bg);
+ color: var(--dm-accent-strong);
+ font-size: 13px;
+ font-weight: 700;
+ overflow: hidden;
+}
+
+.duplicate-member-icon.has-favicon {
+ padding: 0;
+ background: var(--dm-bg-soft);
+}
+
+.duplicate-member-icon.has-favicon img {
+ display: block;
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+ border-radius: inherit;
+}
+
+.duplicate-member-copy {
+ min-width: 0;
+ display: grid;
+ gap: 3px;
+}
+
+.duplicate-member-title {
+ display: flex;
+ align-items: center;
+ gap: 7px;
+ min-width: 0;
+}
+
+.duplicate-side-badge {
+ display: inline-grid;
+ place-items: center;
+ flex: 0 0 20px;
+ width: 20px;
+ height: 20px;
+ border-radius: 6px;
+ background: var(--dm-selected-bg);
+ color: var(--dm-accent-strong);
+ font-size: 10px;
+ font-weight: 750;
+}
+
+.duplicate-member-title strong {
+ font-size: 13px;
+ font-weight: 600;
+ color: var(--dm-text);
+ overflow-wrap: anywhere;
+}
+
+.duplicate-member-copy small {
+ color: var(--dm-text-muted);
+ font-size: 11px;
+ line-height: 1.4;
+}
+
+.duplicate-url {
+ display: block;
+ margin-top: 10px;
+ color: var(--dm-text-soft);
+ font-size: 12px;
+ overflow-wrap: anywhere;
+ text-decoration: none;
+}
+
+.duplicate-url:hover {
+ color: var(--dm-accent);
+}
+
+.duplicate-member p {
+ margin: 8px 0 0;
+ color: var(--dm-text-muted);
+ font-size: 12px;
+ line-height: 1.5;
+}
+
+.duplicate-member-evidence {
+ display: grid;
+ gap: 6px;
+ margin-top: 10px;
+}
+
+.duplicate-member-evidence > div {
+ display: grid;
+ gap: 2px;
+ padding: 7px 10px;
+ border: 1px solid var(--dm-border);
+ border-radius: 9px;
+ background: var(--dm-bg-soft);
+}
+
+.duplicate-member-evidence span {
+ color: var(--dm-text-muted);
+ font-size: 10px;
+ font-weight: 650;
+}
+
+.duplicate-member-evidence code {
+ color: var(--dm-text);
+ font-size: 11px;
+ overflow-wrap: anywhere;
+}
+
+.duplicate-member-evidence > small {
+ color: var(--dm-text-muted);
+ font-size: 11px;
+}
+
+.duplicate-vs {
+ display: grid;
+ place-items: center;
+ color: var(--dm-text-muted);
+ border-left: 1px solid var(--dm-border);
+ border-right: 1px solid var(--dm-border);
+ background: var(--dm-bg-soft);
+ font-size: 16px;
+}
+
+.duplicate-candidate-footer {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 14px;
+ padding: 11px 18px;
+ border-top: 1px solid var(--dm-border);
+ background: var(--dm-bg-soft);
+}
+
+.duplicate-candidate-footer > span {
+ color: var(--dm-text-muted);
+ font-size: 11px;
+}
+
+.duplicate-candidate-footer > div {
+ display: flex;
+ gap: 8px;
+ flex: 0 0 auto;
+}
+
+.duplicate-candidate-footer a.secondary {
+ display: inline-flex;
+ align-items: center;
+ min-height: 32px;
+ padding: 0 11px;
+ text-decoration: none;
+ white-space: nowrap;
+}
+
+.duplicate-empty {
+ max-width: none;
+ margin: 0;
+ display: grid;
+ gap: 6px;
+ padding: 36px 22px;
+ border: 1px solid var(--dm-border);
+ border-radius: 16px;
+ background: var(--dm-bg-card);
+ text-align: center;
+ color: var(--dm-text-muted);
+ font-size: 13px;
+}
+
+.duplicate-empty strong {
+ color: var(--dm-text);
+ font-size: 14px;
+}
+
+.duplicate-shell button:not(:disabled):active,
+.duplicate-shell a.secondary:active {
+ transform: translateY(1px);
+}
@media (max-width: 900px) {
- .duplicate-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
- .duplicate-toolbar { grid-template-columns: 1fr; }
- .duplicate-toolbar-state { justify-content: flex-start; }
+ .duplicate-stats {
+ grid-template-columns: repeat(2, minmax(0, 1fr));
+ }
+ .duplicate-toolbar {
+ grid-template-columns: 1fr;
+ }
+ .duplicate-toolbar-state {
+ justify-content: flex-start;
+ }
}
@media (max-width: 700px) {
- .duplicate-shell { width: min(100% - 24px, 1180px); padding-top: 28px; }
- .duplicate-hero { align-items: stretch; flex-direction: column; }
- .duplicate-pair { grid-template-columns: 1fr; }
- .duplicate-vs { min-height: 34px; border: 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
- .duplicate-candidate-heading, .duplicate-candidate-footer { align-items: stretch; flex-direction: column; }
- .duplicate-candidate-footer > div { justify-content: flex-start; }
+ .duplicate-shell {
+ width: min(100% - 24px, 1180px);
+ padding-top: 20px;
+ }
+ .duplicate-hero {
+ align-items: stretch;
+ flex-direction: column;
+ gap: 12px;
+ }
+ .duplicate-hero-actions {
+ justify-content: flex-start;
+ }
+ .duplicate-pair {
+ grid-template-columns: 1fr;
+ }
+ .duplicate-vs {
+ min-height: 32px;
+ border: 0;
+ border-top: 1px solid var(--dm-border);
+ border-bottom: 1px solid var(--dm-border);
+ }
+ .duplicate-candidate-heading,
+ .duplicate-candidate-footer {
+ align-items: stretch;
+ flex-direction: column;
+ }
+ .duplicate-candidate-footer > div {
+ justify-content: flex-start;
+ }
}
diff --git a/apps/web/src/extension-distribution.ts b/apps/web/src/extension-distribution.ts
index 49e94a6..cbebe95 100644
--- a/apps/web/src/extension-distribution.ts
+++ b/apps/web/src/extension-distribution.ts
@@ -1,4 +1,10 @@
-export const EXTENSION_RELEASE_VERSION = "1.5.5";
+/**
+ * [INPUT]: standalone release metadata with no runtime module dependencies
+ * [OUTPUT]: exports EXTENSION_RELEASE_VERSION, store/download URLs, and compareExtensionVersions
+ * [POS]: single source of truth for expected browser extension release version and download URLs in apps/web/src
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
+export const EXTENSION_RELEASE_VERSION = "1.6.0";
// Fill these when browser-store listings are public. The UI will promote the
// store action while keeping manual downloads visible.
diff --git a/apps/web/src/extension.css b/apps/web/src/extension.css
index 6f23119..3df984f 100644
--- a/apps/web/src/extension.css
+++ b/apps/web/src/extension.css
@@ -1,65 +1,81 @@
-.extension-page { padding: 66px 0 20px; }
-.extension-state { flex: 0 0 auto; padding: 8px 11px; border: 1px solid #2b342f; border-radius: 999px; background: #111613; font-size: 12px; }
+.extension-page { padding: 28px 0 20px; }
+.extension-state { flex: 0 0 auto; padding: 6px 11px; border: 1px solid #2b342f; border-radius: 999px; background: #111613; font-size: 12px; white-space: nowrap; }
.extension-state-neutral { color: #8b9790; }
.extension-state-success { border-color: #31543c; color: #9fd0ae; }
.extension-state-warning { border-color: #584b2c; color: #d6bd78; }
.extension-state-danger { border-color: #5a3734; color: #d8a09c; }
-.extension-hero-card { display: grid; grid-template-columns: minmax(0, 1fr) 150px; gap: 30px; align-items: center; padding: 28px; border: 1px solid #2a342f; border-radius: 22px; background: radial-gradient(circle at 90% 20%, rgba(128,181,146,.13), transparent 16rem), rgba(15,20,18,.82); }
-.extension-hero-copy { max-width: 700px; }
+.extension-hero-card { display: grid; grid-template-columns: minmax(0, 1fr) 120px; gap: 24px; align-items: center; padding: 20px 22px; border: 1px solid #2a342f; border-radius: 16px; background: radial-gradient(circle at 90% 20%, rgba(128,181,146,.12), transparent 16rem), rgba(15,20,18,.82); }
+.extension-hero-copy { max-width: 720px; }
.extension-version { color: #84b394; font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; text-transform: uppercase; letter-spacing: .08em; }
-.extension-hero-copy h2 { margin: 10px 0 9px; font-size: clamp(24px, 4vw, 36px); letter-spacing: -.035em; }
-.extension-hero-copy > p { max-width: 650px; margin: 0; color: #8a958f; line-height: 1.65; }
-.extension-permission-callout { display: grid; gap: 3px; max-width: 650px; margin-top: 16px; padding: 12px 14px; border: 1px solid #584b2c; border-radius: 12px; background: rgba(80,60,24,.16); }
+.extension-hero-copy h2 { margin: 6px 0 7px; font-size: clamp(18px, 2.4vw, 24px); letter-spacing: -.025em; }
+.extension-hero-copy > p { max-width: 660px; margin: 0; color: #8a958f; font-size: 13px; line-height: 1.6; }
+.extension-permission-callout { display: grid; gap: 3px; max-width: 650px; margin-top: 14px; padding: 11px 13px; border: 1px solid #584b2c; border-radius: 11px; background: rgba(80,60,24,.16); }
.extension-permission-callout strong { color: #e1c985; font-size: 12px; }
.extension-permission-callout span { color: #a99d7c; font-size: 12px; line-height: 1.5; }
-.extension-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; margin-top: 22px; }
-.extension-channel-note { margin-top: 15px !important; color: #68746d !important; font-size: 12px; }
-.extension-mark { display: grid; place-items: center; width: 118px; height: 118px; justify-self: end; border: 1px solid #3a4b42; border-radius: 31px; background: #18211c; color: #bce2c7; font-size: 44px; font-weight: 680; letter-spacing: -.08em; box-shadow: inset 0 0 0 1px rgba(255,255,255,.025), 0 18px 55px rgba(0,0,0,.22); }
-.extension-profiles { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 16px; }
-.extension-profile { min-width: 0; padding: 22px; border: 1px solid #28322d; border-radius: 18px; background: rgba(14,19,17,.78); }
+.extension-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; margin-top: 16px; }
+.extension-channel-note { margin-top: 14px !important; color: #68746d !important; font-size: 12px; }
+.extension-mark { display: grid; place-items: center; width: 92px; height: 92px; justify-self: end; border: 1px solid #3a4b42; border-radius: 24px; background: #18211c; color: #bce2c7; font-size: 36px; font-weight: 680; letter-spacing: -.08em; box-shadow: inset 0 0 0 1px rgba(255,255,255,.025), 0 14px 40px rgba(0,0,0,.22); }
+.extension-profiles { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
+.extension-profile { min-width: 0; padding: 18px 20px; border: 1px solid #28322d; border-radius: 15px; background: rgba(14,19,17,.78); }
.extension-profile-recommended { border-color: #3c5a48; background: radial-gradient(circle at 95% 5%, rgba(111,164,128,.12), transparent 16rem), rgba(15,22,18,.9); box-shadow: inset 0 0 0 1px rgba(132,179,148,.035); }
.extension-profile-firefox { grid-column: 1 / -1; border-color: #35443c; background: radial-gradient(circle at 92% 10%, rgba(113,145,126,.08), transparent 18rem), rgba(14,19,17,.78); }
-.extension-profile-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
-.extension-profile-heading h2 { margin: 5px 0 0; font-size: 22px; letter-spacing: -.025em; }
+.extension-profile-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
+.extension-profile-heading h2 { margin: 4px 0 0; font-size: 18px; letter-spacing: -.02em; }
.extension-profile-kicker { color: #769683; font: 10px ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; }
-.extension-profile-badge { flex: 0 0 auto; padding: 6px 8px; border: 1px solid #33443a; border-radius: 999px; color: #88a995; font-size: 10px; letter-spacing: .06em; }
-.extension-profile > p { margin: 15px 0 0; color: #849088; font-size: 13px; line-height: 1.6; }
-.extension-profile ul { display: grid; gap: 7px; margin: 15px 0 0; padding-left: 18px; color: #748078; font-size: 12px; line-height: 1.5; }
-.extension-profile .extension-actions { margin-top: 18px; }
+.extension-profile-badge { flex: 0 0 auto; padding: 4px 8px; border: 1px solid #33443a; border-radius: 999px; color: #88a995; font-size: 10px; letter-spacing: .06em; white-space: nowrap; }
+.extension-profile > p { margin: 12px 0 0; color: #849088; font-size: 13px; line-height: 1.55; }
+.extension-profile ul { display: grid; gap: 6px; margin: 12px 0 0; padding-left: 18px; color: #748078; font-size: 12px; line-height: 1.5; }
+.extension-profile .extension-actions { margin-top: 16px; }
.extension-profile-note { margin: 12px 2px 0; color: #68746d; font-size: 12px; line-height: 1.6; }
.extension-profile-note code { padding: 2px 5px; border: 1px solid #2d3732; border-radius: 5px; background: #0e1311; color: #c8d4cd; }
-.extension-guide { margin-top: 16px; }
-.extension-guide-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; margin-top: 6px; }
+.extension-guide { margin-top: 14px; }
+.extension-guide-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 6px; }
.extension-guide-columns > div { min-width: 0; }
-.extension-guide h3 { margin: 0 0 10px; font-size: 14px; }
-.extension-guide ol { display: grid; gap: 10px; margin: 4px 0 0; padding-left: 22px; color: #9ba69f; font-size: 13px; line-height: 1.55; }
+.extension-guide h3 { margin: 0 0 8px; font-size: 14px; }
+.extension-guide ol { display: grid; gap: 9px; margin: 4px 0 0; padding-left: 20px; color: #9ba69f; font-size: 13px; line-height: 1.55; }
.extension-guide code { padding: 2px 5px; border: 1px solid #2d3732; border-radius: 5px; background: #0e1311; color: #c8d4cd; }
-.extension-diagnostics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 16px; }
+.extension-diagnostics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.extension-diagnostic-card { min-width: 0; }
.diagnostic-list { display: grid; gap: 0; margin: 0; }
-.diagnostic-list > div, .capability-list > div { display: flex; align-items: center; justify-content: space-between; gap: 18px; min-height: 42px; border-top: 1px solid #202723; }
+.diagnostic-list > div, .capability-list > div { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 38px; border-top: 1px solid #202723; }
.diagnostic-list > div:first-child, .capability-list > div:first-child { border-top: 0; }
.diagnostic-list dt, .capability-list span { color: #7f8a84; font-size: 12px; }
.diagnostic-list dd { min-width: 0; margin: 0; overflow: hidden; color: #bec9c2; font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; text-overflow: ellipsis; white-space: nowrap; }
-.capability-list strong { font-size: 11px; font-weight: 620; }
+.capability-list strong { font-size: 11px; font-weight: 620; white-space: nowrap; }
.capability-on { color: #8ec39f; }
.capability-off { color: #65706a; }
.extension-diagnostic-note { margin: 12px 0 0; padding-top: 12px; border-top: 1px solid #202723; color: #8e9993; font-size: 12px; line-height: 1.5; }
-.extension-nudge { display: flex; align-items: center; justify-content: space-between; gap: 18px; width: min(820px, 100%); margin: 12px auto 0; padding: 14px 16px; border: 1px solid #2b3a32; border-radius: 14px; background: rgba(19,27,23,.72); color: inherit; cursor: pointer; text-align: left; }
+
+.extension-nudge {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 16px;
+ width: 100%;
+ margin: 4px 0 0;
+ padding: 10px 14px;
+ border: 1px solid #2b3a32;
+ border-radius: 12px;
+ background: rgba(19,27,23,.72);
+ color: inherit;
+ cursor: pointer;
+ text-align: left;
+ transition: border-color 140ms ease, background-color 140ms ease;
+}
.extension-nudge:hover { border-color: #486253; background: rgba(23,33,28,.9); }
-.extension-nudge-copy { display: grid; gap: 3px; }
-.extension-nudge-copy strong { font-size: 13px; }
-.extension-nudge-copy span { color: #748078; font-size: 12px; }
-.extension-nudge-action { color: #a9d0b5; font-size: 12px; white-space: nowrap; }
+.extension-nudge-copy { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 10px; min-width: 0; }
+.extension-nudge-copy strong { font-size: 12px; font-weight: 620; white-space: nowrap; }
+.extension-nudge-copy span { color: #86948c; font-size: 12px; }
+.extension-nudge-action { flex: 0 0 auto; color: #a9d0b5; font-size: 12px; font-weight: 560; white-space: nowrap; }
.native-extension-link { margin-left: auto; }
@media (max-width: 760px) {
- .extension-page { padding-top: 42px; }
+ .extension-page { padding-top: 20px; }
.extension-hero-card { grid-template-columns: 1fr; }
.extension-mark { display: none; }
.extension-profiles { grid-template-columns: 1fr; }
.extension-profile-firefox { grid-column: auto; }
.extension-guide-columns { grid-template-columns: 1fr; }
.extension-diagnostics-grid { grid-template-columns: 1fr; }
- .extension-nudge { align-items: flex-start; }
+ .extension-nudge { align-items: flex-start; flex-direction: column; gap: 6px; }
}
diff --git a/apps/web/src/health.css b/apps/web/src/health.css
index 80bb799..c12c744 100644
--- a/apps/web/src/health.css
+++ b/apps/web/src/health.css
@@ -1,5 +1,6 @@
.management-summary { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.health-feedback { margin-bottom: 16px; }
+.health-badge { white-space: nowrap; flex-shrink: 0; }
.health-badge.status-healthy { color: #99c9a8; border-color: #355442; }
.health-badge.status-redirected { color: #a9b8d7; border-color: #3b465d; }
.health-badge.status-auth-required, .health-badge.status-forbidden { color: #c7ad83; border-color: #55482f; }
@@ -7,7 +8,19 @@
.health-badge.status-timeout, .health-badge.status-dns-error, .health-badge.status-tls-error, .health-badge.status-unavailable { color: #d09a96; border-color: #5a3835; }
.health-badge.status-local-only { color: #b6b97d; border-color: #484a30; }
.health-badge.status-ignored { color: #988e88; border-color: #3e3733; }
-.health-check-button { min-width: 68px; }
+.health-check-button { min-width: 68px; white-space: nowrap; }
+
+html[data-theme="light"] .health-badge.status-healthy { color: #2b6844; border-color: #a9cdb6; background: #eef7f1; }
+html[data-theme="light"] .health-badge.status-redirected { color: #365080; border-color: #b5c4de; background: #f0f4fa; }
+html[data-theme="light"] .health-badge.status-auth-required,
+html[data-theme="light"] .health-badge.status-forbidden { color: #7d5b24; border-color: #dcc59b; background: #fdf7ec; }
+html[data-theme="light"] .health-badge.status-rate-limited { color: #6c4380; border-color: #cfb6dc; background: #f8f1fb; }
+html[data-theme="light"] .health-badge.status-timeout,
+html[data-theme="light"] .health-badge.status-dns-error,
+html[data-theme="light"] .health-badge.status-tls-error,
+html[data-theme="light"] .health-badge.status-unavailable { color: #9a3e38; border-color: #dfb4b0; background: #fdf1f0; }
+html[data-theme="light"] .health-badge.status-local-only { color: #676a29; border-color: #cfd29c; background: #f7f8ec; }
+html[data-theme="light"] .health-badge.status-ignored { color: #665e59; border-color: #cfc9c5; background: #f4f3f2; }
@media (max-width: 720px) {
.management-summary { justify-content: flex-start; }
diff --git a/apps/web/src/i18n.ts b/apps/web/src/i18n.ts
new file mode 100644
index 0000000..ebabf0e
--- /dev/null
+++ b/apps/web/src/i18n.ts
@@ -0,0 +1,238 @@
+/**
+ * [INPUT]: depends on useCallback, useEffect, useState from react; depends on LOCALE_STORAGE_KEY, normalizeLocalePreference, resolveLocale, tx, and settings/locale types from @dockmark/core; depends on applyLocalePreference, saveAppearanceAndLocale, and syncAppearanceFromCloud from ./theme
+ * [OUTPUT]: exports PUBLIC_LOCALE_STORAGE_KEY, localLocalePreference, currentResolvedLocale, applyLocalePreference, bindSystemLocaleListener, saveAppearanceAndLocale, syncAppearanceAndLocaleFromCloud, useI18n, and usePublicI18n
+ * [POS]: web i18n state, cloud sync, and React hooks for private app and public visitor routes in apps/web/src
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
+import { useCallback, useEffect, useState } from "react";
+import {
+ LOCALE_STORAGE_KEY,
+ normalizeLocalePreference,
+ resolveLocale,
+ tx as coreTx,
+ type AppearanceSettings,
+ type LocalePreference,
+ type ResolvedLocale,
+} from "@dockmark/core";
+import {
+ applyLocalePreference,
+ saveAppearanceAndLocale,
+ syncAppearanceFromCloud,
+} from "./theme";
+
+export const PUBLIC_LOCALE_STORAGE_KEY = "dockmarkPublicLocaleV1";
+
+export { applyLocalePreference, saveAppearanceAndLocale };
+
+export function localLocalePreference(): LocalePreference {
+ if (typeof window === "undefined") return "system";
+ try {
+ return normalizeLocalePreference(window.localStorage.getItem(LOCALE_STORAGE_KEY));
+ } catch {
+ return "system";
+ }
+}
+
+export function currentResolvedLocale(): ResolvedLocale {
+ return resolveLocale(localLocalePreference());
+}
+
+export function bindSystemLocaleListener(): () => void {
+ const listener = () => {
+ if (localLocalePreference() === "system") {
+ applyLocalePreference("system", false);
+ }
+ };
+ window.addEventListener("languagechange", listener);
+ return () => window.removeEventListener("languagechange", listener);
+}
+
+export async function syncAppearanceAndLocaleFromCloud(): Promise {
+ return syncAppearanceFromCloud();
+}
+
+function localPublicLocalePreference(): LocalePreference {
+ if (typeof window === "undefined") return "system";
+ try {
+ return normalizeLocalePreference(window.localStorage.getItem(PUBLIC_LOCALE_STORAGE_KEY));
+ } catch {
+ return "system";
+ }
+}
+
+function applyPublicDocumentLocale(preference: LocalePreference, persist = false): ResolvedLocale {
+ const normalized = normalizeLocalePreference(preference);
+ const resolved = resolveLocale(normalized);
+ if (typeof document !== "undefined") {
+ document.documentElement.dataset.localePreference = normalized;
+ document.documentElement.dataset.locale = resolved;
+ document.documentElement.lang = resolved;
+ }
+ if (persist && typeof window !== "undefined") {
+ try {
+ window.localStorage.setItem(PUBLIC_LOCALE_STORAGE_KEY, normalized);
+ } catch {
+ // Ignore storage write failures in restricted browser contexts.
+ }
+ window.dispatchEvent(new CustomEvent("dockmark:public-locale", { detail: { preference: normalized, locale: resolved } }));
+ }
+ return resolved;
+}
+
+export function useI18n(): {
+ locale: ResolvedLocale;
+ localePreference: LocalePreference;
+ isZh: boolean;
+ tx: (en: string, zh: string) => string;
+ setLocalePreference: (next: LocalePreference, options?: { syncCloud?: boolean }) => Promise;
+} {
+ const [localePreference, setPreferenceState] = useState(() => localLocalePreference());
+ const [locale, setLocaleState] = useState(() => resolveLocale(localLocalePreference()));
+
+ useEffect(() => {
+ const syncFromLocal = () => {
+ const nextPref = localLocalePreference();
+ setPreferenceState(nextPref);
+ setLocaleState(resolveLocale(nextPref));
+ };
+
+ const onLocaleEvent = (event: Event) => {
+ const detail = (event as CustomEvent<{ preference?: LocalePreference; locale?: ResolvedLocale }>).detail;
+ if (detail?.preference) {
+ const nextPref = normalizeLocalePreference(detail.preference);
+ setPreferenceState(nextPref);
+ setLocaleState(detail.locale ?? resolveLocale(nextPref));
+ } else {
+ syncFromLocal();
+ }
+ };
+
+ const onStorage = (event: StorageEvent) => {
+ if (event.key !== null && event.key !== LOCALE_STORAGE_KEY) return;
+ const nextPref = localLocalePreference();
+ applyLocalePreference(nextPref, false);
+ setPreferenceState(nextPref);
+ setLocaleState(resolveLocale(nextPref));
+ };
+
+ const onLanguageChange = () => {
+ const nextPref = localLocalePreference();
+ if (nextPref === "system") {
+ applyLocalePreference("system", false);
+ }
+ syncFromLocal();
+ };
+
+ window.addEventListener("dockmark:locale", onLocaleEvent);
+ window.addEventListener("storage", onStorage);
+ window.addEventListener("languagechange", onLanguageChange);
+ return () => {
+ window.removeEventListener("dockmark:locale", onLocaleEvent);
+ window.removeEventListener("storage", onStorage);
+ window.removeEventListener("languagechange", onLanguageChange);
+ };
+ }, []);
+
+ const setLocalePreference = useCallback(
+ async (next: LocalePreference, options?: { syncCloud?: boolean }) => {
+ const normalized = normalizeLocalePreference(next);
+ const resolved = applyLocalePreference(normalized, true);
+ setPreferenceState(normalized);
+ setLocaleState(resolved);
+
+ if (options?.syncCloud === false) return;
+
+ try {
+ const saved = await saveAppearanceAndLocale({ locale: normalized });
+ const savedResolved = applyLocalePreference(saved.locale, true);
+ setPreferenceState(saved.locale);
+ setLocaleState(savedResolved);
+ } catch (caught) {
+ const status = typeof caught === "object" && caught !== null && "status" in caught
+ ? (caught as { status?: unknown }).status
+ : undefined;
+ if (status === 401 || status === 403) return;
+ throw caught;
+ }
+ },
+ [],
+ );
+
+ const tx = useCallback((en: string, zh: string) => coreTx(locale, en, zh), [locale]);
+
+ return {
+ locale,
+ localePreference,
+ isZh: locale === "zh-CN",
+ tx,
+ setLocalePreference,
+ };
+}
+
+export function usePublicI18n(): {
+ locale: ResolvedLocale;
+ localePreference: LocalePreference;
+ isZh: boolean;
+ tx: (en: string, zh: string) => string;
+ setLocalePreference: (next: LocalePreference) => void;
+} {
+ const [localePreference, setPreferenceState] = useState(() => localPublicLocalePreference());
+ const [locale, setLocaleState] = useState(() => resolveLocale(localPublicLocalePreference()));
+
+ useEffect(() => {
+ const syncPublic = () => {
+ const nextPref = localPublicLocalePreference();
+ const nextLocale = applyPublicDocumentLocale(nextPref, false);
+ setPreferenceState(nextPref);
+ setLocaleState(nextLocale);
+ };
+
+ syncPublic();
+
+ const onPublicLocaleEvent = () => {
+ syncPublic();
+ };
+
+ const onOwnerLocaleEvent = () => {
+ // Keep the visitor's public page language intact if cloud appearance sync finishes after mount.
+ applyPublicDocumentLocale(localPublicLocalePreference(), false);
+ };
+
+ const onStorage = (event: StorageEvent) => {
+ if (event.key !== null && event.key !== PUBLIC_LOCALE_STORAGE_KEY) return;
+ syncPublic();
+ };
+
+ const onLanguageChange = () => {
+ syncPublic();
+ };
+
+ window.addEventListener("dockmark:public-locale", onPublicLocaleEvent);
+ window.addEventListener("dockmark:locale", onOwnerLocaleEvent);
+ window.addEventListener("storage", onStorage);
+ window.addEventListener("languagechange", onLanguageChange);
+ return () => {
+ window.removeEventListener("dockmark:public-locale", onPublicLocaleEvent);
+ window.removeEventListener("dockmark:locale", onOwnerLocaleEvent);
+ window.removeEventListener("storage", onStorage);
+ window.removeEventListener("languagechange", onLanguageChange);
+ };
+ }, []);
+
+ const setLocalePreference = useCallback((next: LocalePreference) => {
+ const normalized = normalizeLocalePreference(next);
+ const resolved = applyPublicDocumentLocale(normalized, true);
+ setPreferenceState(normalized);
+ setLocaleState(resolved);
+ }, []);
+
+ const tx = useCallback((en: string, zh: string) => coreTx(locale, en, zh), [locale]);
+
+ return {
+ locale,
+ localePreference,
+ isZh: locale === "zh-CN",
+ tx,
+ setLocalePreference,
+ };
+}
diff --git a/apps/web/src/inbox.css b/apps/web/src/inbox.css
index 121f248..f0ae38e 100644
--- a/apps/web/src/inbox.css
+++ b/apps/web/src/inbox.css
@@ -1,93 +1,726 @@
-.inbox-shell { width: min(1120px, calc(100% - 40px)); margin: 0 auto; padding: 46px 0 72px; }
-.inbox-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; margin-bottom: 24px; }
-.inbox-hero h1 { margin: 6px 0 10px; font-size: clamp(34px, 5vw, 58px); line-height: .95; letter-spacing: -.045em; }
-.inbox-hero p:not(.eyebrow) { max-width: 720px; margin: 0; color: var(--muted); line-height: 1.65; }
-.inbox-count { min-width: 112px; padding: 18px 20px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); text-align: right; }
-.inbox-count strong { display: block; font-size: 30px; line-height: 1; }
-.inbox-count span { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
-.inbox-panel { border: 1px solid var(--line); border-radius: 20px; background: var(--panel); overflow: hidden; }
-.inbox-panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
-.inbox-panel-heading > div { display: grid; gap: 3px; }
-.inbox-panel-heading strong { font-size: 14px; }
-.inbox-panel-heading span { color: var(--muted); font-size: 12px; }
-.inbox-list { display: grid; }
-.inbox-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(210px, 280px); gap: 18px 24px; align-items: center; padding: 20px; border-bottom: 1px solid var(--line); }
-.inbox-row:last-child { border-bottom: 0; }
-.inbox-copy { min-width: 0; }
-.inbox-title-line { display: flex; align-items: center; gap: 10px; min-width: 0; }
-.inbox-title-line a { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-weight: 700; text-decoration: none; }
-.inbox-title-line a:hover { color: var(--accent); }
-.inbox-title-line > span { flex: 0 0 auto; padding: 3px 7px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .06em; }
-.inbox-ai-select { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 4px; padding: 3px 6px; border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line)); border-radius: 999px; color: var(--accent); cursor: pointer; font-size: 10px; font-weight: 700; letter-spacing: .06em; }
-.inbox-ai-select input { margin: 0; accent-color: var(--accent); }
-.inbox-ai-select.disabled { border-color: var(--line); color: var(--muted); cursor: not-allowed; opacity: .62; }
-.inbox-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 7px; color: var(--muted); font-size: 11px; }
-.inbox-copy p { margin: 9px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
-.inbox-review { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 9px; align-items: end; }
-.inbox-review label { display: grid; gap: 5px; }
-.inbox-review label > span { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .06em; }
-.inbox-review select { width: 100%; min-height: 38px; }
-.inbox-review .primary { min-height: 38px; white-space: nowrap; }
-.inbox-metadata-review { grid-column: 1 / -1; display: grid; gap: 11px; padding: 13px 14px; border: 1px solid color-mix(in srgb, var(--line) 86%, transparent); border-radius: 14px; background: color-mix(in srgb, var(--panel) 72%, var(--bg)); }
-.inbox-metadata-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
-.inbox-metadata-heading > div { display: grid; gap: 3px; min-width: 0; }
-.inbox-metadata-heading strong { font-size: 12px; }
-.inbox-metadata-heading span { color: var(--muted); font-size: 11px; line-height: 1.45; }
-.inbox-metadata-heading .secondary { min-height: 34px; flex: 0 0 auto; white-space: nowrap; }
-.inbox-metadata-fields { display: grid; gap: 7px; }
-.inbox-metadata-field, .inbox-metadata-info { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; background: color-mix(in srgb, var(--panel) 84%, var(--bg)); }
-.inbox-metadata-field.available { border-color: color-mix(in srgb, var(--accent) 34%, var(--line)); }
-.inbox-metadata-field input { margin: 0; accent-color: var(--accent); }
-.inbox-metadata-field > span, .inbox-metadata-info > span { display: grid; gap: 2px; min-width: 0; }
-.inbox-metadata-field small, .inbox-metadata-info small { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .06em; }
-.inbox-metadata-field strong, .inbox-metadata-info strong { overflow: hidden; color: var(--text); font-size: 11px; font-weight: 600; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }
-.inbox-metadata-field em, .inbox-metadata-info em { color: var(--muted); font-size: 10px; font-style: normal; text-align: right; white-space: nowrap; }
-.inbox-metadata-field.available em { color: var(--accent); }
-.inbox-metadata-info { grid-template-columns: minmax(0, 1fr) auto; padding-left: 34px; }
-.inbox-metadata-footnote { color: var(--muted); font-size: 10px; }
-.inbox-empty { display: grid; justify-items: center; gap: 7px; padding: 58px 24px; color: var(--muted); text-align: center; }
-.inbox-empty strong { color: var(--text); }
-.inbox-notice { margin: 0 0 14px; padding: 12px 14px; border-radius: 12px; font-size: 12px; }
-.inbox-notice.success { border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line)); background: color-mix(in srgb, var(--accent) 8%, var(--panel)); }
-.inbox-notice.error { border: 1px solid #71423e; background: #261716; color: #e4aaa5; }
-.inbox-ai-panel { display: grid; gap: 14px; margin-bottom: 16px; padding: 18px 20px; border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--line)); border-radius: 18px; background: color-mix(in srgb, var(--accent) 5%, var(--panel)); }
-.inbox-ai-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
-.inbox-ai-heading h2 { margin: 2px 0 7px; font-size: 20px; letter-spacing: -.025em; }
-.inbox-ai-heading p:not(.eyebrow) { max-width: 760px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
-.inbox-ai-heading code { color: var(--text); }
-.inbox-ai-summary { display: grid; gap: 4px; min-width: 190px; text-align: right; }
-.inbox-ai-summary strong { font-size: 12px; }
-.inbox-ai-summary span { color: var(--muted); font-size: 10px; }
-.inbox-ai-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
-.inbox-ai-note { margin: -2px 0 0; color: var(--muted); font-size: 10px; line-height: 1.45; }
-.inbox-ai-preview { display: grid; gap: 10px; padding-top: 12px; border-top: 1px solid var(--line); }
-.inbox-ai-preview-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
-.inbox-ai-preview-heading > div:first-child { display: grid; gap: 3px; }
-.inbox-ai-preview-heading strong { font-size: 12px; }
-.inbox-ai-preview-heading span { color: var(--muted); font-size: 10px; }
-.inbox-ai-preview-heading > div:last-child { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
-.inbox-ai-preview-list { display: grid; gap: 7px; max-height: 430px; overflow: auto; padding-right: 3px; }
-.inbox-ai-suggestion { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 10px 11px; border: 1px solid var(--line); border-radius: 11px; background: color-mix(in srgb, var(--panel) 82%, var(--bg)); cursor: pointer; }
-.inbox-ai-suggestion input { margin: 0; accent-color: var(--accent); }
-.inbox-ai-suggestion > span { display: grid; gap: 2px; min-width: 0; }
-.inbox-ai-suggestion strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
-.inbox-ai-suggestion small { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
-.inbox-ai-suggestion em { color: var(--accent); font-size: 10px; font-style: normal; text-align: right; white-space: nowrap; }
+.inbox-shell {
+ width: min(1120px, calc(100% - 40px));
+ margin: 0 auto;
+ padding: 28px 0 64px;
+}
+
+.inbox-hero {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 20px;
+ margin-bottom: 18px;
+}
+
+.inbox-hero-copy {
+ min-width: 0;
+ display: grid;
+ gap: 4px;
+}
+
+.inbox-hero h1 {
+ margin: 0;
+ font-size: clamp(22px, 2.4vw, 26px);
+ line-height: 1.2;
+ letter-spacing: -.025em;
+ color: var(--dm-text);
+}
+
+.inbox-hero p {
+ max-width: 720px;
+ margin: 0;
+ color: var(--dm-text-muted);
+ font-size: 13px;
+ line-height: 1.5;
+}
+
+.inbox-hero-pills {
+ display: flex;
+ align-items: center;
+ flex-wrap: wrap;
+ justify-content: flex-end;
+ gap: 8px;
+ flex: 0 0 auto;
+}
+
+.inbox-stat-pill {
+ display: inline-flex;
+ align-items: baseline;
+ gap: 6px;
+ padding: 7px 12px;
+ border: 1px solid var(--dm-border);
+ border-radius: 999px;
+ background: var(--dm-bg-card);
+ color: var(--dm-text);
+ white-space: nowrap;
+}
+
+.inbox-stat-pill strong {
+ font-size: 14px;
+ font-weight: 700;
+ line-height: 1;
+}
+
+.inbox-stat-pill span {
+ color: var(--dm-text-muted);
+ font-size: 11px;
+}
+
+.inbox-stat-pill.muted {
+ background: var(--dm-bg-soft);
+}
+
+.inbox-notice {
+ margin: 0 0 14px;
+ padding: 11px 14px;
+ border-radius: 12px;
+ font-size: 12px;
+ line-height: 1.45;
+}
+
+.inbox-notice.success {
+ border: 1px solid color-mix(in srgb, var(--dm-accent) 40%, var(--dm-border));
+ background: var(--dm-success-bg);
+ color: var(--dm-text);
+}
+
+.inbox-notice.error {
+ border: 1px solid color-mix(in srgb, var(--dm-danger) 48%, var(--dm-border));
+ background: var(--dm-danger-bg);
+ color: var(--dm-danger);
+}
+
+.inbox-ai-panel {
+ display: grid;
+ gap: 12px;
+ margin-bottom: 16px;
+ padding: 16px 18px;
+ border: 1px solid color-mix(in srgb, var(--dm-accent) 26%, var(--dm-border));
+ border-radius: 16px;
+ background: color-mix(in srgb, var(--dm-accent) 5%, var(--dm-bg-card));
+}
+
+.inbox-ai-heading {
+ display: flex;
+ align-items: flex-start;
+ justify-content: space-between;
+ gap: 20px;
+}
+
+.inbox-ai-heading h2 {
+ margin: 0 0 4px;
+ font-size: 15px;
+ font-weight: 650;
+ letter-spacing: -.015em;
+ color: var(--dm-text);
+}
+
+.inbox-ai-heading p {
+ max-width: 740px;
+ margin: 0;
+ color: var(--dm-text-muted);
+ font-size: 12px;
+ line-height: 1.5;
+}
+
+.inbox-ai-summary {
+ display: grid;
+ justify-items: end;
+ gap: 5px;
+ flex: 0 0 auto;
+ text-align: right;
+}
+
+.inbox-ai-pill {
+ display: inline-flex;
+ align-items: baseline;
+ gap: 5px;
+ padding: 4px 10px;
+ border: 1px solid color-mix(in srgb, var(--dm-accent) 34%, var(--dm-border));
+ border-radius: 999px;
+ background: var(--dm-bg-card);
+ color: var(--dm-text-soft);
+ font-size: 11px;
+ white-space: nowrap;
+}
+
+.inbox-ai-pill strong {
+ color: var(--dm-text);
+ font-size: 12px;
+}
+
+.inbox-ai-meta {
+ color: var(--dm-text-muted);
+ font-size: 11px;
+ white-space: nowrap;
+}
+
+.inbox-ai-actions {
+ display: flex;
+ align-items: center;
+ flex-wrap: wrap;
+ gap: 8px;
+}
+
+.inbox-ai-actions button,
+.inbox-ai-actions a {
+ white-space: nowrap;
+}
+
+.inbox-ai-note {
+ margin: -2px 0 0;
+ color: var(--dm-text-muted);
+ font-size: 11px;
+ line-height: 1.45;
+}
+
+.inbox-ai-preview {
+ display: grid;
+ gap: 10px;
+ padding-top: 12px;
+ border-top: 1px solid var(--dm-border);
+}
+
+.inbox-ai-preview-heading {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 14px;
+}
+
+.inbox-ai-preview-heading > div:first-child {
+ display: grid;
+ gap: 3px;
+}
+
+.inbox-ai-preview-heading strong {
+ font-size: 12px;
+ color: var(--dm-text);
+}
+
+.inbox-ai-preview-heading span {
+ color: var(--dm-text-muted);
+ font-size: 11px;
+}
+
+.inbox-ai-preview-actions {
+ display: flex;
+ align-items: center;
+ flex-wrap: wrap;
+ justify-content: flex-end;
+ gap: 8px;
+}
+
+.inbox-ai-preview-actions button {
+ white-space: nowrap;
+}
+
+.inbox-ai-preview-list {
+ display: grid;
+ gap: 7px;
+ max-height: 430px;
+ overflow: auto;
+ padding-right: 3px;
+}
+
+.inbox-ai-suggestion {
+ display: grid;
+ grid-template-columns: auto auto minmax(0, 1fr) auto;
+ align-items: center;
+ gap: 10px;
+ padding: 10px 11px;
+ border: 1px solid var(--dm-border);
+ border-radius: 11px;
+ background: var(--dm-bg-soft);
+ cursor: pointer;
+ transition: border-color 140ms ease, background-color 140ms ease, transform 80ms ease;
+}
+
+.inbox-ai-suggestion:hover {
+ border-color: color-mix(in srgb, var(--dm-accent) 36%, var(--dm-border));
+ background: var(--dm-hover-bg);
+}
+
+.inbox-ai-suggestion:active {
+ transform: translateY(1px);
+}
+
+.inbox-ai-suggestion input {
+ margin: 0;
+ accent-color: var(--dm-accent);
+}
+
+.inbox-ai-suggestion > span {
+ display: grid;
+ gap: 2px;
+ min-width: 0;
+}
+
+.inbox-ai-suggestion strong {
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ font-size: 12px;
+ color: var(--dm-text);
+}
+
+.inbox-ai-suggestion small {
+ overflow: hidden;
+ color: var(--dm-text-muted);
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ font-size: 11px;
+}
+
+.inbox-ai-suggestion em {
+ color: var(--dm-accent);
+ font-size: 10px;
+ font-style: normal;
+ font-weight: 600;
+ text-align: right;
+ white-space: nowrap;
+}
+
+.inbox-panel {
+ border: 1px solid var(--dm-border);
+ border-radius: 16px;
+ background: var(--dm-bg-card);
+ overflow: hidden;
+}
+
+.inbox-panel-heading {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ gap: 16px;
+ padding: 14px 18px;
+ border-bottom: 1px solid var(--dm-border);
+}
+
+.inbox-panel-heading > div {
+ display: grid;
+ gap: 2px;
+ min-width: 0;
+}
+
+.inbox-panel-heading strong {
+ font-size: 14px;
+ color: var(--dm-text);
+}
+
+.inbox-panel-heading span {
+ color: var(--dm-text-muted);
+ font-size: 12px;
+}
+
+.inbox-panel-heading button {
+ flex: 0 0 auto;
+ white-space: nowrap;
+}
+
+.inbox-list {
+ display: grid;
+}
+
+.inbox-row {
+ display: grid;
+ grid-template-columns: minmax(0, 1fr) minmax(220px, 290px);
+ gap: 14px 20px;
+ align-items: center;
+ padding: 16px 18px;
+ border-bottom: 1px solid var(--dm-border);
+ transition: background-color 140ms ease;
+}
+
+.inbox-row:last-child {
+ border-bottom: 0;
+}
+
+.inbox-row:hover {
+ background: color-mix(in srgb, var(--dm-hover-bg) 42%, transparent);
+}
+
+.inbox-copy {
+ min-width: 0;
+}
+
+.inbox-title-line {
+ display: flex;
+ align-items: center;
+ gap: 9px;
+ min-width: 0;
+}
+
+.inbox-favicon,
+.inbox-ai-favicon {
+ display: grid;
+ place-items: center;
+ flex: 0 0 auto;
+ border: 1px solid var(--dm-border);
+ background: var(--dm-accent-bg);
+ color: var(--dm-accent-strong);
+ font-weight: 700;
+ overflow: hidden;
+}
+
+.inbox-favicon {
+ width: 30px;
+ height: 30px;
+ border-radius: 9px;
+ font-size: 12px;
+}
+
+.inbox-ai-favicon {
+ width: 26px;
+ height: 26px;
+ border-radius: 7px;
+ font-size: 11px;
+}
+
+.inbox-favicon.has-favicon,
+.inbox-ai-favicon.has-favicon {
+ padding: 0;
+ background: var(--dm-bg-soft);
+}
+
+.inbox-favicon.has-favicon img,
+.inbox-ai-favicon.has-favicon img {
+ display: block;
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+ border-radius: inherit;
+}
+
+.inbox-title-line a {
+ min-width: 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ color: var(--dm-text);
+ font-size: 14px;
+ font-weight: 620;
+ text-decoration: none;
+}
+
+.inbox-title-line a:hover {
+ color: var(--dm-accent);
+}
+
+.inbox-policy-pill {
+ flex: 0 0 auto;
+ padding: 2px 8px;
+ border: 1px solid var(--dm-border);
+ border-radius: 999px;
+ background: var(--dm-bg-soft);
+ color: var(--dm-text-muted);
+ font-size: 10px;
+ white-space: nowrap;
+}
+
+.inbox-policy-pill.is-local {
+ border-color: color-mix(in srgb, #b3b77b 45%, var(--dm-border));
+ color: var(--dm-text-soft);
+}
+
+.inbox-ai-select {
+ display: inline-flex;
+ flex: 0 0 auto;
+ align-items: center;
+ gap: 4px;
+ padding: 3px 7px;
+ border: 1px solid color-mix(in srgb, var(--dm-accent) 34%, var(--dm-border));
+ border-radius: 999px;
+ color: var(--dm-accent);
+ cursor: pointer;
+ font-size: 10px;
+ font-weight: 700;
+ letter-spacing: .04em;
+ white-space: nowrap;
+ transition: background-color 140ms ease, transform 80ms ease;
+}
+
+.inbox-ai-select:not(.disabled):hover {
+ background: var(--dm-selected-bg);
+}
+
+.inbox-ai-select:not(.disabled):active {
+ transform: translateY(1px);
+}
+
+.inbox-ai-select input {
+ margin: 0;
+ accent-color: var(--dm-accent);
+}
+
+.inbox-ai-select.disabled {
+ border-color: var(--dm-border);
+ color: var(--dm-text-muted);
+ cursor: not-allowed;
+ opacity: .58;
+}
+
+.inbox-meta {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ gap: 5px 10px;
+ margin-top: 6px;
+ color: var(--dm-text-muted);
+ font-size: 11px;
+}
+
+.inbox-tag {
+ padding: 1px 6px;
+ border: 1px solid var(--dm-border);
+ border-radius: 999px;
+ background: var(--dm-bg-soft);
+ color: var(--dm-text-soft);
+ font-size: 10px;
+ white-space: nowrap;
+}
+
+.inbox-copy p {
+ margin: 7px 0 0;
+ color: var(--dm-text-muted);
+ font-size: 12px;
+ line-height: 1.5;
+}
+
+.inbox-review {
+ display: grid;
+ grid-template-columns: minmax(0, 1fr) auto;
+ gap: 8px;
+ align-items: end;
+}
+
+.inbox-review label {
+ display: grid;
+ gap: 4px;
+ min-width: 0;
+}
+
+.inbox-review label > span {
+ color: var(--dm-text-muted);
+ font-size: 11px;
+ white-space: nowrap;
+}
+
+.inbox-review select {
+ width: 100%;
+ min-height: 36px;
+ padding: 0 9px;
+ border: 1px solid var(--dm-border-strong);
+ border-radius: 9px;
+ background: var(--dm-input-bg);
+ color: var(--dm-text);
+}
+
+.inbox-review .primary {
+ min-height: 36px;
+ white-space: nowrap;
+}
+
+.inbox-metadata-review {
+ grid-column: 1 / -1;
+ display: grid;
+ gap: 10px;
+ padding: 12px 14px;
+ border: 1px solid var(--dm-border);
+ border-radius: 12px;
+ background: var(--dm-bg-soft);
+}
+
+.inbox-metadata-heading {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 14px;
+}
+
+.inbox-metadata-heading > div {
+ display: grid;
+ gap: 2px;
+ min-width: 0;
+}
+
+.inbox-metadata-heading strong {
+ font-size: 12px;
+ color: var(--dm-text);
+}
+
+.inbox-metadata-heading span {
+ color: var(--dm-text-muted);
+ font-size: 11px;
+ line-height: 1.45;
+}
+
+.inbox-metadata-heading .secondary {
+ min-height: 32px;
+ flex: 0 0 auto;
+ white-space: nowrap;
+}
+
+.inbox-metadata-fields {
+ display: grid;
+ gap: 6px;
+}
+
+.inbox-metadata-field,
+.inbox-metadata-info {
+ display: grid;
+ grid-template-columns: auto minmax(0, 1fr) auto;
+ align-items: center;
+ gap: 10px;
+ padding: 8px 10px;
+ border: 1px solid var(--dm-border);
+ border-radius: 9px;
+ background: var(--dm-bg-card);
+ transition: border-color 140ms ease, background-color 140ms ease, transform 80ms ease;
+}
+
+.inbox-metadata-field.available {
+ cursor: pointer;
+ border-color: color-mix(in srgb, var(--dm-accent) 36%, var(--dm-border));
+}
+
+.inbox-metadata-field.available:hover {
+ background: var(--dm-hover-bg);
+}
+
+.inbox-metadata-field.available:active {
+ transform: translateY(1px);
+}
+
+.inbox-metadata-field input {
+ margin: 0;
+ accent-color: var(--dm-accent);
+}
+
+.inbox-metadata-field > span,
+.inbox-metadata-info > span {
+ display: grid;
+ gap: 2px;
+ min-width: 0;
+}
+
+.inbox-metadata-field small,
+.inbox-metadata-info small {
+ color: var(--dm-text-muted);
+ font-size: 10px;
+}
+
+.inbox-metadata-field strong,
+.inbox-metadata-info strong {
+ overflow: hidden;
+ color: var(--dm-text);
+ font-size: 12px;
+ font-weight: 560;
+ line-height: 1.35;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.inbox-metadata-field em,
+.inbox-metadata-info em {
+ color: var(--dm-text-muted);
+ font-size: 10px;
+ font-style: normal;
+ text-align: right;
+ white-space: nowrap;
+}
+
+.inbox-metadata-field.available em {
+ color: var(--dm-accent);
+}
+
+.inbox-metadata-info {
+ grid-template-columns: minmax(0, 1fr) auto;
+ padding-left: 32px;
+}
+
+.inbox-metadata-footnote {
+ color: var(--dm-text-muted);
+ font-size: 11px;
+}
+
+.inbox-empty {
+ display: grid;
+ justify-items: center;
+ gap: 6px;
+ padding: 44px 20px;
+ color: var(--dm-text-muted);
+ font-size: 13px;
+ text-align: center;
+}
+
+.inbox-empty strong {
+ color: var(--dm-text);
+ font-size: 14px;
+}
+
+.inbox-shell button:not(:disabled):active,
+.inbox-shell a.secondary:active {
+ transform: translateY(1px);
+}
@media (max-width: 760px) {
- .inbox-shell { width: min(100% - 24px, 1120px); padding-top: 28px; }
- .inbox-hero { align-items: stretch; flex-direction: column; }
- .inbox-count { align-self: flex-start; text-align: left; }
- .inbox-row { grid-template-columns: 1fr; }
- .inbox-review { grid-template-columns: 1fr; }
- .inbox-metadata-heading { align-items: stretch; flex-direction: column; }
- .inbox-metadata-heading .secondary { width: 100%; }
- .inbox-metadata-field, .inbox-metadata-info { grid-template-columns: auto minmax(0, 1fr); }
- .inbox-metadata-field em, .inbox-metadata-info em { grid-column: 2; text-align: left; white-space: normal; }
- .inbox-metadata-info { padding-left: 10px; }
- .inbox-ai-heading, .inbox-ai-preview-heading { align-items: stretch; flex-direction: column; }
- .inbox-ai-summary { min-width: 0; text-align: left; }
- .inbox-ai-preview-heading > div:last-child { justify-content: flex-start; }
- .inbox-ai-suggestion { grid-template-columns: auto minmax(0, 1fr); }
- .inbox-ai-suggestion em { grid-column: 2; text-align: left; white-space: normal; }
+ .inbox-shell {
+ width: min(100% - 24px, 1120px);
+ padding-top: 20px;
+ }
+ .inbox-hero {
+ align-items: stretch;
+ flex-direction: column;
+ gap: 12px;
+ }
+ .inbox-hero-pills {
+ justify-content: flex-start;
+ }
+ .inbox-row {
+ grid-template-columns: 1fr;
+ }
+ .inbox-review {
+ grid-template-columns: 1fr;
+ }
+ .inbox-metadata-heading {
+ align-items: stretch;
+ flex-direction: column;
+ }
+ .inbox-metadata-heading .secondary {
+ width: 100%;
+ }
+ .inbox-metadata-field,
+ .inbox-metadata-info {
+ grid-template-columns: auto minmax(0, 1fr);
+ }
+ .inbox-metadata-field em,
+ .inbox-metadata-info em {
+ grid-column: 2;
+ text-align: left;
+ white-space: normal;
+ }
+ .inbox-metadata-info {
+ padding-left: 10px;
+ }
+ .inbox-ai-heading,
+ .inbox-ai-preview-heading {
+ align-items: stretch;
+ flex-direction: column;
+ }
+ .inbox-ai-summary {
+ justify-items: start;
+ text-align: left;
+ }
+ .inbox-ai-preview-actions {
+ justify-content: flex-start;
+ }
+ .inbox-ai-suggestion {
+ grid-template-columns: auto auto minmax(0, 1fr);
+ }
+ .inbox-ai-suggestion em {
+ grid-column: 3;
+ text-align: left;
+ white-space: normal;
+ }
}
diff --git a/apps/web/src/library-bulk.css b/apps/web/src/library-bulk.css
index 803c8f4..7bef253 100644
--- a/apps/web/src/library-bulk.css
+++ b/apps/web/src/library-bulk.css
@@ -1,10 +1,11 @@
.library-bulk-management {
+ padding-top: 0;
padding-bottom: 0;
}
.library-bulk-card {
display: grid;
- gap: 16px;
+ gap: 14px;
}
.library-bulk-heading {
@@ -15,25 +16,43 @@
}
.library-bulk-heading h2 {
- margin: 2px 0 0;
+ margin: 0;
+ font-size: 18px;
+ letter-spacing: -0.02em;
}
.library-bulk-heading p,
.library-bulk-review p {
margin: 4px 0 0;
- color: var(--text-muted, #819087);
+ color: var(--dm-text-muted);
+ font-size: 12px;
+ line-height: 1.5;
}
.library-bulk-selection {
display: flex;
align-items: center;
justify-content: flex-end;
- gap: 8px;
+ gap: 10px;
flex-wrap: wrap;
+ flex-shrink: 0;
}
.library-bulk-selection strong {
- color: var(--text-primary, #d7e7dc);
+ color: var(--dm-text);
+ font-size: 12px;
+ white-space: nowrap;
+}
+
+.library-bulk-selection button,
+.library-bulk-actions button {
+ white-space: nowrap;
+ flex-shrink: 0;
+}
+
+.library-bulk-actions button:active:not(:disabled),
+.library-bulk-bookmark:active {
+ transform: translateY(1px);
}
.library-bulk-search {
@@ -41,19 +60,24 @@
grid-template-columns: auto minmax(0, 1fr) auto;
align-items: center;
gap: 10px;
- border: 1px solid color-mix(in srgb, var(--accent, #7fb594) 22%, transparent);
- background: color-mix(in srgb, var(--accent, #7fb594) 5%, transparent);
- border-radius: 12px;
- padding: 8px 11px;
+ border: 1px solid var(--dm-border-strong);
+ background: var(--dm-bg-soft);
+ border-radius: 11px;
+ padding: 7px 11px;
+}
+
+.library-bulk-search:focus-within {
+ border-color: var(--dm-accent);
+ box-shadow: 0 0 0 3px color-mix(in srgb, var(--dm-accent) 12%, transparent);
}
.library-bulk-search > span,
.library-bulk-search > strong {
- color: var(--text-muted, #819087);
+ color: var(--dm-text-muted);
}
.library-bulk-search > strong {
- font-size: 12px;
+ font-size: 11px;
white-space: nowrap;
}
@@ -61,6 +85,7 @@
min-width: 0;
border: 0;
background: transparent;
+ color: var(--dm-text);
padding: 4px 0;
box-shadow: none;
}
@@ -74,9 +99,9 @@
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 8px;
- max-height: 300px;
+ max-height: 290px;
overflow: auto;
- padding: 4px;
+ padding: 2px;
scrollbar-gutter: stable;
}
@@ -85,33 +110,49 @@
grid-template-columns: auto minmax(0, 1fr);
align-items: flex-start;
gap: 10px;
- padding: 10px 11px;
- border: 1px solid color-mix(in srgb, var(--accent, #7fb594) 16%, transparent);
+ padding: 9px 11px;
+ border: 1px solid var(--dm-border);
border-radius: 11px;
- background: color-mix(in srgb, var(--surface, #101713) 92%, transparent);
+ background: var(--dm-bg-soft);
cursor: pointer;
+ transition: border-color .14s ease, background .14s ease, transform .1s ease;
+}
+
+.library-bulk-bookmark-policy {
+ grid-template-columns: auto minmax(0, 1fr) auto;
+ align-items: center;
+}
+
+.library-bulk-policy-pill {
+ padding: 2px 7px;
+ border: 1px solid var(--dm-border);
+ border-radius: 999px;
+ font-size: 10px;
+ color: var(--dm-text-muted);
+ white-space: nowrap;
}
.library-bulk-bookmark:hover {
- border-color: color-mix(in srgb, var(--accent, #7fb594) 36%, transparent);
+ border-color: color-mix(in srgb, var(--dm-accent) 42%, var(--dm-border));
+ background: var(--dm-bg-raised);
}
.library-bulk-bookmark.selected {
- border-color: color-mix(in srgb, var(--accent, #7fb594) 58%, transparent);
- background: color-mix(in srgb, var(--accent, #7fb594) 9%, var(--surface, #101713));
+ border-color: color-mix(in srgb, var(--dm-accent) 56%, var(--dm-border));
+ background: var(--dm-accent-bg);
}
.library-bulk-bookmark input {
- width: 16px;
- height: 16px;
+ width: 15px;
+ height: 15px;
margin-top: 2px;
- accent-color: var(--accent, #7fb594);
+ accent-color: var(--dm-accent);
}
.library-bulk-bookmark > span {
display: grid;
min-width: 0;
- gap: 3px;
+ gap: 2px;
}
.library-bulk-bookmark strong,
@@ -121,8 +162,14 @@
white-space: nowrap;
}
+.library-bulk-bookmark strong {
+ font-size: 13px;
+ color: var(--dm-text);
+}
+
.library-bulk-bookmark small {
- color: var(--text-muted, #819087);
+ color: var(--dm-text-muted);
+ font-size: 11px;
}
.library-bulk-grid {
@@ -131,37 +178,45 @@
gap: 12px;
}
-.library-bulk-grid label {
+.library-bulk-grid label,
+.library-bulk-confirm-field {
display: grid;
align-content: start;
gap: 6px;
}
-.library-bulk-grid label > span {
- font-size: 12px;
- font-weight: 700;
- letter-spacing: 0.04em;
- text-transform: uppercase;
- color: var(--text-muted, #819087);
+.library-bulk-grid label > span,
+.library-bulk-confirm-field > span {
+ font-size: 11px;
+ font-weight: 650;
+ color: var(--dm-text-muted);
}
.library-bulk-grid input,
-.library-bulk-grid select {
+.library-bulk-grid select,
+.library-bulk-confirm-field input {
width: 100%;
+ min-width: 0;
+ height: 40px;
+ padding: 0 11px;
+ border: 1px solid var(--dm-border-strong);
+ border-radius: 10px;
+ background: var(--dm-bg-soft);
+ color: var(--dm-text);
}
.library-bulk-help,
.library-bulk-error {
- font-size: 12px;
+ font-size: 11px;
line-height: 1.45;
}
.library-bulk-help {
- color: var(--text-muted, #819087);
+ color: var(--dm-text-muted);
}
.library-bulk-error {
- color: #f0a8a8;
+ color: var(--dm-danger);
}
.library-bulk-actions {
@@ -172,10 +227,10 @@
}
.library-bulk-review {
- border: 1px solid color-mix(in srgb, var(--accent, #7fb594) 42%, transparent);
- background: color-mix(in srgb, var(--accent, #7fb594) 9%, transparent);
+ border: 1px solid color-mix(in srgb, var(--dm-accent) 44%, var(--dm-border));
+ background: color-mix(in srgb, var(--dm-accent-bg) 55%, var(--dm-bg-card));
border-radius: 14px;
- padding: 16px;
+ padding: 15px;
display: grid;
gap: 12px;
}
@@ -184,20 +239,22 @@
.library-bulk-review-list {
display: flex;
flex-wrap: wrap;
- gap: 8px;
+ gap: 7px;
}
.library-bulk-review-summary span,
.library-bulk-review-list span {
- border: 1px solid color-mix(in srgb, var(--accent, #7fb594) 32%, transparent);
- background: color-mix(in srgb, var(--accent, #7fb594) 8%, transparent);
+ border: 1px solid color-mix(in srgb, var(--dm-accent) 34%, var(--dm-border));
+ background: var(--dm-bg-card);
border-radius: 999px;
- padding: 6px 9px;
- font-size: 12px;
+ padding: 4px 10px;
+ font-size: 11px;
+ color: var(--dm-text);
}
.library-bulk-review-list span {
- color: var(--text-muted, #819087);
+ color: var(--dm-text-muted);
+ border-color: var(--dm-border);
background: transparent;
}
@@ -215,27 +272,3 @@
justify-content: flex-start;
}
}
-
-[data-theme="light"] .library-bulk-search,
-:root[data-theme="light"] .library-bulk-search {
- background: #f8fbf8;
- border-color: #d7e3da;
-}
-
-[data-theme="light"] .library-bulk-bookmark,
-:root[data-theme="light"] .library-bulk-bookmark {
- background: #fbfcfb;
- border-color: #dce6df;
-}
-
-[data-theme="light"] .library-bulk-bookmark.selected,
-:root[data-theme="light"] .library-bulk-bookmark.selected {
- background: #f1f7f2;
- border-color: #bdd5c4;
-}
-
-[data-theme="light"] .library-bulk-review,
-:root[data-theme="light"] .library-bulk-review {
- background: #f3f8f4;
- border-color: #cfe0d4;
-}
diff --git a/apps/web/src/light-theme-consistency.css b/apps/web/src/light-theme-consistency.css
index 614d495..4e0b1f8 100644
--- a/apps/web/src/light-theme-consistency.css
+++ b/apps/web/src/light-theme-consistency.css
@@ -1,6 +1,5 @@
-/* Final light-mode cleanup for the older Transfer / Extension / Public Page
- surfaces that intentionally used dark inverse cards before the shared theme
- token pass. Dark mode remains unchanged. */
+/* Final light-mode cleanup for Transfer / Extension / Auth / Public Page
+ surfaces so light mode has cohesive contrast everywhere. */
html[data-theme="light"] .extension-state {
border-color: var(--dm-border);
@@ -28,7 +27,7 @@ html[data-theme="light"] .extension-hero-card {
background:
radial-gradient(circle at 90% 20%, rgba(79,128,99,.10), transparent 17rem),
rgba(255,255,255,.88);
- box-shadow: 0 18px 44px rgba(40,67,54,.05);
+ box-shadow: 0 14px 36px rgba(40,67,54,.05);
}
html[data-theme="light"] .extension-version,
html[data-theme="light"] .extension-profile-kicker { color: var(--dm-accent); }
@@ -42,20 +41,20 @@ html[data-theme="light"] .extension-mark {
border-color: #bdd2c5;
background: #e8f1eb;
color: var(--dm-accent-strong);
- box-shadow: inset 0 0 0 1px rgba(255,255,255,.7), 0 16px 36px rgba(40,67,54,.08);
+ box-shadow: inset 0 0 0 1px rgba(255,255,255,.7), 0 12px 28px rgba(40,67,54,.08);
}
html[data-theme="light"] .extension-profile,
html[data-theme="light"] .extension-profile-firefox {
border-color: var(--dm-border);
- background: rgba(255,255,255,.86);
- box-shadow: 0 12px 30px rgba(40,67,54,.035);
+ background: rgba(255,255,255,.88);
+ box-shadow: 0 10px 26px rgba(40,67,54,.035);
}
html[data-theme="light"] .extension-profile-recommended {
border-color: #a8cbb5;
background:
radial-gradient(circle at 95% 5%, rgba(79,128,99,.11), transparent 17rem),
#f8fbf9;
- box-shadow: inset 0 0 0 1px rgba(79,128,99,.05), 0 12px 30px rgba(40,67,54,.04);
+ box-shadow: inset 0 0 0 1px rgba(79,128,99,.05), 0 10px 26px rgba(40,67,54,.04);
}
html[data-theme="light"] .extension-profile-badge {
border-color: #b9d0c1;
@@ -78,7 +77,7 @@ html[data-theme="light"] .capability-list > div,
html[data-theme="light"] .extension-diagnostic-note { border-color: var(--dm-border); }
html[data-theme="light"] .extension-nudge {
border-color: var(--dm-border);
- background: rgba(255,255,255,.82);
+ background: rgba(255,255,255,.86);
}
html[data-theme="light"] .extension-nudge:hover {
border-color: #a8cbb5;
@@ -87,6 +86,27 @@ html[data-theme="light"] .extension-nudge:hover {
html[data-theme="light"] .extension-nudge-copy span { color: var(--dm-text-muted); }
html[data-theme="light"] .extension-nudge-action { color: var(--dm-accent-strong); }
+html[data-theme="light"] .auth-card {
+ border-color: var(--dm-border);
+ background: rgba(255, 255, 255, .94);
+ box-shadow: 0 22px 64px rgba(40, 67, 54, .08);
+}
+html[data-theme="light"] .auth-card > p,
+html[data-theme="light"] .auth-card label,
+html[data-theme="light"] .auth-setup-steps span,
+html[data-theme="light"] .auth-loading { color: var(--dm-text-muted); }
+html[data-theme="light"] .auth-brand span {
+ border-color: var(--dm-border-strong);
+ background: var(--dm-bg-raised);
+ color: var(--dm-accent-strong);
+}
+html[data-theme="light"] .auth-setup-card code,
+html[data-theme="light"] .auth-setup-steps code {
+ border-color: var(--dm-border);
+ background: var(--dm-bg-soft);
+ color: var(--dm-accent-strong);
+}
+
html[data-theme="light"] .file-drop {
border-color: var(--dm-border-strong);
background: #fbfcfb;
diff --git a/apps/web/src/main.tsx b/apps/web/src/main.tsx
index 031f2ea..1f5b27c 100644
--- a/apps/web/src/main.tsx
+++ b/apps/web/src/main.tsx
@@ -1,8 +1,26 @@
+/**
+ * [INPUT]: depends on PrivateRoot, PublicPage, theme helpers from ./theme, locale helpers from ./i18n, and global/feature CSS bundles
+ * [OUTPUT]: bootstraps pre-paint appearance/locale state, binds system listeners, and mounts the private or public React root into #root
+ * [POS]: Web SPA entrypoint. Routes /app* to PrivateRoot and all other paths to PublicPage while preventing theme/locale flash.
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import { PrivateRoot } from "./PrivateRoot";
import { PublicPage } from "./PublicPage";
-import { applyAppearance, bindSystemAppearanceListener, localAppearance, syncAppearanceFromCloud } from "./theme";
+import {
+ APPEARANCE_STORAGE_KEY,
+ applyAppearance,
+ bindSystemAppearanceListener,
+ fetchAppearanceSettings,
+ localAppearance,
+} from "./theme";
+import {
+ applyLocalePreference,
+ bindSystemLocaleListener,
+ localLocalePreference,
+ syncAppearanceAndLocaleFromCloud,
+} from "./i18n";
import "./styles.css";
import "./workspaces.css";
import "./session.css";
@@ -19,12 +37,32 @@ import "./responsive-shell.css";
const root = document.getElementById("root");
if (!root) throw new Error("Missing #root");
+const privateRoute = window.location.pathname === "/app" || window.location.pathname.startsWith("/app/");
+
applyAppearance(localAppearance(), false);
+if (privateRoute) {
+ applyLocalePreference(localLocalePreference(), false);
+}
const unbindSystemAppearance = bindSystemAppearanceListener();
-window.addEventListener("pagehide", unbindSystemAppearance, { once: true });
-void syncAppearanceFromCloud();
+const unbindSystemLocale = bindSystemLocaleListener();
+window.addEventListener(
+ "pagehide",
+ () => {
+ unbindSystemAppearance();
+ unbindSystemLocale();
+ },
+ { once: true },
+);
-const privateRoute = window.location.pathname === "/app" || window.location.pathname.startsWith("/app/");
+if (privateRoute) {
+ void syncAppearanceAndLocaleFromCloud();
+} else if (!localStorage.getItem(APPEARANCE_STORAGE_KEY)) {
+ void fetchAppearanceSettings()
+ .then((settings) => {
+ applyAppearance(settings.preference, false);
+ })
+ .catch(() => undefined);
+}
createRoot(root).render(
diff --git a/apps/web/src/maintenance.css b/apps/web/src/maintenance.css
index 4ba51f0..1bb37eb 100644
--- a/apps/web/src/maintenance.css
+++ b/apps/web/src/maintenance.css
@@ -1,87 +1,63 @@
-.maintenance-section { display: grid; gap: 16px; margin-bottom: 46px; }
+.maintenance-section { display: grid; gap: 16px; margin-bottom: 40px; }
.maintenance-heading { margin: 0; order: 0; }
+.maintenance-heading h2 { margin: 0; font-size: 18px; letter-spacing: -0.02em; }
.maintenance-section > .error-banner, .maintenance-feedback { order: 1; }
.maintenance-grid { display: grid; grid-template-columns: minmax(260px, .72fr) minmax(0, 1.45fr); gap: 14px; align-items: start; order: 3; }
-.maintenance-list { display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 9px; max-height: 720px; overflow: hidden; padding: 10px; }
+.maintenance-list { display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 9px; max-height: 700px; overflow: hidden; padding: 10px; }
.maintenance-list-tools { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 9px; }
-.maintenance-list-tools input { min-width: 0; height: 36px; padding: 0 11px; border: 1px solid #2d3932; border-radius: 9px; color: #dbe5df; background: #0f1512; font: inherit; font-size: 11px; outline: none; }
-.maintenance-list-tools input:focus { border-color: #6d987a; box-shadow: 0 0 0 2px rgb(109 152 122 / 16%); }
-.maintenance-list-tools span { color: #6f7b74; font-size: 10px; white-space: nowrap; }
-.maintenance-list-scroll { display: grid; align-content: start; gap: 7px; min-height: 0; overflow-y: scroll; padding-right: 4px; scrollbar-gutter: stable; }
-.maintenance-list-scroll::-webkit-scrollbar { width: 8px; }
-.maintenance-list-scroll::-webkit-scrollbar-track { border-radius: 999px; background: #101612; }
-.maintenance-list-scroll::-webkit-scrollbar-thumb { border: 2px solid #101612; border-radius: 999px; background: #52645a; }
-.maintenance-list-scroll { scrollbar-width: thin; scrollbar-color: #52645a #101612; }
-.maintenance-list-item { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 12px; width: 100%; padding: 12px; border: 1px solid transparent; border-radius: 11px; color: inherit; background: transparent; text-align: left; cursor: pointer; }
-.maintenance-list-item:hover { border-color: #2d3932; background: #111713; }
-.maintenance-list-item.active { border-color: #496653; background: #142019; }
-.maintenance-list-item > span { display: grid; gap: 4px; min-width: 0; }
+.maintenance-list-tools input { min-width: 0; height: 36px; padding: 0 11px; border: 1px solid var(--dm-border-strong); border-radius: 9px; color: var(--dm-text); background: var(--dm-bg-soft); font: inherit; font-size: 12px; outline: none; }
+.maintenance-list-tools input:focus { border-color: var(--dm-accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--dm-accent) 16%, transparent); }
+.maintenance-list-tools span { color: var(--dm-text-muted); font-size: 11px; white-space: nowrap; }
+.maintenance-list-scroll { display: grid; align-content: start; gap: 6px; min-height: 0; overflow-y: auto; padding-right: 4px; scrollbar-gutter: stable; }
+.maintenance-list-item { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 10px; width: 100%; padding: 10px 11px; border: 1px solid transparent; border-radius: 11px; color: inherit; background: transparent; text-align: left; cursor: pointer; transition: border-color .14s ease, background .14s ease, transform .1s ease; }
+.maintenance-list-item:hover { border-color: var(--dm-border); background: var(--dm-bg-soft); }
+.maintenance-list-item:active { transform: translateY(1px); }
+.maintenance-list-item.active { border-color: color-mix(in srgb, var(--dm-accent) 52%, var(--dm-border)); background: var(--dm-accent-bg); }
+.maintenance-list-item > span { display: grid; gap: 3px; min-width: 0; }
.maintenance-list-item strong, .maintenance-list-item small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
-.maintenance-list-item strong { font-size: 13px; }
-.maintenance-list-item small { color: #77827c; font-size: 10px; }
-.maintenance-list-item em { font-size: 10px; font-style: normal; text-transform: uppercase; letter-spacing: .08em; }
+.maintenance-list-item strong { font-size: 13px; color: var(--dm-text); }
+.maintenance-list-item small { color: var(--dm-text-muted); font-size: 11px; }
+.maintenance-list-item em { font-size: 10px; font-style: normal; white-space: nowrap; }
.maintenance-inspector { display: grid; gap: 14px; min-width: 0; }
-.maintenance-card { display: grid; gap: 16px; padding: 18px; }
-.maintenance-card-heading { display: flex; align-items: start; justify-content: space-between; gap: 18px; }
-.maintenance-card-heading h3 { margin: 4px 0 5px; font-size: 16px; }
-.maintenance-card-heading p { margin: 0; max-width: 650px; color: #77827c; font-size: 11px; line-height: 1.55; }
-.maintenance-card-heading a { display: block; overflow: hidden; max-width: 650px; color: #8fa097; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
-.maintenance-empty, .maintenance-muted { color: #77827c; font-size: 11px; }
+.maintenance-card { display: grid; gap: 14px; padding: 16px; }
+.maintenance-card-heading { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
+.maintenance-card-heading h3 { margin: 0 0 4px; font-size: 15px; }
+.maintenance-card-heading p { margin: 0; max-width: 650px; color: var(--dm-text-muted); font-size: 12px; line-height: 1.5; }
+.maintenance-card-heading a { display: block; overflow: hidden; max-width: 620px; color: var(--dm-text-muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
+.maintenance-selected-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
+.maintenance-favicon { flex: 0 0 38px; width: 38px; height: 38px; }
+.maintenance-selected-copy { display: grid; gap: 3px; min-width: 0; }
+.maintenance-empty, .maintenance-muted { color: var(--dm-text-muted); font-size: 12px; }
.maintenance-feedback { margin: 0; }
-.selected-badges { display: flex; flex: 0 0 auto; align-items: center; gap: 7px; }
-.maintenance-policy { padding: 5px 8px; border: 1px solid #2e3b34; border-radius: 999px; color: #87978e; background: #101612; font-size: 8px; font-weight: 650; text-transform: uppercase; letter-spacing: .08em; }
+.selected-badges { display: flex; flex: 0 0 auto; align-items: center; gap: 7px; flex-wrap: wrap; }
+.maintenance-policy { padding: 4px 8px; border: 1px solid var(--dm-border); border-radius: 999px; color: var(--dm-text-muted); background: var(--dm-bg-soft); font-size: 10px; font-weight: 600; white-space: nowrap; }
.metadata-fields { display: grid; gap: 8px; }
-.metadata-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 58px; padding: 10px 12px; border: 1px solid #27312c; border-radius: 11px; background: #0f1512; }
-.metadata-row > span, .redirect-review > span { display: grid; gap: 4px; min-width: 0; }
-.metadata-row small, .redirect-review small { color: #6f7b74; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
-.metadata-row strong, .redirect-review strong { overflow-wrap: anywhere; color: #bdc9c1; font-size: 11px; font-weight: 550; line-height: 1.45; }
-.redirect-review { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 13px; border: 1px solid #42604c; border-radius: 12px; background: #101b14; }
-.health-actions { display: flex; flex: 0 0 auto; gap: 8px; }
-.cleanup-eligibility { margin: 0; padding: 9px 11px; border: 1px solid #303b35; border-radius: 9px; color: #849089; background: #101612; font-size: 10px; line-height: 1.45; }
-.cleanup-eligibility.eligible { border-color: #3e624a; color: #a9cab4; background: #101b14; }
+.metadata-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 54px; padding: 9px 12px; border: 1px solid var(--dm-border); border-radius: 11px; background: var(--dm-bg-soft); }
+.metadata-row > span, .redirect-review > span { display: grid; gap: 3px; min-width: 0; }
+.metadata-row small, .redirect-review small { color: var(--dm-text-muted); font-size: 10px; }
+.metadata-row strong, .redirect-review strong { overflow-wrap: anywhere; color: var(--dm-text-soft); font-size: 12px; font-weight: 550; line-height: 1.45; }
+.redirect-review { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 13px; border: 1px solid color-mix(in srgb, var(--dm-accent) 48%, var(--dm-border)); border-radius: 12px; background: var(--dm-accent-bg); }
+.health-actions, .cleanup-actions { display: flex; flex: 0 0 auto; gap: 8px; }
+.maintenance-card button, .cleanup-panel button { white-space: nowrap; flex-shrink: 0; }
+.maintenance-card button:active:not(:disabled), .cleanup-panel button:active:not(:disabled) { transform: translateY(1px); }
+.cleanup-eligibility { margin: 0; padding: 9px 11px; border: 1px solid var(--dm-border); border-radius: 9px; color: var(--dm-text-muted); background: var(--dm-bg-soft); font-size: 11px; line-height: 1.45; }
+.cleanup-eligibility.eligible { border-color: color-mix(in srgb, var(--dm-accent) 52%, var(--dm-border)); color: var(--dm-accent-strong); background: var(--dm-accent-bg); }
.health-history { display: grid; gap: 6px; }
-.health-history-row { display: grid; grid-template-columns: 105px 58px 48px 74px minmax(120px,1fr) 150px; align-items: center; gap: 10px; min-height: 38px; padding: 7px 9px; border-bottom: 1px solid #222b27; color: #849089; font-size: 10px; }
+.health-history-row { display: grid; grid-template-columns: 105px 66px 48px 72px minmax(110px,1fr) 150px; align-items: center; gap: 10px; min-height: 36px; padding: 7px 9px; border-bottom: 1px solid var(--dm-border); color: var(--dm-text-muted); font-size: 11px; }
.health-history-row:last-child { border-bottom: 0; }
.health-history-url { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
-.health-source { color: #66736c; font-size: 10px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; }
-.health-source.source-extension { color: #9fb9a7; }
-.maintenance-health { color: #76827b; }
-.cleanup-panel { display: grid; gap: 14px; padding: 18px; order: 4; scroll-margin-top: 18px; }
-.cleanup-panel:has(.cleanup-row) { order: 2; border-color: #3e624a; }
-.cleanup-actions { display: flex; flex: 0 0 auto; gap: 8px; }
+.health-source { color: var(--dm-text-muted); font-size: 10px; font-weight: 650; white-space: nowrap; }
+.health-source.source-extension { color: var(--dm-accent-strong); }
+.maintenance-health { color: var(--dm-text-muted); }
+.cleanup-panel { display: grid; gap: 14px; padding: 16px; order: 4; scroll-margin-top: 18px; }
+.cleanup-panel:has(.cleanup-row) { order: 2; border-color: color-mix(in srgb, var(--dm-accent) 46%, var(--dm-border)); }
.cleanup-list { display: grid; gap: 7px; }
-.cleanup-row { display: grid; grid-template-columns: 20px minmax(0,1fr) auto; align-items: center; gap: 11px; min-height: 58px; padding: 10px 12px; border: 1px solid #27312c; border-radius: 11px; background: #0f1512; cursor: pointer; }
-.cleanup-row input { width: 16px; height: 16px; accent-color: #91bc9f; }
-.cleanup-row > span:nth-child(2) { display: grid; gap: 4px; min-width: 0; }
+.cleanup-row { display: grid; grid-template-columns: 20px minmax(0,1fr) auto; align-items: center; gap: 11px; min-height: 54px; padding: 9px 12px; border: 1px solid var(--dm-border); border-radius: 11px; background: var(--dm-bg-soft); cursor: pointer; }
+.cleanup-row input { width: 16px; height: 16px; accent-color: var(--dm-accent); }
+.cleanup-row > span:nth-child(2) { display: grid; gap: 3px; min-width: 0; }
.cleanup-row strong, .cleanup-row small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
-.cleanup-row strong { font-size: 12px; }
-.cleanup-row small { color: #77827c; font-size: 10px; }
-
-html[data-theme="light"] .maintenance-list-tools input { border-color: var(--dm-border); color: var(--dm-text); background: #fff; }
-html[data-theme="light"] .maintenance-list-tools input:focus { border-color: #7fa88d; box-shadow: 0 0 0 2px rgb(127 168 141 / 15%); }
-html[data-theme="light"] .maintenance-list-tools span { color: var(--dm-text-muted); }
-html[data-theme="light"] .maintenance-list-scroll::-webkit-scrollbar-track { background: #edf2ef; }
-html[data-theme="light"] .maintenance-list-scroll::-webkit-scrollbar-thumb { border-color: #edf2ef; background: #9cadA3; }
-html[data-theme="light"] .maintenance-list-scroll { scrollbar-color: #9cada3 #edf2ef; }
-html[data-theme="light"] .maintenance-list-item:hover { border-color: var(--dm-border); background: var(--dm-bg-soft); }
-html[data-theme="light"] .maintenance-list-item.active { border-color: #8cb09a; background: #e6f0ea; }
-html[data-theme="light"] .maintenance-list-item small,
-html[data-theme="light"] .maintenance-card-heading p,
-html[data-theme="light"] .maintenance-card-heading a,
-html[data-theme="light"] .maintenance-muted,
-html[data-theme="light"] .cleanup-row small { color: var(--dm-text-muted); }
-html[data-theme="light"] .maintenance-policy { border-color: var(--dm-border); color: var(--dm-text-muted); background: var(--dm-bg-soft); }
-html[data-theme="light"] .metadata-row,
-html[data-theme="light"] .cleanup-row { border-color: var(--dm-border); background: var(--dm-bg-soft); }
-html[data-theme="light"] .metadata-row strong,
-html[data-theme="light"] .redirect-review strong { color: var(--dm-text-soft); }
-html[data-theme="light"] .redirect-review { border-color: #a8c9b4; background: #edf6f0; }
-html[data-theme="light"] .cleanup-eligibility { border-color: var(--dm-border); color: var(--dm-text-muted); background: var(--dm-bg-soft); }
-html[data-theme="light"] .cleanup-eligibility.eligible { border-color: #9fc4aa; color: #356047; background: #edf6f0; }
-html[data-theme="light"] .cleanup-panel:has(.cleanup-row) { border-color: #9fc4aa; }
-html[data-theme="light"] .health-history-row { border-color: var(--dm-border); color: var(--dm-text-muted); }
-html[data-theme="light"] .health-source { color: var(--dm-text-muted); }
-html[data-theme="light"] .health-source.source-extension { color: #47725a; }
+.cleanup-row strong { font-size: 12px; color: var(--dm-text); }
+.cleanup-row small { color: var(--dm-text-muted); font-size: 11px; }
@media (max-width: 900px) {
.maintenance-grid { grid-template-columns: 1fr; }
diff --git a/apps/web/src/public-page.css b/apps/web/src/public-page.css
index b7f1d7a..4ed3ffc 100644
--- a/apps/web/src/public-page.css
+++ b/apps/web/src/public-page.css
@@ -1,42 +1,123 @@
-.public-shell { position: relative; width: min(1120px, calc(100% - 40px)); margin: 0 auto; padding-bottom: 48px; }
-.public-topbar { display: flex; align-items: center; justify-content: space-between; min-height: 76px; border-bottom: 1px solid #202623; }
-.public-brand { display: inline-flex; align-items: center; gap: 10px; }
-.public-brand > span { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid #39433e; border-radius: 10px; background: #151b18; color: #b8e0c5; font-weight: 800; }
-.public-brand strong { letter-spacing: -.02em; }
-.public-manage { padding: 8px 11px; border: 1px solid #2f3934; border-radius: 9px; color: #93a29a; background: #111613; font-size: 11px; }
-.public-manage:hover { color: #d9e6de; border-color: #4a5c51; }
-.public-hero { max-width: 760px; padding: 92px 0 54px; }
-.public-hero h1 { margin: 14px 0 20px; font-size: clamp(46px, 8vw, 82px); }
-.public-intro { max-width: 660px; color: #849089; font-size: 15px; line-height: 1.75; }
-.public-search { display: flex; align-items: center; gap: 10px; max-width: 620px; min-height: 54px; margin-top: 30px; padding: 0 16px; border: 1px solid #34403a; border-radius: 15px; background: rgba(14,19,17,.82); }
-.public-search > span { color: #809087; font-size: 22px; }
-.public-search input { flex: 1; min-width: 0; border: 0; outline: 0; color: #edf3ef; background: transparent; }
-.public-search:focus-within { border-color: #729f82; box-shadow: 0 0 0 3px rgba(114,159,130,.1); }
-.public-groups { display: grid; gap: 38px; }
-.public-group { display: grid; gap: 14px; }
-.public-group-heading { display: flex; align-items: center; gap: 9px; color: #85928b; }
-.public-group-heading > span { color: #6e8175; font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; }
-.public-group-heading h2 { margin: 0; color: #cbd8d0; font-size: 14px; text-transform: uppercase; letter-spacing: .08em; }
-.public-group-heading small { margin-left: auto; color: #59655e; }
-.public-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; }
-.public-card { display: flex; align-items: center; gap: 13px; min-height: 78px; padding: 14px; border: 1px solid #252d29; border-radius: 15px; background: rgba(14,19,17,.68); transition: transform .15s ease, border-color .15s ease, background .15s ease; }
-.public-card:hover { transform: translateY(-1px); border-color: #3b4b42; background: #121915; }
-.public-card-icon { display: grid; place-items: center; flex: 0 0 40px; width: 40px; height: 40px; border: 1px solid #303a35; border-radius: 12px; background: #1b231e; color: #b8d6c1; font-weight: 700; }
-.public-card-copy { display: grid; gap: 4px; min-width: 0; flex: 1; }
-.public-card-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
-.public-card-copy small { overflow: hidden; color: #717e77; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
-.public-card-arrow { color: #59665f; }
-.public-empty, .public-message { padding: 34px; border: 1px dashed #2b342f; border-radius: 16px; color: #77827c; text-align: center; }
-.public-empty { display: grid; gap: 6px; }
-.public-empty strong { color: #b5c2ba; }
-.public-error { border-color: #573431; color: #d2a09b; }
-.public-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 64px; padding: 22px 0; border-top: 1px solid #202623; color: #5e6a64; font-size: 11px; }
-.public-footer a { color: #87978e; }
+.public-shell { position: relative; width: min(1100px, calc(100% - 40px)); margin: 0 auto; padding-bottom: 48px; }
+.public-topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 62px; border-bottom: 1px solid var(--dm-border); }
+.public-brand { display: inline-flex; align-items: center; gap: 9px; flex: 0 0 auto; }
+.public-brand > span { display: grid; place-items: center; width: 32px; height: 32px; border: 1px solid var(--dm-border-strong); border-radius: 9px; background: var(--dm-bg-raised); color: var(--dm-accent-strong); font-weight: 800; }
+.public-brand strong { font-size: 15px; letter-spacing: -.02em; }
+.public-topbar-actions { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
+.public-control-pill {
+ display: inline-flex;
+ align-items: center;
+ gap: 5px;
+ height: 30px;
+ padding: 0 9px;
+ border: 1px solid var(--dm-border);
+ border-radius: 8px;
+ background: var(--dm-bg-card);
+ color: var(--dm-text-soft);
+ font-size: 11px;
+ font-weight: 550;
+ cursor: pointer;
+ white-space: nowrap;
+ transition: border-color 140ms ease, background-color 140ms ease, color 140ms ease;
+}
+.public-control-pill:hover { border-color: color-mix(in srgb, var(--dm-accent) 46%, var(--dm-border)); background: var(--dm-hover-bg); color: var(--dm-text); }
+.public-manage {
+ display: inline-flex;
+ align-items: center;
+ height: 30px;
+ padding: 0 10px;
+ border: 1px solid var(--dm-border-strong);
+ border-radius: 8px;
+ color: var(--dm-text-soft);
+ background: var(--dm-bg-card);
+ font-size: 11px;
+ font-weight: 560;
+ white-space: nowrap;
+ transition: border-color 140ms ease, background-color 140ms ease, color 140ms ease;
+}
+.public-manage:hover { color: var(--dm-text); border-color: var(--dm-accent); background: var(--dm-hover-bg); }
+
+.public-hero { padding: 30px 0 22px; }
+.public-hero-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
+.public-hero h1 { margin: 0 0 6px; font-size: clamp(24px, 3vw, 32px); line-height: 1.18; letter-spacing: -.03em; font-weight: 650; }
+.public-intro { max-width: 640px; margin: 0; color: var(--dm-text-muted); font-size: 13px; line-height: 1.55; }
+.public-count-badge {
+ flex: 0 0 auto;
+ padding: 5px 10px;
+ border: 1px solid var(--dm-border);
+ border-radius: 999px;
+ background: var(--dm-bg-soft);
+ color: var(--dm-text-muted);
+ font-size: 11px;
+ white-space: nowrap;
+}
+.public-search {
+ display: flex;
+ align-items: center;
+ gap: 10px;
+ max-width: 640px;
+ min-height: 46px;
+ margin-top: 16px;
+ padding: 0 14px;
+ border: 1px solid var(--dm-border-strong);
+ border-radius: 13px;
+ background: color-mix(in srgb, var(--dm-bg-card) 86%, transparent);
+}
+.public-search > span { color: var(--dm-text-muted); font-size: 19px; line-height: 1; }
+.public-search input { flex: 1; min-width: 0; border: 0; outline: 0; color: var(--dm-text); background: transparent; font-size: 14px; }
+.public-search:focus-within { border-color: var(--dm-accent); box-shadow: 0 0 0 3px var(--dm-focus-ring); }
+
+.public-groups { display: grid; gap: 26px; }
+.public-group { display: grid; gap: 10px; }
+.public-group-heading { display: flex; align-items: center; gap: 8px; color: var(--dm-text-soft); }
+.public-group-heading > span { color: var(--dm-accent); font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; }
+.public-group-heading h2 { margin: 0; color: var(--dm-text); font-size: 13px; font-weight: 640; letter-spacing: .02em; }
+.public-group-heading small { margin-left: auto; color: var(--dm-text-muted); font-size: 11px; }
+.public-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 9px; }
+.public-card {
+ display: flex;
+ align-items: center;
+ gap: 11px;
+ min-height: 66px;
+ padding: 11px 12px;
+ border: 1px solid var(--dm-border);
+ border-radius: 13px;
+ background: color-mix(in srgb, var(--dm-bg-card) 82%, transparent);
+ transition: transform 130ms ease, border-color 140ms ease, background-color 140ms ease;
+}
+.public-card:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--dm-accent) 46%, var(--dm-border)); background: var(--dm-hover-bg); }
+.public-card-icon {
+ display: grid;
+ place-items: center;
+ flex: 0 0 34px;
+ width: 34px;
+ height: 34px;
+ overflow: hidden;
+ border: 1px solid var(--dm-border-strong);
+ border-radius: 9px;
+ background: var(--dm-accent-bg);
+ color: var(--dm-accent-strong);
+ font-size: 13px;
+ font-weight: 700;
+}
+.public-card-icon img { width: 18px; height: 18px; object-fit: contain; border-radius: 3px; }
+.public-card-copy { display: grid; gap: 3px; min-width: 0; flex: 1; }
+.public-card-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 600; }
+.public-card-copy small { overflow: hidden; color: var(--dm-text-muted); text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
+.public-card-arrow { color: var(--dm-text-muted); font-size: 12px; }
+.public-empty, .public-message { padding: 28px; border: 1px dashed var(--dm-border); border-radius: 14px; color: var(--dm-text-muted); font-size: 13px; text-align: center; }
+.public-empty { display: grid; gap: 5px; }
+.public-empty strong { color: var(--dm-text); }
+.public-error { border-color: #573431; color: var(--dm-danger); }
+.public-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 44px; padding: 18px 0; border-top: 1px solid var(--dm-border); color: var(--dm-text-muted); font-size: 11px; }
+.public-footer a { color: var(--dm-text-soft); }
+.public-footer a:hover { color: var(--dm-text); }
@media (max-width: 900px) { .public-grid { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 640px) {
- .public-shell { width: min(100% - 24px, 1120px); }
- .public-hero { padding-top: 58px; }
+ .public-shell { width: min(100% - 24px, 1100px); }
+ .public-hero { padding-top: 22px; }
+ .public-hero-head { align-items: flex-start; flex-direction: column; gap: 8px; }
.public-grid { grid-template-columns: 1fr; }
- .public-manage { padding: 7px 9px; }
+ .public-manage, .public-control-pill { padding: 0 8px; }
}
diff --git a/apps/web/src/reorder.css b/apps/web/src/reorder.css
index 14aa1d0..a4acdbd 100644
--- a/apps/web/src/reorder.css
+++ b/apps/web/src/reorder.css
@@ -1,19 +1,20 @@
.reorder-row { transition: border-color .16s ease, background .16s ease, opacity .16s ease; }
.reorder-row[draggable="true"] { cursor: grab; }
.reorder-row[draggable="true"]:active { cursor: grabbing; }
-.reorder-row.is-dragging { opacity: .45; border-color: #5f806c; background: rgba(35, 50, 42, .72); }
-.drag-handle { flex: 0 0 auto; color: #58655e; font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: -3px; user-select: none; }
+.reorder-row.is-dragging { opacity: .45; border-color: var(--dm-accent); background: var(--dm-accent-bg); }
+.drag-handle { flex: 0 0 auto; color: var(--dm-text-muted); opacity: .7; font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: -3px; user-select: none; }
.bookmark-drag-handle { align-self: stretch; display: grid; place-items: center; padding-right: 2px; }
.reorder-action:disabled { opacity: .28; cursor: default; }
.grouped-bookmark-list { gap: 16px; }
/* Grid children default to min-width:auto, which lets a long bookmark title
size the track and push the whole management column past the viewport. */
.bookmark-group { display: grid; grid-template-columns: minmax(0, 1fr); gap: 7px; }
-.bookmark-group-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 4px; color: #91a098; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
-.bookmark-group-heading > span { color: #5f6b65; }
+.bookmark-group-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 4px; color: var(--dm-text-soft); font-size: 11px; font-weight: 650; letter-spacing: .04em; }
+.bookmark-group-heading > span { color: var(--dm-text-muted); }
.bookmark-group-items { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.bookmark-group-items > * { min-width: 0; }
-.reorder-button { min-width: 34px; padding: 0 8px; }
+.reorder-button { min-width: 34px; padding: 0 8px; white-space: nowrap; }
+.reorder-button:active:not(:disabled) { transform: translateY(1px); }
@media (max-width: 720px) {
.bookmark-drag-handle { display: none; }
.reorder-button { min-width: 36px; }
diff --git a/apps/web/src/responsive-shell.css b/apps/web/src/responsive-shell.css
index 6b25bbd..d621c6b 100644
--- a/apps/web/src/responsive-shell.css
+++ b/apps/web/src/responsive-shell.css
@@ -17,6 +17,7 @@
.private-utility-brand {
flex: 0 0 auto;
+ white-space: nowrap;
}
.private-utility-bar nav,
@@ -35,10 +36,13 @@
.private-utility-bar nav {
flex: 0 1 auto;
+ align-items: center;
margin-left: auto;
}
.private-utility-bar nav button,
+.private-utility-bar nav .utility-quick-group,
+.private-utility-bar nav .private-utility-divider,
.workspace-section-nav .ghost {
flex: 0 0 auto;
white-space: nowrap;
@@ -163,18 +167,15 @@
margin-left: 0;
}
- .hero {
- padding-top: 42px;
- padding-bottom: 34px;
- }
-
- .hero h1 {
- font-size: clamp(34px, 11vw, 44px);
+ .hero,
+ .launcher-hero {
+ padding-top: 18px;
+ padding-bottom: 14px;
}
.command {
- min-height: 56px;
- padding-left: 13px;
+ min-height: 50px;
+ padding-left: 12px;
}
.command-shortcuts {
@@ -185,7 +186,9 @@
width: 100%;
}
- .feature-grid {
- margin-top: 34px;
+ .launcher-bookmark-grid,
+ .launcher-workspace-grid,
+ .launcher-tabs-strip {
+ grid-template-columns: 1fr;
}
}
diff --git a/apps/web/src/search-engines.css b/apps/web/src/search-engines.css
index f5e891d..2291337 100644
--- a/apps/web/src/search-engines.css
+++ b/apps/web/src/search-engines.css
@@ -1,41 +1,384 @@
-.search-settings-grid { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 18px; align-items: start; }
-.search-engine-form { position: sticky; top: 18px; display: grid; gap: 13px; }
-.search-engine-form label { display: grid; gap: 7px; color: var(--dm-text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .07em; }
-.search-engine-form input, .search-engine-edit input { width: 100%; min-width: 0; height: 42px; padding: 0 11px; border: 1px solid #303934; border-radius: 10px; outline: 0; color: #edf3ef; background: #0e1311; }
-.search-engine-form input:focus, .search-engine-edit input:focus { border-color: #729f82; box-shadow: 0 0 0 3px rgba(114,159,130,.1); }
-.search-engine-list { display: grid; gap: 9px; }
-.search-engine-card { display: grid; gap: 14px; }
-.search-engine-card.default { border-color: #435c4c; }
-.search-engine-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
-.search-engine-icon { display: grid; place-items: center; flex: 0 0 42px; width: 42px; height: 42px; border: 1px solid #303a35; border-radius: 12px; background: #1b231e; color: #b8d6c1; font-weight: 700; }
-.search-engine-copy { flex: 1; min-width: 0; display: grid; gap: 5px; }
-.search-engine-copy > div { display: flex; align-items: center; gap: 8px; }
-.search-engine-copy strong { font-size: 14px; }
-.search-engine-copy small { overflow: hidden; color: #738078; text-overflow: ellipsis; white-space: nowrap; }
-.default-pill { padding: 3px 6px; border: 1px solid #44604e; border-radius: 999px; color: #9fc3aa; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; }
-.search-engine-actions { display: flex; justify-content: flex-end; gap: 7px; flex-wrap: wrap; }
-.search-engine-edit { display: grid; grid-template-columns: .65fr .4fr 1.4fr; gap: 8px; align-items: center; }
-.search-engine-edit .edit-actions { grid-column: 1 / -1; }
-.bang-input { display: flex; align-items: center; border: 1px solid #303934; border-radius: 10px; background: #0e1311; overflow: hidden; }
-.bang-input:focus-within { border-color: #729f82; box-shadow: 0 0 0 3px rgba(114,159,130,.1); }
-.bang-input > span { padding-left: 10px; color: #7c8c83; }
-.bang-input input { border: 0 !important; box-shadow: none !important; padding-left: 3px; }
-.bang-help { margin-top: 18px; }
-.bang-help h2 { margin: 0 0 8px; font-size: 15px; }
-.bang-help p { margin: 0; color: var(--dm-text-muted); line-height: 1.65; font-size: 13px; }
-.bang-help kbd { margin: 0 3px; }
-
-.command-shortcuts { display: flex; align-items: center; gap: 8px; }
-.command-shortcuts kbd { white-space: nowrap; }
-.result.selected { background: #1a241f; box-shadow: inset 0 0 0 1px #354b3d; }
-.result-button { width: 100%; border: 0; color: inherit; background: transparent; cursor: pointer; font: inherit; text-align: left; }
-.command-footer { display: flex; justify-content: space-between; gap: 12px; padding: 10px 17px 12px; border-top: 1px solid #202824; color: #647169; font-size: 10px; }
-.command-footer span { display: flex; align-items: center; gap: 6px; }
-.command-footer kbd { padding: 3px 5px; }
-.bang-token { color: #a6cbb2; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
+.search-management {
+ padding: 28px 0 24px;
+}
+
+.search-tool-header {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 16px;
+ margin-bottom: 18px;
+ padding-bottom: 14px;
+ border-bottom: 1px solid var(--dm-border);
+}
+
+.search-tool-copy {
+ display: grid;
+ gap: 4px;
+ min-width: 0;
+}
+
+.search-tool-copy h1 {
+ margin: 0;
+ font-size: clamp(22px, 2.4vw, 26px);
+ line-height: 1.2;
+ letter-spacing: -0.025em;
+ font-weight: 640;
+ color: var(--dm-text);
+}
+
+.search-tool-copy p {
+ margin: 0;
+ color: var(--dm-text-muted);
+ font-size: 13px;
+ line-height: 1.45;
+}
+
+.search-tool-pills {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ flex-wrap: wrap;
+ justify-content: flex-end;
+ flex-shrink: 0;
+}
+
+.search-tool-pills .library-count {
+ padding: 5px 10px;
+ font-size: 12px;
+ white-space: nowrap;
+}
+
+.search-default-count {
+ border-color: color-mix(in srgb, var(--dm-accent) 44%, var(--dm-border));
+ background: var(--dm-accent-bg);
+ color: var(--dm-accent-strong);
+}
+
+.search-management button {
+ white-space: nowrap;
+ transition: transform 110ms ease, background-color 140ms ease, border-color 140ms ease, color 140ms ease;
+}
+
+.search-management button:active:not(:disabled) {
+ transform: translateY(1px);
+}
+
+.search-settings-grid {
+ display: grid;
+ grid-template-columns: 320px minmax(0, 1fr);
+ gap: 16px;
+ align-items: start;
+}
+
+.search-engine-form {
+ position: sticky;
+ top: 18px;
+ display: grid;
+ gap: 12px;
+}
+
+.search-engine-form label {
+ display: grid;
+ gap: 6px;
+ color: var(--dm-text-muted);
+ font-size: 12px;
+ font-weight: 520;
+}
+
+.search-engine-form input,
+.search-engine-edit input {
+ width: 100%;
+ min-width: 0;
+ height: 42px;
+ padding: 0 11px;
+ border: 1px solid var(--dm-border-strong);
+ border-radius: 10px;
+ outline: 0;
+ color: var(--dm-text);
+ background: var(--dm-input-bg, var(--dm-bg-soft));
+ transition: border-color 140ms ease, background-color 140ms ease, box-shadow 140ms ease;
+}
+
+.search-engine-form input:focus,
+.search-engine-edit input:focus {
+ border-color: var(--dm-accent);
+ box-shadow: 0 0 0 3px var(--dm-focus-ring, rgba(114, 159, 130, 0.14));
+}
+
+.search-engine-list {
+ display: grid;
+ gap: 9px;
+}
+
+.search-engine-card {
+ display: grid;
+ gap: 12px;
+ transition: border-color 140ms ease;
+}
+
+.search-engine-card:hover {
+ border-color: color-mix(in srgb, var(--dm-accent) 34%, var(--dm-border));
+}
+
+.search-engine-card.default {
+ border-color: color-mix(in srgb, var(--dm-accent) 48%, var(--dm-border));
+}
+
+.search-engine-main {
+ display: flex;
+ align-items: center;
+ gap: 12px;
+ min-width: 0;
+}
+
+.search-engine-icon {
+ display: grid;
+ place-items: center;
+ flex: 0 0 40px;
+ width: 40px;
+ height: 40px;
+ border: 1px solid var(--dm-border-strong);
+ border-radius: 11px;
+ background: var(--dm-accent-bg);
+ color: var(--dm-accent-strong);
+ font-weight: 700;
+ overflow: hidden;
+}
+
+.search-engine-icon.has-favicon {
+ padding: 4px;
+ background: var(--dm-bg-soft);
+}
+
+.search-engine-icon.has-favicon img {
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+ border-radius: inherit;
+}
+
+.search-engine-copy {
+ flex: 1;
+ min-width: 0;
+ display: grid;
+ gap: 5px;
+}
+
+.search-engine-title-line {
+ display: flex;
+ align-items: center;
+ gap: 7px;
+ flex-wrap: wrap;
+}
+
+.search-engine-copy strong {
+ font-size: 14px;
+ font-weight: 600;
+ color: var(--dm-text);
+}
+
+.search-engine-copy small {
+ overflow: hidden;
+ color: var(--dm-text-muted);
+ font-size: 12px;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.default-pill,
+.keyword-pill,
+.search-domain-pill {
+ padding: 2px 8px;
+ border-radius: 999px;
+ font-size: 11px;
+ white-space: nowrap;
+}
+
+.default-pill {
+ border: 1px solid color-mix(in srgb, var(--dm-accent) 48%, var(--dm-border));
+ background: var(--dm-accent-bg);
+ color: var(--dm-accent-strong);
+ font-weight: 600;
+}
+
+.keyword-pill {
+ border: 1px solid var(--dm-border-strong);
+ background: var(--dm-bg-soft);
+ color: var(--dm-accent);
+ font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
+}
+
+.search-domain-pill {
+ border: 1px solid var(--dm-border);
+ background: var(--dm-bg-soft);
+ color: var(--dm-text-muted);
+}
+
+.search-engine-actions {
+ display: flex;
+ justify-content: flex-end;
+ align-items: center;
+ gap: 7px;
+ flex-wrap: wrap;
+}
+
+.search-engine-actions .text-action {
+ min-width: 26px;
+ min-height: 28px;
+ padding: 0 6px;
+ border: 1px solid var(--dm-border);
+ border-radius: 8px;
+ background: var(--dm-bg-soft);
+ color: var(--dm-text-soft);
+ font-size: 12px;
+}
+
+.search-engine-actions .text-action:hover:not(:disabled) {
+ border-color: var(--dm-border-strong);
+ color: var(--dm-text);
+ background: var(--dm-hover-bg, var(--dm-bg-raised));
+}
+
+.search-engine-actions .text-action:disabled {
+ opacity: 0.32;
+ cursor: default;
+}
+
+.search-engine-edit {
+ display: grid;
+ grid-template-columns: 0.65fr 0.4fr 1.4fr;
+ gap: 8px;
+ align-items: center;
+}
+
+.search-engine-edit .edit-actions {
+ grid-column: 1 / -1;
+ margin-top: 2px;
+}
+
+.bang-input {
+ display: flex;
+ align-items: center;
+ border: 1px solid var(--dm-border-strong);
+ border-radius: 10px;
+ background: var(--dm-input-bg, var(--dm-bg-soft));
+ overflow: hidden;
+}
+
+.bang-input:focus-within {
+ border-color: var(--dm-accent);
+ box-shadow: 0 0 0 3px var(--dm-focus-ring, rgba(114, 159, 130, 0.14));
+}
+
+.bang-input > span {
+ padding-left: 10px;
+ color: var(--dm-text-muted);
+ font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
+}
+
+.bang-input input {
+ border: 0 !important;
+ box-shadow: none !important;
+ padding-left: 3px;
+}
+
+.bang-help {
+ margin-top: 16px;
+}
+
+.bang-help h2 {
+ margin: 0 0 6px;
+ font-size: 15px;
+}
+
+.bang-help p {
+ margin: 0;
+ color: var(--dm-text-muted);
+ line-height: 1.65;
+ font-size: 13px;
+}
+
+.bang-help kbd {
+ margin: 0 3px;
+}
+
+/* Launcher command footer & shortcut styles */
+.command-shortcuts {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+}
+
+.command-shortcuts kbd {
+ white-space: nowrap;
+}
+
+.result.selected {
+ background: var(--dm-selected-bg, #1a241f);
+ box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--dm-accent) 42%, var(--dm-border));
+}
+
+.result-button {
+ width: 100%;
+ border: 0;
+ color: inherit;
+ background: transparent;
+ cursor: pointer;
+ font: inherit;
+ text-align: left;
+}
+
+.command-footer {
+ display: flex;
+ justify-content: space-between;
+ gap: 12px;
+ padding: 10px 17px 12px;
+ border-top: 1px solid var(--dm-border);
+ color: var(--dm-text-muted);
+ font-size: 10px;
+}
+
+.command-footer span {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+}
+
+.command-footer kbd {
+ padding: 3px 5px;
+}
+
+.bang-token {
+ color: var(--dm-accent-strong);
+ font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
+}
@media (max-width: 860px) {
- .search-settings-grid { grid-template-columns: 1fr; }
- .search-engine-form { position: static; }
- .search-engine-edit { grid-template-columns: 1fr; }
+ .search-settings-grid {
+ grid-template-columns: 1fr;
+ }
+
+ .search-engine-form {
+ position: static;
+ }
+
+ .search-engine-edit {
+ grid-template-columns: 1fr;
+ }
+}
+
+@media (max-width: 720px) {
+ .search-management {
+ padding-top: 20px;
+ }
+
+ .search-tool-header {
+ align-items: flex-start;
+ flex-direction: column;
+ }
+
+ .search-tool-pills {
+ justify-content: flex-start;
+ }
}
diff --git a/apps/web/src/security.css b/apps/web/src/security.css
index 10c70c6..988c445 100644
--- a/apps/web/src/security.css
+++ b/apps/web/src/security.css
@@ -7,34 +7,72 @@
display: flex;
align-items: center;
justify-content: space-between;
- gap: 18px;
+ gap: 16px;
border-bottom: 1px solid var(--dm-border);
background: color-mix(in srgb, var(--dm-bg) 94%, transparent);
backdrop-filter: blur(16px);
-webkit-backdrop-filter: blur(16px);
}
-.private-utility-brand { display: inline-flex; align-items: center; gap: 8px; min-height: 30px; padding: 0 6px; margin-left: -6px; border-radius: 8px; color: var(--dm-text-soft); font-size: 12px; }
+.private-utility-brand { display: inline-flex; align-items: center; gap: 7px; min-height: 30px; padding: 0 6px; margin-left: -6px; border-radius: 8px; color: var(--dm-text-soft); font-size: 12px; }
.private-utility-brand:hover { background: color-mix(in srgb, var(--dm-accent) 12%, transparent); color: var(--dm-text); }
.private-utility-brand span { color: var(--dm-accent-strong); font-weight: 800; }
-.private-utility-bar nav { display: flex; gap: 5px; }
+.private-utility-bar nav { display: flex; align-items: center; gap: 4px; }
.private-utility-bar nav button {
- padding: 7px 10px;
+ padding: 6px 9px;
border: 0;
border-radius: 8px;
color: var(--dm-text-soft);
background: transparent;
cursor: pointer;
font-size: 11px;
+ line-height: 1.25;
+ transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease;
}
.private-utility-bar nav button:hover,
.private-utility-bar nav button.active { color: var(--dm-text); background: var(--dm-bg-raised); }
+
+.private-utility-divider {
+ width: 1px;
+ height: 16px;
+ margin: 0 3px;
+ background: var(--dm-border);
+}
+.utility-quick-group {
+ display: inline-flex;
+ align-items: center;
+ gap: 4px;
+}
+.private-utility-bar nav button.utility-quick-toggle,
+.utility-quick-toggle {
+ display: inline-flex;
+ align-items: center;
+ gap: 4px;
+ height: 26px;
+ padding: 0 8px;
+ border: 1px solid var(--dm-border);
+ border-radius: 7px;
+ background: var(--dm-bg-card);
+ color: var(--dm-text-soft);
+ font-size: 11px;
+ font-weight: 550;
+ cursor: pointer;
+ white-space: nowrap;
+ transition: border-color 140ms ease, background-color 140ms ease, color 140ms ease;
+}
+.private-utility-bar nav button.utility-quick-toggle:hover,
+.utility-quick-toggle:hover {
+ border-color: color-mix(in srgb, var(--dm-accent) 48%, var(--dm-border));
+ background: var(--dm-hover-bg);
+ color: var(--dm-text);
+}
+
.private-inbox-nav { display: inline-flex; align-items: center; gap: 6px; }
.private-inbox-badge {
display: inline-grid;
place-items: center;
- min-width: 20px;
- height: 20px;
- padding: 0 6px;
+ min-width: 18px;
+ height: 18px;
+ padding: 0 5px;
border: 1px solid color-mix(in srgb, var(--dm-accent) 45%, transparent);
border-radius: 999px;
background: var(--dm-accent-bg);
@@ -45,42 +83,43 @@
}
.auth-shell { position: relative; display: grid; place-items: center; min-height: 100vh; padding: 32px 18px; }
-.auth-brand { position: absolute; top: 28px; left: 32px; display: inline-flex; align-items: center; gap: 10px; }
-.auth-brand span { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid #39433e; border-radius: 10px; background: #151b18; color: #b8e0c5; }
-.auth-card { width: min(470px, 100%); padding: 28px; border: 1px solid #28312c; border-radius: 22px; background: rgba(13, 18, 16, .9); box-shadow: 0 28px 100px rgba(0,0,0,.32); }
-.auth-card h1 { margin: 12px 0 12px; font-size: clamp(34px, 6vw, 48px); }
-.auth-card > p { color: #849089; line-height: 1.65; }
-.auth-card form { display: grid; gap: 14px; margin: 24px 0 18px; }
-.auth-card label { display: grid; gap: 7px; color: #849089; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
-.auth-card input { width: 100%; height: 46px; padding: 0 13px; border: 1px solid #34403a; border-radius: 11px; outline: 0; color: #f2f7f4; background: #0b100e; }
+.auth-brand { position: absolute; top: 24px; left: 28px; display: inline-flex; align-items: center; gap: 10px; }
+.auth-brand span { display: grid; place-items: center; width: 32px; height: 32px; border: 1px solid #39433e; border-radius: 9px; background: #151b18; color: #b8e0c5; font-weight: 800; }
+.auth-quick-controls { position: absolute; top: 26px; right: 28px; display: inline-flex; align-items: center; gap: 6px; }
+.auth-card { width: min(440px, 100%); padding: 26px; border: 1px solid #28312c; border-radius: 18px; background: rgba(13, 18, 16, .92); box-shadow: 0 24px 80px rgba(0,0,0,.3); }
+.auth-card h1 { margin: 10px 0 10px; font-size: clamp(24px, 4vw, 30px); line-height: 1.18; letter-spacing: -.03em; }
+.auth-card > p { margin: 0; color: #849089; font-size: 13px; line-height: 1.6; }
+.auth-card form { display: grid; gap: 14px; margin: 20px 0 16px; }
+.auth-card label { display: grid; gap: 6px; color: #849089; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
+.auth-card input { width: 100%; height: 42px; padding: 0 12px; border: 1px solid #34403a; border-radius: 10px; outline: 0; color: #f2f7f4; background: #0b100e; }
.auth-card input:focus { border-color: #729f82; box-shadow: 0 0 0 3px rgba(114,159,130,.1); }
-.auth-card .primary { min-height: 42px; }
+.auth-card .primary { min-height: 40px; }
.auth-setup-card code,
-.auth-setup-steps code { padding: 9px 11px; border: 1px solid #303934; border-radius: 9px; color: #b8d6c1; background: #0b100e; font-size: 12px; }
-.auth-setup-steps { display: grid; gap: 10px; margin: 22px 0; }
-.auth-setup-steps span { color: #77827c; font-size: 12px; line-height: 1.55; }
-.auth-loading { color: #8e9a94; }
+.auth-setup-steps code { padding: 8px 10px; border: 1px solid #303934; border-radius: 8px; color: #b8d6c1; background: #0b100e; font-size: 12px; overflow-wrap: anywhere; }
+.auth-setup-steps { display: grid; gap: 8px; margin: 18px 0; }
+.auth-setup-steps span { color: #77827c; font-size: 12px; line-height: 1.5; }
+.auth-loading { color: var(--dm-text-muted); font-size: 14px; }
-.settings-page { padding-top: 58px; }
-.settings-page-heading p:last-child { max-width: 680px; color: #7f8b84; line-height: 1.65; }
+.settings-page { padding-top: 28px; }
+.settings-page-heading p:last-child { max-width: 680px; color: var(--dm-text-muted); line-height: 1.55; }
.security-section,
-.public-settings-section { display: grid; gap: 16px; margin-bottom: 46px; }
-.settings-page .browser-settings-section { margin-bottom: 46px; }
-.pair-code-panel { display: grid; gap: 12px; }
-.pair-code-panel > code { width: max-content; padding: 12px 14px; border: 1px solid #486152; border-radius: 11px; background: #0b100e; color: #d5eadb; font: 700 20px ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; }
-.pair-code-panel > span { color: #77827c; font-size: 11px; }
+.public-settings-section { display: grid; gap: 16px; margin-bottom: 42px; }
+.settings-page .browser-settings-section { margin-bottom: 42px; }
+.pair-code-panel { display: grid; gap: 10px; }
+.pair-code-panel > code { width: max-content; padding: 10px 14px; border: 1px solid #486152; border-radius: 10px; background: #0b100e; color: #d5eadb; font: 700 18px ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; }
+.pair-code-panel > span { color: var(--dm-text-muted); font-size: 11px; }
.security-device-list { display: grid; gap: 8px; }
-.security-device { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px; border: 1px solid #262f2a; border-radius: 12px; background: #111613; }
-.security-device > span { display: grid; gap: 4px; min-width: 0; }
+.security-device { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 11px 12px; border: 1px solid #262f2a; border-radius: 11px; background: #111613; }
+.security-device > span { display: grid; gap: 3px; min-width: 0; }
.security-device strong { font-size: 13px; }
-.security-device small { color: #77827c; font-size: 11px; }
+.security-device small { color: var(--dm-text-muted); font-size: 11px; }
.security-device-revoked { opacity: .55; }
-.revoked-devices { margin-top: 12px; color: #77827c; font-size: 12px; }
+.revoked-devices { margin-top: 12px; color: var(--dm-text-muted); font-size: 12px; }
.revoked-devices summary { margin-bottom: 8px; cursor: pointer; }
.public-bookmark-picker { display: grid; gap: 6px; max-height: 520px; overflow: auto; }
-.public-bookmark-row { display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 11px; align-items: center; padding: 11px 12px; border: 1px solid #252d29; border-radius: 11px; background: #101512; cursor: pointer; }
-.public-bookmark-row > span { display: grid; gap: 3px; min-width: 0; }
+.public-bookmark-row { display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 11px; align-items: center; padding: 10px 12px; border: 1px solid #252d29; border-radius: 11px; background: #101512; cursor: pointer; }
+.public-bookmark-row > span { display: grid; gap: 2px; min-width: 0; }
.public-bookmark-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.public-bookmark-row small { overflow: hidden; color: #6f7a74; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.public-bookmark-row em { color: #66736b; font-size: 10px; font-style: normal; letter-spacing: .08em; }
@@ -91,7 +130,9 @@
.private-utility-bar { padding: 0 12px; }
.private-utility-brand { font-size: 0; }
.private-utility-brand span { font-size: 12px; }
- .auth-brand { top: 20px; left: 20px; }
- .auth-card { padding: 22px; }
+ .auth-brand { top: 18px; left: 18px; }
+ .auth-quick-controls { top: 18px; right: 18px; }
+ .auth-card { padding: 20px; }
.security-device { align-items: flex-start; flex-direction: column; }
+ .settings-page { padding-top: 20px; }
}
diff --git a/apps/web/src/session.css b/apps/web/src/session.css
index 94b3a05..7790f37 100644
--- a/apps/web/src/session.css
+++ b/apps/web/src/session.css
@@ -1,74 +1,497 @@
-.session-grid { grid-template-columns: 310px minmax(0, 1fr); }
-.session-create-form, .session-meta-form, .session-item-edit { display: grid; gap: 10px; }
-.session-create-form input, .session-create-form textarea, .session-meta-form input,
-.session-add-fields input, .session-item-edit input {
- width: 100%; min-width: 0; padding: 0 11px; border: 1px solid #303934; border-radius: 10px;
- outline: 0; color: #edf3ef; background: #0e1311;
-}
-.session-create-form input, .session-meta-form input, .session-add-fields input, .session-item-edit input { height: 42px; }
-.session-create-form textarea { min-height: 150px; padding: 11px; resize: vertical; line-height: 1.5; }
-.session-create-form input:focus, .session-create-form textarea:focus, .session-meta-form input:focus,
-.session-add-fields input:focus, .session-item-edit input:focus {
- border-color: #729f82; box-shadow: 0 0 0 3px rgba(114,159,130,.1);
-}
-.session-nav { margin-top: 14px; }
+.session-management {
+ padding: 28px 0 24px;
+}
+
+.session-tool-header {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 16px;
+ margin-bottom: 18px;
+ padding-bottom: 14px;
+ border-bottom: 1px solid var(--dm-border);
+}
+
+.session-tool-copy {
+ display: grid;
+ gap: 4px;
+ min-width: 0;
+}
+
+.session-tool-copy h1 {
+ margin: 0;
+ font-size: clamp(22px, 2.4vw, 26px);
+ line-height: 1.2;
+ letter-spacing: -0.025em;
+ font-weight: 640;
+ color: var(--dm-text);
+}
+
+.session-tool-copy p {
+ margin: 0;
+ color: var(--dm-text-muted);
+ font-size: 13px;
+ line-height: 1.45;
+}
+
+.session-tool-pills {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ flex-wrap: wrap;
+ justify-content: flex-end;
+ flex-shrink: 0;
+}
+
+.session-tool-pills .library-count {
+ padding: 5px 10px;
+ font-size: 12px;
+ white-space: nowrap;
+}
+
+.session-grid {
+ grid-template-columns: 310px minmax(0, 1fr);
+}
+
+.session-create-form,
+.session-meta-form,
+.session-item-edit {
+ display: grid;
+ gap: 10px;
+}
+
+.session-create-form input,
+.session-create-form textarea,
+.session-meta-form input,
+.session-add-fields input,
+.session-item-edit input {
+ width: 100%;
+ min-width: 0;
+ padding: 0 11px;
+ border: 1px solid var(--dm-border-strong);
+ border-radius: 10px;
+ outline: 0;
+ color: var(--dm-text);
+ background: var(--dm-input-bg, var(--dm-bg-soft));
+ transition: border-color 140ms ease, background-color 140ms ease, box-shadow 140ms ease;
+}
+
+.session-create-form input,
+.session-meta-form input,
+.session-add-fields input,
+.session-item-edit input {
+ height: 42px;
+}
+
+.session-create-form textarea {
+ min-height: 138px;
+ padding: 11px;
+ resize: vertical;
+ line-height: 1.5;
+}
+
+.session-create-form input:focus,
+.session-create-form textarea:focus,
+.session-meta-form input:focus,
+.session-add-fields input:focus,
+.session-item-edit input:focus {
+ border-color: var(--dm-accent);
+ box-shadow: 0 0 0 3px var(--dm-focus-ring, rgba(114, 159, 130, 0.14));
+}
+
+.session-management button {
+ white-space: nowrap;
+ transition: transform 110ms ease, background-color 140ms ease, border-color 140ms ease, color 140ms ease;
+}
+
+.session-management button:active:not(:disabled) {
+ transform: translateY(1px);
+}
+
+.session-nav {
+ margin-top: 12px;
+ display: grid;
+ gap: 4px;
+}
+
+.session-nav .card-heading {
+ margin-bottom: 8px;
+}
+
.session-nav-item {
- display: flex; width: 100%; align-items: center; gap: 10px; padding: 9px; border: 1px solid transparent;
- border-radius: 11px; color: #aeb8b2; background: transparent; cursor: pointer; text-align: left;
-}
-.session-nav-item:hover, .session-nav-item.active { border-color: #2b3630; background: #151b18; }
-.session-nav-item > span:last-child { display: grid; min-width: 0; gap: 3px; }
-.session-nav-item strong, .session-nav-item small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
-.session-nav-item strong { font-size: 13px; font-weight: 590; }
-.session-nav-item small { color: var(--dm-text-muted); font-size: 10px; }
+ display: flex;
+ width: 100%;
+ align-items: center;
+ gap: 10px;
+ padding: 9px;
+ border: 1px solid transparent;
+ border-radius: 11px;
+ color: var(--dm-text-soft);
+ background: transparent;
+ cursor: pointer;
+ text-align: left;
+ white-space: normal;
+}
+
+.session-nav-item:hover {
+ color: var(--dm-text);
+ background: var(--dm-hover-bg, var(--dm-bg-raised));
+}
+
+.session-nav-item.active {
+ border-color: color-mix(in srgb, var(--dm-accent) 42%, var(--dm-border));
+ color: var(--dm-text);
+ background: var(--dm-selected-bg, var(--dm-accent-bg));
+}
+
+.session-nav-item > span:last-child {
+ display: grid;
+ min-width: 0;
+ gap: 3px;
+}
+
+.session-nav-item strong,
+.session-nav-item small {
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.session-nav-item strong {
+ font-size: 13px;
+ font-weight: 590;
+}
+
+.session-nav-item small {
+ color: var(--dm-text-muted);
+ font-size: 11px;
+}
+
.session-nav-icon {
- display: grid; place-items: center; flex: 0 0 34px; width: 34px; height: 34px; border: 1px solid #303a35;
- border-radius: 10px; background: #1a211d; color: #a7c8b2; font-size: 11px; font-weight: 700;
+ display: grid;
+ place-items: center;
+ flex: 0 0 34px;
+ width: 34px;
+ height: 34px;
+ border: 1px solid var(--dm-border-strong);
+ border-radius: 10px;
+ background: var(--dm-accent-bg);
+ color: var(--dm-accent-strong);
+ font-size: 12px;
+ font-weight: 700;
+}
+
+.session-header-content {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 18px;
}
-.session-header-content { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
-.session-header-content > div:first-child { min-width: 0; }
-.session-title-row { display: flex; align-items: center; gap: 11px; }
-.session-title-row h2 { margin: 0; font-size: 24px; letter-spacing: -.03em; }
+
+.session-header-lead {
+ min-width: 0;
+}
+
+.session-title-row {
+ display: flex;
+ align-items: center;
+ gap: 11px;
+ min-width: 0;
+}
+
+.session-title-row h2 {
+ margin: 0;
+ font-size: 20px;
+ letter-spacing: -0.02em;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
.session-large-icon {
- display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid #35413a; border-radius: 12px;
- background: #19211c; color: #afd1ba; font-size: 20px;
-}
-.session-header-content p { margin: 8px 0 0 53px; color: var(--dm-text-muted); font-size: 12px; }
-.session-header-actions { display: flex; flex: 0 0 auto; gap: 8px; }
-.session-add-card { display: grid; gap: 12px; }
-.session-add-fields { display: grid; grid-template-columns: .9fr 1.5fr auto auto; gap: 9px; align-items: center; }
-.session-pin-toggle { display: inline-flex; align-items: center; gap: 7px; color: #909b95; font-size: 12px; white-space: nowrap; }
-.session-pin-toggle input { width: auto; height: auto; accent-color: #91bc9f; }
-.session-items { display: grid; gap: 8px; }
+ display: grid;
+ place-items: center;
+ flex: 0 0 42px;
+ width: 42px;
+ height: 42px;
+ border: 1px solid var(--dm-border-strong);
+ border-radius: 12px;
+ background: var(--dm-accent-bg);
+ color: var(--dm-accent-strong);
+ font-size: 19px;
+}
+
+.session-header-content p {
+ margin: 8px 0 0 53px;
+ color: var(--dm-text-muted);
+ font-size: 12px;
+ line-height: 1.5;
+}
+
+.session-header-actions {
+ display: flex;
+ flex: 0 0 auto;
+ gap: 8px;
+ flex-wrap: wrap;
+}
+
+.session-add-card {
+ display: grid;
+ gap: 12px;
+}
+
+.session-add-card .card-heading {
+ margin-bottom: 0;
+}
+
+.session-add-fields {
+ display: grid;
+ grid-template-columns: 0.9fr 1.5fr auto auto;
+ gap: 9px;
+ align-items: center;
+}
+
+.session-pin-toggle {
+ display: inline-flex;
+ align-items: center;
+ gap: 7px;
+ color: var(--dm-text-soft);
+ font-size: 12px;
+ white-space: nowrap;
+ cursor: pointer;
+}
+
+.session-pin-toggle input {
+ width: auto;
+ height: auto;
+ accent-color: var(--dm-accent);
+}
+
+.session-items {
+ display: grid;
+ gap: 8px;
+}
+
.session-item-card {
- display: flex; align-items: center; gap: 13px; min-height: 76px; padding: 13px; border: 1px solid #242c28;
- border-radius: 15px; background: rgba(14, 19, 17, .65);
-}
-.session-item-card > form { width: 100%; }
-.session-item-index { flex: 0 0 34px; color: #65706a; font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; text-align: center; }
-.session-item-copy { display: grid; flex: 1; min-width: 0; gap: 4px; }
-.session-item-copy a, .session-item-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
-.session-item-copy strong { font-size: 14px; font-weight: 590; }
-.session-item-copy small { color: var(--dm-text-muted); }
-.session-item-meta { display: flex; gap: 8px; color: #819087; font-size: 10px; }
-.session-item-meta span { padding: 2px 6px; border: 1px solid #2b342f; border-radius: 999px; }
-.session-item-actions { display: flex; align-items: center; gap: 7px; }
-.session-item-edit { grid-template-columns: .9fr 1.5fr auto; align-items: center; }
-.session-item-edit .edit-actions { grid-column: 1 / -1; margin-top: 0; }
-.session-web-note { margin: 4px 4px 0; color: var(--dm-text-muted); font-size: 11px; line-height: 1.6; }
-.session-empty { min-height: 220px; align-content: center; }
-.result-button { width: 100%; border: 0; color: inherit; background: transparent; cursor: pointer; }
+ display: flex;
+ align-items: center;
+ gap: 12px;
+ min-height: 76px;
+ padding: 12px 14px;
+ border: 1px solid var(--dm-border);
+ border-radius: 14px;
+ background: color-mix(in srgb, var(--dm-bg-card) 88%, transparent);
+ transition: border-color 140ms ease, background-color 140ms ease;
+}
+
+.session-item-card:hover {
+ border-color: color-mix(in srgb, var(--dm-accent) 34%, var(--dm-border));
+}
+
+.session-item-card > form {
+ width: 100%;
+}
+
+.session-item-index {
+ flex: 0 0 26px;
+ color: var(--dm-text-muted);
+ font: 11px ui-monospace, SFMono-Regular, Menlo, monospace;
+ text-align: center;
+}
+
+.session-item-favicon {
+ display: grid;
+ place-items: center;
+ flex: 0 0 38px;
+ width: 38px;
+ height: 38px;
+ border: 1px solid var(--dm-border-strong);
+ border-radius: 10px;
+ background: var(--dm-accent-bg);
+ color: var(--dm-accent-strong);
+ font-size: 14px;
+ font-weight: 700;
+ overflow: hidden;
+}
+
+.session-item-favicon.has-favicon {
+ padding: 4px;
+ background: var(--dm-bg-soft);
+}
+
+.session-item-favicon.has-favicon img {
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+ border-radius: inherit;
+}
+
+.session-item-copy {
+ display: grid;
+ flex: 1;
+ min-width: 0;
+ gap: 4px;
+}
+
+.session-item-copy a,
+.session-item-copy small {
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.session-item-copy a:hover strong {
+ color: var(--dm-accent-strong);
+}
+
+.session-item-copy strong {
+ font-size: 14px;
+ font-weight: 590;
+ color: var(--dm-text);
+}
+
+.session-item-copy small {
+ color: var(--dm-text-muted);
+ font-size: 12px;
+}
+
+.session-item-meta {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 6px;
+}
+
+.session-item-meta span {
+ padding: 2px 8px;
+ border: 1px solid var(--dm-border);
+ border-radius: 999px;
+ background: var(--dm-bg-soft);
+ color: var(--dm-text-muted);
+ font-size: 11px;
+ white-space: nowrap;
+}
+
+.session-item-meta .session-domain-pill {
+ color: var(--dm-text-soft);
+ border-color: var(--dm-border-strong);
+}
+
+.session-item-meta .session-pinned-pill {
+ color: var(--dm-accent-strong);
+ border-color: color-mix(in srgb, var(--dm-accent) 42%, var(--dm-border));
+ background: var(--dm-accent-bg);
+}
+
+.session-item-actions {
+ display: flex;
+ align-items: center;
+ gap: 7px;
+ flex-shrink: 0;
+}
+
+.session-item-actions .text-action {
+ min-width: 26px;
+ min-height: 28px;
+ padding: 0 6px;
+ border: 1px solid var(--dm-border);
+ border-radius: 8px;
+ background: var(--dm-bg-soft);
+ color: var(--dm-text-soft);
+ font-size: 12px;
+}
+
+.session-item-actions .text-action:hover:not(:disabled) {
+ border-color: var(--dm-border-strong);
+ color: var(--dm-text);
+ background: var(--dm-hover-bg, var(--dm-bg-raised));
+}
+
+.session-item-actions .text-action:disabled {
+ opacity: 0.32;
+ cursor: default;
+}
+
+.session-item-edit {
+ grid-template-columns: 0.9fr 1.5fr auto;
+ align-items: center;
+}
+
+.session-item-edit .edit-actions {
+ grid-column: 1 / -1;
+ margin-top: 0;
+}
+
+.session-web-note {
+ margin: 4px 2px 0;
+ color: var(--dm-text-muted);
+ font-size: 12px;
+ line-height: 1.55;
+}
+
+.session-empty {
+ min-height: 220px;
+ align-content: center;
+}
+
+.result-button {
+ width: 100%;
+ border: 0;
+ color: inherit;
+ background: transparent;
+ cursor: pointer;
+}
@media (max-width: 920px) {
- .session-grid { grid-template-columns: 1fr; }
- .session-add-fields { grid-template-columns: 1fr 1fr; }
- .session-header-content { align-items: flex-start; flex-direction: column; }
- .session-header-content p { margin-left: 0; }
+ .session-grid {
+ grid-template-columns: 1fr;
+ }
+
+ .session-add-fields {
+ grid-template-columns: 1fr 1fr;
+ }
+
+ .session-header-content {
+ align-items: flex-start;
+ flex-direction: column;
+ }
+
+ .session-header-content p {
+ margin-left: 0;
+ }
}
@media (max-width: 720px) {
- .session-add-fields, .session-item-edit { grid-template-columns: 1fr; }
- .session-item-card { align-items: flex-start; flex-wrap: wrap; }
- .session-item-actions { width: 100%; padding-left: 47px; }
- .session-header-actions { width: 100%; flex-wrap: wrap; }
+ .session-management {
+ padding-top: 20px;
+ }
+
+ .session-tool-header {
+ align-items: flex-start;
+ flex-direction: column;
+ }
+
+ .session-tool-pills {
+ justify-content: flex-start;
+ }
+
+ .session-add-fields,
+ .session-item-edit {
+ grid-template-columns: 1fr;
+ }
+
+ .session-item-card {
+ align-items: flex-start;
+ flex-wrap: wrap;
+ }
+
+ .session-item-actions {
+ width: 100%;
+ padding-left: 0;
+ flex-wrap: wrap;
+ }
+
+ .session-header-actions {
+ width: 100%;
+ flex-wrap: wrap;
+ }
}
diff --git a/apps/web/src/settings.css b/apps/web/src/settings.css
index 6c89859..9a26654 100644
--- a/apps/web/src/settings.css
+++ b/apps/web/src/settings.css
@@ -1,33 +1,34 @@
-.browser-settings-section { display: grid; gap: 18px; margin: 26px 0; }
-.settings-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; padding: 24px; border: 1px solid #26302b; border-radius: 20px; background: rgba(15, 20, 18, .72); }
-.settings-heading h2 { margin: 8px 0 8px; font-size: clamp(26px, 4vw, 42px); letter-spacing: -.035em; }
-.settings-heading p { margin: 0; max-width: 720px; color: #7d8982; line-height: 1.6; }
-.settings-sync-state { display: grid; flex: 0 0 auto; gap: 5px; min-width: 170px; text-align: right; }
-.settings-sync-state strong { color: #a8d3b5; font-size: 13px; }
-.settings-sync-state span { color: #68736d; font-size: 11px; }
+.browser-settings-section { display: grid; gap: 16px; margin: 18px 0; }
+.settings-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 20px; border: 1px solid #26302b; border-radius: 16px; background: rgba(15, 20, 18, .72); }
+.settings-heading h2 { margin: 2px 0 6px; font-size: clamp(18px, 2.2vw, 22px); line-height: 1.25; letter-spacing: -.02em; font-weight: 630; }
+.settings-heading p { margin: 0; max-width: 720px; color: #7d8982; font-size: 13px; line-height: 1.55; }
+.settings-sync-state { display: grid; flex: 0 0 auto; gap: 4px; min-width: 160px; text-align: right; }
+.settings-sync-state strong { color: var(--dm-accent-strong); font-size: 12px; }
+.settings-sync-state span { color: var(--dm-text-muted); font-size: 11px; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
-.settings-card { min-height: 210px; }
+.settings-card { min-height: 186px; }
.settings-card-wide { grid-column: 1 / -1; min-height: 0; }
-.settings-card .card-heading h3 { margin: 0; font-size: 16px; }
+.settings-card .card-heading h3 { margin: 0; font-size: 15px; font-weight: 620; }
.settings-card .card-heading p { max-width: 620px; }
-.settings-segmented { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding: 5px; border: 1px solid #29332e; border-radius: 12px; background: #0d1210; }
-.settings-segmented button { min-height: 38px; border: 0; border-radius: 8px; color: #7e8983; background: transparent; cursor: pointer; }
+.settings-segmented { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; padding: 4px; border: 1px solid #29332e; border-radius: 11px; background: #0d1210; }
+.settings-segmented button { min-height: 36px; padding: 0 8px; border: 0; border-radius: 8px; color: #7e8983; background: transparent; cursor: pointer; font-size: 12px; white-space: nowrap; }
.settings-segmented button:hover { color: #cbd7d0; background: #141a17; }
.settings-segmented button.active { color: #dff0e4; background: #1d2a23; box-shadow: inset 0 0 0 1px #3a5143; }
-.settings-field { display: grid; gap: 8px; color: #7f8b84; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; }
-.settings-field input, .settings-field select { width: 100%; height: 42px; padding: 0 11px; border: 1px solid #303934; border-radius: 10px; outline: 0; color: #edf3ef; background: #0e1311; }
+.settings-field { display: grid; gap: 7px; color: var(--dm-text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .07em; }
+.settings-field input, .settings-field select { width: 100%; height: 40px; padding: 0 11px; border: 1px solid #303934; border-radius: 10px; outline: 0; color: #edf3ef; background: #0e1311; }
.settings-field input:focus, .settings-field select:focus { border-color: #729f82; box-shadow: 0 0 0 3px rgba(114,159,130,.1); }
.settings-options-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
-.settings-toggle { display: flex; align-items: center; justify-content: space-between; gap: 18px; min-height: 72px; padding: 14px; border: 1px solid #27302c; border-radius: 13px; background: #0f1512; }
-.settings-toggle > span { display: grid; gap: 4px; }
+.settings-toggle { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 66px; padding: 12px 14px; border: 1px solid #27302c; border-radius: 12px; background: #0f1512; }
+.settings-toggle > span { display: grid; gap: 3px; }
.settings-toggle strong { font-size: 13px; font-weight: 600; }
-.settings-toggle small { color: #718078; line-height: 1.45; }
+.settings-toggle small { color: var(--dm-text-muted); font-size: 12px; line-height: 1.4; }
.settings-toggle input { width: 18px; height: 18px; accent-color: #91bc9f; }
-.settings-actions-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 18px; border: 1px solid #242d28; border-radius: 16px; background: rgba(14, 19, 17, .66); }
+.settings-actions-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 14px 16px; border: 1px solid #242d28; border-radius: 14px; background: rgba(14, 19, 17, .66); }
.settings-actions-row > div:first-child { min-width: 0; }
-.settings-message { margin: 0 0 5px; color: #a9c9b4; font-size: 12px; }
-.settings-footnote { margin: 12px 0 0; color: #69756e; font-size: 11px; line-height: 1.55; }
+.settings-message { margin: 0 0 5px; color: var(--dm-accent-strong); font-size: 12px; }
+.settings-footnote { margin: 10px 0 0; color: var(--dm-text-muted); font-size: 11px; line-height: 1.5; }
.settings-actions-row .settings-footnote { margin: 0; }
+.settings-actions-row .extension-actions { margin-top: 0; }
@media (max-width: 760px) {
.settings-heading { align-items: start; flex-direction: column; }
@@ -38,53 +39,51 @@
.settings-actions-row .extension-actions { justify-content: flex-end; }
}
-
.settings-subnav {
position: sticky;
- top: calc(var(--dm-private-nav-height) + 14px);
+ top: calc(var(--dm-private-nav-height) + 12px);
z-index: 20;
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 8px;
- margin: -18px 0 28px;
- padding: 7px;
+ margin: 0 0 20px;
+ padding: 6px;
border: 1px solid var(--dm-border);
- border-radius: 16px;
+ border-radius: 14px;
background: color-mix(in srgb, var(--dm-bg) 92%, transparent);
backdrop-filter: blur(14px);
}
.settings-subnav button {
display: grid;
- gap: 4px;
+ gap: 3px;
min-width: 0;
- padding: 11px 12px;
+ padding: 9px 11px;
border: 1px solid transparent;
- border-radius: 11px;
- /* Section labels rather than supporting copy, so they need the soft text
- colour to stay legible at 10-12px. */
+ border-radius: 10px;
color: var(--dm-text-soft);
background: transparent;
cursor: pointer;
text-align: left;
+ transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease;
}
.settings-subnav button:hover { color: var(--dm-text); background: var(--dm-bg-soft); }
.settings-subnav button.active { border-color: var(--dm-border-strong); color: var(--dm-text); background: var(--dm-bg-raised); }
.settings-subnav strong { font-size: 12px; }
-.settings-subnav span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
-.settings-loading-card { padding: 28px; border: 1px dashed var(--dm-border); border-radius: 16px; color: var(--dm-text-muted); text-align: center; }
+.settings-subnav span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; color: var(--dm-text-muted); }
+.settings-loading-card { padding: 26px; border: 1px dashed var(--dm-border); border-radius: 14px; color: var(--dm-text-muted); text-align: center; }
.public-curation-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr); gap: 14px; }
.public-layout-card, .public-publish-card { min-width: 0; }
-.public-layout-groups { display: grid; gap: 14px; }
-.public-layout-group { overflow: hidden; border: 1px solid var(--dm-border); border-radius: 14px; background: color-mix(in srgb, var(--dm-bg-soft) 72%, transparent); }
-.public-layout-group > header { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 12px; border-bottom: 1px solid var(--dm-border); }
-.public-layout-group > header > div:first-child { display: grid; gap: 3px; min-width: 0; }
+.public-layout-groups { display: grid; gap: 12px; }
+.public-layout-group { overflow: hidden; border: 1px solid var(--dm-border); border-radius: 13px; background: color-mix(in srgb, var(--dm-bg-soft) 72%, transparent); }
+.public-layout-group > header { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 12px; border-bottom: 1px solid var(--dm-border); }
+.public-layout-group > header > div:first-child { display: grid; gap: 2px; min-width: 0; }
.public-layout-group > header strong { font-size: 12px; }
.public-layout-group > header span { color: var(--dm-text-muted); font-size: 10px; }
.public-layout-items { display: grid; }
-.public-layout-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; min-height: 58px; padding: 9px 12px; border-top: 1px solid var(--dm-border); }
+.public-layout-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; min-height: 54px; padding: 8px 12px; border-top: 1px solid var(--dm-border); }
.public-layout-item:first-child { border-top: 0; }
-.public-layout-item > span:nth-child(2) { display: grid; gap: 3px; min-width: 0; }
+.public-layout-item > span:nth-child(2) { display: grid; gap: 2px; min-width: 0; }
.public-layout-item strong, .public-layout-item small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.public-layout-item strong { font-size: 12px; }
.public-layout-item small { color: var(--dm-text-muted); font-size: 10px; }
@@ -99,7 +98,7 @@
.public-curation-layout { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
- .settings-subnav { position: static; grid-template-columns: 1fr; margin-top: -24px; }
+ .settings-subnav { position: static; grid-template-columns: 1fr; margin-top: 0; }
.settings-subnav span { white-space: normal; }
.public-layout-group > header, .public-layout-item { align-items: flex-start; }
.public-layout-group > header { flex-direction: column; }
@@ -107,19 +106,18 @@
.public-layout-item .public-order-actions { grid-column: 2; }
}
-
.public-publish-tools { display: grid; gap: 10px; margin-bottom: 12px; }
.public-publish-search {
display: flex;
align-items: center;
gap: 9px;
- min-height: 42px;
+ min-height: 40px;
padding: 0 11px;
border: 1px solid var(--dm-border);
border-radius: 10px;
background: var(--dm-bg-soft);
}
-.public-publish-search > span { flex: 0 0 auto; color: var(--dm-text-muted); font-size: 18px; }
+.public-publish-search > span { flex: 0 0 auto; color: var(--dm-text-muted); font-size: 17px; }
.public-publish-search input {
flex: 1;
min-width: 0;
@@ -131,26 +129,26 @@
.public-publish-search input::placeholder { color: var(--dm-text-muted); }
.public-publish-search:focus-within { border-color: var(--dm-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--dm-accent) 14%, transparent); }
.public-publish-filter { grid-template-columns: repeat(3, minmax(0, 1fr)); }
-.public-publish-filter button { padding-inline: 8px; font-size: 10px; }
+.public-publish-filter button { padding-inline: 6px; font-size: 11px; }
.public-bulk-bar {
display: flex;
align-items: center;
gap: 10px;
flex-wrap: wrap;
- min-height: 46px;
+ min-height: 44px;
margin-bottom: 10px;
- padding: 8px 10px;
+ padding: 7px 10px;
border: 1px solid var(--dm-border);
border-radius: 11px;
background: color-mix(in srgb, var(--dm-bg-soft) 78%, transparent);
}
-.public-select-visible { display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto; color: var(--dm-text-soft); font-size: 10px; cursor: pointer; white-space: nowrap; }
+.public-select-visible { display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto; color: var(--dm-text-soft); font-size: 11px; cursor: pointer; white-space: nowrap; }
.public-select-visible input,
.public-bookmark-select input { width: 16px; height: 16px; margin: 0; accent-color: var(--dm-accent); }
-.public-selected-count { flex: 0 1 auto; min-width: 0; color: var(--dm-text-muted); font-size: 10px; white-space: nowrap; }
+.public-selected-count { flex: 0 1 auto; min-width: 0; color: var(--dm-text-muted); font-size: 11px; white-space: nowrap; }
.public-bulk-actions { display: flex; align-items: center; gap: 7px; flex: 0 0 auto; margin-left: auto; }
-.public-bulk-actions .secondary { min-height: 32px; padding-inline: 9px; font-size: 10px; white-space: nowrap; }
+.public-bulk-actions .secondary { min-height: 30px; padding-inline: 9px; font-size: 11px; white-space: nowrap; }
.public-bookmark-manager { align-content: start; }
.public-bookmark-row.public-bookmark-manage {
@@ -167,14 +165,14 @@
min-width: 0;
cursor: pointer;
}
-.public-bookmark-select > span { display: grid; gap: 3px; min-width: 0; }
+.public-bookmark-select > span { display: grid; gap: 2px; min-width: 0; }
.public-bookmark-select strong,
.public-bookmark-select small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.public-bookmark-select strong { font-size: 12px; }
.public-bookmark-select small { color: var(--dm-text-muted); font-size: 10px; }
-.public-bookmark-row.public-bookmark-manage em { min-width: 64px; color: var(--dm-text-muted); text-align: right; }
+.public-bookmark-row.public-bookmark-manage em { min-width: 56px; color: var(--dm-text-muted); text-align: right; white-space: nowrap; }
.public-bookmark-row.public-bookmark-manage.is-published em { color: var(--dm-accent-strong); }
-.public-bookmark-row.public-bookmark-manage > button { min-width: 54px; text-align: right; }
+.public-bookmark-row.public-bookmark-manage > button { min-width: 52px; text-align: right; }
.public-bookmark-row.public-bookmark-manage > button:disabled,
.public-bookmark-select input:disabled,
.public-select-visible input:disabled { opacity: .45; cursor: default; }
@@ -196,7 +194,6 @@ html[data-theme="light"] .public-bookmark-row.public-bookmark-manage.is-publishe
.public-bulk-actions { flex-wrap: wrap; }
}
-
.public-bookmark-row.public-bookmark-manage:has(input:checked) {
border-color: color-mix(in srgb, var(--dm-accent) 72%, var(--dm-border));
background: color-mix(in srgb, var(--dm-accent-bg) 58%, var(--dm-bg-card));
diff --git a/apps/web/src/smart-collections.css b/apps/web/src/smart-collections.css
index a32179a..a8c0fa0 100644
--- a/apps/web/src/smart-collections.css
+++ b/apps/web/src/smart-collections.css
@@ -1,60 +1,496 @@
-.smart-shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 46px 0 72px; }
-.smart-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; margin-bottom: 24px; }
-.smart-hero h1 { margin: 6px 0 10px; font-size: clamp(34px, 5vw, 58px); line-height: .95; letter-spacing: -.045em; }
-.smart-hero p:not(.eyebrow) { max-width: 680px; margin: 0; color: var(--muted); line-height: 1.65; }
-.smart-summary { min-width: 132px; padding: 18px 20px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); text-align: right; }
-.smart-summary strong { display: block; font-size: 30px; line-height: 1; }
-.smart-summary span { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .07em; }
-.smart-grid { display: grid; grid-template-columns: minmax(220px, 290px) minmax(0, 1fr); gap: 18px; align-items: start; }
-.smart-list, .smart-editor { overflow: hidden; }
-.smart-list-heading, .smart-editor-heading, .smart-preview-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
-.smart-list-heading > div, .smart-preview-heading > div { display: grid; gap: 3px; }
-.smart-list-heading span, .smart-preview-heading span { color: var(--muted); font-size: 11px; }
-.smart-list-row { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--text); text-align: left; cursor: pointer; }
-.smart-list-row:hover, .smart-list-row.active { background: color-mix(in srgb, var(--accent) 8%, var(--panel)); }
-.smart-list-row span { min-width: 0; display: grid; gap: 3px; }
-.smart-list-row strong, .smart-list-row small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
-.smart-list-row small { color: var(--muted); }
-.smart-list-row em { min-width: 28px; font-style: normal; color: var(--muted); text-align: right; }
-.smart-editor-heading h2 { margin: 4px 0 0; }
-.smart-actions, .smart-preview-actions { display: flex; align-items: center; gap: 10px; }
-.smart-preview-actions { justify-content: flex-end; flex-wrap: wrap; }
-.smart-filter-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; padding: 20px; }
-.smart-filter-grid label { display: grid; gap: 6px; }
-.smart-filter-grid label > span { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .07em; }
-.smart-filter-grid small { color: var(--muted); font-size: 10px; }
-.smart-filter-grid input, .smart-filter-grid select { width: 100%; min-height: 40px; }
-.smart-preview-heading { border-top: 1px solid var(--line); }
-.smart-preview-list { display: grid; }
-.smart-bookmark { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
-.smart-bookmark:last-child { border-bottom: 0; }
-.smart-bookmark > div:first-child { min-width: 0; }
-.smart-bookmark a { color: var(--text); text-decoration: none; }
-.smart-bookmark a:hover { color: var(--accent); }
-.smart-bookmark small { display: block; margin-top: 4px; color: var(--muted); }
-.smart-bookmark p { margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
-.smart-bookmark-meta { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; max-width: 42%; }
-.smart-bookmark-meta span { padding: 3px 7px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 10px; white-space: nowrap; }
-.smart-empty { padding: 32px 20px; color: var(--muted); text-align: center; }
-.smart-bulk-handoff { margin-top: 22px; display: grid; gap: 12px; }
-.smart-bulk-handoff-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; padding: 0 4px; }
-.smart-bulk-handoff-heading h2 { margin: 4px 0 0; }
-.smart-bulk-handoff-heading > span { color: var(--muted); font-size: 12px; text-align: right; }
-.smart-bulk-handoff .library-bulk-management { width: auto; margin: 0; padding: 0; }
-.smart-bulk-handoff .library-bulk-card { box-shadow: 0 18px 50px color-mix(in srgb, #000 12%, transparent); }
+.smart-shell {
+ width: min(1180px, calc(100% - 40px));
+ margin: 0 auto;
+ padding: 28px 0 64px;
+}
+
+.smart-hero {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 20px;
+ margin-bottom: 18px;
+}
+
+.smart-hero-copy {
+ min-width: 0;
+ display: grid;
+ gap: 4px;
+}
+
+.smart-hero h1 {
+ margin: 0;
+ font-size: clamp(22px, 2.4vw, 26px);
+ line-height: 1.2;
+ letter-spacing: -.025em;
+ color: var(--dm-text);
+}
+
+.smart-hero p {
+ max-width: 680px;
+ margin: 0;
+ color: var(--dm-text-muted);
+ font-size: 13px;
+ line-height: 1.5;
+}
+
+.smart-hero-pills {
+ display: flex;
+ align-items: center;
+ flex-wrap: wrap;
+ justify-content: flex-end;
+ gap: 8px;
+ flex: 0 0 auto;
+}
+
+.smart-stat-pill {
+ display: inline-flex;
+ align-items: baseline;
+ gap: 6px;
+ padding: 7px 12px;
+ border: 1px solid var(--dm-border);
+ border-radius: 999px;
+ background: var(--dm-bg-card);
+ color: var(--dm-text);
+ white-space: nowrap;
+}
+
+.smart-stat-pill strong {
+ font-size: 14px;
+ font-weight: 700;
+ line-height: 1;
+}
+
+.smart-stat-pill span {
+ color: var(--dm-text-muted);
+ font-size: 11px;
+}
+
+.smart-stat-pill.muted {
+ background: var(--dm-bg-soft);
+}
+
+.smart-grid {
+ display: grid;
+ grid-template-columns: minmax(230px, 296px) minmax(0, 1fr);
+ gap: 16px;
+ align-items: start;
+}
+
+.smart-list,
+.smart-editor {
+ max-width: none;
+ margin: 0;
+ overflow: hidden;
+ border: 1px solid var(--dm-border);
+ border-radius: 16px;
+ background: var(--dm-bg-card);
+}
+
+.smart-list-heading,
+.smart-editor-heading,
+.smart-preview-heading {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 14px;
+ padding: 14px 18px;
+ border-bottom: 1px solid var(--dm-border);
+}
+
+.smart-list-heading > div,
+.smart-editor-heading > div:first-child,
+.smart-preview-heading > div:first-child {
+ display: grid;
+ gap: 2px;
+ min-width: 0;
+}
+
+.smart-list-heading strong,
+.smart-preview-heading strong {
+ font-size: 14px;
+ color: var(--dm-text);
+}
+
+.smart-list-heading span,
+.smart-editor-heading > div:first-child span,
+.smart-preview-heading > div:first-child span {
+ color: var(--dm-text-muted);
+ font-size: 12px;
+}
+
+.smart-list-heading button,
+.smart-actions button,
+.smart-preview-actions button {
+ flex: 0 0 auto;
+ white-space: nowrap;
+}
+
+.smart-list-row {
+ width: 100%;
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 12px;
+ padding: 12px 16px;
+ border: 0;
+ border-bottom: 1px solid var(--dm-border);
+ background: transparent;
+ color: var(--dm-text);
+ text-align: left;
+ cursor: pointer;
+ transition: background-color 140ms ease, transform 80ms ease;
+}
+
+.smart-list-row:last-child {
+ border-bottom: 0;
+}
+
+.smart-list-row:hover,
+.smart-list-row.active {
+ background: var(--dm-selected-bg);
+}
+
+.smart-list-row:active {
+ transform: translateY(1px);
+}
+
+.smart-list-row span {
+ min-width: 0;
+ display: grid;
+ gap: 3px;
+}
+
+.smart-list-row strong {
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ font-size: 13px;
+ font-weight: 600;
+}
+
+.smart-list-row small {
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ color: var(--dm-text-muted);
+ font-size: 11px;
+}
+
+.smart-list-row em {
+ flex: 0 0 auto;
+ min-width: 24px;
+ padding: 2px 7px;
+ border: 1px solid var(--dm-border);
+ border-radius: 999px;
+ background: var(--dm-bg-soft);
+ font-style: normal;
+ font-size: 11px;
+ color: var(--dm-text-soft);
+ text-align: center;
+ white-space: nowrap;
+}
+
+.smart-list-row.active em {
+ border-color: color-mix(in srgb, var(--dm-accent) 44%, var(--dm-border));
+ color: var(--dm-accent-strong);
+}
+
+.smart-editor-heading h2 {
+ margin: 0;
+ font-size: 16px;
+ font-weight: 650;
+ letter-spacing: -.015em;
+ color: var(--dm-text);
+}
+
+.smart-actions,
+.smart-preview-actions {
+ display: flex;
+ align-items: center;
+ gap: 10px;
+}
+
+.smart-preview-actions {
+ justify-content: flex-end;
+ flex-wrap: wrap;
+}
+
+.smart-filter-grid {
+ display: grid;
+ grid-template-columns: repeat(2, minmax(0, 1fr));
+ gap: 14px;
+ padding: 16px 18px;
+}
+
+.smart-filter-grid label {
+ display: grid;
+ gap: 5px;
+ min-width: 0;
+}
+
+.smart-filter-grid label > span {
+ color: var(--dm-text-soft);
+ font-size: 12px;
+ font-weight: 560;
+}
+
+.smart-filter-grid small {
+ color: var(--dm-text-muted);
+ font-size: 11px;
+}
+
+.smart-filter-grid input,
+.smart-filter-grid select {
+ width: 100%;
+ min-height: 38px;
+ padding: 0 10px;
+ border: 1px solid var(--dm-border-strong);
+ border-radius: 9px;
+ background: var(--dm-input-bg);
+ color: var(--dm-text);
+}
+
+.smart-preview-heading {
+ border-top: 1px solid var(--dm-border);
+}
+
+.smart-filter-chips {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 6px;
+ padding: 10px 18px;
+ border-bottom: 1px solid var(--dm-border);
+ background: var(--dm-bg-soft);
+}
+
+.smart-filter-chip {
+ padding: 3px 9px;
+ border: 1px solid color-mix(in srgb, var(--dm-accent) 34%, var(--dm-border));
+ border-radius: 999px;
+ background: var(--dm-bg-card);
+ color: var(--dm-text-soft);
+ font-size: 11px;
+ white-space: nowrap;
+}
+
+.smart-filter-chip.is-all {
+ border-color: var(--dm-border);
+ color: var(--dm-text-muted);
+}
+
+.smart-preview-list {
+ display: grid;
+}
+
+.smart-bookmark {
+ display: flex;
+ align-items: flex-start;
+ justify-content: space-between;
+ gap: 16px;
+ padding: 13px 18px;
+ border-bottom: 1px solid var(--dm-border);
+ transition: background-color 140ms ease;
+}
+
+.smart-bookmark:last-child {
+ border-bottom: 0;
+}
+
+.smart-bookmark:hover {
+ background: color-mix(in srgb, var(--dm-hover-bg) 48%, transparent);
+}
+
+.smart-bookmark-main {
+ display: flex;
+ align-items: flex-start;
+ gap: 11px;
+ min-width: 0;
+ flex: 1;
+}
+
+.smart-bookmark-icon {
+ display: grid;
+ place-items: center;
+ flex: 0 0 34px;
+ width: 34px;
+ height: 34px;
+ border: 1px solid var(--dm-border);
+ border-radius: 10px;
+ background: var(--dm-accent-bg);
+ color: var(--dm-accent-strong);
+ font-size: 13px;
+ font-weight: 700;
+ overflow: hidden;
+}
+
+.smart-bookmark-icon.has-favicon {
+ padding: 0;
+ background: var(--dm-bg-soft);
+}
+
+.smart-bookmark-icon.has-favicon img {
+ display: block;
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+ border-radius: inherit;
+}
+
+.smart-bookmark-copy {
+ min-width: 0;
+ display: grid;
+ gap: 2px;
+}
+
+.smart-bookmark-copy a {
+ color: var(--dm-text);
+ text-decoration: none;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.smart-bookmark-copy a:hover {
+ color: var(--dm-accent);
+}
+
+.smart-bookmark-copy strong {
+ font-size: 13px;
+ font-weight: 600;
+}
+
+.smart-bookmark-copy small {
+ display: block;
+ color: var(--dm-text-muted);
+ font-size: 11px;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.smart-bookmark-copy p {
+ margin: 4px 0 0;
+ color: var(--dm-text-muted);
+ font-size: 12px;
+ line-height: 1.45;
+}
+
+.smart-bookmark-meta {
+ display: flex;
+ flex-wrap: wrap;
+ justify-content: flex-end;
+ gap: 5px;
+ max-width: 42%;
+ flex: 0 0 auto;
+}
+
+.smart-bookmark-meta span {
+ padding: 2px 8px;
+ border: 1px solid var(--dm-border);
+ border-radius: 999px;
+ background: var(--dm-bg-soft);
+ color: var(--dm-text-muted);
+ font-size: 10px;
+ white-space: nowrap;
+}
+
+.smart-bookmark-meta span.is-inbox {
+ border-color: color-mix(in srgb, var(--dm-accent) 44%, var(--dm-border));
+ color: var(--dm-accent);
+}
+
+.smart-empty {
+ padding: 32px 20px;
+ color: var(--dm-text-muted);
+ font-size: 13px;
+ text-align: center;
+}
+
+.smart-bulk-handoff {
+ margin-top: 20px;
+ display: grid;
+ gap: 10px;
+}
+
+.smart-bulk-handoff-heading {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 16px;
+ padding: 0 2px;
+}
+
+.smart-bulk-handoff-heading h2 {
+ margin: 0;
+ font-size: 16px;
+ font-weight: 650;
+ color: var(--dm-text);
+}
+
+.smart-bulk-handoff-heading > span {
+ color: var(--dm-text-muted);
+ font-size: 12px;
+ text-align: right;
+ white-space: nowrap;
+}
+
+.smart-bulk-handoff .library-bulk-management {
+ width: auto;
+ margin: 0;
+ padding: 0;
+}
+
+.smart-bulk-handoff .library-bulk-card {
+ box-shadow: 0 14px 38px color-mix(in srgb, #000 10%, transparent);
+}
+
+.smart-shell button:not(:disabled):active {
+ transform: translateY(1px);
+}
@media (max-width: 840px) {
- .smart-shell { width: min(100% - 24px, 1180px); padding-top: 28px; }
- .smart-hero { align-items: stretch; flex-direction: column; }
- .smart-summary { align-self: flex-start; text-align: left; }
- .smart-grid { grid-template-columns: 1fr; }
- .smart-bulk-handoff-heading { align-items: flex-start; flex-direction: column; }
- .smart-bulk-handoff-heading > span { text-align: left; }
+ .smart-shell {
+ width: min(100% - 24px, 1180px);
+ padding-top: 20px;
+ }
+ .smart-hero {
+ align-items: stretch;
+ flex-direction: column;
+ gap: 12px;
+ }
+ .smart-hero-pills {
+ justify-content: flex-start;
+ }
+ .smart-grid {
+ grid-template-columns: 1fr;
+ }
+ .smart-bulk-handoff-heading {
+ align-items: flex-start;
+ flex-direction: column;
+ gap: 6px;
+ }
+ .smart-bulk-handoff-heading > span {
+ text-align: left;
+ white-space: normal;
+ }
}
@media (max-width: 620px) {
- .smart-filter-grid { grid-template-columns: 1fr; }
- .smart-editor-heading, .smart-preview-heading, .smart-bookmark { align-items: stretch; flex-direction: column; }
- .smart-preview-actions { justify-content: flex-start; }
- .smart-bookmark-meta { justify-content: flex-start; max-width: none; }
+ .smart-filter-grid {
+ grid-template-columns: 1fr;
+ }
+ .smart-editor-heading,
+ .smart-preview-heading,
+ .smart-bookmark {
+ align-items: stretch;
+ flex-direction: column;
+ }
+ .smart-preview-actions {
+ justify-content: flex-start;
+ }
+ .smart-bookmark-meta {
+ justify-content: flex-start;
+ max-width: none;
+ }
}
diff --git a/apps/web/src/styles.css b/apps/web/src/styles.css
index 77bf49c..f957697 100644
--- a/apps/web/src/styles.css
+++ b/apps/web/src/styles.css
@@ -25,55 +25,292 @@ body::before {
background-size: auto, 32px 32px, 32px 32px;
}
-.shell { position: relative; width: min(1100px, calc(100% - 40px)); margin: 0 auto; padding-bottom: 72px; }
+.shell { position: relative; width: min(1100px, calc(100% - 40px)); margin: 0 auto; padding-bottom: 64px; }
.topbar { height: 82px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #202623; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: -.02em; }
.brand-button { padding: 0; border: 0; background: transparent; cursor: pointer; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border: 1px solid #39433e; border-radius: 10px; background: #151b18; color: #b8e0c5; }
nav { display: flex; align-items: center; gap: 6px; }
.ghost, .settings { border: 0; color: #a9b2ad; background: transparent; cursor: pointer; }
-.ghost { padding: 10px 12px; border-radius: 9px; }
+.ghost { padding: 8px 11px; border-radius: 9px; font-size: 13px; font-weight: 500; transition: background-color 140ms ease, color 140ms ease; }
.ghost:hover, .ghost.active { color: #edf3ef; background: #151b18; }
.ghost:disabled { opacity: .4; cursor: default; background: transparent; }
.settings { width: 36px; height: 36px; border: 1px solid #2a322e; border-radius: 10px; background: #121714; }
-.hero { padding: 92px 0 46px; max-width: 820px; margin: auto; text-align: center; }
-.eyebrow { color: var(--dm-accent); letter-spacing: .18em; font-size: 11px; font-weight: 700; }
-h1 { font-size: clamp(42px, 7vw, 72px); line-height: 1.02; letter-spacing: -.055em; margin: 18px 0 36px; font-weight: 620; }
-.command { display: flex; align-items: center; gap: 12px; padding: 9px 12px 9px 16px; min-height: 62px; border: 1px solid #34403a; background: rgba(18, 24, 21, .88); border-radius: 18px; box-shadow: 0 20px 80px rgba(0, 0, 0, .3); text-align: left; }
-.command:focus-within { border-color: #729f82; box-shadow: 0 0 0 3px rgba(114,159,130,.12), 0 20px 80px rgba(0,0,0,.3); }
-.search-icon { color: var(--dm-text-soft); font-size: 24px; }
-.command input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: #f5faf7; font-size: 16px; }
+.hero { padding: 28px 0 18px; max-width: 860px; margin: 0 auto; }
+.launcher-hero { padding: 28px 0 16px; max-width: 100%; }
+.eyebrow { margin: 0; color: var(--dm-accent); letter-spacing: .16em; font-size: 10px; font-weight: 700; text-transform: uppercase; }
+h1 { font-size: clamp(24px, 3vw, 32px); line-height: 1.18; letter-spacing: -.03em; margin: 8px 0 14px; font-weight: 640; }
+
+.command {
+ display: flex;
+ align-items: center;
+ gap: 10px;
+ padding: 8px 12px 8px 15px;
+ min-height: 54px;
+ border: 1px solid #34403a;
+ background: rgba(18, 24, 21, .9);
+ border-radius: 14px;
+ box-shadow: 0 14px 44px rgba(0, 0, 0, .24);
+ text-align: left;
+ transition: border-color 140ms ease, box-shadow 140ms ease;
+}
+.command:focus-within { border-color: #729f82; box-shadow: 0 0 0 3px rgba(114,159,130,.14), 0 14px 44px rgba(0,0,0,.24); }
+.search-icon { color: var(--dm-text-soft); font-size: 20px; line-height: 1; }
+.command input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: #f5faf7; font-size: 15px; }
.command input::placeholder { color: var(--dm-text-muted); }
-kbd { padding: 6px 8px; color: var(--dm-text-muted); border: 1px solid #303934; border-radius: 8px; background: #0d1210; font-size: 11px; }
+.command-clear {
+ display: grid;
+ place-items: center;
+ width: 26px;
+ height: 26px;
+ padding: 0;
+ border: 1px solid var(--dm-border);
+ border-radius: 7px;
+ background: var(--dm-bg-soft);
+ color: var(--dm-text-soft);
+ cursor: pointer;
+ font-size: 16px;
+ line-height: 1;
+}
+.command-clear:hover { color: var(--dm-text); border-color: var(--dm-border-strong); }
+kbd { padding: 4px 7px; color: var(--dm-text-muted); border: 1px solid #303934; border-radius: 7px; background: #0d1210; font-size: 11px; white-space: nowrap; }
+
+.command-syntax-bar {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 12px;
+ flex-wrap: wrap;
+ margin-top: 10px;
+}
+.command-syntax-pills { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
+.syntax-pill {
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
+ height: 26px;
+ padding: 0 9px;
+ border: 1px solid var(--dm-border);
+ border-radius: 8px;
+ background: color-mix(in srgb, var(--dm-bg-card) 82%, transparent);
+ color: var(--dm-text-soft);
+ font-size: 11px;
+ cursor: pointer;
+ white-space: nowrap;
+ transition: border-color 140ms ease, background-color 140ms ease, color 140ms ease;
+}
+.syntax-pill code { color: var(--dm-accent-strong); font: 600 11px ui-monospace, SFMono-Regular, Menlo, monospace; }
+.syntax-pill:hover { border-color: color-mix(in srgb, var(--dm-accent) 46%, var(--dm-border)); background: var(--dm-hover-bg); color: var(--dm-text); }
+
+.launcher-status-pill {
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
+ color: var(--dm-text-muted);
+ font-size: 11px;
+ white-space: nowrap;
+}
+.launcher-status-pill .status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dm-text-muted); opacity: .7; }
+.launcher-status-pill.connected { color: var(--dm-accent-strong); }
+.launcher-status-pill.connected .status-dot { background: var(--dm-accent); opacity: 1; }
-.panel { max-width: 820px; margin: 0 auto; border: 1px solid #252d29; background: rgba(15, 20, 18, .75); border-radius: 20px; overflow: hidden; }
-.panel-heading { display: flex; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid #222925; color: var(--dm-text-soft); font-size: 12px; text-transform: uppercase; letter-spacing: .09em; }
+.panel { max-width: 100%; margin: 0 auto; border: 1px solid #252d29; background: rgba(15, 20, 18, .78); border-radius: 16px; overflow: hidden; }
+.launcher-error-panel { margin-bottom: 14px; }
+.panel-heading { display: flex; justify-content: space-between; padding: 11px 16px; border-bottom: 1px solid #222925; color: var(--dm-text-soft); font-size: 11px; text-transform: uppercase; letter-spacing: .09em; }
.muted { color: #65706a; }
-.results { padding: 7px; }
-.result { display: flex; align-items: center; gap: 12px; min-height: 58px; padding: 8px 11px; border-radius: 13px; }
+.results { padding: 6px; }
+.result { display: flex; align-items: center; gap: 11px; min-height: 50px; padding: 7px 10px; border-radius: 11px; }
.result:hover { background: #171e1a; }
-.favicon { display: grid; place-items: center; flex: 0 0 38px; width: 38px; height: 38px; border: 1px solid #303a35; border-radius: 11px; background: #202823; color: #b9d8c4; font-weight: 700; }
-.result-copy { display: flex; flex: 1; min-width: 0; flex-direction: column; gap: 3px; text-align: left; }
-.result-copy strong { font-size: 14px; font-weight: 600; }
-.result-copy small { overflow: hidden; color: var(--dm-text-muted); text-overflow: ellipsis; white-space: nowrap; }
-.pill { color: var(--dm-text-soft); font-size: 11px; }
-.panel-error { display: grid; gap: 8px; padding: 24px; }
-.panel-error span { color: #8d9992; font-size: 13px; }
-.panel-error button { width: max-content; margin-top: 5px; }
-.empty-command { padding: 26px 14px; color: var(--dm-text-muted); text-align: center; }
-
-.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 72px; }
-.feature-grid article { min-height: 190px; padding: 22px; border: 1px solid #222925; border-radius: 18px; background: rgba(15,20,18,.55); }
-.feature-grid article > span { color: #627068; font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; }
-.feature-grid h2 { margin: 42px 0 8px; font-size: 17px; }
-.feature-grid p { margin: 0; color: #818c86; font-size: 13px; line-height: 1.6; }
-
-.management { padding: 66px 0 20px; }
-.management-heading { display: flex; align-items: end; justify-content: space-between; gap: 32px; margin-bottom: 40px; }
-.management-heading h1 { margin-bottom: 0; font-size: clamp(38px, 5.5vw, 62px); }
-.library-count { flex: 0 0 auto; padding: 8px 11px; border: 1px solid #2b342f; border-radius: 999px; color: #849089; background: #111613; font-size: 12px; }
-.management-grid { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 18px; align-items: start; }
+.favicon { display: grid; place-items: center; flex: 0 0 34px; width: 34px; height: 34px; overflow: hidden; border: 1px solid #303a35; border-radius: 9px; background: #202823; color: #b9d8c4; font-size: 13px; font-weight: 700; }
+.favicon img { width: 18px; height: 18px; object-fit: contain; border-radius: 3px; }
+.result-copy { display: flex; flex: 1; min-width: 0; flex-direction: column; gap: 2px; text-align: left; }
+.result-copy strong { overflow: hidden; font-size: 13px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
+.result-copy small { overflow: hidden; color: var(--dm-text-muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
+.pill { color: var(--dm-text-soft); font-size: 11px; white-space: nowrap; }
+.panel-error { display: grid; gap: 8px; padding: 18px 20px; }
+.panel-error span { color: var(--dm-text-muted); font-size: 13px; }
+.panel-error button { width: max-content; margin-top: 4px; }
+.empty-command { padding: 24px 14px; color: var(--dm-text-muted); font-size: 13px; text-align: center; }
+
+/* Launcher Dashboard */
+.launcher-dashboard { display: grid; gap: 24px; margin-top: 16px; }
+.launcher-section { display: grid; gap: 10px; min-width: 0; }
+.launcher-section-head { display: flex; align-items: center; gap: 8px; min-height: 24px; }
+.launcher-section-head h2 { margin: 0; font-size: 13px; font-weight: 640; letter-spacing: -.01em; color: var(--dm-text); }
+.launcher-section-count {
+ padding: 2px 7px;
+ border: 1px solid var(--dm-border);
+ border-radius: 999px;
+ background: var(--dm-bg-soft);
+ color: var(--dm-text-muted);
+ font-size: 11px;
+ font-variant-numeric: tabular-nums;
+}
+.launcher-section-link { margin-left: auto; font-size: 12px; font-weight: 500; }
+
+.launcher-tabs-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
+.launcher-tab-chip {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ min-width: 0;
+ height: 38px;
+ padding: 0 11px;
+ border: 1px solid var(--dm-border);
+ border-radius: 10px;
+ background: color-mix(in srgb, var(--dm-bg-card) 85%, transparent);
+ color: var(--dm-text);
+ font-size: 12px;
+ cursor: pointer;
+ text-align: left;
+ transition: border-color 140ms ease, background-color 140ms ease;
+}
+.launcher-tab-chip:hover { border-color: color-mix(in srgb, var(--dm-accent) 46%, var(--dm-border)); background: var(--dm-hover-bg); }
+.launcher-tab-chip.is-active { border-color: color-mix(in srgb, var(--dm-accent) 52%, var(--dm-border)); background: var(--dm-selected-bg); }
+.launcher-tab-arrow { flex: 0 0 auto; color: var(--dm-accent-strong); font-size: 12px; }
+.launcher-tab-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 540; }
+.launcher-tab-chip small { flex: 0 0 auto; max-width: 96px; overflow: hidden; color: var(--dm-text-muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
+
+.launcher-workspace-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
+.launcher-workspace-card {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 12px;
+ min-width: 0;
+ padding: 11px 12px;
+ border: 1px solid var(--dm-border);
+ border-radius: 13px;
+ background: color-mix(in srgb, var(--dm-bg-card) 86%, transparent);
+ transition: border-color 140ms ease, background-color 140ms ease;
+}
+.launcher-workspace-card:hover { border-color: color-mix(in srgb, var(--dm-accent) 42%, var(--dm-border)); }
+.launcher-workspace-main { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
+.launcher-workspace-icon {
+ display: grid;
+ place-items: center;
+ flex: 0 0 34px;
+ width: 34px;
+ height: 34px;
+ border: 1px solid var(--dm-border-strong);
+ border-radius: 9px;
+ background: var(--dm-accent-bg);
+ color: var(--dm-accent-strong);
+ font-size: 13px;
+ font-weight: 700;
+}
+.launcher-workspace-copy { display: grid; gap: 3px; min-width: 0; }
+.launcher-workspace-copy strong { overflow: hidden; font-size: 13px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
+.launcher-workspace-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; color: var(--dm-text-muted); font-size: 11px; }
+.launcher-mode-badge {
+ padding: 1px 6px;
+ border: 1px solid var(--dm-border);
+ border-radius: 999px;
+ background: var(--dm-bg-soft);
+ color: var(--dm-text-soft);
+ font-size: 10px;
+}
+.launcher-launch-btn { flex: 0 0 auto; min-height: 30px; padding: 0 11px; font-size: 12px; white-space: nowrap; }
+
+.launcher-filter-bar {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ flex-wrap: wrap;
+}
+.launcher-filter-pill {
+ display: inline-flex;
+ align-items: center;
+ gap: 5px;
+ height: 29px;
+ padding: 0 10px;
+ border: 1px solid var(--dm-border);
+ border-radius: 999px;
+ background: color-mix(in srgb, var(--dm-bg-card) 82%, transparent);
+ color: var(--dm-text-soft);
+ font-size: 12px;
+ cursor: pointer;
+ white-space: nowrap;
+ transition: border-color 140ms ease, background-color 140ms ease, color 140ms ease;
+}
+.launcher-filter-pill em { font-style: normal; color: var(--dm-text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
+.launcher-filter-pill:hover { border-color: color-mix(in srgb, var(--dm-accent) 44%, var(--dm-border)); color: var(--dm-text); background: var(--dm-hover-bg); }
+.launcher-filter-pill.active {
+ border-color: color-mix(in srgb, var(--dm-accent) 60%, var(--dm-border));
+ background: var(--dm-selected-bg);
+ color: var(--dm-accent-strong);
+ font-weight: 560;
+}
+.launcher-filter-pill.active em { color: var(--dm-accent-strong); }
+
+.launcher-bookmark-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(236px, 1fr)); gap: 9px; }
+.launcher-bookmark-card {
+ display: flex;
+ flex-direction: column;
+ justify-content: space-between;
+ gap: 8px;
+ min-width: 0;
+ padding: 11px 12px;
+ border: 1px solid var(--dm-border);
+ border-radius: 13px;
+ background: color-mix(in srgb, var(--dm-bg-card) 86%, transparent);
+ transition: transform 130ms ease, border-color 140ms ease, background-color 140ms ease;
+}
+.launcher-bookmark-card:hover {
+ transform: translateY(-1px);
+ border-color: color-mix(in srgb, var(--dm-accent) 48%, var(--dm-border));
+ background: var(--dm-hover-bg);
+}
+.launcher-bookmark-top { display: flex; align-items: center; gap: 10px; min-width: 0; }
+.launcher-card-icon {
+ display: grid;
+ place-items: center;
+ flex: 0 0 32px;
+ width: 32px;
+ height: 32px;
+ overflow: hidden;
+ border: 1px solid var(--dm-border-strong);
+ border-radius: 9px;
+ background: var(--dm-accent-bg);
+ color: var(--dm-accent-strong);
+ font-size: 13px;
+ font-weight: 700;
+}
+.launcher-card-icon img { width: 18px; height: 18px; object-fit: contain; border-radius: 3px; }
+.launcher-bookmark-copy { display: grid; gap: 2px; min-width: 0; flex: 1; }
+.launcher-bookmark-copy strong { overflow: hidden; font-size: 13px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
+.launcher-bookmark-copy small { overflow: hidden; color: var(--dm-text-muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
+.launcher-bookmark-tags { display: flex; flex-wrap: wrap; gap: 4px; }
+.launcher-tag-pill {
+ padding: 2px 6px;
+ border: 1px solid var(--dm-border);
+ border-radius: 6px;
+ background: var(--dm-bg-soft);
+ color: var(--dm-text-soft);
+ font-size: 10px;
+ line-height: 1.3;
+ white-space: nowrap;
+}
+.launcher-empty {
+ display: grid;
+ gap: 5px;
+ padding: 28px 18px;
+ border: 1px dashed var(--dm-border);
+ border-radius: 14px;
+ color: var(--dm-text-muted);
+ font-size: 13px;
+ text-align: center;
+}
+.launcher-empty strong { color: var(--dm-text); }
+
+/* Management Views — Compact Tool-Grade Density */
+.management { padding: 28px 0 18px; }
+.management-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
+.management-heading h1 { margin: 2px 0 0; font-size: clamp(22px, 2.6vw, 28px); line-height: 1.2; letter-spacing: -.025em; font-weight: 640; }
+.management-heading p:not(.eyebrow) { margin: 5px 0 0; color: var(--dm-text-muted); font-size: 13px; line-height: 1.5; }
+.library-count { flex: 0 0 auto; padding: 6px 11px; border: 1px solid #2b342f; border-radius: 999px; color: #849089; background: #111613; font-size: 12px; white-space: nowrap; }
+.management-grid { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 16px; align-items: start; }
/* Sidebar content must be able to shrink below its intrinsic width, otherwise
long category names plus the row action buttons size the grid track and push
the cards out over the management column. */
@@ -81,41 +318,51 @@ kbd { padding: 6px 8px; color: var(--dm-text-muted); border: 1px solid #303934;
.manager-sidebar > * { min-width: 0; }
.manager-main { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; min-width: 0; }
.manager-main > * { min-width: 0; }
-.form-card { padding: 18px; border: 1px solid #252d29; border-radius: 18px; background: rgba(15, 20, 18, .78); }
-.card-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
-.card-heading h2 { margin: 0; font-size: 16px; }
-.card-heading p { margin: 5px 0 0; color: var(--dm-text-muted); font-size: 12px; }
-.card-heading > span { color: #65706a; font-size: 12px; }
+.form-card { padding: 16px; border: 1px solid #252d29; border-radius: 15px; background: rgba(15, 20, 18, .78); }
+.card-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
+.card-heading h2 { margin: 0; font-size: 15px; font-weight: 620; }
+.card-heading p { margin: 4px 0 0; color: var(--dm-text-muted); font-size: 12px; line-height: 1.45; }
+.card-heading > span { color: var(--dm-text-muted); font-size: 12px; white-space: nowrap; }
.field-grid { display: grid; grid-template-columns: 1fr 1.4fr; gap: 12px; }
-.field-grid label { display: grid; gap: 7px; color: var(--dm-text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .07em; }
+.field-grid label { display: grid; gap: 6px; color: var(--dm-text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .07em; }
.field-grid input, .field-grid select, .compact-form input, .category-edit input {
- width: 100%; min-width: 0; height: 42px; padding: 0 11px; border: 1px solid #303934; border-radius: 10px; outline: 0; color: #edf3ef; background: #0e1311;
+ width: 100%; min-width: 0; height: 40px; padding: 0 11px; border: 1px solid #303934; border-radius: 10px; outline: 0; color: #edf3ef; background: #0e1311;
}
.field-grid input:focus, .field-grid select:focus, .compact-form input:focus, .category-edit input:focus { border-color: #729f82; box-shadow: 0 0 0 3px rgba(114,159,130,.1); }
.field-grid select { appearance: auto; }
-.primary, .secondary, .danger-button { min-height: 36px; padding: 0 12px; border-radius: 9px; cursor: pointer; }
+.primary, .secondary, .danger-button {
+ min-height: 34px;
+ padding: 0 12px;
+ border-radius: 9px;
+ cursor: pointer;
+ font-size: 13px;
+ white-space: nowrap;
+ transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease, transform 120ms ease;
+}
+.primary:active:not(:disabled), .secondary:active:not(:disabled), .danger-button:active:not(:disabled) { transform: translateY(.5px); }
.primary { border: 1px solid #7ea88d; background: #91bc9f; color: #0a100d; font-weight: 650; }
.secondary { border: 1px solid #313b35; background: #151b18; color: #b9c4be; }
.danger-button { border: 1px solid #51302f; background: #231514; color: #d49b98; }
.primary:disabled, .secondary:disabled, .danger-button:disabled { opacity: .45; cursor: default; }
.compact-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; margin-bottom: 14px; }
.category-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
-.category-row { min-height: 39px; display: flex; align-items: center; gap: 8px; min-width: 0; padding: 5px 4px; border-top: 1px solid #1d2420; }
+.category-row { min-height: 38px; display: flex; align-items: center; gap: 8px; min-width: 0; padding: 5px 4px; border-top: 1px solid #1d2420; }
.category-row > span { color: #65706a; font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; }
.category-row strong { flex: 1; min-width: 0; overflow: hidden; font-size: 13px; font-weight: 540; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { display: flex; gap: 7px; flex: 0 0 auto; opacity: 0; }
.category-row:hover .row-actions { opacity: 1; }
-.text-action { padding: 0; border: 0; background: transparent; color: var(--dm-accent); cursor: pointer; font-size: 10px; }
+.text-action { padding: 0; border: 0; background: transparent; color: var(--dm-accent); cursor: pointer; font-size: 11px; white-space: nowrap; }
+.text-action:hover { color: var(--dm-accent-strong); }
.muted-action { color: var(--dm-text-soft); }
.danger-text { color: var(--dm-danger); }
.category-edit { display: grid; grid-template-columns: 1fr auto auto; gap: 7px; width: 100%; align-items: center; }
.category-edit input { height: 34px; }
-.empty-copy { margin: 12px 4px 0; color: var(--dm-text-muted); font-size: 12px; }
+.empty-copy { margin: 10px 4px 0; color: var(--dm-text-muted); font-size: 12px; }
.bookmark-form .primary { flex: 0 0 auto; }
.bookmark-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
-.bookmark-card { display: flex; align-items: center; gap: 13px; min-height: 76px; min-width: 0; padding: 13px; border: 1px solid #242c28; border-radius: 15px; background: rgba(14, 19, 17, .65); }
+.bookmark-card { display: flex; align-items: center; gap: 13px; min-height: 70px; min-width: 0; padding: 12px; border: 1px solid #242c28; border-radius: 14px; background: rgba(14, 19, 17, .65); }
.bookmark-card > form { width: 100%; }
-.bookmark-icon { display: grid; place-items: center; flex: 0 0 42px; width: 42px; height: 42px; border: 1px solid #313b35; border-radius: 12px; background: #1b231e; color: #b8d6c1; font-weight: 700; }
+.bookmark-icon { display: grid; place-items: center; flex: 0 0 38px; width: 38px; height: 38px; border: 1px solid #313b35; border-radius: 10px; background: #1b231e; color: #b8d6c1; font-weight: 700; }
.bookmark-details { display: grid; gap: 4px; flex: 1; min-width: 0; }
.bookmark-title-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bookmark-title-line a { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@@ -128,9 +375,9 @@ kbd { padding: 6px 8px; color: var(--dm-text-muted); border: 1px solid #303934;
.health-ignore { border-color: #3c3330; color: #9d8b83; }
.health-manual { border-color: #34374b; color: #9298c2; }
.edit-actions { display: flex; gap: 8px; margin-top: 12px; }
-.empty-state { display: grid; gap: 5px; padding: 36px; border: 1px dashed #2b342f; border-radius: 15px; color: var(--dm-text-muted); text-align: center; }
+.empty-state { display: grid; gap: 5px; padding: 32px; border: 1px dashed #2b342f; border-radius: 14px; color: var(--dm-text-muted); text-align: center; }
.empty-state strong { color: #b8c3bd; }
-.error-banner { margin-bottom: 16px; padding: 12px 14px; border: 1px solid #5a3734; border-radius: 11px; background: #211413; color: #d4a09c; font-size: 13px; }
+.error-banner { margin-bottom: 14px; padding: 11px 14px; border: 1px solid #5a3734; border-radius: 11px; background: #211413; color: #d4a09c; font-size: 13px; }
@media (max-width: 860px) {
.management-grid { grid-template-columns: 1fr; }
@@ -141,10 +388,9 @@ kbd { padding: 6px 8px; color: var(--dm-text-muted); border: 1px solid #303934;
@media (max-width: 720px) {
.shell { width: min(100% - 24px, 1100px); }
.topbar .ghost:disabled { display: none; }
- .hero { padding-top: 58px; }
- .feature-grid { grid-template-columns: 1fr; margin-top: 42px; }
- .management { padding-top: 42px; }
- .management-heading { align-items: start; flex-direction: column; }
+ .hero, .launcher-hero { padding-top: 20px; }
+ .management { padding-top: 20px; }
+ .management-heading { align-items: start; flex-direction: column; gap: 10px; }
.bookmark-card { align-items: flex-start; flex-wrap: wrap; }
/* The drag handle is hidden at this width, so indenting the row actions by its
old width pushed the button row past the card on narrow screens. */
@@ -152,27 +398,24 @@ kbd { padding: 6px 8px; color: var(--dm-text-muted); border: 1px solid #303934;
.row-actions { opacity: 1; }
}
-
-.bookmark-management-hub { padding-top: 26px; }
+.bookmark-management-hub { padding-top: 22px; }
.section-tabs {
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 8px;
- margin-bottom: -28px;
- padding: 7px;
+ margin-bottom: 12px;
+ padding: 6px;
border: 1px solid var(--dm-border);
- border-radius: 16px;
+ border-radius: 14px;
background: var(--dm-bg-soft);
}
.section-tabs button {
display: grid;
- gap: 4px;
+ gap: 3px;
min-width: 0;
- padding: 11px 12px;
+ padding: 9px 11px;
border: 1px solid transparent;
- border-radius: 11px;
- /* These are primary section labels rather than supporting copy, so they use the
- soft text colour to stay legible at 10-12px. */
+ border-radius: 10px;
color: var(--dm-text-soft);
background: transparent;
cursor: pointer;
@@ -182,11 +425,11 @@ kbd { padding: 6px 8px; color: var(--dm-text-muted); border: 1px solid #303934;
.section-tabs button.active { border-color: var(--dm-border-strong); color: var(--dm-text); background: var(--dm-bg-raised); }
.section-tabs strong { font-size: 12px; }
.section-tabs span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
-.bookmark-section-stack { padding-top: 40px; }
+.bookmark-section-stack { padding-top: 8px; }
.bookmark-section-stack > :first-child { margin-top: 0; }
@media (max-width: 760px) {
- .section-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: -10px; }
+ .section-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 10px; }
}
@media (max-width: 520px) {
.section-tabs { grid-template-columns: 1fr; }
diff --git a/apps/web/src/theme.css b/apps/web/src/theme.css
index 217a2ca..4e7d071 100644
--- a/apps/web/src/theme.css
+++ b/apps/web/src/theme.css
@@ -62,8 +62,6 @@ body::before {
html[data-theme="light"] .topbar,
html[data-theme="light"] .public-topbar,
html[data-theme="light"] .public-footer { border-color: var(--dm-border); }
-/* Nav buttons are 16px body text, so light mode needs the softer text colour to
- clear 4.5:1 rather than the muted tone used for small supporting copy. */
html[data-theme="light"] .ghost { color: var(--dm-text-soft); }
html[data-theme="light"] .public-intro,
html[data-theme="light"] .settings-heading p { color: var(--dm-text-muted); }
@@ -79,12 +77,18 @@ html[data-theme="light"] .primary { border-color: #6c9a7d; background: #74a889;
html[data-theme="light"] .form-card,
html[data-theme="light"] .panel,
html[data-theme="light"] .bookmark-card,
-html[data-theme="light"] .feature-grid article,
html[data-theme="light"] .settings-heading,
html[data-theme="light"] .settings-actions-row,
html[data-theme="light"] .public-card,
-html[data-theme="light"] .public-search { border-color: var(--dm-border); background: rgba(255,255,255,.82); box-shadow: 0 14px 38px rgba(40,67,54,.04); }
-html[data-theme="light"] .command { border-color: var(--dm-border-strong); background: rgba(255,255,255,.92); box-shadow: 0 20px 70px rgba(40,67,54,.08); }
+html[data-theme="light"] .public-search,
+html[data-theme="light"] .launcher-bookmark-card,
+html[data-theme="light"] .launcher-workspace-card,
+html[data-theme="light"] .launcher-tab-chip {
+ border-color: var(--dm-border);
+ background: rgba(255,255,255,.88);
+ box-shadow: 0 10px 28px rgba(40,67,54,.04);
+}
+html[data-theme="light"] .command { border-color: var(--dm-border-strong); background: rgba(255,255,255,.94); box-shadow: 0 16px 48px rgba(40,67,54,.08); }
html[data-theme="light"] .command input,
html[data-theme="light"] .public-search input,
html[data-theme="light"] .field-grid input,
@@ -93,15 +97,15 @@ html[data-theme="light"] .compact-form input,
html[data-theme="light"] .category-edit input,
html[data-theme="light"] .settings-field input,
html[data-theme="light"] .settings-field select { color: var(--dm-text); background: #fff; border-color: var(--dm-border); }
-html[data-theme="light"] .command input::placeholder { color: #91a097; }
+html[data-theme="light"] .command input::placeholder { color: #7e9187; }
html[data-theme="light"] kbd { color: var(--dm-text-muted); border-color: var(--dm-border); background: var(--dm-bg-soft); }
html[data-theme="light"] .result:hover,
html[data-theme="light"] .public-card:hover { background: var(--dm-bg-soft); }
html[data-theme="light"] .favicon,
html[data-theme="light"] .bookmark-icon,
-html[data-theme="light"] .public-card-icon { border-color: var(--dm-border); background: var(--dm-accent-bg); color: var(--dm-accent-strong); }
+html[data-theme="light"] .public-card-icon,
+html[data-theme="light"] .launcher-card-icon { border-color: var(--dm-border); background: var(--dm-accent-bg); color: var(--dm-accent-strong); }
html[data-theme="light"] .result-copy small,
-html[data-theme="light"] .feature-grid p,
html[data-theme="light"] .bookmark-details small,
html[data-theme="light"] .public-card-copy small,
html[data-theme="light"] .settings-footnote,
@@ -122,42 +126,55 @@ html[data-theme="light"] .settings-toggle { border-color: var(--dm-border); back
html[data-theme="light"] .error-banner,
html[data-theme="light"] .public-error { border-color: #e1b8b4; background: #fff3f2; color: #9f4e49; }
-/* Some Settings rows intentionally keep Dockmark's dark inverse surface in light mode. */
-html[data-theme="light"] .security-device,
-html[data-theme="light"] .public-bookmark-row {
- border-color: #203129;
- background: var(--dm-inverse-bg);
-}
-html[data-theme="light"] .security-device strong,
-html[data-theme="light"] .public-bookmark-row strong { color: var(--dm-inverse-text); }
-html[data-theme="light"] .security-device small,
-html[data-theme="light"] .public-bookmark-row small { color: var(--dm-inverse-soft); }
-html[data-theme="light"] .public-bookmark-row em {
- color: #aab9b1;
- font-weight: 700;
- letter-spacing: .1em;
+html[data-theme="light"] .security-device {
+ border-color: var(--dm-border);
+ background: var(--dm-bg-card);
}
-html[data-theme="light"] .public-bookmark-row:has(input:checked) {
- border-color: #5c8c6d;
- background: #0e1a14;
+html[data-theme="light"] .security-device strong { color: var(--dm-text); }
+html[data-theme="light"] .security-device small { color: var(--dm-text-muted); }
+html[data-theme="light"] .pair-code-panel > code {
+ border-color: #a8cbb5;
+ background: var(--dm-bg-soft);
+ color: var(--dm-accent-strong);
}
-html[data-theme="light"] .public-bookmark-row:has(input:checked) em { color: #b7e4c4; }
+
+.appearance-group { display: grid; gap: 10px; }
+.appearance-group-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
+.appearance-group-head h3 { margin: 0; font-size: 14px; font-weight: 620; color: var(--dm-text); }
+.appearance-group-head span { color: var(--dm-text-muted); font-size: 11px; }
.appearance-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
-.appearance-option { display: grid; grid-template-columns: 92px 1fr 24px; align-items: center; gap: 14px; min-height: 118px; text-align: left; color: inherit; cursor: pointer; }
-.appearance-option.active { border-color: var(--dm-accent); box-shadow: inset 0 0 0 1px var(--dm-accent); }
+.appearance-option { display: grid; grid-template-columns: 84px 1fr 22px; align-items: center; gap: 12px; min-height: 102px; text-align: left; color: inherit; cursor: pointer; transition: border-color 140ms ease, background-color 140ms ease; }
+.appearance-option:hover:not(:disabled) { border-color: color-mix(in srgb, var(--dm-accent) 44%, var(--dm-border)); }
+.appearance-option.active { border-color: var(--dm-accent); box-shadow: inset 0 0 0 1px var(--dm-accent); background: color-mix(in srgb, var(--dm-selected-bg) 42%, var(--dm-bg-card)); }
.appearance-option:disabled { cursor: default; opacity: .72; }
-.appearance-option-copy { display: grid; gap: 5px; }
+.appearance-option-copy { display: grid; gap: 4px; min-width: 0; }
.appearance-option-copy strong { font-size: 14px; }
-.appearance-option-copy small { color: var(--dm-text-muted); line-height: 1.45; }
+.appearance-option-copy small { color: var(--dm-text-muted); font-size: 12px; line-height: 1.4; }
.appearance-check { color: var(--dm-accent-strong); font-weight: 800; text-align: center; }
-.appearance-preview { position: relative; display: block; width: 92px; height: 66px; overflow: hidden; border: 1px solid #34403a; border-radius: 10px; background: #0a0f0c; }
+
+.appearance-preview { position: relative; display: block; width: 84px; height: 60px; overflow: hidden; border: 1px solid #34403a; border-radius: 9px; background: #0a0f0c; }
.appearance-preview-light { border-color: #c9d7cf; background: #f4f7f5; }
.appearance-preview-system { background: linear-gradient(135deg, #f4f7f5 0 50%, #0a0f0c 50% 100%); }
-.appearance-preview-bar { position: absolute; top: 9px; left: 9px; right: 9px; height: 6px; border-radius: 5px; background: #789486; }
-.appearance-preview-card { position: absolute; left: 9px; bottom: 10px; width: 49px; height: 29px; border-radius: 7px; background: rgba(145,188,159,.24); border: 1px solid rgba(145,188,159,.42); }
+.appearance-preview-bar { position: absolute; top: 8px; left: 8px; right: 8px; height: 5px; border-radius: 4px; background: #789486; }
+.appearance-preview-card { position: absolute; left: 8px; bottom: 9px; width: 44px; height: 26px; border-radius: 6px; background: rgba(145,188,159,.24); border: 1px solid rgba(145,188,159,.42); }
.appearance-preview-light .appearance-preview-card { background: #fff; border-color: #d1ddd6; }
-.appearance-preview-dot { position: absolute; right: 11px; bottom: 14px; width: 12px; height: 12px; border-radius: 50%; background: #91bc9f; }
+.appearance-preview-dot { position: absolute; right: 10px; bottom: 13px; width: 11px; height: 11px; border-radius: 50%; background: #91bc9f; }
+
+.locale-option { grid-template-columns: 60px 1fr 22px; min-height: 86px; }
+.locale-preview-badge {
+ display: grid;
+ place-items: center;
+ width: 60px;
+ height: 44px;
+ border: 1px solid var(--dm-border-strong);
+ border-radius: 9px;
+ background: var(--dm-accent-bg);
+ color: var(--dm-accent-strong);
+ font-size: 13px;
+ font-weight: 700;
+ letter-spacing: .04em;
+}
@media (max-width: 820px) {
.appearance-grid { grid-template-columns: 1fr; }
diff --git a/apps/web/src/theme.ts b/apps/web/src/theme.ts
index 374378b..feba367 100644
--- a/apps/web/src/theme.ts
+++ b/apps/web/src/theme.ts
@@ -1,7 +1,19 @@
+/**
+ * [INPUT]: depends on LOCALE_STORAGE_KEY, normalizeAppearanceSettings, normalizeLocalePreference, resolveLocale, and appearance/locale types from @dockmark/core
+ * [OUTPUT]: exports APPEARANCE_STORAGE_KEY, applyAppearance, applyLocalePreference, localAppearance, fetchAppearanceSettings, saveAppearanceSettings, saveAppearanceAndLocale, syncAppearanceFromCloud, and bindSystemAppearanceListener
+ * [POS]: React-free DOM theme/locale application and /api/settings/appearance client in apps/web/src; consumed by main.tsx, AppearanceSettings.tsx, and i18n.ts
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
import {
+ LOCALE_STORAGE_KEY,
normalizeAppearanceSettings,
+ normalizeLocalePreference,
+ resolveLocale,
type AppearancePreference,
type AppearanceSettings,
+ type LocalePreference,
+ type ResolvedLocale,
+ type UpdateAppearanceSettingsInput,
} from "@dockmark/core";
export const APPEARANCE_STORAGE_KEY = "dockmarkAppearanceV1";
@@ -46,6 +58,27 @@ export function applyAppearance(preference: AppearancePreference, persist = true
window.dispatchEvent(new CustomEvent("dockmark:appearance", { detail: { preference, theme } }));
}
+export function applyLocalePreference(preference: LocalePreference, persist = true): ResolvedLocale {
+ const normalized = normalizeLocalePreference(preference);
+ const resolved = resolveLocale(normalized);
+ if (typeof document !== "undefined") {
+ document.documentElement.dataset.localePreference = normalized;
+ document.documentElement.dataset.locale = resolved;
+ document.documentElement.lang = resolved;
+ }
+ if (persist && typeof window !== "undefined") {
+ try {
+ window.localStorage.setItem(LOCALE_STORAGE_KEY, normalized);
+ } catch {
+ // Ignore storage write failures in restricted browser contexts.
+ }
+ }
+ if (typeof window !== "undefined") {
+ window.dispatchEvent(new CustomEvent("dockmark:locale", { detail: { preference: normalized, locale: resolved } }));
+ }
+ return resolved;
+}
+
export function localAppearance(): AppearancePreference {
const stored = localStorage.getItem(APPEARANCE_STORAGE_KEY);
return stored === "light" || stored === "dark" || stored === "system" ? stored : "system";
@@ -61,24 +94,33 @@ export async function fetchAppearanceSettings(): Promise {
return normalizeAppearanceSettings(payload.settings);
}
-export async function saveAppearanceSettings(preference: AppearancePreference): Promise {
+export async function saveAppearanceAndLocale(input: UpdateAppearanceSettingsInput): Promise {
const response = await fetch("/api/settings/appearance", {
method: "PATCH",
headers: { "content-type": "application/json" },
- body: JSON.stringify({ preference }),
+ body: JSON.stringify(input),
});
const payload = await response.json().catch(() => ({})) as {
settings?: unknown;
error?: { message?: string };
};
- if (!response.ok) throw new Error(payload.error?.message ?? `Appearance update failed (${response.status}).`);
+ if (!response.ok) {
+ const error = new Error(payload.error?.message ?? `Appearance update failed (${response.status}).`) as Error & { status?: number };
+ error.status = response.status;
+ throw error;
+ }
return normalizeAppearanceSettings(payload.settings);
}
-export async function syncAppearanceFromCloud() {
+export async function saveAppearanceSettings(preference: AppearancePreference): Promise {
+ return saveAppearanceAndLocale({ preference });
+}
+
+export async function syncAppearanceFromCloud(): Promise {
try {
const settings = await fetchAppearanceSettings();
applyAppearance(settings.preference);
+ applyLocalePreference(settings.locale);
return settings;
} catch {
return null;
diff --git a/apps/web/src/transfer.css b/apps/web/src/transfer.css
index a1891fc..a92ba7e 100644
--- a/apps/web/src/transfer.css
+++ b/apps/web/src/transfer.css
@@ -1,88 +1,687 @@
-.transfer-page { padding: 66px 0 20px; }
-.transfer-grid { display: grid; grid-template-columns: 1.35fr .65fr; gap: 14px; margin: 18px 0; }
-.transfer-card { min-height: 190px; }
-.native-import-card { display: grid; gap: 16px; margin-bottom: 18px; }
-.native-readonly { align-self: start; padding: 4px 7px; border: 1px solid #31513d; border-radius: 999px; color: #96bca3; font-size: 10px; letter-spacing: .08em; }
-.native-import-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
-.native-import-actions > span { color: #748078; font-size: 11px; }
-.file-drop { min-height: 112px; display: grid; place-items: center; align-content: center; gap: 6px; padding: 20px; border: 1px dashed #35413a; border-radius: 13px; background: #0d1210; cursor: pointer; text-align: center; }
-.file-drop:hover { border-color: #6f9780; background: #111713; }
-.file-drop input { position: absolute; inline-size: 1px; block-size: 1px; opacity: 0; pointer-events: none; }
-.file-drop strong { font-size: 14px; }
-.file-drop span { color: #718078; font-size: 12px; }
-.export-actions { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 24px; }
-.transfer-feedback { margin-top: 14px; }
-.success-banner { padding: 12px 14px; border: 1px solid #31513d; border-radius: 11px; background: #102018; color: #9dceb0; font-size: 13px; }
-.import-preview, .mapping-preview { margin-top: 26px; border: 1px solid #252d29; border-radius: 18px; background: rgba(15,20,18,.78); overflow: hidden; }
-.native-import-preview { margin-bottom: 18px; }
-.mapping-preview { margin-bottom: 18px; }
-.preview-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; padding: 18px; border-bottom: 1px solid #242c28; }
-.preview-heading h2 { margin: 6px 0 0; font-size: 17px; }
-.preview-actions { display: flex; align-items: center; gap: 10px; }
-.import-stats, .mapping-stats { display: grid; grid-template-columns: repeat(5, 1fr); border-bottom: 1px solid #242c28; }
-.import-stats.native-stats { grid-template-columns: repeat(6, 1fr); }
-.import-stats span, .mapping-stats span { display: grid; gap: 2px; padding: 13px 16px; color: var(--dm-text-muted); border-right: 1px solid #242c28; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
-.import-stats span:last-child, .mapping-stats span:last-child { border-right: 0; }
-.import-stats strong, .mapping-stats strong { color: #c7d2cc; font-size: 17px; font-weight: 580; letter-spacing: -.02em; }
-.import-list, .mapping-list { max-height: 520px; overflow: auto; padding: 6px; }
-.import-row { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 8px 10px; border-radius: 11px; }
-.import-row:hover { background: #151b18; }
-.import-row > input { accent-color: #8fbc9f; }
-.import-copy { display: grid; gap: 3px; flex: 1; min-width: 0; }
-.import-copy strong, .import-copy small, .import-copy span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
-.import-copy strong { font-size: 13px; font-weight: 580; }
-.import-copy small { color: #707c75; }
-.import-copy span { color: #88938d; font-size: 10px; }
-.import-status { padding: 4px 7px; border: 1px solid #303a35; border-radius: 999px; color: #839087; font-size: 10px; letter-spacing: .06em; }
-.status-duplicate, .status-invalid { opacity: .56; }
-.status-mapped { opacity: .62; }
-.status-mapped .import-status { color: #8db99c; border-color: #31513d; }
-.status-invalid .import-status { color: #c28c88; border-color: #553532; }
-.policy-local-only { color: #b5b77d; border-color: #45472e; }
-.preview-limit { margin: 0; padding: 12px 16px; color: #6f7b74; border-top: 1px solid #242c28; font-size: 11px; }
-.mapping-row { display: grid; gap: 10px; min-height: 72px; padding: 10px 12px; border-radius: 11px; }
-.mapping-row:hover { background: #151b18; }
-.mapping-row-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
-.mapping-copy { display: grid; gap: 3px; flex: 1; min-width: 0; }
-.mapping-copy strong, .mapping-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
-.mapping-copy strong { font-size: 13px; font-weight: 580; }
-.mapping-copy small { color: #707c75; font-size: 11px; }
-.mapping-status { flex: 0 0 auto; padding: 4px 7px; border: 1px solid #303a35; border-radius: 999px; color: #839087; font-size: 10px; letter-spacing: .06em; white-space: nowrap; }
-.mapping-status-synced { color: #8db99c; border-color: #31513d; }
-.mapping-status-native-changed, .mapping-status-mapping-stale { color: #c5b87d; border-color: #4b452b; }
-.mapping-status-native-missing, .mapping-status-cloud-missing { color: #c6a071; border-color: #4e3d29; }
-.mapping-status-cloud-changed, .mapping-status-conflict { color: #ca8f8b; border-color: #553532; }
-.mapping-row-review { padding: 14px; border: 1px solid #3d2d2b; background: rgba(45,24,23,.22); }
-.mapping-row-review:hover { background: rgba(45,24,23,.3); }
-.mapping-review-panel { display: grid; gap: 12px; padding-top: 12px; border-top: 1px solid #392d2a; }
-.mapping-review-panel > p { margin: 0; color: #bda39f; font-size: 11px; line-height: 1.55; }
-.mapping-review-sides { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
-.mapping-review-sides > div { display: grid; gap: 6px; min-width: 0; padding: 11px; border: 1px solid #2b342f; border-radius: 11px; background: rgba(10,15,13,.58); }
-.mapping-review-sides span { color: #849087; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
-.mapping-review-sides strong, .mapping-review-sides small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
-.mapping-review-sides strong { display: grid; gap: 3px; padding: 8px 9px; border: 1px solid #35433b; border-radius: 8px; background: rgba(52,72,61,.2); color: #e0ebe5; font-size: 13px; }
-.mapping-review-sides strong::before { content: "TITLE"; color: #8fbc9f; font-size: 8px; font-weight: 700; letter-spacing: .1em; }
-.mapping-review-sides small { display: grid; grid-template-columns: 64px minmax(0,1fr); gap: 7px; align-items: baseline; color: #748078; font-size: 10px; }
-.mapping-review-sides small:first-of-type::before { content: "URL"; color: #849087; font-size: 8px; font-weight: 700; letter-spacing: .08em; }
-.mapping-review-sides small:last-of-type::before { content: "LOCATION"; color: #849087; font-size: 8px; font-weight: 700; letter-spacing: .08em; }
-.mapping-review-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
-.mapping-review-actions .secondary { padding: 8px 10px; }
-.mapping-relink-control { display: flex; align-items: center; gap: 6px; min-width: min(100%, 420px); flex: 1; }
-.mapping-relink-control select { min-width: 0; flex: 1; padding: 8px 10px; border: 1px solid #344039; border-radius: 9px; background: #0d1210; color: #b7c2bc; font: inherit; }
-.mapping-relink-control select:focus { outline: 1px solid #6f9780; outline-offset: 1px; }
-.mapping-review-note { color: #6f7b74; font-size: 10px; line-height: 1.5; }
-.mapping-note { margin: 0; padding: 12px 16px; color: #748078; border-top: 1px solid #242c28; font-size: 11px; line-height: 1.55; }
+.transfer-page {
+ padding: 28px 0 24px;
+}
+
+.transfer-tool-header {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 16px;
+ margin-bottom: 18px;
+ padding-bottom: 14px;
+ border-bottom: 1px solid var(--dm-border);
+}
+
+.transfer-tool-copy {
+ display: grid;
+ gap: 4px;
+ min-width: 0;
+}
+
+.transfer-tool-copy h1 {
+ margin: 0;
+ font-size: clamp(22px, 2.4vw, 26px);
+ line-height: 1.2;
+ letter-spacing: -0.025em;
+ font-weight: 640;
+ color: var(--dm-text);
+}
+
+.transfer-tool-copy p {
+ margin: 0;
+ color: var(--dm-text-muted);
+ font-size: 13px;
+ line-height: 1.45;
+}
+
+.transfer-tool-pills {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ flex-wrap: wrap;
+ justify-content: flex-end;
+ flex-shrink: 0;
+}
+
+.transfer-tool-pills .library-count {
+ padding: 5px 10px;
+ font-size: 12px;
+ white-space: nowrap;
+}
+
+.transfer-page button {
+ white-space: nowrap;
+ transition: transform 110ms ease, background-color 140ms ease, border-color 140ms ease, color 140ms ease;
+}
+
+.transfer-page button:active:not(:disabled) {
+ transform: translateY(1px);
+}
+
+.transfer-grid {
+ display: grid;
+ grid-template-columns: 1.35fr 0.65fr;
+ gap: 14px;
+ margin: 16px 0;
+}
+
+.transfer-card {
+ min-height: 184px;
+ display: flex;
+ flex-direction: column;
+ justify-content: space-between;
+}
+
+.native-import-card {
+ display: grid;
+ gap: 14px;
+ margin-bottom: 16px;
+}
+
+.native-readonly {
+ align-self: start;
+ padding: 4px 9px;
+ border: 1px solid color-mix(in srgb, var(--dm-accent) 44%, var(--dm-border));
+ border-radius: 999px;
+ background: var(--dm-accent-bg);
+ color: var(--dm-accent-strong);
+ font-size: 10px;
+ letter-spacing: 0.06em;
+ white-space: nowrap;
+}
+
+.native-import-actions {
+ display: flex;
+ align-items: center;
+ gap: 12px;
+ flex-wrap: wrap;
+}
+
+.native-import-actions > span {
+ color: var(--dm-text-muted);
+ font-size: 12px;
+ line-height: 1.45;
+}
+
+.file-drop {
+ min-height: 110px;
+ display: grid;
+ place-items: center;
+ align-content: center;
+ gap: 6px;
+ padding: 18px;
+ border: 1px dashed var(--dm-border-strong);
+ border-radius: 13px;
+ background: var(--dm-input-bg, var(--dm-bg-soft));
+ color: var(--dm-text);
+ cursor: pointer;
+ text-align: center;
+ transition: border-color 140ms ease, background-color 140ms ease, transform 110ms ease;
+}
+
+.file-drop:hover {
+ border-color: var(--dm-accent);
+ background: var(--dm-hover-bg, var(--dm-bg-raised));
+}
+
+.file-drop:active {
+ transform: translateY(1px);
+}
+
+.file-drop input {
+ position: absolute;
+ inline-size: 1px;
+ block-size: 1px;
+ opacity: 0;
+ pointer-events: none;
+}
+
+.file-drop strong {
+ font-size: 14px;
+ color: var(--dm-text);
+}
+
+.file-drop span {
+ color: var(--dm-text-muted);
+ font-size: 12px;
+}
+
+.export-actions {
+ display: flex;
+ gap: 8px;
+ flex-wrap: wrap;
+ padding-top: 16px;
+}
+
+.transfer-feedback {
+ margin-top: 14px;
+}
+
+.success-banner {
+ padding: 12px 14px;
+ border: 1px solid color-mix(in srgb, var(--dm-accent) 48%, var(--dm-border));
+ border-radius: 11px;
+ background: var(--dm-success-bg, #102018);
+ color: var(--dm-accent-strong);
+ font-size: 13px;
+}
+
+.import-preview,
+.mapping-preview {
+ margin-top: 22px;
+ border: 1px solid var(--dm-border);
+ border-radius: 16px;
+ background: color-mix(in srgb, var(--dm-bg-card) 90%, transparent);
+ overflow: hidden;
+}
+
+.native-import-preview,
+.mapping-preview {
+ margin-bottom: 16px;
+}
+
+.preview-heading {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 16px;
+ padding: 16px 18px;
+ border-bottom: 1px solid var(--dm-border);
+}
+
+.preview-label {
+ margin: 0;
+ color: var(--dm-accent);
+ font-size: 11px;
+ font-weight: 650;
+ letter-spacing: 0.04em;
+}
+
+.preview-heading h2 {
+ margin: 4px 0 0;
+ font-size: 16px;
+ color: var(--dm-text);
+}
+
+.preview-actions {
+ display: flex;
+ align-items: center;
+ gap: 10px;
+ flex-wrap: wrap;
+}
+
+.import-stats,
+.mapping-stats {
+ display: grid;
+ grid-template-columns: repeat(5, 1fr);
+ border-bottom: 1px solid var(--dm-border);
+}
+
+.import-stats.native-stats {
+ grid-template-columns: repeat(6, 1fr);
+}
+
+.import-stats span,
+.mapping-stats span {
+ display: grid;
+ gap: 2px;
+ padding: 12px 16px;
+ color: var(--dm-text-muted);
+ background: var(--dm-bg-soft);
+ border-right: 1px solid var(--dm-border);
+ font-size: 11px;
+}
+
+.import-stats span:last-child,
+.mapping-stats span:last-child {
+ border-right: 0;
+}
+
+.import-stats strong,
+.mapping-stats strong {
+ color: var(--dm-text);
+ font-size: 17px;
+ font-weight: 600;
+ letter-spacing: -0.02em;
+}
+
+.import-list,
+.mapping-list {
+ max-height: 520px;
+ overflow: auto;
+ padding: 6px;
+}
+
+.import-row {
+ display: flex;
+ align-items: center;
+ gap: 12px;
+ min-height: 64px;
+ padding: 8px 10px;
+ border-radius: 11px;
+ cursor: pointer;
+ transition: background-color 140ms ease;
+}
+
+.import-row:hover {
+ background: var(--dm-hover-bg, var(--dm-bg-raised));
+}
+
+.import-row:has(input:checked) {
+ background: var(--dm-selected-bg, var(--dm-accent-bg));
+}
+
+.import-row > input {
+ accent-color: var(--dm-accent);
+ flex-shrink: 0;
+}
+
+.import-favicon {
+ display: grid;
+ place-items: center;
+ flex: 0 0 34px;
+ width: 34px;
+ height: 34px;
+ border: 1px solid var(--dm-border-strong);
+ border-radius: 9px;
+ background: var(--dm-accent-bg);
+ color: var(--dm-accent-strong);
+ font-size: 13px;
+ font-weight: 700;
+ overflow: hidden;
+}
+
+.import-favicon.has-favicon {
+ padding: 3px;
+ background: var(--dm-bg-soft);
+}
+
+.import-favicon.has-favicon img {
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+ border-radius: inherit;
+}
+
+.import-copy {
+ display: grid;
+ gap: 3px;
+ flex: 1;
+ min-width: 0;
+}
+
+.import-copy strong,
+.import-copy small,
+.import-copy span {
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.import-copy strong {
+ font-size: 13px;
+ font-weight: 590;
+ color: var(--dm-text);
+}
+
+.import-copy small {
+ color: var(--dm-text-muted);
+ font-size: 12px;
+}
+
+.import-copy span {
+ color: var(--dm-text-soft);
+ font-size: 11px;
+}
+
+.import-status {
+ flex: 0 0 auto;
+ padding: 3px 8px;
+ border: 1px solid var(--dm-border-strong);
+ border-radius: 999px;
+ background: var(--dm-bg-soft);
+ color: var(--dm-text-soft);
+ font-size: 11px;
+ white-space: nowrap;
+}
+
+.status-duplicate,
+.status-invalid {
+ opacity: 0.6;
+}
+
+.status-mapped {
+ opacity: 0.68;
+}
+
+.status-mapped .import-status {
+ color: var(--dm-accent-strong);
+ border-color: color-mix(in srgb, var(--dm-accent) 44%, var(--dm-border));
+ background: var(--dm-accent-bg);
+}
+
+.status-invalid .import-status {
+ color: var(--dm-danger);
+ border-color: color-mix(in srgb, var(--dm-danger) 44%, var(--dm-border));
+ background: var(--dm-danger-bg, rgba(167, 85, 80, 0.14));
+}
+
+.policy-local-only {
+ color: #c2be7b;
+ border-color: rgba(194, 190, 123, 0.35);
+}
+
+html[data-theme="light"] .policy-local-only {
+ color: #7a6328;
+ border-color: #dfc995;
+ background: #fff8e9;
+}
+
+.preview-limit {
+ margin: 0;
+ padding: 12px 16px;
+ color: var(--dm-text-muted);
+ border-top: 1px solid var(--dm-border);
+ font-size: 12px;
+}
+
+.mapping-row {
+ display: grid;
+ gap: 10px;
+ min-height: 70px;
+ padding: 10px 12px;
+ border-radius: 11px;
+ transition: background-color 140ms ease;
+}
+
+.mapping-row:hover {
+ background: var(--dm-hover-bg, var(--dm-bg-raised));
+}
+
+.mapping-row-main {
+ display: flex;
+ align-items: center;
+ gap: 12px;
+ min-width: 0;
+}
+
+.mapping-copy {
+ display: grid;
+ gap: 3px;
+ flex: 1;
+ min-width: 0;
+}
+
+.mapping-copy strong,
+.mapping-copy small {
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.mapping-copy strong {
+ font-size: 13px;
+ font-weight: 590;
+ color: var(--dm-text);
+}
+
+.mapping-copy small {
+ color: var(--dm-text-muted);
+ font-size: 11px;
+}
+
+.mapping-status {
+ flex: 0 0 auto;
+ padding: 3px 8px;
+ border: 1px solid var(--dm-border-strong);
+ border-radius: 999px;
+ background: var(--dm-bg-soft);
+ color: var(--dm-text-soft);
+ font-size: 11px;
+ white-space: nowrap;
+}
+
+.mapping-status-synced {
+ color: var(--dm-accent-strong);
+ border-color: color-mix(in srgb, var(--dm-accent) 44%, var(--dm-border));
+ background: var(--dm-accent-bg);
+}
+
+.mapping-status-native-changed,
+.mapping-status-mapping-stale {
+ color: #c5b87d;
+ border-color: #4b452b;
+}
+
+.mapping-status-native-missing,
+.mapping-status-cloud-missing {
+ color: #c6a071;
+ border-color: #4e3d29;
+}
+
+.mapping-status-cloud-changed,
+.mapping-status-conflict {
+ color: var(--dm-danger);
+ border-color: color-mix(in srgb, var(--dm-danger) 44%, var(--dm-border));
+ background: var(--dm-danger-bg, rgba(167, 85, 80, 0.14));
+}
+
+.mapping-row-review {
+ padding: 14px;
+ border: 1px solid color-mix(in srgb, var(--dm-danger) 36%, var(--dm-border));
+ background: var(--dm-danger-bg, rgba(45, 24, 23, 0.22));
+}
+
+.mapping-row-review:hover {
+ background: color-mix(in srgb, var(--dm-danger-bg, rgba(45, 24, 23, 0.28)) 88%, var(--dm-bg-raised));
+}
+
+.mapping-review-panel {
+ display: grid;
+ gap: 12px;
+ padding-top: 12px;
+ border-top: 1px solid color-mix(in srgb, var(--dm-danger) 28%, var(--dm-border));
+}
+
+.mapping-review-panel > p {
+ margin: 0;
+ color: var(--dm-text-soft);
+ font-size: 12px;
+ line-height: 1.55;
+}
+
+.mapping-review-sides {
+ display: grid;
+ grid-template-columns: 1fr 1fr;
+ gap: 10px;
+}
+
+.mapping-review-sides > div {
+ display: grid;
+ gap: 6px;
+ min-width: 0;
+ padding: 11px;
+ border: 1px solid var(--dm-border);
+ border-radius: 11px;
+ background: var(--dm-bg-soft);
+}
+
+.mapping-review-sides span {
+ color: var(--dm-text-muted);
+ font-size: 10px;
+ text-transform: uppercase;
+ letter-spacing: 0.08em;
+}
+
+.mapping-review-sides strong,
+.mapping-review-sides small {
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.mapping-review-sides strong {
+ display: grid;
+ gap: 3px;
+ padding: 8px 9px;
+ border: 1px solid var(--dm-border-strong);
+ border-radius: 8px;
+ background: var(--dm-accent-bg);
+ color: var(--dm-text);
+ font-size: 13px;
+}
+
+.mapping-review-sides strong::before {
+ content: "TITLE";
+ color: var(--dm-accent);
+ font-size: 8px;
+ font-weight: 700;
+ letter-spacing: 0.1em;
+}
+
+.mapping-review-sides small {
+ display: grid;
+ grid-template-columns: 64px minmax(0, 1fr);
+ gap: 7px;
+ align-items: baseline;
+ color: var(--dm-text-muted);
+ font-size: 11px;
+}
+
+.mapping-review-sides small:first-of-type::before {
+ content: "URL";
+ color: var(--dm-text-muted);
+ font-size: 8px;
+ font-weight: 700;
+ letter-spacing: 0.08em;
+}
+
+.mapping-review-sides small:last-of-type::before {
+ content: "LOCATION";
+ color: var(--dm-text-muted);
+ font-size: 8px;
+ font-weight: 700;
+ letter-spacing: 0.08em;
+}
+
+.mapping-review-actions {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ flex-wrap: wrap;
+}
+
+.mapping-review-actions .secondary {
+ padding: 8px 10px;
+}
+
+.mapping-relink-control {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ min-width: min(100%, 420px);
+ flex: 1;
+}
+
+.mapping-relink-control select {
+ min-width: 0;
+ flex: 1;
+ padding: 8px 10px;
+ border: 1px solid var(--dm-border-strong);
+ border-radius: 9px;
+ background: var(--dm-input-bg, var(--dm-bg-soft));
+ color: var(--dm-text);
+ font: inherit;
+}
+
+.mapping-relink-control select:focus {
+ outline: 1px solid var(--dm-accent);
+ outline-offset: 1px;
+}
+
+.mapping-review-note {
+ color: var(--dm-text-muted);
+ font-size: 11px;
+ line-height: 1.5;
+}
+
+.mapping-note {
+ margin: 0;
+ padding: 12px 16px;
+ color: var(--dm-text-muted);
+ border-top: 1px solid var(--dm-border);
+ font-size: 12px;
+ line-height: 1.55;
+}
+
+html[data-theme="light"] .mapping-status-native-changed,
+html[data-theme="light"] .mapping-status-mapping-stale,
+html[data-theme="light"] .mapping-status-native-missing,
+html[data-theme="light"] .mapping-status-cloud-missing {
+ border-color: #dfc995;
+ background: #fff8e9;
+ color: #7a6328;
+}
@media (max-width: 800px) {
- .transfer-page { padding-top: 42px; }
- .transfer-grid { grid-template-columns: 1fr; }
- .preview-heading { align-items: start; flex-direction: column; }
- .preview-actions { width: 100%; flex-wrap: wrap; }
- .import-stats, .import-stats.native-stats, .mapping-stats { grid-template-columns: repeat(2, 1fr); }
- .import-stats span, .mapping-stats span { border-bottom: 1px solid #242c28; }
- .mapping-row-main { align-items: flex-start; flex-wrap: wrap; }
- .mapping-copy { width: 100%; flex-basis: 100%; }
- .mapping-review-sides { grid-template-columns: 1fr; }
- .mapping-review-actions { align-items: stretch; }
- .mapping-relink-control { min-width: 100%; width: 100%; }
-}
\ No newline at end of file
+ .transfer-page {
+ padding-top: 20px;
+ }
+
+ .transfer-tool-header {
+ align-items: flex-start;
+ flex-direction: column;
+ }
+
+ .transfer-tool-pills {
+ justify-content: flex-start;
+ }
+
+ .transfer-grid {
+ grid-template-columns: 1fr;
+ }
+
+ .preview-heading {
+ align-items: start;
+ flex-direction: column;
+ }
+
+ .preview-actions {
+ width: 100%;
+ flex-wrap: wrap;
+ }
+
+ .import-stats,
+ .import-stats.native-stats,
+ .mapping-stats {
+ grid-template-columns: repeat(2, 1fr);
+ }
+
+ .import-stats span,
+ .mapping-stats span {
+ border-bottom: 1px solid var(--dm-border);
+ }
+
+ .mapping-row-main {
+ align-items: flex-start;
+ flex-wrap: wrap;
+ }
+
+ .mapping-copy {
+ width: 100%;
+ flex-basis: 100%;
+ }
+
+ .mapping-review-sides {
+ grid-template-columns: 1fr;
+ }
+
+ .mapping-review-actions {
+ align-items: stretch;
+ }
+
+ .mapping-relink-control {
+ min-width: 100%;
+ width: 100%;
+ }
+}
diff --git a/apps/web/src/ui-polish.css b/apps/web/src/ui-polish.css
index 6b9b701..4717398 100644
--- a/apps/web/src/ui-polish.css
+++ b/apps/web/src/ui-polish.css
@@ -274,7 +274,8 @@ html[data-theme="light"] .inbox-panel,
html[data-theme="light"] .inbox-ai-panel,
html[data-theme="light"] .smart-summary,
html[data-theme="light"] .smart-list,
-html[data-theme="light"] .smart-editor {
+html[data-theme="light"] .smart-editor,
+html[data-theme="light"] .auth-card {
color: var(--dm-text);
}
diff --git a/apps/web/src/workspaces.css b/apps/web/src/workspaces.css
index 443978f..5573d6b 100644
--- a/apps/web/src/workspaces.css
+++ b/apps/web/src/workspaces.css
@@ -7,10 +7,68 @@
text-align: inherit;
}
-.workspace-grid { grid-template-columns: 300px minmax(0, 1fr); }
+.workspace-management {
+ padding: 28px 0 24px;
+}
+
+.workspace-tool-header {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 16px;
+ margin-bottom: 18px;
+ padding-bottom: 14px;
+ border-bottom: 1px solid var(--dm-border);
+}
+
+.workspace-tool-copy {
+ display: grid;
+ gap: 4px;
+ min-width: 0;
+}
+
+.workspace-tool-copy h1 {
+ margin: 0;
+ font-size: clamp(22px, 2.4vw, 26px);
+ line-height: 1.2;
+ letter-spacing: -0.025em;
+ font-weight: 640;
+ color: var(--dm-text);
+}
+
+.workspace-tool-copy p {
+ margin: 0;
+ color: var(--dm-text-muted);
+ font-size: 13px;
+ line-height: 1.45;
+}
+
+.workspace-tool-pills {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ flex-wrap: wrap;
+ justify-content: flex-end;
+ flex-shrink: 0;
+}
+
+.workspace-tool-pills .library-count {
+ padding: 5px 10px;
+ font-size: 12px;
+ white-space: nowrap;
+}
+
+.workspace-grid {
+ grid-template-columns: 300px minmax(0, 1fr);
+}
+
.workspace-create-form,
.workspace-meta-form,
-.workspace-item-edit { display: grid; gap: 10px; }
+.workspace-item-edit {
+ display: grid;
+ gap: 10px;
+}
+
.workspace-create-form input,
.workspace-create-form textarea,
.workspace-meta-form input,
@@ -22,15 +80,21 @@
width: 100%;
min-width: 0;
padding: 10px 11px;
- border: 1px solid #303934;
+ border: 1px solid var(--dm-border-strong);
border-radius: 10px;
outline: 0;
- color: #edf3ef;
- background: #0e1311;
+ color: var(--dm-text);
+ background: var(--dm-input-bg, var(--dm-bg-soft));
font: inherit;
+ transition: border-color 140ms ease, background-color 140ms ease, box-shadow 140ms ease;
}
+
.workspace-create-form textarea,
-.workspace-meta-form textarea { min-height: 82px; resize: vertical; }
+.workspace-meta-form textarea {
+ min-height: 82px;
+ resize: vertical;
+}
+
.workspace-create-form input:focus,
.workspace-create-form textarea:focus,
.workspace-meta-form input:focus,
@@ -39,114 +103,383 @@
.workspace-add-card select:focus,
.workspace-item-edit input:focus,
.workspace-item-edit select:focus {
- border-color: #729f82;
- box-shadow: 0 0 0 3px rgba(114,159,130,.1);
+ border-color: var(--dm-accent);
+ box-shadow: 0 0 0 3px var(--dm-focus-ring, rgba(114, 159, 130, 0.14));
+}
+
+.workspace-management button {
+ white-space: nowrap;
+ transition: transform 110ms ease, background-color 140ms ease, border-color 140ms ease, color 140ms ease;
+}
+
+.workspace-management button:active:not(:disabled) {
+ transform: translateY(1px);
+}
+
+.workspace-nav {
+ margin-top: 12px;
+ display: grid;
+ gap: 4px;
+}
+
+.workspace-nav .card-heading {
+ margin-bottom: 8px;
}
-.workspace-nav { margin-top: 12px; }
.workspace-nav-item {
display: flex;
align-items: center;
gap: 10px;
width: 100%;
padding: 9px;
- border: 0;
+ border: 1px solid transparent;
border-radius: 11px;
- color: #aeb9b2;
+ color: var(--dm-text-soft);
background: transparent;
cursor: pointer;
text-align: left;
+ white-space: normal;
}
-.workspace-nav-item:hover,
-.workspace-nav-item.active { color: #edf3ef; background: #171e1a; }
-.workspace-nav-item > span:last-child { display: grid; gap: 2px; min-width: 0; }
-.workspace-nav-item strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
-.workspace-nav-item small { color: #6d7872; font-size: 11px; }
+
+.workspace-nav-item:hover {
+ color: var(--dm-text);
+ background: var(--dm-hover-bg, var(--dm-bg-raised));
+}
+
+.workspace-nav-item.active {
+ border-color: color-mix(in srgb, var(--dm-accent) 42%, var(--dm-border));
+ color: var(--dm-text);
+ background: var(--dm-selected-bg, var(--dm-accent-bg));
+}
+
+.workspace-nav-item > span:last-child {
+ display: grid;
+ gap: 2px;
+ min-width: 0;
+}
+
+.workspace-nav-item strong {
+ overflow: hidden;
+ font-size: 13px;
+ font-weight: 590;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.workspace-nav-item small {
+ color: var(--dm-text-muted);
+ font-size: 11px;
+}
+
.workspace-nav-icon,
.workspace-large-icon {
- /* Workspace icons hold free-form emoji or words that can render much wider
- than the badge. Centring with `place-items` overflows in both directions and
- is not clipped, so use an inline-flex box that clips cleanly instead. */
display: inline-flex;
align-items: center;
justify-content: center;
flex: 0 0 auto;
overflow: hidden;
- border: 1px solid #313b35;
- background: #1b231e;
- color: #b8d6c1;
+ border: 1px solid var(--dm-border-strong);
+ background: var(--dm-accent-bg);
+ color: var(--dm-accent-strong);
font-weight: 700;
text-align: center;
white-space: nowrap;
line-height: 1;
}
-.workspace-nav-icon { width: 34px; height: 34px; border-radius: 10px; font-size: 17px; }
-.workspace-large-icon { width: 46px; height: 46px; border-radius: 13px; font-size: 22px; }
+
+.workspace-nav-icon {
+ width: 34px;
+ height: 34px;
+ border-radius: 10px;
+ font-size: 16px;
+}
+
+.workspace-large-icon {
+ width: 44px;
+ height: 44px;
+ border-radius: 12px;
+ font-size: 20px;
+}
.workspace-header-content {
display: flex;
justify-content: space-between;
- gap: 24px;
+ gap: 20px;
+ align-items: center;
+}
+
+.workspace-header-lead {
+ min-width: 0;
+}
+
+.workspace-title-row {
+ display: flex;
align-items: center;
+ gap: 12px;
+ min-width: 0;
}
-.workspace-title-row { display: flex; align-items: center; gap: 12px; }
-.workspace-title-row h2 { margin: 0; font-size: 23px; }
-.workspace-header-content p { max-width: 620px; margin: 9px 0 0; color: #7e8a83; line-height: 1.5; }
-.workspace-header-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
-.workspace-add-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
-.workspace-add-card { display: grid; gap: 9px; }
-.workspace-add-card .card-heading { margin-bottom: 5px; }
-.workspace-add-card select { min-height: 42px; }
+.workspace-title-row h2 {
+ margin: 0;
+ font-size: 20px;
+ letter-spacing: -0.02em;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.workspace-header-content p {
+ max-width: 620px;
+ margin: 8px 0 0;
+ color: var(--dm-text-muted);
+ font-size: 13px;
+ line-height: 1.5;
+}
+
+.workspace-header-actions {
+ display: flex;
+ flex-wrap: wrap;
+ justify-content: flex-end;
+ gap: 8px;
+ flex-shrink: 0;
+}
+
+.workspace-add-grid {
+ display: grid;
+ grid-template-columns: 1fr 1fr;
+ gap: 12px;
+}
+
+.workspace-add-card {
+ display: grid;
+ gap: 9px;
+}
+
+.workspace-add-card .card-heading {
+ margin-bottom: 4px;
+}
+
+.workspace-add-card select {
+ min-height: 42px;
+}
+
+.workspace-items {
+ display: grid;
+ gap: 8px;
+}
-.workspace-items { display: grid; gap: 8px; }
.workspace-item-card {
display: flex;
align-items: center;
gap: 12px;
- min-height: 78px;
- padding: 13px;
- border: 1px solid #242c28;
- border-radius: 15px;
- background: rgba(14, 19, 17, .65);
+ min-height: 76px;
+ padding: 12px 14px;
+ border: 1px solid var(--dm-border);
+ border-radius: 14px;
+ background: color-mix(in srgb, var(--dm-bg-card) 88%, transparent);
+ transition: border-color 140ms ease, background-color 140ms ease;
}
+
+.workspace-item-card:hover {
+ border-color: color-mix(in srgb, var(--dm-accent) 34%, var(--dm-border));
+}
+
.workspace-item-index {
- flex: 0 0 34px;
- color: #58645d;
+ flex: 0 0 26px;
+ color: var(--dm-text-muted);
font: 11px ui-monospace, SFMono-Regular, Menlo, monospace;
text-align: center;
}
-.workspace-item-copy { display: grid; flex: 1; gap: 4px; min-width: 0; }
+
+.workspace-item-favicon {
+ display: grid;
+ place-items: center;
+ flex: 0 0 38px;
+ width: 38px;
+ height: 38px;
+ border: 1px solid var(--dm-border-strong);
+ border-radius: 10px;
+ background: var(--dm-accent-bg);
+ color: var(--dm-accent-strong);
+ font-size: 14px;
+ font-weight: 700;
+ overflow: hidden;
+}
+
+.workspace-item-favicon.has-favicon {
+ padding: 4px;
+ background: var(--dm-bg-soft);
+}
+
+.workspace-item-favicon.has-favicon img {
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+ border-radius: inherit;
+}
+
+.workspace-item-copy {
+ display: grid;
+ flex: 1;
+ gap: 4px;
+ min-width: 0;
+}
+
.workspace-item-copy a,
-.workspace-item-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
-.workspace-item-copy strong { font-size: 14px; font-weight: 590; }
-.workspace-item-copy small { color: var(--dm-text-muted); }
-.workspace-item-meta { display: flex; flex-wrap: wrap; gap: 6px; }
+.workspace-item-copy small {
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.workspace-item-copy a:hover strong {
+ color: var(--dm-accent-strong);
+}
+
+.workspace-item-copy strong {
+ font-size: 14px;
+ font-weight: 590;
+ color: var(--dm-text);
+}
+
+.workspace-item-copy small {
+ color: var(--dm-text-muted);
+ font-size: 12px;
+}
+
+.workspace-item-meta {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 6px;
+}
+
.workspace-item-meta span {
- padding: 3px 6px;
- border: 1px solid #2d3631;
+ padding: 2px 8px;
+ border: 1px solid var(--dm-border);
border-radius: 999px;
+ background: var(--dm-bg-soft);
color: var(--dm-text-muted);
- font-size: 10px;
- text-transform: uppercase;
- letter-spacing: .05em;
+ font-size: 11px;
+ white-space: nowrap;
+}
+
+.workspace-item-meta .workspace-domain-pill {
+ color: var(--dm-text-soft);
+ border-color: var(--dm-border-strong);
+}
+
+.workspace-item-meta .workspace-mode-pill.mode-pinned {
+ color: var(--dm-accent-strong);
+ border-color: color-mix(in srgb, var(--dm-accent) 42%, var(--dm-border));
+ background: var(--dm-accent-bg);
+}
+
+.workspace-item-meta .workspace-local-pill {
+ color: #c2be7b;
+ border-color: rgba(194, 190, 123, 0.35);
+}
+
+html[data-theme="light"] .workspace-item-meta .workspace-local-pill {
+ color: #7a6328;
+ border-color: #dfc995;
+ background: #fff8e9;
+}
+
+.workspace-item-actions {
+ display: flex;
+ align-items: center;
+ gap: 7px;
+ flex-shrink: 0;
+}
+
+.workspace-item-actions .text-action {
+ min-width: 26px;
+ min-height: 28px;
+ padding: 0 6px;
+ border: 1px solid var(--dm-border);
+ border-radius: 8px;
+ background: var(--dm-bg-soft);
+ color: var(--dm-text-soft);
+ font-size: 12px;
+}
+
+.workspace-item-actions .text-action:hover:not(:disabled) {
+ border-color: var(--dm-border-strong);
+ color: var(--dm-text);
+ background: var(--dm-hover-bg, var(--dm-bg-raised));
+}
+
+.workspace-item-actions .text-action:disabled {
+ opacity: 0.32;
+ cursor: default;
+}
+
+.workspace-item-edit {
+ width: 100%;
+ grid-template-columns: 1fr 1.4fr 190px;
+ align-items: end;
+}
+
+.workspace-item-edit .edit-actions {
+ margin-top: 0;
+}
+
+.workspace-web-note {
+ margin: 4px 2px 0;
+ color: var(--dm-text-muted);
+ font-size: 12px;
+ line-height: 1.55;
+}
+
+.workspace-empty {
+ margin-top: 0;
}
-.workspace-item-actions { display: flex; align-items: center; gap: 7px; }
-.workspace-item-actions .text-action:disabled { opacity: .3; cursor: default; }
-.workspace-item-edit { width: 100%; grid-template-columns: 1fr 1.4fr 180px; align-items: end; }
-.workspace-item-edit .edit-actions { margin-top: 0; }
-.workspace-web-note { margin: 5px 2px 0; color: var(--dm-text-muted); font-size: 11px; line-height: 1.55; }
-.workspace-empty { margin-top: 0; }
@media (max-width: 900px) {
- .workspace-grid { grid-template-columns: 1fr; }
- .workspace-add-grid { grid-template-columns: 1fr; }
- .workspace-header-content { align-items: flex-start; flex-direction: column; }
- .workspace-header-actions { justify-content: flex-start; }
- .workspace-item-edit { grid-template-columns: 1fr; }
+ .workspace-grid {
+ grid-template-columns: 1fr;
+ }
+
+ .workspace-add-grid {
+ grid-template-columns: 1fr;
+ }
+
+ .workspace-header-content {
+ align-items: flex-start;
+ flex-direction: column;
+ }
+
+ .workspace-header-actions {
+ justify-content: flex-start;
+ }
+
+ .workspace-item-edit {
+ grid-template-columns: 1fr;
+ }
}
@media (max-width: 720px) {
- .workspace-item-card { align-items: flex-start; flex-wrap: wrap; }
- .workspace-item-actions { width: 100%; padding-left: 46px; flex-wrap: wrap; }
+ .workspace-management {
+ padding-top: 20px;
+ }
+
+ .workspace-tool-header {
+ align-items: flex-start;
+ flex-direction: column;
+ }
+
+ .workspace-tool-pills {
+ justify-content: flex-start;
+ }
+
+ .workspace-item-card {
+ align-items: flex-start;
+ flex-wrap: wrap;
+ }
+
+ .workspace-item-actions {
+ width: 100%;
+ padding-left: 0;
+ flex-wrap: wrap;
+ }
}
diff --git a/apps/web/worker/GEMINI.md b/apps/web/worker/GEMINI.md
new file mode 100644
index 0000000..1bfa1cb
--- /dev/null
+++ b/apps/web/worker/GEMINI.md
@@ -0,0 +1,31 @@
+# apps/web/worker/
+> L2 | Parent: /GEMINI.md
+
+Cloudflare Worker HTTP API layer backed by D1 (`DB`), mounted at `router.ts` and delegating core CRUD and SPA fallback to `index.ts`.
+
+## Member list
+router.ts: Top-level Worker `fetch` dispatcher enforcing auth/device access, CSRF same-origin checks, public route exemptions (`/api/health`, `GET /api/settings/appearance`, `GET /api/public/bookmarks`), and domain handler routing
+index.ts: Base Worker handling `/api/health`, `/api/categories`, `/api/bookmarks`, workspace delegation, health checks, and static asset fallback
+auth.ts: Session cookie and paired-device bearer token authentication, PBKDF2 password hashing, device pairing exchange, and `/api/auth/*` endpoints
+settings.ts: `/api/settings/browser` and `/api/settings/appearance` persistence in `app_settings` (theme `preference` + `locale`) plus browser bootstrap payloads
+ai-organization.ts: `/api/ai/status` and `/api/ai/organize` OpenAI-compatible proxy with SSRF/redirect guards, `HealthPolicy === "normal"` gating, and locale-aware (`en` / `zh-CN`) prompt instructions
+ai-batch-apply.ts: `/api/ai/apply` transactional D1 batch updater applying reviewed AI title, description, category, and tag suggestions
+bookmark-details.ts: `/api/bookmarks/with-tags` and `/api/bookmarks/:id/with-tags` composite bookmark + tag create/update endpoints
+capture-inbox.ts: `/api/capture/review`, `/api/inbox`, `/api/inbox/count`, and inbox triage/dismissal routes
+capture-write.ts: `/api/capture/bookmark` and `/api/capture/batch` extension-authenticated capture write routes with duplicate handling
+change-journal.ts: `/api/library/change-journal` audit log reader and journal entry recorder for reversible library mutations
+duplicate-review.ts: `/api/library/duplicates` duplicate URL group detection and reviewed merge/archive actions
+health-check.ts: Server-side bookmark reachability probing respecting `HealthPolicy` and recording `health_checks` rows
+library-batch-maintenance.ts: Active/archived bookmark listing (`/api/bookmarks`, `/api/bookmarks/archived`) and `/api/bookmarks/batch-maintenance` bulk archive/restore/policy updates
+library-batch-organize.ts: `/api/bookmarks/batch-organize` bulk category and tag assignment for selected bookmarks
+local-health-result.ts: Extension-reported local-network bookmark health probe ingestion
+metadata.ts: Safe public URL title/description/icon fetcher for bookmark metadata enrichment
+public-bookmarks.ts: `/api/public/bookmarks` public curated listing and `/api/public/bookmarks/selection` owner curation controls
+reorder.ts: `/api/categories/reorder` and `/api/bookmarks/reorder` position persistence
+search-engines.ts: `/api/search-engines` CRUD and default engine selection backed by `@dockmark/core` keyword/template validation
+sessions.ts: `/api/sessions` saved browser tab-window snapshots and item CRUD
+smart-collections.ts: `/api/smart-collections` saved filter collection CRUD
+tags.ts: `/api/bookmark-tags` and `/api/bookmarks/:id/tags` normalized tag association endpoints
+workspaces.ts: `/api/workspaces` named workspace and workspace item CRUD with open-mode and URL policy normalization
+
+[PROTOCOL]: Update this header on change, then check GEMINI.md
diff --git a/apps/web/worker/ai-organization.ts b/apps/web/worker/ai-organization.ts
index 2cdd73a..c00f8eb 100644
--- a/apps/web/worker/ai-organization.ts
+++ b/apps/web/worker/ai-organization.ts
@@ -1,4 +1,10 @@
-import { inferHealthPolicy, normalizeBookmarkUrl, type HealthPolicy } from "@dockmark/core";
+/**
+ * [INPUT]: depends on inferHealthPolicy, normalizeBookmarkUrl, HealthPolicy, and ResolvedLocale from @dockmark/core; queries D1 bookmarks, categories, tags, and bookmark_tags
+ * [OUTPUT]: exports AiOrganizationEnv, AiOrganizationHttpError, and handleAiOrganizationApi
+ * [POS]: Worker HTTP handler for /api/ai/status and /api/ai/organize in apps/web/worker; proxies OpenAI-compatible suggestion calls with locale-aware prompts
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
+import { inferHealthPolicy, normalizeBookmarkUrl, type HealthPolicy, type ResolvedLocale } from "@dockmark/core";
type BindValue = string | number | null;
@@ -282,8 +288,12 @@ async function loadOrganizationInput(db: D1DatabaseLike, ids: string[]) {
};
}
-function providerRequestBody(model: string, input: Awaited>) {
- const system = [
+function providerRequestBody(
+ model: string,
+ input: Awaited>,
+ locale: ResolvedLocale,
+) {
+ const instructions = [
"You organize a personal bookmark library.",
"Return JSON only as an object with a suggestions array.",
"Each suggestion must contain bookmarkId, title, description, categoryName, tags.",
@@ -293,7 +303,14 @@ function providerRequestBody(model: string, input: Awaited>,
timeoutSeconds: number,
+ locale: ResolvedLocale,
) {
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), timeoutSeconds * 1000);
- const body = providerRequestBody(model, input);
+ const body = providerRequestBody(model, input, locale);
try {
const response = await fetchProviderResponse(endpoint, apiKey, body, controller.signal);
@@ -446,9 +464,10 @@ async function organize(request: Request, env: AiOrganizationEnv) {
const endpoint = providerEndpoint(requiredString(body, "endpoint", 4096));
const model = requiredString(body, "model", 200);
const timeoutSeconds = providerTimeoutSeconds(body.timeoutSeconds);
+ const locale: ResolvedLocale = body.locale === "zh-CN" ? "zh-CN" : "en";
const ids = bookmarkIds(body.bookmarkIds);
const input = await loadOrganizationInput(env.DB, ids);
- const payload = await callProvider(endpoint, model, apiKey, input, timeoutSeconds);
+ const payload = await callProvider(endpoint, model, apiKey, input, timeoutSeconds, locale);
const text = extractText(payload);
if (!text) {
throw new AiOrganizationHttpError(502, "provider_missing_output", "AI provider response did not contain a supported text result.");
diff --git a/apps/web/worker/settings.ts b/apps/web/worker/settings.ts
index 8839e91..77daee2 100644
--- a/apps/web/worker/settings.ts
+++ b/apps/web/worker/settings.ts
@@ -1,3 +1,9 @@
+/**
+ * [INPUT]: depends on browser/appearance settings helpers and LocalePreference from @dockmark/core; queries D1 app_settings, bookmark_tags, smart_collections, and bookmarks tables
+ * [OUTPUT]: exports SettingsDbLike, SettingsHttpError, loadAppearanceSettings, and handleSettingsApi
+ * [POS]: Worker HTTP handler for /api/settings/browser and /api/settings/appearance in apps/web/worker
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
import {
DEFAULT_APPEARANCE_SETTINGS,
DEFAULT_BROWSER_SETTINGS,
@@ -11,6 +17,7 @@ import {
type BookmarkConflictPreference,
type BrowserNewTabSettings,
type BrowserSettings,
+ type LocalePreference,
type UpdateAppearanceSettingsInput,
type UpdateBrowserSettingsInput,
} from "@dockmark/core";
@@ -96,6 +103,11 @@ function parseAppearancePreference(value: unknown): AppearancePreference {
throw new SettingsHttpError(400, "invalid_field", "preference must be system, light or dark.");
}
+function parseLocalePreference(value: unknown): LocalePreference {
+ if (value === "system" || value === "en" || value === "zh-CN") return value;
+ throw new SettingsHttpError(400, "invalid_field", "locale must be system, en or zh-CN.");
+}
+
function parseInteger(value: unknown, key: string, min: number, max: number) {
if (typeof value !== "number" || !Number.isInteger(value) || value < min || value > max) {
throw new SettingsHttpError(400, "invalid_field", `${key} must be an integer between ${min} and ${max}.`);
@@ -219,6 +231,7 @@ function parseBrowserUpdate(body: Record): UpdateBrowserSetting
function parseAppearanceUpdate(body: Record): UpdateAppearanceSettingsInput {
const update: UpdateAppearanceSettingsInput = {};
if (hasOwn(body, "preference")) update.preference = parseAppearancePreference(body.preference);
+ if (hasOwn(body, "locale")) update.locale = parseLocalePreference(body.locale);
return update;
}
diff --git a/packages/core/GEMINI.md b/packages/core/GEMINI.md
new file mode 100644
index 0000000..2635afa
--- /dev/null
+++ b/packages/core/GEMINI.md
@@ -0,0 +1,18 @@
+# packages/core/
+> L2 | Parent: /GEMINI.md
+
+Shared zero-dependency domain layer consumed by `@dockmark/web`, `apps/web/worker`, and `@dockmark/extension`.
+
+## Member list
+package.json: `@dockmark/core` workspace manifest exporting `./src/index.ts` and running `tsc -p tsconfig.json`
+tsconfig.json: Package TypeScript config extending `../../tsconfig.base.json`
+src/index.ts: Public barrel re-exporting models, settings, i18n, URL policy, bookmark URL normalization, command ranking, and search utilities
+src/models.ts: Core entity types and CRUD input contracts (`Bookmark`, `Category`, `Workspace`, `Session`, `SearchEngine`, `HealthCheck`, `HealthPolicy`, `HealthStatus`, `CommandSource`, `CommandResult`)
+src/settings.ts: `BrowserSettings` and `AppearanceSettings` (including `locale: LocalePreference`) schemas, version constants, defaults, normalizers, and merge helpers
+src/i18n.ts: Shared `LocalePreference` (`"system" | "en" | "zh-CN"`), `ResolvedLocale`, `LOCALE_STORAGE_KEY`, locale normalization/resolution, `tx`, `formatRelativeTime`, and canonical `SOURCE_LABELS`, `HEALTH_STATUS_LABELS`, `HEALTH_POLICY_LABELS` dictionaries
+src/url-policy.ts: Hostname/IPv4/IPv6 inspection (`inferHealthPolicy`) classifying localhost, private LAN, link-local, and non-HTTP URLs as `local-only`
+src/bookmark-url.ts: Input URL normalization (`normalizeBookmarkUrl`) prepending `http://` for local bare hosts and `https://` for public hosts
+src/command-rank.ts: Launcher source weights (`LAUNCHER_SOURCE_WEIGHT`), default labels, and `rankCommandResults` ordering
+src/search.ts: Search engine keyword validation (`normalizeSearchKeyword`), `%s` template validation (`validateSearchTemplate`), and query URL builder
+
+[PROTOCOL]: Update this header on change, then check GEMINI.md
diff --git a/packages/core/src/i18n.ts b/packages/core/src/i18n.ts
new file mode 100644
index 0000000..d212a7e
--- /dev/null
+++ b/packages/core/src/i18n.ts
@@ -0,0 +1,116 @@
+/**
+ * [INPUT]: depends on CommandSource, HealthPolicy, and HealthStatus types from ./models
+ * [OUTPUT]: provides locale types, LOCALE_STORAGE_KEY, normalizeLocalePreference, resolveLocale, tx, formatRelativeTime, SOURCE_LABELS, HEALTH_STATUS_LABELS, and HEALTH_POLICY_LABELS
+ * [POS]: shared i18n primitives and canonical bilingual dictionaries in packages/core/src; consumed by settings, web, worker, and extension
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
+import type { CommandSource, HealthPolicy, HealthStatus } from "./models";
+
+export type LocalePreference = "system" | "en" | "zh-CN";
+export type ResolvedLocale = "en" | "zh-CN";
+
+export const LOCALE_STORAGE_KEY = "dockmarkLocaleV1";
+
+export function normalizeLocalePreference(value: unknown): LocalePreference {
+ if (typeof value !== "string") return "system";
+ const normalized = value.trim().toLowerCase().replace(/_/g, "-");
+ if (normalized === "en" || normalized.startsWith("en-")) return "en";
+ if (normalized === "zh" || normalized.startsWith("zh-")) return "zh-CN";
+ return "system";
+}
+
+export function resolveLocale(preference: LocalePreference, browserLanguage?: string): ResolvedLocale {
+ if (preference === "en" || preference === "zh-CN") return preference;
+ const candidate = (browserLanguage ?? (typeof navigator !== "undefined" ? navigator.language : "en")).trim().toLowerCase();
+ return candidate.startsWith("zh") ? "zh-CN" : "en";
+}
+
+export function tx(locale: ResolvedLocale, en: string, zh: string): string {
+ return locale === "zh-CN" ? zh : en;
+}
+
+export function formatRelativeTime(isoValue: string | null | undefined, locale: ResolvedLocale): string {
+ if (!isoValue) return tx(locale, "never", "从未");
+ const timestamp = Date.parse(isoValue);
+ if (!Number.isFinite(timestamp)) return tx(locale, "never", "从未");
+
+ const diffMs = Math.max(0, Date.now() - timestamp);
+ const diffMinutes = Math.floor(diffMs / 60_000);
+ if (diffMinutes < 1) return tx(locale, "just now", "刚刚");
+ if (diffMinutes < 60) return tx(locale, `${diffMinutes}m ago`, `${diffMinutes} 分钟前`);
+
+ const diffHours = Math.floor(diffMinutes / 60);
+ if (diffHours < 24) return tx(locale, `${diffHours}h ago`, `${diffHours} 小时前`);
+
+ const diffDays = Math.floor(diffHours / 24);
+ return tx(locale, `${diffDays}d ago`, `${diffDays} 天前`);
+}
+
+export const SOURCE_LABELS: Record> = {
+ en: {
+ tab: "Open tab",
+ workspace: "Workspace",
+ session: "Session",
+ collection: "Collection",
+ bookmark: "Bookmark",
+ navigation: "Navigation",
+ search: "Search",
+ },
+ "zh-CN": {
+ tab: "打开的标签页",
+ workspace: "工作区",
+ session: "会话",
+ collection: "智能合集",
+ bookmark: "书签",
+ navigation: "导航",
+ search: "搜索",
+ },
+};
+
+export const HEALTH_STATUS_LABELS: Record> = {
+ en: {
+ unknown: "Unknown",
+ healthy: "Healthy",
+ redirected: "Redirected",
+ "auth-required": "Auth required",
+ forbidden: "Forbidden",
+ "rate-limited": "Rate limited",
+ timeout: "Timeout",
+ "dns-error": "DNS error",
+ "tls-error": "TLS error",
+ unavailable: "Unavailable",
+ "local-only": "Local-only",
+ ignored: "Ignored",
+ },
+ "zh-CN": {
+ unknown: "未知",
+ healthy: "正常",
+ redirected: "已重定向",
+ "auth-required": "需要认证",
+ forbidden: "禁止访问",
+ "rate-limited": "触发限流",
+ timeout: "请求超时",
+ "dns-error": "DNS 错误",
+ "tls-error": "TLS 错误",
+ unavailable: "无法访问",
+ "local-only": "仅本地",
+ ignored: "已忽略",
+ },
+};
+
+export const HEALTH_POLICY_LABELS: Record> = {
+ en: {
+ auto: "Auto",
+ normal: "Normal",
+ ignore: "Ignore",
+ "local-only": "Local-only",
+ manual: "Manual",
+ },
+ "zh-CN": {
+ auto: "自动",
+ normal: "常规",
+ ignore: "忽略",
+ "local-only": "仅本地",
+ manual: "手动",
+ },
+};
diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts
index b927a7c..8b815c4 100644
--- a/packages/core/src/index.ts
+++ b/packages/core/src/index.ts
@@ -1,5 +1,12 @@
+/**
+ * [INPUT]: depends on models, settings, i18n, url-policy, bookmark-url, command-rank, and search modules
+ * [OUTPUT]: re-exports the public @dockmark/core surface
+ * [POS]: package barrel entry point for packages/core/src
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
export * from "./models";
export * from "./settings";
+export * from "./i18n";
export * from "./url-policy";
export * from "./bookmark-url";
export * from "./command-rank";
diff --git a/packages/core/src/settings.ts b/packages/core/src/settings.ts
index 92ecad7..b864f6e 100644
--- a/packages/core/src/settings.ts
+++ b/packages/core/src/settings.ts
@@ -1,4 +1,11 @@
+/**
+ * [INPUT]: depends on Id from ./models; depends on LocalePreference and normalizeLocalePreference from ./i18n
+ * [OUTPUT]: provides browser and appearance settings contracts, defaults, normalizers, and merge helpers
+ * [POS]: schema and normalization boundary for persisted app_settings payloads in packages/core/src
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
import type { Id } from "./models";
+import { normalizeLocalePreference, type LocalePreference } from "./i18n";
export const BROWSER_SETTINGS_VERSION = 1;
export const APPEARANCE_SETTINGS_VERSION = 1;
@@ -29,11 +36,13 @@ export interface UpdateBrowserSettingsInput {
export interface AppearanceSettings {
version: typeof APPEARANCE_SETTINGS_VERSION;
preference: AppearancePreference;
+ locale: LocalePreference;
updatedAt: string | null;
}
export interface UpdateAppearanceSettingsInput {
preference?: AppearancePreference;
+ locale?: LocalePreference;
}
export const DEFAULT_BROWSER_SETTINGS: BrowserSettings = {
@@ -52,6 +61,7 @@ export const DEFAULT_BROWSER_SETTINGS: BrowserSettings = {
export const DEFAULT_APPEARANCE_SETTINGS: AppearanceSettings = {
version: APPEARANCE_SETTINGS_VERSION,
preference: "system",
+ locale: "system",
updatedAt: null,
};
@@ -118,6 +128,7 @@ export function normalizeAppearanceSettings(value: unknown): AppearanceSettings
return {
version: APPEARANCE_SETTINGS_VERSION,
preference: normalizeAppearancePreference(record.preference),
+ locale: normalizeLocalePreference(record.locale),
updatedAt: typeof record.updatedAt === "string" && record.updatedAt ? record.updatedAt : null,
};
}
@@ -146,6 +157,7 @@ export function mergeAppearanceSettings(
return normalizeAppearanceSettings({
...current,
...(input.preference === undefined ? {} : { preference: input.preference }),
+ ...(input.locale === undefined ? {} : { locale: input.locale }),
updatedAt,
});
}
diff --git a/scripts/chromium-extension-smoke.mjs b/scripts/chromium-extension-smoke.mjs
index 4a61e4c..5691496 100644
--- a/scripts/chromium-extension-smoke.mjs
+++ b/scripts/chromium-extension-smoke.mjs
@@ -1,3 +1,9 @@
+/**
+ * [INPUT]: depends on built apps/extension/.output/chrome-mv3 and playwright Chromium
+ * [OUTPUT]: verifies Standard MV3 extension handshake, permissions, local-health prompt, bilingual EN/zh-CN popup workbench, searchable Open Tabs, and pinned Session restore
+ * [POS]: primary Chromium E2E smoke test for the Standard Dockmark extension profile in scripts/
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
import assert from "node:assert/strict";
import { createServer } from "node:http";
import { mkdtemp, readFile, rm } from "node:fs/promises";
@@ -74,7 +80,7 @@ try {
const commands = await popup.evaluate(async () => chrome.commands.getAll());
const launcherCommand = commands.find((command) => command.name === "open-dockmark-launcher");
assert.ok(launcherCommand, "Dockmark launcher command should be registered.");
- assert.match(launcherCommand.description ?? "", /Dockmark launcher/i);
+ assert.match(launcherCommand.description ?? "", /Dockmark launcher|Dockmark 启动台/i);
const capabilities = await popup.evaluate(async () =>
chrome.runtime.sendMessage({ type: "dockmark:get-capabilities" }),
@@ -100,7 +106,9 @@ try {
assert.equal(hasLocalHostAccess, false, "Local host access must not be granted at install time.");
await popup.evaluate(async ({ localPattern, origin }) => {
+ localStorage.setItem("dockmarkLocaleV1", "en");
await chrome.storage.local.set({
+ dockmarkLocaleV1: "en",
dockmarkPendingLocalHealthPermissionV1: {
url: `${origin}/health`,
origin,
@@ -116,6 +124,13 @@ try {
await permissionPage.getByText("Allow this local host?", { exact: true }).waitFor();
assert.match(await permissionPage.locator("body").innerText(), /http:\/\/127\.0\.0\.1\/\*/);
assert.match(await permissionPage.locator("body").innerText(), /does not request access to every website/i);
+ await permissionPage.evaluate(async () => chrome.storage.local.set({ dockmarkLocaleV1: "zh-CN" }));
+ await permissionPage.getByText("允许访问此本地主机?", { exact: true }).waitFor();
+ assert.equal(await permissionPage.evaluate(() => document.documentElement.lang), "zh-CN");
+ await permissionPage.evaluate(async () => {
+ localStorage.setItem("dockmarkLocaleV1", "en");
+ await chrome.storage.local.set({ dockmarkLocaleV1: "en" });
+ });
await popup.evaluate(async () => chrome.storage.local.remove("dockmarkPendingLocalHealthPermissionV1"));
await permissionPage.close();
@@ -132,6 +147,129 @@ try {
assert.ok(firstTab?.id != null, "The extension should enumerate the first browser tab.");
assert.ok(secondTab?.id != null, "The extension should enumerate the second browser tab.");
+ // Verify popup renders cleanly in EN and zh-CN with Settings drawer and searchable Open Tabs.
+ await popup.reload();
+ await popup.waitForLoadState("domcontentloaded");
+ await popup.locator('[data-testid="popup-open-tabs"]').waitFor();
+ assert.equal(await popup.evaluate(() => document.documentElement.lang), "en");
+ const tabSearch = popup.locator(".tab-search-input");
+ await tabSearch.fill("Target Two");
+ await popup.locator(".tab-row").filter({ hasText: "Dockmark Target Two" }).first().waitFor();
+ assert.equal(await popup.locator(".tab-row").count(), 1, "Open Tabs search should narrow live tabs to matching rows.");
+ await tabSearch.fill("");
+
+ await popup.getByRole("button", { name: "Extension settings" }).click();
+ await popup.locator('[data-testid="popup-settings"]').waitFor();
+ await popup.getByRole("radio", { name: "简体中文" }).click();
+ await popup.getByText("扩展设置", { exact: true }).waitFor();
+ assert.equal(await popup.evaluate(() => document.documentElement.lang), "zh-CN");
+ const storedLocale = await popup.evaluate(async () => (await chrome.storage.local.get("dockmarkLocaleV1")).dockmarkLocaleV1);
+ assert.equal(storedLocale, "zh-CN", "Popup language selection should persist dockmarkLocaleV1 to chrome.storage.local.");
+ await popup.getByRole("button", { name: "完成" }).click();
+ await popup.getByText("打开的标签页", { exact: true }).waitFor();
+
+ // Verify connected + paired 3-tab segmented workbench in both EN and zh-CN.
+ const pairedPopup = await context.newPage();
+ await pairedPopup.addInitScript(({ origin }) => {
+ const nativeContains = chrome.permissions.contains.bind(chrome.permissions);
+ chrome.permissions.contains = (query, callback) => {
+ if (Array.isArray(query?.origins) && query.origins.includes(`${origin}/*`)) {
+ if (typeof callback === "function") {
+ callback(true);
+ return undefined;
+ }
+ return Promise.resolve(true);
+ }
+ return nativeContains(query, callback);
+ };
+ const nativeSendMessage = chrome.runtime.sendMessage.bind(chrome.runtime);
+ chrome.runtime.sendMessage = (message, ...rest) => {
+ if (message?.type === "dockmark:configure-bridge") {
+ const cb = typeof rest[rest.length - 1] === "function" ? rest[rest.length - 1] : null;
+ if (cb) {
+ cb({ ok: true });
+ return undefined;
+ }
+ return Promise.resolve({ ok: true });
+ }
+ return nativeSendMessage(message, ...rest);
+ };
+ const nativeFetch = window.fetch.bind(window);
+ window.fetch = async (input, init = {}) => {
+ const requestUrl = new URL(
+ typeof input === "string" || input instanceof URL ? input.toString() : input.url,
+ window.location.href,
+ );
+ if (requestUrl.origin !== origin || !requestUrl.pathname.startsWith("/api/")) {
+ return nativeFetch(input, init);
+ }
+ const json = (data) => new Response(JSON.stringify(data), {
+ status: 200,
+ headers: { "content-type": "application/json; charset=utf-8" },
+ });
+ if (requestUrl.pathname === "/api/sessions") {
+ return json({
+ sessions: [{
+ id: "session-smoke",
+ name: "Smoke Window",
+ sourceDevice: "Chromium",
+ createdAt: new Date().toISOString(),
+ updatedAt: new Date().toISOString(),
+ items: [{ id: "item-1", title: "Dockmark Target One", url: `${origin}/one`, pinned: false, position: 0 }],
+ }],
+ });
+ }
+ if (requestUrl.pathname === "/api/settings/appearance") {
+ return json({ settings: { version: 1, preference: "system", locale: "en", updatedAt: new Date().toISOString() } });
+ }
+ if (requestUrl.pathname === "/api/capture/review") {
+ return json({ items: [] });
+ }
+ return json({});
+ };
+ }, { origin });
+
+ await popup.evaluate(async ({ origin }) => {
+ localStorage.setItem("dockmarkLocaleV1", "en");
+ await chrome.storage.local.set({
+ dockmarkServerUrl: origin,
+ dockmarkDeviceToken: "smoke-device-token",
+ dockmarkLocaleV1: "en",
+ });
+ }, { origin });
+
+ await pairedPopup.goto(`chrome-extension://${extensionId}/popup.html`);
+ await pairedPopup.waitForLoadState("domcontentloaded");
+ await pairedPopup.getByRole("tab", { name: "Capture" }).waitFor();
+ await pairedPopup.getByRole("tab", { name: "Multi-Tab" }).waitFor();
+ await pairedPopup.getByRole("tab", { name: /Sessions/ }).waitFor();
+ await pairedPopup.locator('[data-testid="popup-quick-capture"]').waitFor();
+ await pairedPopup.locator(".tab-search-input").fill("Target One");
+ await pairedPopup.locator(".tab-row").filter({ hasText: "Dockmark Target One" }).first().waitFor();
+ await pairedPopup.locator(".tab-search-input").fill("");
+
+ await pairedPopup.getByRole("tab", { name: /Sessions/ }).click();
+ await pairedPopup.getByText("Smoke Window", { exact: true }).waitFor();
+ await pairedPopup.getByRole("tab", { name: "Multi-Tab" }).click();
+ await pairedPopup.getByRole("tab", { name: "Capture" }).click();
+
+ await pairedPopup.evaluate(async () => {
+ localStorage.setItem("dockmarkLocaleV1", "zh-CN");
+ await chrome.storage.local.set({ dockmarkLocaleV1: "zh-CN" });
+ });
+ await pairedPopup.getByRole("tab", { name: "收录与标签页" }).waitFor();
+ await pairedPopup.getByRole("tab", { name: "批量收录" }).waitFor();
+ await pairedPopup.getByRole("tab", { name: /会话/ }).waitFor();
+ await pairedPopup.getByText("快速收录", { exact: true }).waitFor();
+ assert.equal(await pairedPopup.evaluate(() => document.documentElement.lang), "zh-CN");
+ await pairedPopup.close();
+
+ await popup.evaluate(async () => {
+ localStorage.setItem("dockmarkLocaleV1", "en");
+ await chrome.storage.local.remove(["dockmarkServerUrl", "dockmarkDeviceToken"]);
+ await chrome.storage.local.set({ dockmarkLocaleV1: "en" });
+ });
+
await popup.evaluate(async (tabId) =>
chrome.runtime.sendMessage({ type: "dockmark:activate-tab", tabId }),
firstTab.id,
@@ -166,8 +304,9 @@ try {
console.log("✓ Native bookmark import, mapping sync and explicit writeback capabilities advertised");
console.log("✓ Native bookmark capability is optional and ungranted by default");
console.log("✓ Local health capability is advertised without install-time host grants");
- console.log("✓ Local health permission page scopes the request to one hostname");
+ console.log("✓ Local health permission page scopes the request to one hostname and renders EN/zh-CN");
console.log("✓ Standard build does not override the browser new tab page");
+ console.log("✓ Popup renders cleanly in EN and zh-CN with Settings drawer, 3-tab segmented workbench, and searchable Open Tabs");
console.log("✓ Open-tab enumeration and activation");
console.log("✓ Pinned Session restore");
} finally {
diff --git a/scripts/chromium-newtab-parity-smoke.mjs b/scripts/chromium-newtab-parity-smoke.mjs
index 6cfd947..3b1e084 100644
--- a/scripts/chromium-newtab-parity-smoke.mjs
+++ b/scripts/chromium-newtab-parity-smoke.mjs
@@ -1,3 +1,9 @@
+/**
+ * [INPUT]: depends on packaged apps/extension/.output/chrome-mv3-newtab and playwright Chromium
+ * [OUTPUT]: verifies canonical Web/New Tab result ordering, eight-result cap with default Search slot, localized EN/zh-CN kind labels, and Escape-to-blur
+ * [POS]: launcher parity Chromium smoke test in scripts/
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
import assert from "node:assert/strict";
import { mkdtemp, rm } from "node:fs/promises";
import { tmpdir } from "node:os";
@@ -26,8 +32,15 @@ try {
const page = await context.newPage();
await page.goto(`chrome-extension://${extensionId}/newtab.html`);
await page.waitForLoadState("domcontentloaded");
+ await page.waitForFunction(() => {
+ const text = document.querySelector("#connection-state")?.textContent?.trim();
+ return Boolean(text && text !== "Starting…" && text !== "启动中…");
+ });
await page.evaluate(() => {
+ // Keep synthetic openTabs stable if document.title changes during EN/zh-CN assertions.
+ chrome.tabs.query = async () => openTabs;
+ window.dockmarkI18n.apply("en", true);
const now = new Date().toISOString();
settings = normalizeSettings({
version: 1,
@@ -126,6 +139,17 @@ try {
.map((value) => value.toLocaleLowerCase());
assert.deepEqual(labels, ["open tab", "workspace", "session", "collection", "bookmark", "search"]);
+ await page.evaluate(() => {
+ window.dockmarkI18n.apply("zh-CN", true);
+ renderSearchResults();
+ });
+ const zhLabels = await page.locator("#command-results .result-kind").allInnerTexts();
+ assert.deepEqual(zhLabels, ["打开的标签页", "工作区", "会话", "智能合集", "书签", "搜索"]);
+ await page.evaluate(() => {
+ window.dockmarkI18n.apply("en", true);
+ renderSearchResults();
+ });
+
const titles = await page.locator("#command-results .result-row strong").allInnerTexts();
assert.deepEqual(titles.slice(0, 5), [
"Shared Match Tab",
@@ -136,6 +160,7 @@ try {
]);
await page.evaluate(() => {
+ window.dockmarkI18n.apply("en", true);
const now = new Date().toISOString();
snapshot = {
...snapshot,
diff --git a/scripts/chromium-newtab-smoke.mjs b/scripts/chromium-newtab-smoke.mjs
index 242644e..51af88e 100644
--- a/scripts/chromium-newtab-smoke.mjs
+++ b/scripts/chromium-newtab-smoke.mjs
@@ -1,3 +1,9 @@
+/**
+ * [INPUT]: depends on packaged apps/extension/.output/chrome-mv3-newtab and playwright Chromium
+ * [OUTPUT]: verifies New Tab local-first snapshot refresh, offline search, category/collection filter pills, bilingual EN/zh-CN runtime, and cache clearing
+ * [POS]: primary Chromium E2E smoke test for the Dockmark New Tab extension variant in scripts/
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
import assert from "node:assert/strict";
import { createServer } from "node:http";
import { mkdtemp, readFile, rm } from "node:fs/promises";
@@ -101,7 +107,7 @@ try {
};
}
if (path === "/api/settings/appearance") {
- return { settings: { version: 1, preference: "light", updatedAt: now } };
+ return { settings: { version: 1, preference: "light", locale: "en", updatedAt: now } };
}
if (path === "/api/settings/browser") {
return {
@@ -332,6 +338,51 @@ try {
await page.locator("#command-results .result-row").filter({ hasText: "Second Cached Bookmark" }).first().waitFor();
assert.equal(await page.locator("#command-results .result-row").filter({ hasText: "Cached Example" }).count(), 0);
+ // Verify compact redesigned launcher controls (no giant marketing hero), filter pills, and EN <-> zh-CN locale switching.
+ assert.equal(await page.locator(".hero h1").count(), 0, "Compact New Tab launcher should not render a giant hero headline.");
+ await page.locator("#theme-toggle").waitFor();
+ await page.locator("#locale-toggle").waitFor();
+ await page.locator(".syntax-hints").waitFor();
+
+ await page.locator("#bookmark-filters").waitFor();
+ const filterLabelsEn = await page.locator("#bookmark-filters .filter-pill").allInnerTexts();
+ assert.deepEqual(filterLabelsEn, ["All", "Developer docs", "Inbox reading", "Developer", "Uncategorized"]);
+
+ await page.locator("#bookmark-filters .filter-pill", { hasText: "Inbox reading" }).click();
+ await page.locator("#bookmarks .bookmark-card").filter({ hasText: "Second Cached Bookmark" }).first().waitFor();
+ assert.equal(await page.locator("#bookmarks .bookmark-card").filter({ hasText: "Cached Example" }).count(), 0);
+
+ await page.locator("#bookmark-filters .filter-pill", { hasText: "Developer" }).last().click();
+ await page.locator("#bookmarks .bookmark-card").filter({ hasText: "Cached Example" }).first().waitFor();
+ assert.equal(await page.locator("#bookmarks .bookmark-card").filter({ hasText: "Second Cached Bookmark" }).count(), 0);
+
+ await page.locator("#bookmark-filters .filter-pill", { hasText: "All" }).click();
+ await page.locator("#bookmarks .bookmark-card").filter({ hasText: "Cached Example" }).first().waitFor();
+
+ await page.evaluate(async () => {
+ localStorage.setItem("dockmarkLocaleV1", "zh-CN");
+ await chrome.storage.local.set({ dockmarkLocaleV1: "zh-CN" });
+ });
+ await page.waitForFunction(() => document.documentElement.lang === "zh-CN");
+ await page.getByRole("heading", { name: "书签", exact: true }).waitFor();
+ await page.getByRole("heading", { name: "工作区", exact: true }).waitFor();
+ await page.getByText("管理 Dockmark", { exact: true }).waitFor();
+ assert.equal(await page.locator("#clear-cache").innerText(), "清除本地快照");
+ assert.match(await page.locator("#connection-state").innerText(), /已缓存 · 手动刷新/);
+ const filterLabelsZh = await page.locator("#bookmark-filters .filter-pill").allInnerTexts();
+ assert.deepEqual(filterLabelsZh, ["全部", "Developer docs", "Inbox reading", "Developer", "未分类"]);
+
+ await page.locator("#search").fill("Developer docs");
+ const zhCollectionResult = page.locator("#command-results .result-row").filter({ hasText: "Developer docs" }).first();
+ await zhCollectionResult.waitFor();
+ assert.match(await zhCollectionResult.innerText(), /智能合集/);
+ await page.locator("#search").fill("");
+
+ await page.locator("#locale-toggle").click();
+ await page.waitForFunction(() => document.documentElement.lang === "en");
+ await page.getByRole("heading", { name: "Bookmarks", exact: true }).waitFor();
+ assert.equal(await page.locator("#clear-cache").innerText(), "Clear local snapshot");
+
await page.locator("#search").fill("offline query");
await page.getByText("Search Secondary Search for “offline query”", { exact: true }).waitFor();
@@ -371,6 +422,7 @@ try {
console.log("✓ Transparent adaptive D dot favicon and manifest brand icons are packaged");
console.log("✓ Current refresh reads browser settings once and persists tags, Smart Collections and Inbox membership atomically");
console.log("✓ Cached bookmarks and Workspaces render without Dockmark host permission/network");
+ console.log("✓ Compact New Tab launcher renders category/collection filter pills and switches cleanly between EN and zh-CN");
console.log("✓ Offline search matches bookmark description, category, tags and combined #tag terms");
console.log("✓ Cached Smart Collections are searchable and browse their matching bookmarks offline");
console.log("✓ Inbox-state Smart Collections use cached Inbox membership offline");
diff --git a/scripts/chromium-newtab-ux-smoke.mjs b/scripts/chromium-newtab-ux-smoke.mjs
index d2bf5f5..bb62b74 100644
--- a/scripts/chromium-newtab-ux-smoke.mjs
+++ b/scripts/chromium-newtab-ux-smoke.mjs
@@ -1,3 +1,9 @@
+/**
+ * [INPUT]: depends on packaged apps/extension/.output/chrome-mv3-newtab and playwright Chromium
+ * [OUTPUT]: verifies bare ! bang shortcuts, Session auto-refresh hydration/search/restore, keyboard open modifiers, and / focus shortcut
+ * [POS]: launcher UX Chromium smoke test in scripts/
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
import assert from "node:assert/strict";
import { createServer } from "node:http";
import { mkdtemp, rm } from "node:fs/promises";
@@ -39,7 +45,9 @@ try {
const page = await context.newPage();
await page.goto(launcherUrl);
await page.evaluate(async ({ origin, now }) => {
+ localStorage.setItem("dockmarkLocaleV1", "en");
await chrome.storage.local.set({
+ dockmarkLocaleV1: "en",
dockmarkServerUrl: origin,
dockmarkBrowserSettingsV1: {
version: 1,
diff --git a/scripts/chromium-web-shell-smoke.mjs b/scripts/chromium-web-shell-smoke.mjs
index 64dff02..78e91fa 100644
--- a/scripts/chromium-web-shell-smoke.mjs
+++ b/scripts/chromium-web-shell-smoke.mjs
@@ -1,3 +1,9 @@
+/**
+ * [INPUT]: depends on apps/web/src shell stylesheets and playwright Chromium
+ * [OUTPUT]: verifies zero horizontal overflow, sticky 46px/64px/128px geometry, and responsive nav behavior at 1280/900/720/390px in both English and Simplified Chinese
+ * [POS]: Chromium responsive shell layout smoke test in scripts/
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
import assert from "node:assert/strict";
import { readFile } from "node:fs/promises";
import path from "node:path";
@@ -14,26 +20,58 @@ const cssPaths = [
];
const css = (await Promise.all(cssPaths.map((file) => readFile(path.join(root, file), "utf8")))).join("\n");
-const utilityButtons = ["Workspace", "Inbox", "Collections", "Duplicates", "Settings", "Sign out"];
-const sectionButtons = ["Launcher", "Workspaces", "Sessions", "Bookmarks", "Search", "Transfer", "Extension"];
+const LOCALE_FIXTURES = [
+ {
+ locale: "en",
+ publicLabel: "Public page",
+ utilityButtons: ["Workspace", "Inbox", "Collections", "Duplicates", "Settings"],
+ themeLabel: "System",
+ langToggle: "中文",
+ signOutLabel: "Sign out",
+ sectionButtons: ["Launcher", "Workspaces", "Sessions", "Bookmarks", "Search", "Transfer", "Extension"],
+ resultHeading: "Command results",
+ bridgeMeta: "Browser bridge · 20 open tabs",
+ resultPill: "Open tab",
+ expectPhoneSectionOverflow: true,
+ },
+ {
+ locale: "zh-CN",
+ publicLabel: "公开主页",
+ utilityButtons: ["工作台", "收件箱", "智能合集", "重复项", "设置"],
+ themeLabel: "跟随系统",
+ langToggle: "EN",
+ signOutLabel: "退出",
+ sectionButtons: ["启动台", "工作区", "会话", "书签", "搜索", "导入导出", "扩展"],
+ resultHeading: "命令结果",
+ bridgeMeta: "浏览器桥接 · 20 个打开的标签页",
+ resultPill: "打开的标签页",
+ expectPhoneSectionOverflow: false,
+ },
+];
-function fixture() {
+function fixture(copy) {
return `
-
+
-
D· Public page
-
${utilityButtons.map((label) => `${label} `).join("")}
+
D· ${copy.publicLabel}
+
+ ${copy.utilityButtons.map((label) => `${label} `).join("")}
+
+
+ ◐ ${copy.themeLabel}
+ ${copy.langToggle}
+
+ ${copy.signOutLabel}
+
D· Dockmark
- ${sectionButtons.map((label) => `${label} `).join("")}
+ ${copy.sectionButtons.map((label) => `${label} `).join("")}
- Command results Browser bridge · 20 open tabs
+ ${copy.resultHeading} ${copy.bridgeMeta}
- ↗ Example result with a deliberately long title that must stay inside the responsive shell https://example.com/a/very/long/path/that/should/ellipsis Open tab
+ ↗ Example result with a deliberately long title that must stay inside the responsive shell https://example.com/a/very/long/path/that/should/ellipsis ${copy.resultPill}
↑ ↓ select Enter run Tab accept bangShift /⌘ /Ctrl +Enter new tab / focus Esc clear
@@ -62,70 +100,81 @@ const browser = await chromium.launch({ channel: "chromium", headless: true });
try {
const page = await browser.newPage();
- for (const width of [1280, 900, 720, 390]) {
- await page.setViewportSize({ width, height: 720 });
- await page.setContent(fixture(), { waitUntil: "domcontentloaded" });
+ for (const copy of LOCALE_FIXTURES) {
+ for (const width of [1280, 900, 720, 390]) {
+ await page.setViewportSize({ width, height: 720 });
+ await page.setContent(fixture(copy), { waitUntil: "domcontentloaded" });
- const layout = await page.evaluate(() => {
- const utility = document.querySelector(".private-utility-bar");
- const secondary = document.querySelector(".topbar");
- const sectionNav = document.querySelector(".workspace-section-nav");
- const utilityNav = document.querySelector(".private-utility-bar nav");
- const sidebar = document.querySelector(".manager-sidebar");
- const brand = document.querySelector(".topbar .brand");
- const brandLabel = document.querySelector(".topbar .brand > span:not(.brand-mark)");
- if (!(utility instanceof HTMLElement) || !(secondary instanceof HTMLElement) || !(sectionNav instanceof HTMLElement) || !(utilityNav instanceof HTMLElement) || !(sidebar instanceof HTMLElement) || !(brand instanceof HTMLElement) || !(brandLabel instanceof HTMLElement)) {
- throw new Error("Responsive shell fixture is incomplete.");
- }
- return {
- documentWidth: document.documentElement.scrollWidth,
- bodyWidth: document.body.scrollWidth,
- viewportWidth: window.innerWidth,
- utilityHeight: utility.getBoundingClientRect().height,
- secondaryHeight: secondary.getBoundingClientRect().height,
- secondaryTop: getComputedStyle(secondary).top,
- secondaryPosition: getComputedStyle(secondary).position,
- sidebarTop: getComputedStyle(sidebar).top,
- sectionNavOverflowing: sectionNav.scrollWidth > sectionNav.clientWidth,
- utilityNavOverflowing: utilityNav.scrollWidth > utilityNav.clientWidth,
- brandDisplay: getComputedStyle(brand).display,
- brandLabelDisplay: getComputedStyle(brandLabel).display,
- };
- });
+ const layout = await page.evaluate(() => {
+ const utility = document.querySelector(".private-utility-bar");
+ const secondary = document.querySelector(".topbar");
+ const sectionNav = document.querySelector(".workspace-section-nav");
+ const utilityNav = document.querySelector(".private-utility-bar nav");
+ const sidebar = document.querySelector(".manager-sidebar");
+ const brand = document.querySelector(".topbar .brand");
+ const brandLabel = document.querySelector(".topbar .brand > span:not(.brand-mark)");
+ if (!(utility instanceof HTMLElement) || !(secondary instanceof HTMLElement) || !(sectionNav instanceof HTMLElement) || !(utilityNav instanceof HTMLElement) || !(sidebar instanceof HTMLElement) || !(brand instanceof HTMLElement) || !(brandLabel instanceof HTMLElement)) {
+ throw new Error("Responsive shell fixture is incomplete.");
+ }
+ const navButtons = [
+ ...utilityNav.querySelectorAll("button"),
+ ...sectionNav.querySelectorAll("button"),
+ ];
+ const maxNavButtonHeight = Math.max(...navButtons.map((button) => button.getBoundingClientRect().height));
+ return {
+ documentWidth: document.documentElement.scrollWidth,
+ bodyWidth: document.body.scrollWidth,
+ viewportWidth: window.innerWidth,
+ utilityHeight: utility.getBoundingClientRect().height,
+ secondaryHeight: secondary.getBoundingClientRect().height,
+ secondaryTop: getComputedStyle(secondary).top,
+ secondaryPosition: getComputedStyle(secondary).position,
+ sidebarTop: getComputedStyle(sidebar).top,
+ sectionNavOverflowing: sectionNav.scrollWidth > sectionNav.clientWidth,
+ utilityNavOverflowing: utilityNav.scrollWidth > utilityNav.clientWidth,
+ brandDisplay: getComputedStyle(brand).display,
+ brandLabelDisplay: getComputedStyle(brandLabel).display,
+ maxNavButtonHeight,
+ };
+ });
- assert.ok(layout.documentWidth <= width + 1, `${width}px viewport should not have document-level horizontal overflow.`);
- assert.ok(layout.bodyWidth <= width + 1, `${width}px viewport should not have body-level horizontal overflow.`);
- assert.equal(layout.utilityHeight, 46);
- assert.equal(layout.secondaryHeight, 64);
- assert.equal(layout.secondaryPosition, "sticky");
- assert.equal(layout.secondaryTop, "46px");
- assert.equal(layout.sidebarTop, "128px");
+ assert.ok(layout.documentWidth <= width + 1, `[${copy.locale}] ${width}px viewport should not have document-level horizontal overflow.`);
+ assert.ok(layout.bodyWidth <= width + 1, `[${copy.locale}] ${width}px viewport should not have body-level horizontal overflow.`);
+ assert.equal(layout.utilityHeight, 46, `[${copy.locale}] ${width}px utility bar should stay 46px tall.`);
+ assert.equal(layout.secondaryHeight, 64, `[${copy.locale}] ${width}px secondary topbar should stay 64px tall.`);
+ assert.equal(layout.secondaryPosition, "sticky");
+ assert.equal(layout.secondaryTop, "46px");
+ assert.equal(layout.sidebarTop, "128px");
+ assert.ok(layout.maxNavButtonHeight <= 42, `[${copy.locale}] ${width}px nav labels should stay single-line (got ${layout.maxNavButtonHeight}px).`);
- if (width === 1280) {
- assert.notEqual(layout.brandLabelDisplay, "none", "Desktop should keep the Dockmark secondary brand label.");
- }
- if (width === 720) {
- assert.equal(layout.brandLabelDisplay, "none", "Tablet layout should reclaim space by hiding the secondary brand label.");
- }
- if (width === 390) {
- assert.equal(layout.brandDisplay, "none", "Phone layout should dedicate the secondary bar to section navigation.");
- assert.equal(layout.sectionNavOverflowing, true, "Phone section navigation should scroll within its own bar instead of widening the page.");
- assert.equal(layout.utilityNavOverflowing, true, "Phone utility navigation should scroll within the utility bar instead of widening the page.");
- }
+ if (width === 1280) {
+ assert.notEqual(layout.brandLabelDisplay, "none", `[${copy.locale}] Desktop should keep the Dockmark secondary brand label.`);
+ }
+ if (width === 720) {
+ assert.equal(layout.brandLabelDisplay, "none", `[${copy.locale}] Tablet layout should reclaim space by hiding the secondary brand label.`);
+ }
+ if (width === 390) {
+ assert.equal(layout.brandDisplay, "none", `[${copy.locale}] Phone layout should dedicate the secondary bar to section navigation.`);
+ if (copy.expectPhoneSectionOverflow) {
+ assert.equal(layout.sectionNavOverflowing, true, `[${copy.locale}] Phone section navigation should scroll within its own bar instead of widening the page.`);
+ }
+ assert.equal(layout.utilityNavOverflowing, true, `[${copy.locale}] Phone utility navigation should scroll within the utility bar instead of widening the page.`);
+ }
- await page.evaluate(() => window.scrollTo(0, 900));
- await page.waitForTimeout(50);
- const sticky = await page.evaluate(() => {
- const utility = document.querySelector(".private-utility-bar")?.getBoundingClientRect();
- const secondary = document.querySelector(".topbar")?.getBoundingClientRect();
- return { utilityTop: utility?.top, secondaryTop: secondary?.top };
- });
- assert.ok(Math.abs((sticky.utilityTop ?? 999) - 0) <= 1, `${width}px utility bar should remain pinned to the viewport top.`);
- assert.ok(Math.abs((sticky.secondaryTop ?? 999) - 46) <= 1, `${width}px workspace nav should remain pinned directly below the utility bar.`);
+ await page.evaluate(() => window.scrollTo(0, 900));
+ await page.waitForTimeout(50);
+ const sticky = await page.evaluate(() => {
+ const utility = document.querySelector(".private-utility-bar")?.getBoundingClientRect();
+ const secondary = document.querySelector(".topbar")?.getBoundingClientRect();
+ return { utilityTop: utility?.top, secondaryTop: secondary?.top };
+ });
+ assert.ok(Math.abs((sticky.utilityTop ?? 999) - 0) <= 1, `[${copy.locale}] ${width}px utility bar should remain pinned to the viewport top.`);
+ assert.ok(Math.abs((sticky.secondaryTop ?? 999) - 46) <= 1, `[${copy.locale}] ${width}px workspace nav should remain pinned directly below the utility bar.`);
+ }
}
- console.log("✓ Web shell has no document-level horizontal overflow at 1280/900/720/390px");
- console.log("✓ Utility and workspace navigation remain stacked and sticky while scrolling");
+ console.log("✓ Web shell has no document-level horizontal overflow at 1280/900/720/390px in both EN and zh-CN");
+ console.log("✓ Utility and workspace navigation remain stacked, single-line, and sticky while scrolling");
console.log("✓ Tablet and phone breakpoints reclaim nav space without clipping the page");
console.log("✓ Internal sticky sidebars offset below both navigation bars");
} finally {
diff --git a/scripts/package-newtab-extension.mjs b/scripts/package-newtab-extension.mjs
index ebcf12c..4bcf0bf 100644
--- a/scripts/package-newtab-extension.mjs
+++ b/scripts/package-newtab-extension.mjs
@@ -1,3 +1,9 @@
+/**
+ * [INPUT]: depends on apps/extension/.output/chrome-mv3 and apps/extension/package.json
+ * [OUTPUT]: produces apps/extension/.output/chrome-mv3-newtab and dockmark-newtab-chrome-v.zip
+ * [POS]: release packaging script for the opt-in Dockmark New Tab Chromium variant
+ * [PROTOCOL]: Update this header on change, then check GEMINI.md
+ */
import { cp, readFile, rename, rm, writeFile } from "node:fs/promises";
import { spawnSync } from "node:child_process";
import path from "node:path";
@@ -21,11 +27,22 @@ await cp(sourceDir, variantDir, { recursive: true });
const manifestPath = path.join(variantDir, "manifest.json");
const manifest = JSON.parse(await readFile(manifestPath, "utf8"));
manifest.name = "Dockmark New Tab";
-manifest.description = "Dockmark browser bridge with a local-first, offline-capable Dockmark launcher on every new tab.";
+manifest.description = "__MSG_newtabDescription__";
manifest.chrome_url_overrides = { newtab: "newtab.html" };
await writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`);
-for (const required of ["newtab.html", "newtab.js", "newtab-search.js", "newtab-ux.js", "newtab-parity.js", "newtab-auth.js", "newtab-theme.js", "newtab.css", "newtab-icon.svg"]) {
+for (const required of [
+ "newtab.html",
+ "newtab.js",
+ "newtab-i18n.js",
+ "newtab-search.js",
+ "newtab-ux.js",
+ "newtab-parity.js",
+ "newtab-auth.js",
+ "newtab-theme.js",
+ "newtab.css",
+ "newtab-icon.svg",
+]) {
await readFile(path.join(variantDir, required));
}