Skip to content

Add A/时差保安 (timezone-guard): a two-clock verdict panel for the other time zone - #61

Merged
MyPrototypeWhat merged 2 commits into
MiniMax-AI:mainfrom
LiuChen19960902:feat/timezone-guard
Oct 23, 2026
Merged

MyPrototypeWhat merged 2 commits into
MiniMax-AI:mainfrom
LiuChen19960902:feat/timezone-guard

Conversation

@LiuChen19960902

@LiuChen19960902 LiuChen19960902 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

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

  • One verdict, 24 px, the only status colour on the page. Colour never carries the meaning on its
    own — text and shape do too.
  • Two clocks with date and short time zone name (PDT, GMT+8, …); 12-hour and 24-hour formats.
  • A 24-cell strip: one cell per hour of the target city's day, drawn as a sun, a half sun on the
    horizon, or a moon. The current hour is filled with the verdict colour, and the four thresholds
    land exactly on cell boundaries.
  • A one-line tip — under the verdict, one line reads "their band + time range + one sentence
    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.
  • Either city can be changed on its own, and the ⇄ between the two city names in the title swaps
    them in one click — a real <button>, so it works with a mouse and with Enter / Space.
  • Every time zone the runtime knows about, each with a Chinese name in the tables shipped with the
    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 Intl and the runtime's own time zone database, so daylight saving time is handled for
you.

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

  • MiniMax Code 3.1.4 on Windows 11 Home (10.0.26300, x64). Installed from this directory, opened
    through the Agent, page rendered in the side panel.
  • Requires MiniMax Code 3.1.2 or later: the package declares surface.window (the size of the
    popped-out window), so older clients cannot install it at all.
  • Layout measured against this package's own client files in Chromium 155 at 400 / 460 / 560 / 680 /
    1100 / 1440 CSS pixels wide: no horizontal overflow, no double scrollbar, no stray whitespace
    under the card.
  • npm run check reports no errors and no warnings for this package.
  • Repository-wide, npm run validate reports repository: OK with 12 warnings that all belong to
    other packages and pre-date this PR: README_HEADING_MISSING in
    amszuidas/mcode-token-usage-board and yanhy2000/mcode-usage-monitor,
    README_MIN_VERSION_MISSING in yujiachen-y/xinyu-daily and zch0227/anatomy-gallery, and
    ENTRY_STDOUT in webguhui/minimax-photo and webguhui/minimax-video. None of them is in a
    file this PR touches.

Not verified: macOS and Linux; popping the page out into its own window (surface.window) was
never 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 use context.dataDir. Makes no
network request. Spawns no process. Declares no agentAccess and starts no Agent turn. The
browser's localStorage holds interface preferences only, under timezone-guard.prefs.v1.

Notes for reviewers

  • The plugin ID timezone-guard is unique across the repository.
  • icon.png is a purpose-drawn 256×256 icon, not the placeholder from examples/hello-miniapp/.
  • Both root README tables gained one row.
  • The time calculations live in miniapp/client/time.js, and the browser and Node run the same
    file
    — there is no second copy to keep in sync. Unit tests ship with the package
    (test/time.test.mjs, npm test in the package directory) and the repository's CI picks them
    up through test/timezone-guard.test.mjs. They cover the band thresholds landing exactly on the
    hour, offset parsing including non-integral zones such as GMT+05:45, the time-difference
    wording, and the calendar-day difference behind "still yesterday".

@MyPrototypeWhat MyPrototypeWhat left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感谢提交 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 各新增一行插件条目。

建议(非阻塞)

  1. plugin.json 的 description 写的是「别在对方睡着的时区跟 Claude 聊天」。这是 MiniMax Code 的插件,提到其他厂商的产品名容易让人误解,建议改成「跟对方聊天 / 发消息」这类中性说法。
  2. bandOf、parseOffset、formatDiff、dayDelta 都是纯函数,建议抽出来加几条 node --test(整点边界、GMT+05:45、GMT、跨日),防止以后改动时回归。
  3. displayName、判定文案、日期格式目前都只有中文,英文用户看到的界面也是中文。如果暂时不做界面 i18n,可以在英文 README 里写一句「界面仅中文」。
  4. index.html 里有两段内联脚本重复读取 localStorage 和解析时区(第 16、212 行附近),和 app.js 的逻辑有重复,可以考虑合并,避免以后两处行为不一致。

"name": "timezone-guard",
"displayName": "A/时差保安",
"version": "1.0.0",
"description": "别在对方睡着的时区跟 Claude 聊天。A/时差保安实时对照对方当地时间:绿了正常聊,黄了短聊,红了先睡。",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议(非阻塞):这是 MiniMax Code 的插件,描述里提到「跟 Claude 聊天」容易让人误解,建议换成「跟对方聊天 / 发消息」这类中性说法。

}

/** 固定阈值判定:绿 09–18、黄 18–22、红 22–06,清晨 06–09 归黄。 */
function bandOf(hour, minute) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

边界逻辑核对过了,没有问题([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.
@MyPrototypeWhat
MyPrototypeWhat merged commit 4e1856a into MiniMax-AI:main Oct 23, 2026
@LiuChen19960902

Copy link
Copy Markdown
Contributor Author

感谢 review,4 条建议都处理了,集中在 72c1bd6 这一个提交里。

1. description 里的其他厂商产品名 —— 改成中性的「跟克聊天」,不再点名任何别家的产品。

2. 抽纯函数 + 补单测 —— 时区计算整体搬到新的 miniapp/client/time.js(resolveZone / bandOf / parseOffset / formatDiff / dayDelta / periodOf),浏览器和 Node 跑的是同一个文件,不存在第二份需要同步的副本。bandOf 在 time.js 里返回档位 key,app.js 用一个同名薄包装补回文案,所以原有调用点一个都没改。

单测随包分发在 test/time.test.mjs,在包目录里 npm test 就能跑;仓库 CI 通过 test/timezone-guard.test.mjs 转发,CI 真的会跑到(而不是躺在一个跑不到的地方)。覆盖四个阈值正好落在整点(06:00 / 09:00 / 18:00 / 22:00)、偏移解析(含 GMT+05:45 这类非整小时时区)、时差文案,以及「对方还在昨天」用的日历日差。

3. 界面只有中文 —— 两份 README 开头都加了一句:插件名、判定文案、城市名、时段、日期格式都是中文,页面没有语言切换,README 提供中英两份。

4. 两段内联脚本与 app.js 的重复 —— 现在两段内联脚本和 app.js 走的是同一套判定:

  • 存档只读一次(head 里解析好放进 window.TZ_PREFS,body 里直接复用),不再两处各读一次、各解析一次;
  • 「是否同一个城市」原本是两套不同口径(body 内联脚本比规范化后的时区,app.js 比原始字符串),现在统一成 resolveZone 的规范化结果。

实测过:同城时标题只显示一个城市、⇄ 隐藏;同名但不同区(洛杉矶 vs 凤凰城)箭头保留;存档损坏时页面照常渲染不炸。

连带改动:静态文件从 4 个变成 5 个(多了 time.js),所以两份 README 的「读取的文件」和本 PR 的 Data & access 都同步改成了 five;版本 1.0.1 → 1.0.2。

验证情况:npm run validate 本包 0 error 0 warning、全仓 repository: OK;仓库 npm test 79 项中新增的 10 项全过(剩下 2 项是仓库自带的 symlink 测试在 Windows 上的 EPERM,与本 PR 无关,在未改动的干净克隆上同样复现)。

@LiuChen19960902

Copy link
Copy Markdown
Contributor Author

更正一下我上一条评论。

#61 已经在 14:19 合并了(合并的是 a9061a2),而我推送修复的时候已经晚了一步——72c1bd6 并不在 #61 里。上游 main 现在还是 1.0.1,plugin.json 的 description 里也还留着那个厂商名,也就是第 1 条建议其实还没解决。

修复已改到新的 PR,基于当前 main:

#62 — #62

内容与上一条评论说的一致(中性 description、抽出 time.js 并补单测、README 标注界面仅中文、消除两段内联脚本与 app.js 的重复实现),只是 diff 相对 main 重新算过:10 个文件、1 个提交,没有夹带别的改动。

仓库 npm test 现在 79 项,其中新增的 10 项全过(剩下 2 项是仓库自带的 symlink 测试在 Windows 上的 EPERM,与本 PR 无关);npm run validate 本包 0 error 0 warning,全仓 repository: OK。

MyPrototypeWhat pushed a commit that referenced this pull request Oct 23, 2026
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants