Repository navigation
Conversation
…ditor A rule can now be limited to time windows of the gateway machine's local clock: the new condition kind "Time" in the rule editor has seven weekday toggles (Monday first, all on by default) and a start and end time (09:00–18:00 by default), and each window becomes one value in core's grammar (`mon-fri 09:00-18:00`, `sat,sun 00:00-24:00`, `22:00-06:00`). Several windows are several values, matched like the other multi-value conditions. Values written by hand are parsed back into the editor; one that does not parse is shown as raw text that can still be edited or removed. The editor keeps its rows as its own state and derives the values from them, rather than re-parsing on every change: a half-typed time would otherwise fail to parse and turn the row into the raw fallback mid-edit. A row with no day selected or an unparseable time writes a value that does not parse on purpose, so the save button reports it instead of silently meaning "every day". Wherever conditions are summarised (route rules, dry-run mismatches) the value reads as a sentence: 周一至周五 09:00–18:00 / Mon–Fri 09:00–18:00, with overnight windows marked (22:00–次日 06:00 / 22:00–06:00 next day). The dry run's "actual" value (`fri 16:42`) is read the same way. `src/generated/tw-api.ts` gains `"time"` in `ConditionField` by hand; the file is regenerated when the core tag is moved. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Contributor
Author
|
Superseded by #315, which merged this branch together with the core v0.69.0 pin and the regenerated bindings; released in 2026.10.13. The red checks here were the control-plane tests running against the previously pinned core. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A rule can be limited to time windows of the gateway machine's local clock (contract A, lite side).
mon-fri 09:00-18:00,sat,sun 00:00-24:00,22:00-06:00; consecutive days collapse into a range (three or more; two days staysat,sun), ranges may wrap (fri-mon), the day part is omitted when all seven are on. "Add time window" adds another value; several windows are matched like the other multi-value conditions. Existing values are parsed back into the picker (case-insensitive, lenient whitespace,9:00); a value that does not parse is shown as raw text that can still be edited or removed. Overnight windows show 「次日」 / "next day" beside the end time.条件「时段」须选择至少一天,时间写成 HH:MM,示例:09:00), never silently written as "every day".9:00is normalised to09:00on blur;24:00is accepted as an end.时段 周一至周五 09:00–18:00 或 22:00–次日 06:00/Time Mon–Fri 09:00–18:00 or 22:00–06:00 next day. The dry run's "actual" value is read the same way when core sends it as<day> HH:MM(e.g.fri 16:42→周五 16:42); any other form is shown as is.src/routing/timeWindow.ts(parse / format / describe) with tests: grammar round trips, normalisation, wrapping day ranges, overnight,24:00, malformed input, zh / en wording.Depends on
The core PR for the
timecondition (contract A):ConditionField::Time, the local-time fact inRequestFacts, and theconfig.rule_time_syntaxvalidation. Until it lands, saving a rule with this condition is refused by core as an unknown field.src/generated/tw-api.tsgains"time"inConditionFieldby hand (and nothing else); the file is regenerated as usual when the core tag is moved.Verified
pnpm typecheck— passes.pnpm test— 103 files, 1076 tests pass (31 new intimeWindow.test.ts, 2 new cases inlabels.test.ts).时段 周一至周五 09:00–18:00 或 22:00–次日 06:00), the no-day error in the footer, blur normalisation and the invalid marking of a half-typed time.Not covered
docs/screenshots); the dry-run dialog has no time input since core evaluates with the current time.fri 16:42) is an assumption about the core PR; other forms fall back to the raw string.🤖 Generated with Claude Code