Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions GEMINI.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Dockmark - Self-hosted personal bookmark, workspace, and browser command launcher

TypeScript ^7.0.2 + React ^19.2.8 + Vite ^8.2.2 + Cloudflare Workers & D1 (Wrangler 4.131.1, @cloudflare/vite-plugin ^1.54.7) + WXT ^0.21.4

<directory>
apps/ - Deployable web app, Cloudflare Worker API, and browser extensions (2 subdirectories: web/, extension/)
packages/ - Shared domain contracts, settings normalization, i18n, search, and URL policy (1 subdirectory: core/)
scripts/ - Release packaging, Cloudflare deploy/migration helpers, and Chromium smoke suites (14 scripts)
docs/ - Architecture, API, security, roadmap, and Firefox validation specifications (1 subdirectory: brand/)
</directory>

<config>
package.json - npm workspace root scripts for dev, build, typecheck, extension packaging, D1 migrations, and smoke tests
tsconfig.base.json - Strict ES2022 bundler TypeScript configuration (strict, exactOptionalPropertyTypes, verbatimModuleSyntax, noUncheckedIndexedAccess)
wrangler.jsonc - Cloudflare Workers entry (apps/web/worker/router.ts), SPA asset serving, and D1 database binding (DB)
.editorconfig - Cross-editor indentation, charset, and newline formatting rules
</config>

[PROTOCOL]: Update this header on change, then check GEMINI.md
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ Dockmark is web-first: bookmarks, reusable Workspaces, temporary Sessions and co

The Web app resolves the favicon dynamically so it follows the active System / Light / Dark appearance. The static SVG above documents the canonical mark: dark mode uses the `#0a0f0c` Dockmark surface with the soft green mark, while light mode uses the paired `#f4f7f5` surface with dark green ink.

> Status: **v0.9.0** — reviewed page metadata, server-side public URL health checks, redirect review, conservative cleanup, persisted health history and extension-only local/private URL checks with explicit per-host permission are implemented. Browser sync remains review-gated: no silent background bookmark mutation.
> Status: **v1.6.0** — bilingual **English (`en`) & Simplified Chinese (`zh-CN`)** localization synced across Web, Extension Popup, New Tab, and AI organization, paired with a compact tool-grade UI overhaul (Spotlight launcher dashboard, category/collection filter pills, state-aware 3-tab extension workbench with searchable Open Tabs, reviewed capture Inbox, Smart Collections, Duplicate Review, Change Journal, and Firefox MV3 support). Browser sync remains review-gated: no silent background bookmark mutation.

## Bilingual UI & Redesigned Workspace (v1.6.0)

- **English (`en`) & Simplified Chinese (`zh-CN`)**: Choose `System / English / 简体中文` in **Settings → Appearance & Language** (`外观与语言`), or switch in one click from the Web utility bar, Public Page header, Extension Popup settings drawer, or New Tab topbar. Private workspace preferences sync via `/api/settings/appearance` (`dockmarkLocaleV1`), while the Public Page (`/`) keeps visitor language local (`dockmarkPublicLocaleV1`) without mutating owner data.
- **Locale-aware AI Organization**: `/api/ai/organize` follows the active UI language (`en` or `zh-CN`) so suggested descriptions and tags match your workspace locale while preserving recognizable product and repository names.
- **Compact High-Efficiency UI**: Both Web Launcher (`/app`) and local-first New Tab focus immediately on the Spotlight command bar (`!g` Search · `@` Smart Collection · `#` Tag), paired with one-click Category/Collection filter pills, favicon/monogram bookmark cards, and launchable Workspace cards.
- **State-Aware Extension Workbench**: The 384px Popup transitions from a focused two-step connect/pair wizard to a 3-tab daily workbench (**Capture** with searchable Open Tabs, **Multi-Tab** reviewed capture, and **Sessions**) with Theme/Language controls tucked inside the collapsible settings drawer.

## Deploy to Cloudflare

Expand Down
40 changes: 40 additions & 0 deletions apps/extension/GEMINI.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# apps/extension/
> L2 | Parent: ../../GEMINI.md

Member list
package.json: Extension workspace package manifest (`@dockmark/extension` v1.6.0), WXT build/zip scripts for Chrome, New Tab variant, and Firefox MV3.
wxt.config.ts: WXT MV3 manifest generator for Chrome and Firefox; sets `default_locale: "en"`, localized `__MSG_*__` descriptions, optional `bookmarks`/host permissions, `Alt+Shift+D` command, and `d` omnibox keyword.
tsconfig.json: TypeScript compiler configuration extending `.wxt/tsconfig.json`.
entrypoints/background.ts: MV3 service worker handling Web bridge registration, tab activation, Workspace/Session restore, native bookmark sync/writeback, and local health dispatch.
entrypoints/popup/index.html: HTML shell for the 384px extension popup workbench.
entrypoints/popup/main.tsx: State-aware React 19 popup workbench with header status pill, setup wizard / 3-tab daily segmented views (Capture + searchable Open Tabs, Multi-Tab, Sessions), and settings drawer toggle.
entrypoints/popup/api.ts: Popup domain types, storage keys, URL/monogram helpers, Bearer-authenticated `requestJson`, and best-effort remote appearance/locale sync.
entrypoints/popup/OpenTabsPanel.tsx: Real-time filterable Open Tabs list with host monograms, `Current`/`Switch` pills, and keyboard navigation across all open tabs.
entrypoints/popup/SessionsPanel.tsx: Sessions tab view for saving the current window as a cloud Session and restoring recent cloud Sessions.
entrypoints/popup/SetupWizard.tsx: Two-step onboarding card for connecting the Dockmark server origin and exchanging a one-time pairing code.
entrypoints/popup/SettingsDrawer.tsx: Collapsible settings view housing Theme/Language segmented controls, server reconnect, device unpair, and optional native bookmarks toggle.
entrypoints/popup/ReviewedCapture.tsx: Multi-tab capture review panel with normalized URL dedup summary (`New`/`Existing`/`Repeated`), batch selection, and Inbox save.
entrypoints/popup/style.css: Compact dark/light forest-sage styling for the 384px popup workbench.
entrypoints/local-health-permission/index.html: HTML shell for the single-host local health permission prompt.
entrypoints/local-health-permission/main.ts: Scoped local/private hostname permission prompt with light/dark theme detection and EN/zh-CN localization.
entrypoints/local-health-permission/style.css: Dark/light forest-sage styling for the local health permission page.
lib/ext-locale.ts: Shared extension theme (`dockmarkAppearanceV1`) and locale (`dockmarkLocaleV1`) persistence, DOM application, and `browser.storage.local` reactive sync built on `@dockmark/core`.
lib/local-health.ts: Local/private bookmark HTTP probe runner that gates host checks behind single-hostname `optional_host_permissions`.
lib/launcher-access.ts: Global `Alt+Shift+D` launcher opener and `d + Space` omnibox search over cached local snapshots.
public/dockmark-bridge.js: Content script bridging trusted Dockmark Web pages to `background.ts` via `window.postMessage`.
public/_locales/en/messages.json: English MV3 manifest localization catalog (`extDescription`, `cmdOpenLauncher`, `newtabDescription`).
public/_locales/zh_CN/messages.json: Simplified Chinese MV3 manifest localization catalog (`extDescription`, `cmdOpenLauncher`, `newtabDescription`).
public/newtab.html: Local-first New Tab launcher page with compact topbar, Spotlight command bar, syntax hints, filterable Bookmarks panel, and Workspaces panel.
public/newtab.css: Compact dark/light forest-sage styling for the New Tab launcher, domain monograms, filter pills, and workspace mode indicators.
public/newtab-theme.js: Head-loaded theme bootstrapper synchronizing `dockmarkAppearanceV1` across `localStorage` and `chrome.storage.local`.
public/newtab-i18n.js: Head-loaded EN/zh-CN localization runtime (`window.dockmarkI18n`) synchronizing `dockmarkLocaleV1` and translating static/dynamic New Tab copy.
public/newtab-auth.js: Fetch wrapper injecting `Authorization: Bearer` for paired `/api/*` requests and routing `#manage` clicks to `/app`.
public/newtab.js: Core New Tab launcher state, snapshot rendering, Category/`@Collection` filter pills, theme/locale quick toggles, and command execution.
public/newtab-library-cache.js: Single-pass cloud refresh override caching bookmarks, tags, Smart Collections, Inbox IDs, Sessions, appearance, and locale atomically.
public/newtab-search.js: Local-first `#tag` filtering, Smart Collection search, and `@Collection` browsing layer over `buildResults`.
public/newtab-ux.js: Bare `!` bang suggestions, Session search/restore, Shift/Ctrl+Enter open modifiers, `/` focus shortcut, and launcher focus messaging.
public/newtab-parity.js: Canonical Web Launcher result ranking, eight-result cap with default Search slot, localized result-kind badges, and Escape-to-blur.
public/newtab-icon.svg: Adaptive light/dark `D·` SVG favicon for extension pages.
public/icons/: Packaged PNG extension icons (`dockmark-16.png`, `dockmark-32.png`, `dockmark-48.png`, `dockmark-128.png`).

[PROTOCOL]: Update this header on change, then check GEMINI.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="color-scheme" content="dark" />
<meta name="color-scheme" content="light dark" />
<meta name="theme-color" content="#0a0f0c" />
<title>Dockmark · Local health access</title>
<link rel="icon" href="/newtab-icon.svg" type="image/svg+xml" />
Expand Down
127 changes: 107 additions & 20 deletions apps/extension/entrypoints/local-health-permission/main.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
/**
* [INPUT]: depends on browser from wxt/browser; depends on LOCAL_HEALTH_PENDING_KEY from ../../lib/local-health; depends on ext-locale helpers from ../../lib/ext-locale
* [OUTPUT]: renders the scoped single-host local health permission prompt with light/dark theme and EN/zh-CN localization
* [POS]: standalone extension entrypoint opened by lib/local-health.ts when a local/private bookmark needs explicit browser host permission
* [PROTOCOL]: Update this header on change, then check GEMINI.md
*/
import { browser } from "wxt/browser";
import {
applyExtensionAppearance,
applyExtensionLocale,
hydrateExtensionPreferences,
readLocalAppearance,
readLocalLocalePreference,
subscribeExtensionPreferences,
tx,
type ResolvedLocale,
} from "../../lib/ext-locale";
import {
LOCAL_HEALTH_PENDING_KEY,
type PendingLocalHealthPermission,
} from "../../lib/local-health";
import "./style.css";

applyExtensionAppearance(readLocalAppearance(), false);
let currentLocale: ResolvedLocale = applyExtensionLocale(readLocalLocalePreference(), false).locale;

const root = document.getElementById("root");
if (!root) throw new Error("Missing #root");
const appRoot = root;
Expand All @@ -14,36 +33,68 @@ let busy = false;
let message: string | null = null;
let error: string | null = null;

function syncDocumentTitle() {
document.title = tx(
currentLocale,
"Dockmark · Local health access",
"Dockmark · 本地健康检查权限",
);
}

async function closeCurrentTab() {
const tab = await browser.tabs.getCurrent();
if (tab?.id != null) await browser.tabs.remove(tab.id);
else window.close();
}

function render() {
appRoot.innerHTML = "";
syncDocumentTitle();
appRoot.replaceChildren();

const main = document.createElement("main");
main.className = "permission-shell";

const card = document.createElement("section");
card.className = "permission-card";
const eyebrow = document.createElement("p");

const brandBar = document.createElement("div");
brandBar.className = "brand-bar";
const mark = document.createElement("span");
mark.className = "brand-mark";
mark.textContent = "D·";
const brandName = document.createElement("strong");
brandName.textContent = "Dockmark";
const eyebrow = document.createElement("span");
eyebrow.className = "eyebrow";
eyebrow.textContent = "LOCAL HEALTH CHECK";
eyebrow.textContent = tx(currentLocale, "Local health check", "本地健康检查");
brandBar.append(mark, brandName, eyebrow);

const title = document.createElement("h1");
title.textContent = pending ? "Allow this local host?" : "No local host is waiting.";
title.textContent = pending
? tx(currentLocale, "Allow this local host?", "允许访问此本地主机?")
: tx(currentLocale, "No local host is waiting.", "当前没有待授权的本地主机。");

const intro = document.createElement("p");
intro.className = "intro";
intro.textContent = pending
? "Dockmark requests access only to the exact local hostname needed for the bookmark you chose to check. It does not request access to every website."
: "Return to Dockmark Settings → Metadata & Health and choose Check locally on a local-only bookmark.";
card.append(eyebrow, title, intro);
? tx(
currentLocale,
"Dockmark requests access only to the exact local hostname needed for the bookmark you chose to check. It does not request access to every website.",
"Dockmark 仅向浏览器申请访问你选择检查的这一个本地主机名,不会请求访问所有网站。",
)
: tx(
currentLocale,
"Return to Dockmark Settings → Metadata & Health and choose Check locally on a local-only bookmark.",
"请返回 Dockmark 设置 → 元数据与健康检查,在仅本地可访问的书签上选择“本地检查”。",
);

card.append(brandBar, title, intro);

if (pending) {
const host = document.createElement("div");
host.className = "host-card";
const label = document.createElement("small");
label.textContent = "Requested host permission";
label.textContent = tx(currentLocale, "Requested host permission", "申请的主机权限");
const strong = document.createElement("strong");
strong.textContent = pending.pattern;
const url = document.createElement("span");
Expand All @@ -53,29 +104,40 @@ function render() {

const privacy = document.createElement("p");
privacy.className = "privacy-note";
privacy.textContent = "The permission is granted by the browser to this extension. Dockmark's Worker still never fetches local/private URLs.";
privacy.textContent = tx(
currentLocale,
"Granted by your browser to this extension only. Dockmark's Worker never fetches local or private URLs.",
"此权限仅由浏览器授予当前扩展,Dockmark 云端 Worker 始终不会请求本地或内网地址。",
);
card.append(privacy);

const actions = document.createElement("div");
actions.className = "actions";
const cancel = document.createElement("button");
cancel.type = "button";
cancel.className = "secondary";
cancel.textContent = "Cancel";
cancel.textContent = tx(currentLocale, "Cancel", "取消");
cancel.disabled = busy;
cancel.addEventListener("click", () => void cancelPending());

const allow = document.createElement("button");
allow.type = "button";
allow.className = "primary";
allow.textContent = busy ? "Waiting for browser…" : "Allow this host";
allow.textContent = busy
? tx(currentLocale, "Waiting for browser…", "等待浏览器确认…")
: tx(currentLocale, "Allow this host", "允许此主机");
allow.disabled = busy;
allow.addEventListener("click", () => void grantPending());

actions.append(cancel, allow);
card.append(actions);
} else {
const actions = document.createElement("div");
actions.className = "actions";
const close = document.createElement("button");
close.type = "button";
close.className = "primary";
close.textContent = "Close";
close.textContent = tx(currentLocale, "Close", "关闭");
close.addEventListener("click", () => void closeCurrentTab());
actions.append(close);
card.append(actions);
Expand All @@ -96,30 +158,42 @@ async function loadPending() {
const stored = await browser.storage.local.get(LOCAL_HEALTH_PENDING_KEY);
const value = stored[LOCAL_HEALTH_PENDING_KEY];
pending = value && typeof value === "object" && !Array.isArray(value)
? value as PendingLocalHealthPermission
? (value as PendingLocalHealthPermission)
: null;
render();
}

async function grantPending() {
if (!pending || busy) return;
const targetPattern = pending.pattern;
busy = true;
message = null;
error = null;
render();
try {
const granted = await browser.permissions.request({ origins: [pending.pattern] });
// Keep permissions.request synchronous from the click gesture with no await before it.
const granted = await browser.permissions.request({ origins: [targetPattern] });
if (!granted) {
error = "The browser did not grant this host permission.";
error = tx(
currentLocale,
"The browser did not grant this host permission.",
"浏览器未授予此主机权限。",
);
return;
}
await browser.storage.local.remove(LOCAL_HEALTH_PENDING_KEY);
await browser.runtime.sendMessage({ type: "dockmark:local-health-permission-updated" }).catch(() => undefined);
pending = null;
message = "Host access granted. Return to Dockmark and run Check locally again.";
message = tx(
currentLocale,
"Host access granted. Return to Dockmark and run Check locally again.",
"已授予主机访问权限。请返回 Dockmark 重新运行本地检查。",
);
window.setTimeout(() => void closeCurrentTab(), 900);
} catch (caught) {
error = caught instanceof Error ? caught.message : "Could not grant host permission.";
error = caught instanceof Error
? caught.message
: tx(currentLocale, "Could not grant host permission.", "无法授予主机权限。");
} finally {
busy = false;
render();
Expand All @@ -130,16 +204,29 @@ async function cancelPending() {
if (busy) return;
await browser.storage.local.remove(LOCAL_HEALTH_PENDING_KEY);
pending = null;
message = "Request cancelled.";
message = tx(currentLocale, "Request cancelled.", "已取消授权请求。");
render();
window.setTimeout(() => void closeCurrentTab(), 350);
}

subscribeExtensionPreferences({
onLocale: (_pref, locale) => {
currentLocale = locale;
render();
},
});

browser.storage.onChanged.addListener((changes, areaName) => {
if (areaName === "local" && changes[LOCAL_HEALTH_PENDING_KEY]) void loadPending();
});

void loadPending().catch((caught) => {
error = caught instanceof Error ? caught.message : "Could not load the pending host permission.";
void (async () => {
const hydrated = await hydrateExtensionPreferences();
currentLocale = hydrated.locale;
await loadPending();
})().catch((caught) => {
error = caught instanceof Error
? caught.message
: tx(currentLocale, "Could not load the pending host permission.", "无法加载待授权的主机权限。");
render();
});
Loading
Loading