Repository navigation
Add A/时差保安 (timezone-guard): a two-clock verdict panel for the other time zone - #61
Conversation
MyPrototypeWhat
left a comment
There was a problem hiding this comment.
感谢提交 A/时差保安!已在 dbd4cb82e85355f6359bdef521bfd86e6d78d997 上完整审阅。
结论:无阻塞问题,可以合并;下面几条建议可酌情处理。
已核对
- 红线:Node 端只是一个静态资源服务器(GET/HEAD + 白名单 4 个文件,路径取 basename,不能穿越目录),不读登录凭据、宿主数据库或其他插件数据;没有 fetch/XHR/WebSocket/sendBeacon/外部 URL,也没有遥测,和 README 里「纯本地」的说法一致。偏好只写在本页
localStorage(timezone-guard.prefs.v1)。 - 清单:
surface.window声明正确;README 的 Tested environment 写明了需要 MiniMax Code 3.1.2 或更高版本,node scripts/validate.mjs结果是plugins/liuchen19960902/timezone-guard: OK,repository 也是 OK。 - 测试:仓库测试 69/69 通过。
- 时区逻辑:偏移量用 Intl
longOffset实时计算,所以 DST 切换、+05:30 / +05:45 / +12:45 这类非整小时时区都正确;bandOf的边界是 [09:00,18:00) 绿、[06:00,09:00) 和 [18:00,22:00) 黄、[22:00,06:00) 红,06:00/09:00/18:00/22:00 这几个整点归属正确;跨日用日历日差判断「昨天 / 明天」;偏移相同但时区不同(例如洛杉矶 vs 凤凰城)不会说成「同一时区」,这点处理得很好。 - 其他:MIT LICENSE、icon 256×256、中英文 README 都齐了;改动范围只有本插件目录,加上两个根目录 README 各新增一行插件条目。
建议(非阻塞)
plugin.json的description写的是「别在对方睡着的时区跟 Claude 聊天」。这是 MiniMax Code 的插件,提到其他厂商的产品名容易让人误解,建议改成「跟对方聊天 / 发消息」这类中性说法。bandOf、parseOffset、formatDiff、dayDelta都是纯函数,建议抽出来加几条node --test(整点边界、GMT+05:45、GMT、跨日),防止以后改动时回归。displayName、判定文案、日期格式目前都只有中文,英文用户看到的界面也是中文。如果暂时不做界面 i18n,可以在英文 README 里写一句「界面仅中文」。index.html里有两段内联脚本重复读取localStorage和解析时区(第 16、212 行附近),和app.js的逻辑有重复,可以考虑合并,避免以后两处行为不一致。
| "name": "timezone-guard", | ||
| "displayName": "A/时差保安", | ||
| "version": "1.0.0", | ||
| "description": "别在对方睡着的时区跟 Claude 聊天。A/时差保安实时对照对方当地时间:绿了正常聊,黄了短聊,红了先睡。", |
There was a problem hiding this comment.
建议(非阻塞):这是 MiniMax Code 的插件,描述里提到「跟 Claude 聊天」容易让人误解,建议换成「跟对方聊天 / 发消息」这类中性说法。
| } | ||
|
|
||
| /** 固定阈值判定:绿 09–18、黄 18–22、红 22–06,清晨 06–09 归黄。 */ | ||
| function bandOf(hour, minute) { |
There was a problem hiding this comment.
边界逻辑核对过了,没有问题([9,18) 绿、[6,9) 和 [18,22) 黄、其余红)。建议把 bandOf / parseOffset / dayDelta 抽出来,补几条 node --test,覆盖整点边界、+05:45 和跨日。
The preview captions claimed the target clock read 19:49, but the screenshot actually shows 20:23 (08:23 晚上 in the 12-hour Chinese format). Both READMEs now say 20:23. Version 1.0.0 -> 1.0.1, because the package content changed after the pull request was opened.
|
感谢 review,4 条建议都处理了,集中在 1. 2. 抽纯函数 + 补单测 —— 时区计算整体搬到新的 单测随包分发在 3. 界面只有中文 —— 两份 README 开头都加了一句:插件名、判定文案、城市名、时段、日期格式都是中文,页面没有语言切换,README 提供中英两份。 4. 两段内联脚本与
实测过:同城时标题只显示一个城市、⇄ 隐藏;同名但不同区(洛杉矶 vs 凤凰城)箭头保留;存档损坏时页面照常渲染不炸。 连带改动:静态文件从 4 个变成 5 个(多了 验证情况: |
|
更正一下我上一条评论。 #61 已经在 14:19 合并了(合并的是 修复已改到新的 PR,基于当前 内容与上一条评论说的一致(中性 description、抽出 仓库 |
* Address the review: neutral description, shared time module, unit tests, Chinese-only note - plugin.json: the description no longer names another vendor product. - The time calculations (resolveZone / bandOf / parseOffset / formatDiff / dayDelta / periodOf) move to miniapp/client/time.js, which the browser and Node run as the same file. That makes them unit-testable, and it gives index.html and app.js one single implementation of "is this the same city" instead of two that could drift apart. - The package ships test/time.test.mjs; the repository CI runs it through test/timezone-guard.test.mjs. - Both READMEs now state that the interface is Chinese only. Five static files are served now instead of four, so the Data & access sections and the PR description are updated to match. Version 1.0.1 -> 1.0.2. * Reword the description to the neutral phrasing from the review The previous revision replaced the vendor name with a bare "克", which read as an unfinished sentence next to the "对方" used later in the same line. It now says "跟对方聊天", matching what the review asked for. * Keep the plugin tests in the plugin, and stop formatting in the pure helper Review follow-up, three items: - Remove the root test/timezone-guard.test.mjs forwarder. The repository suite enforces the repo-wide Mini App rules; plugin-specific tests stay with the plugin. The root test/ directory is now identical to main again. - Run the package tests with bare `node --test` instead of a glob. On Node 20 the glob form fails because --test gained glob support only in 21; the suggested `node --test test/` fails on Node 22+ with MODULE_NOT_FOUND because a bare directory is no longer accepted as a positional argument. The no-argument form auto-discovers and needs no version-specific syntax. - formatDiff now returns plain text. The leading space moved to app.js, where the strings are actually joined: the whole-hour form carries its own "约", non-integral offsets get a space. The tests no longer hard-code padding; they assert no padding at all. --------- Co-authored-by: FineCat <LiuChen19960902@users.noreply.github.com>
A/时差保安 · Timezone Guard
A two-clock verdict panel for the other time zone. Before you message someone across the date
line, it shows their local clock next to yours and turns it into one answer: talk normally,
keep it short, or go to sleep.
The verdict reads the target city's local time, not yours — it is their convenience that
matters, and your own city is shown only for reference. The thresholds are the same for every
city: day 09:00–18:00, evening 18:00–22:00, early morning 06:00–09:00 (both yellow), night
22:00–06:00.
What is in the package
own — text and shape do too.
horizon, or a moon. The current hour is filled with the verdict colour, and the four thresholds
land exactly on cell boundaries.
of advice", plus an optional note about your own hours when your side sits in a later band. No
message templates, no copy button, and nothing is pushed into a chat box.
them in one click — a real
<button>, so it works with a mouse and with Enter / Space.package (418 on the tested runtime; a zone newer than the bundled table falls back to its English
name), plus country-level entries such as "中国(默认)".
No network, no account, no push, no calendar. No third-party runtime dependencies: the Node
side uses built-in modules only, the page uses native APIs only. Times and offsets come from the
browser's
Intland the runtime's own time zone database, so daylight saving time is handled foryou.
The interface is Chinese only — plugin name, verdict, city names, time periods and date format
are all Chinese, and the page has no language switch. The README ships in English and 简体中文.
Tested environment
through the Agent, page rendered in the side panel.
surface.window(the size of thepopped-out window), so older clients cannot install it at all.
1100 / 1440 CSS pixels wide: no horizontal overflow, no double scrollbar, no stray whitespace
under the card.
npm run checkreports no errors and no warnings for this package.npm run validatereportsrepository: OKwith 12 warnings that all belong toother packages and pre-date this PR:
README_HEADING_MISSINGinamszuidas/mcode-token-usage-boardandyanhy2000/mcode-usage-monitor,README_MIN_VERSION_MISSINGinyujiachen-y/xinyu-dailyandzch0227/anatomy-gallery, andENTRY_STDOUTinwebguhui/minimax-photoandwebguhui/minimax-video. None of them is in afile this PR touches.
Not verified: macOS and Linux; popping the page out into its own window (
surface.window) wasnever exercised. The page is a single responsive column either way.
Data & access
Reads only the five static files inside its own package directory:
index.html,styles.css,cities.js,time.js,app.js. Writes no files and does not usecontext.dataDir. Makes nonetwork request. Spawns no process. Declares no
agentAccessand starts no Agent turn. Thebrowser's
localStorageholds interface preferences only, undertimezone-guard.prefs.v1.Notes for reviewers
timezone-guardis unique across the repository.icon.pngis a purpose-drawn 256×256 icon, not the placeholder fromexamples/hello-miniapp/.miniapp/client/time.js, and the browser and Node run the samefile — there is no second copy to keep in sync. Unit tests ship with the package
(
test/time.test.mjs,npm testin the package directory) and the repository's CI picks themup through
test/timezone-guard.test.mjs. They cover the band thresholds landing exactly on thehour, offset parsing including non-integral zones such as
GMT+05:45, the time-differencewording, and the calendar-day difference behind "still yesterday".