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
17 changes: 12 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,14 @@ jobs:
fi
echo "VERSION=$GOT" >> "$GITHUB_ENV"

- name: A published release has an English summary
if: github.ref_type == 'tag'
run: |
if [ ! -f "release-notes/$VERSION.md" ]; then
echo "缺少英文发布说明:release-notes/$VERSION.md" >&2
exit 1
fi

# 清单向 GitHub 要:和它在发布页上「自动生成」的是同一份。演练时这个 tag
# 可能还不存在,那就算到这次的 commit 为止(tag 存在时 target_commitish 不起作用)
- name: Write it
Expand Down Expand Up @@ -790,9 +798,8 @@ jobs:

- run: echo "VERSION=${GITHUB_REF_NAME#v}" >> "$GITHUB_ENV"

# tag 上那段话写进 latest.json,是给已经装上的应用的发布说明(2026.9.13
# 之前的版本在更新窗口里显示它)—— 自动生成的提交清单在那个位置对用户
# 没有意义。发布页上的正文是另一份,见 `release-body`。
# tag 注解给应用的更新窗口提供中文说明。manifest.py 也会从
# release-notes/<版本>.md 读出英文摘要,供英文界面使用。
#
# **不从工作区的 git 里读。**`actions/checkout` 取 tag 时建的是一个
# 直接指向 commit 的轻量引用,注解对象根本不在这个克隆里;
Expand All @@ -806,7 +813,7 @@ jobs:
set -euo pipefail
: > notes.txt
REF="repos/$GITHUB_REPOSITORY/git/ref/tags/$GITHUB_REF_NAME"
# 轻量 tag 指向的是 commit,没有正文可取 —— 那就不写发布说明。
# 轻量 tag 取不到注解,manifest.py 会报缺少中文发布说明。
if [ "$(gh api "$REF" --jq .object.type)" = tag ]; then
SHA=$(gh api "$REF" --jq .object.sha)
gh api "repos/$GITHUB_REPOSITORY/git/tags/$SHA" --jq .message \
Expand All @@ -825,7 +832,7 @@ jobs:
- name: One manifest for every platform
run: |
set -euo pipefail
python3 scripts/manifest.py "$VERSION" notes.txt \
python3 -B scripts/manifest.py "$VERSION" notes.txt \
"darwin-aarch64=dist/ThinkWatch-Lite-$VERSION-darwin-arm64.dmg" \
"windows-x86_64=dist/ThinkWatch-Lite-$VERSION-windows-x64-setup.exe" \
"windows-aarch64=dist/ThinkWatch-Lite-$VERSION-windows-arm64-setup.exe" \
Expand Down
50 changes: 28 additions & 22 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,14 @@ Warnings are errors. The toolchain is `stable`, so a newer stable than
your local one can surface lints you cannot see — `rustup update stable`
before blaming CI.

## Translating protection rules

When updating the Core pin, update `src/i18n/guard.zh.json` for any
added or changed security rules. Use the guard and rule ID for a rule,
or the guard and slug for a group. The security UI, messages and native
notifications share this catalog. Core supplies the English fallback,
and prefix descriptions are rendered from the live matcher.

## Things this UI must not do

These are load-bearing and a PR that breaks one will be asked to change:
Expand Down Expand Up @@ -201,28 +209,26 @@ change to `release.yml`, push the branch as `rehearse/<name>`: every job
runs and the installers are kept as the run's artifacts, but nothing is
published.

A release has two texts:

- **The tag message.** Its first line is `ThinkWatch Lite <version>`; the
rest becomes the `notes` of `latest.json`, the manifest for in-app
updates. It is not shown on the release page.
- **The release page**, titled `ThinkWatch Lite <version>` and written in
English by `scripts/release_notes.py`, in this order:
1. `release-notes/<version>.md`, when that file exists: a summary of the
release in paragraphs or lists, without a top-level heading. Add it in
the pull request that bumps the version, because the tag fixes what
the tree contains.
2. A table of the file for each platform, and the Homebrew and Linux
install commands.
3. How to verify a download against its `.sha256`.
4. GitHub's list of the pull requests merged since the previous release.

The text is written when the release is created. A release that already
exists keeps its text, so a correction after publishing is made on the
release page itself. CI runs `python3 scripts/release_notes_test.py`,
which checks the script against `release.yml` and renders every file in
`release-notes/`; a rehearsal shows the complete text in the summary of
its run.
Each published release needs two Markdown summaries for the in-app update window.

- Write the **Chinese summary** in the annotated tag message after the
`ThinkWatch Lite <version>` title and a blank line. It becomes `notes`
in `latest.json`.
- Add the **English summary** at `release-notes/<version>.md` in the pull
request that bumps the version. Use paragraphs or lists and start any
headings at level two. It becomes `notes_en` in `latest.json` and the
first section of the GitHub release page.

The release page is titled `ThinkWatch Lite <version>` and generated by
`scripts/release_notes.py`. After the English summary, it lists the
downloads and install commands, explains how to verify the downloads,
and includes GitHub's list of pull requests merged since the previous release.

The text is written when the release is created. To correct it after
publication, edit the release page directly. CI runs
`python3 scripts/release_notes_test.py` to check the release scripts and
every file in `release-notes/`. A rehearsal shows the release page text
in the run summary and can run before the English summary is written.

## Product screenshots

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "thinkwatch-lite",
"private": true,
"description": "Desktop app for a local AI API gateway on macOS, Windows and Linux",
"version": "2026.11.20",
"version": "2026.11.22",
"type": "module",
"packageManager": "pnpm@11.13.1",
"scripts": {
Expand Down
2 changes: 2 additions & 0 deletions release-notes/2026.11.22.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Added Japanese, Traditional Chinese, Korean, and Spanish to the app. ThinkWatch Lite follows the system's preferred language at startup. You can also switch languages in Settings.
- The update window now shows release notes when available, with support for Markdown, wrapping, and scrolling. Chinese interfaces show the Chinese summary, and other interfaces show the English summary.
27 changes: 22 additions & 5 deletions scripts/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
Linux 上只发 AppImage,它原地换掉自己(见 `src-tauri/src/update.rs`);
`scripts/install.sh` 也从这一份里找本架构的 AppImage。

用法:manifest.py <版本> <发布说明文件> <平台>=<文件> [<平台>=<文件> ...]
用法:manifest.py <版本> <中文发布说明文件> <平台>=<文件> [<平台>=<文件> ...]

中文说明沿用 Tauri 的 notes 字段;英文说明取 release-notes/<版本>.md,写在 notes_en。

清单里的 URL 必须和最终挂在 release 上的文件名一字不差,所以文件名不在
这里拼:文件的路径由调用方传进来,URL 用的就是它的名字。两处各拼一遍的
Expand All @@ -26,6 +28,8 @@
import pathlib
import sys

from release_notes import NOTES_DIR, NotesError, summary

REPO = "ThinkWatchProject/ThinkWatch-Lite"
# 平台键由更新器自己拼:目标系统 + 架构(macOS 上叫 darwin)。**只收这几个**
# —— 拼错一个字母,那个平台的用户就永远问不到新版本,而清单看起来完好。
Expand Down Expand Up @@ -88,10 +92,25 @@ def entry(path: pathlib.Path, version: str, want: bytes) -> dict:
}


def update_notes(version: str, chinese_file: pathlib.Path, notes_dir: pathlib.Path = NOTES_DIR) -> dict[str, str]:
"""老版本仍从 notes 读中文,新版本按语言读对应的一份。"""
chinese = chinese_file.read_text(encoding="utf-8").strip()
if not chinese:
raise NotesError(f"v{version} 的 tag 注解缺少中文发布说明:在标题和空行之后填写正文")
english = summary(version, notes_dir)
if english is None:
raise NotesError(f"缺少英文发布说明:release-notes/{version}.md")
return {"notes": chinese, "notes_en": english}


def main() -> None:
if len(sys.argv) < 4:
sys.exit("用法:manifest.py <版本> <发布说明文件> <平台>=<文件> [...]")
sys.exit("用法:manifest.py <版本> <中文发布说明文件> <平台>=<文件> [...]")
version, notes_file, pairs = sys.argv[1], sys.argv[2], sys.argv[3:]
try:
notes = update_notes(version, pathlib.Path(notes_file))
except NotesError as e:
sys.exit(str(e))

root = pathlib.Path(__file__).resolve().parent.parent
conf = json.loads((root / "src-tauri/tauri.conf.json").read_text(encoding="utf-8"))
Expand Down Expand Up @@ -121,10 +140,8 @@ def main() -> None:
.isoformat()
.replace("+00:00", "Z"),
"platforms": platforms,
**notes,
}
notes = pathlib.Path(notes_file).read_text(encoding="utf-8").strip()
if notes:
manifest["notes"] = notes

out = pathlib.Path(pairs[0].partition("=")[2]).parent / "latest.json"
out.write_text(json.dumps(manifest, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
Expand Down
8 changes: 4 additions & 4 deletions scripts/release_notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

正文是英文的,依次是:

1. `release-notes/<版本>.md`:这一版的说明。**可以没有**,没有就从下载表开始。
1. `release-notes/<版本>.md`:这一版的英文说明。正式发版时必须提供,演练时可省略。
2. 下载表:每个文件一行(Windows 每个架构两行:安装程序、绿色版 zip),文件名和
release.yml 挂上去的一字不差;再给 Homebrew 和 Linux 安装脚本的命令、绿色版的
用法。
Expand All @@ -14,8 +14,8 @@
调用方用 `gh api repos/<仓库>/releases/generate-notes` 取来。拆成参数传进来,
这个脚本就不碰网络,测试可以直接喂它。

**tag 的注解不在这里。**那段中文写进 latest.json(见 manifest.py),是给已经装上
的应用的;发布页面向从网页来下载的人。
应用的英文更新说明也取这份摘要。tag 注解里的中文说明和英文摘要一起写进
latest.json(见 manifest.py)。

说明文件写坏了(有中文、有一级标题、是空的)就不写正文 —— 发版流水线在这一步
停下,比发出去再改好。CI 在每个 PR 上把 `release-notes/` 下的每一份都过一遍
Expand Down Expand Up @@ -68,7 +68,7 @@ def summary(version: str, notes_dir: pathlib.Path = NOTES_DIR) -> str | None:
text = path.read_text(encoding="utf-8").strip()
name = f"release-notes/{path.name}"
if not text:
raise NotesError(f"{name} 是空的:没有要说的就删掉这个文件")
raise NotesError(f"{name} 是空的:请填写英文发布说明")
for n, line in enumerate(text.splitlines(), 1):
if CJK.search(line):
raise NotesError(
Expand Down
21 changes: 21 additions & 0 deletions scripts/release_notes_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,27 @@ def test_the_portable_build_has_its_own_keys(self):
self.assertEqual(manifest.PLATFORMS["windows-x86_64-portable"], "-windows-x64-portable.zip")
self.assertEqual(manifest.PLATFORMS["windows-aarch64-portable"], "-windows-arm64-portable.zip")

def test_update_notes_keep_the_legacy_field_and_add_english(self):
d = notes_dir(self, {
"tag.txt": " \n- 修复路由\n",
"2026.9.16.md": "\n- Fixed routing\n",
})
self.assertEqual(
manifest.update_notes("2026.9.16", d / "tag.txt", d),
{"notes": "- 修复路由", "notes_en": "- Fixed routing"},
)

def test_publishing_requires_both_summaries_for_the_same_release(self):
d = notes_dir(self, {
"tag.txt": "修复路由",
"empty-tag.txt": "\n ",
"2026.9.15.md": "Previous release",
})
with self.assertRaisesRegex(rn.NotesError, r"release-notes/2026\.9\.16\.md"):
manifest.update_notes("2026.9.16", d / "tag.txt", d)
with self.assertRaisesRegex(rn.NotesError, "缺少中文发布说明"):
manifest.update_notes("2026.9.15", d / "empty-tag.txt", d)


class Summary(unittest.TestCase):
def test_absent_is_none(self):
Expand Down
6 changes: 4 additions & 2 deletions scripts/shots/boot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@
// 文案写成「这台电脑」。所以这里不 import 任何东西。

const q = new URLSearchParams(location.search);
const lang = q.get("lang") === "en" ? "en" : "zh";
const wanted = q.get("lang");
export const lang = wanted === "en" || wanted === "ja" || wanted === "zh-Hant" || wanted === "ko" || wanted === "es"
? wanted : "zh";

window.__TW_LANG__ = lang;
window.__TW_PLATFORM__ = "macos";
// `__TW_VIBRANT__` 故意不设:真应用的侧栏是系统的半透材质,由窗口服务器画,离屏拍不到。
// 不设它,侧栏按实色画,和别的平台一样
// 热启动:core 已经在跑,窗口取好首屏的数才露面,没有启动画面
(window as { __TW_WARM__?: boolean }).__TW_WARM__ = true;
document.documentElement.lang = lang === "en" ? "en" : "zh-CN";
document.documentElement.lang = lang === "zh" ? "zh-CN" : lang;

/**
* 定住的时钟:2026-09-25(周五)16:42:07,**本地时间**。
Expand Down
2 changes: 1 addition & 1 deletion scripts/shots/mock/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import REQUESTS from "../core/requests.json";
import { P } from "./params";
import { HOUR, MIN, NOW, clone, msg } from "./util";

const en = P.lang === "en";
const en = P.lang !== "zh" && P.lang !== "zh-Hant";

/** 一个类型「放宽」之后的样子:`"free" | "per-token"` 这类取值放宽成 string,结构不变 */
type Widen<T> = T extends string
Expand Down
3 changes: 2 additions & 1 deletion scripts/shots/mock/params.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// 这一张图是哪个场景、哪种语言。mock 的数据按它摆(连着远程时列表里当前的是哪一条……)
import { sceneOf } from "../scenes";
import { lang } from "../boot";

const q = new URLSearchParams(location.search);

export const P = {
scene: sceneOf(q.get("scene")),
lang: (q.get("lang") === "en" ? "en" : "zh") as "zh" | "en",
lang,
/** 打开哪一页 */
page: sceneOf(q.get("scene"))?.page ?? null,
/** 连着远程 core(`homelab`) */
Expand Down
2 changes: 1 addition & 1 deletion scripts/shots/mock/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function rng(seed: number) {
export const msg = (code: string, text: string, args: Record<string, string> = {}): Msg => ({ code, args, text });

/** 本来就是一句话的示例数据(用户起的名字、对话内容):按界面语言二选一 */
export const L = <A>(zh: A, en: A): A => (P.lang === "en" ? en : zh);
export const L = <A>(zh: A, en: A): A => (P.lang === "zh" || P.lang === "zh-Hant" ? zh : en);

export const clone = <T>(x: T): T => structuredClone(x);

Expand Down
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "thinkwatch-lite"
version = "2026.11.20"
version = "2026.11.22"
edition = "2024"
# **这个数决定依赖能升到哪一版。**edition 2024 的解析器只挑声明的 Rust
# 版本编得动的依赖:写 1.85 的时候,`cargo update` 一直停在旧的 time 和
Expand Down
15 changes: 10 additions & 5 deletions src-tauri/src/autostart/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,15 @@ impl Autostart {
format!("路径中含有 % 时无法开机启动:{program}。请将应用移到不含 % 的目录。"),
format!(
"Launch at login does not work when the path contains %: {program}. Move the app to a directory without % in its path."
)
);
format!("路徑中含有 % 時無法開機啟動:{program}。請將應用移到不含 % 的目錄。"),
)));
}
if self.file.as_os_str().is_empty() || !self.file.is_absolute() {
return Err(io::Error::other(tr!(
"未能确定自启目录(HOME 未设置)",
"The autostart directory could not be determined (HOME is not set)"
"The autostart directory could not be determined (HOME is not set)";
"未能確定自啟目錄(HOME 未設定)",
)));
}
let dir = self.file.parent().expect("the entry is inside a directory");
Expand All @@ -94,7 +96,8 @@ impl Autostart {
e.kind(),
tr!(
format!("无法创建目录 {}:{e}", dir.display()),
format!("The directory {} could not be created: {e}", dir.display())
format!("The directory {} could not be created: {e}", dir.display());
format!("無法建立目錄 {}:{e}", dir.display()),
),
)
})?;
Expand Down Expand Up @@ -189,7 +192,8 @@ fn program(
.ok_or_else(|| {
tr!(
"未能确定应用程序的位置",
"The location of the application could not be determined"
"The location of the application could not be determined";
"未能確定應用程式的位置",
)
.to_string()
})?;
Expand All @@ -199,7 +203,8 @@ fn program(
format!(
"The application path is not valid UTF-8: {}",
p.to_string_lossy()
)
);
format!("應用程式路徑不是有效的 UTF-8:{}", p.to_string_lossy()),
)
})
}
Expand Down
9 changes: 6 additions & 3 deletions src-tauri/src/chatgpt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ fn pending(id: &str, get: impl Fn(&Pending) -> Option<String>) -> Result<String,
.ok_or_else(|| {
tr!(
"这次登录已经结束,请重新发起",
"This sign-in has ended; start a new one"
"This sign-in has ended; start a new one";
"這次登入已經結束,請重新發起",
)
.to_string()
})
Expand All @@ -150,14 +151,16 @@ pub(crate) fn open_page(app: &tauri::AppHandle, url: &str) -> Result<(), String>
if !is_web_page(url) {
return Err(tr!(
format!("登录页地址不是 https 网页:{url}"),
format!("The sign-in address is not an https web page: {url}")
format!("The sign-in address is not an https web page: {url}");
format!("登入頁地址不是 https 網頁:{url}"),
)
.to_string());
}
app.opener().open_url(url, None::<&str>).map_err(|e| {
tr!(
format!("无法打开浏览器:{e}"),
format!("The browser could not be opened: {e}")
format!("The browser could not be opened: {e}");
format!("無法開啟瀏覽器:{e}"),
)
})
}
Expand Down
3 changes: 2 additions & 1 deletion src-tauri/src/cleanup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ fn run(req: &Request) -> Vec<UninstallStep> {
format!("未能确定程序位置,注册项未清理({e})"),
format!(
"The program location could not be determined, so its registry entries were left in place ({e})"
)
);
format!("未能確定程式位置,註冊項未清理({e})"),
))),
}
// 卸载程序接着要删 twcore.exe,数据目录也要等它放手:不等它走,那个文件删不掉、
Expand Down
Loading
Loading