Skip to content

Feature/v3.3.2#50

Merged
magmacomputing merged 8 commits into
mainfrom
feature/v3.3.2
Jun 26, 2026
Merged

Feature/v3.3.2#50
magmacomputing merged 8 commits into
mainfrom
feature/v3.3.2

Conversation

@magmacomputing

@magmacomputing magmacomputing commented Jun 25, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features
    • Added dynamic custom format tokens via the token registry, including modifier-aware outputs.
    • Introduced the :yy compound date modifier for 2-digit years (e.g., {dmy:yy}), superseding legacy *6 tokens.
    • Released version 3.4.0 across packages.
  • Documentation
    • Updated release notes and token/cookbook docs with dynamic token examples and timezone-change guidance.
  • Bug Fixes
    • Prevented registry-defined core token names from overriding standard formatting behavior.
  • Tests
    • Added coverage for dynamic tokens and dmy/mdy/ymd with :yy/:year modifiers.

@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6ce6313c-3eea-4895-aab5-bad749e49d8a

📥 Commits

Reviewing files that changed from the base of the PR and between 94abe1b and a259cee.

📒 Files selected for processing (3)
  • packages/tempo/.vitepress/config.ts
  • packages/tempo/doc/tempo.shorthand.md
  • packages/tempo/index.md
✅ Files skipped from review due to trivial changes (2)
  • packages/tempo/index.md
  • packages/tempo/doc/tempo.shorthand.md

📝 Walkthrough

Walkthrough

This PR adds custom token evaluation to Tempo formatting, updates compound date tokens to support :yy and :year, expands tests and documentation, and bumps package versions to 3.4.0.

Changes

Tempo tokens and release updates

Layer / File(s) Summary
Token registry types
packages/tempo/src/tempo.type.ts
registry.tokens is added to Tempo configuration and discovery types with a token function signature that receives zdt and { modifiers, config }.
Formatter token resolution
packages/tempo/src/module/module.format.ts, packages/tempo/src/support/support.index.ts, packages/tempo/src/support/support.util.ts
dmy/mdy/ymd now vary year width for :yy and :year, and config.registry.tokens[token] functions run before the #... fallback; supporting support exports and hasOwn wiring are updated alongside this path.
Formatter tests
packages/tempo/test/instance/instance.format.test.ts
The formatter test file adds coverage for custom token functions, protected core token names, and compound date tokens with and without the new year-width modifiers.
Release docs and versioning
package.json, packages/library/package.json, packages/tempo/package.json, packages/tempo/CHANGELOG.md, packages/tempo/doc/releases/v3.x.md, packages/tempo/doc/tempo.config.md, packages/tempo/doc/tempo.cookbook.md, packages/tempo/doc/tempo.format.md, packages/tempo/src/tempo.version.ts
Release notes, API docs, cookbook examples, and package/version metadata are updated for version 3.4.0, including the new token registry entry point and :yy documentation.

Sequence Diagram(s)

sequenceDiagram
  participant format as format(obj?, fmt?, options?)
  participant registry as config.registry.tokens[token]
  participant tokenfn as custom token function
  participant fallback as Tempo-term lookup fallback

  format->>registry: look up token
  alt config.registry.tokens[token] is a function
    registry->>tokenfn: call(zdt, { modifiers, config })
    tokenfn-->>format: string | number | bigint
  else no custom token function
    format->>fallback: resolve #... token name
    fallback-->>format: token text
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • magmacomputing/magma#19: Both PRs touch Tempo formatting behavior and formatter module replacement or extension in packages/tempo/src/module/module.format.ts.
  • magmacomputing/magma#43: Both PRs modify Tempo’s token formatting pipeline and modifier handling in packages/tempo/src/module/module.format.ts.

Poem

I hopped through tokens in the moonlit glen,
:yy twinkled, then hopped again.
My ears caught registry.tokens in tune,
And carrots glowed like a formatter moon.
🐰 Hop-hop—Tempo sings by noon!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is vague and reads like a branch name, not a description of the version bump and Tempo feature additions. Rename the PR to a concise summary of the main change, such as adding dynamic format tokens and releasing Tempo 3.4.0.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/v3.3.2

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (2)
packages/tempo/doc/releases/v3.x.md (1)

10-12: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Fix inconsistent indentation.

Line 12 uses spaces while surrounding lines use tabs. Maintain consistent tab indentation.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/tempo/doc/releases/v3.x.md` around lines 10 - 12, The Tempo.init
configuration snippet has inconsistent indentation, with one line using spaces
while the surrounding lines use tabs. Update the indentation in the Tempo.init
block to use consistent tab-based alignment throughout, keeping the locale and
registry entries formatted uniformly.
packages/tempo/src/tempo.type.ts (1)

247-247: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract and strongly type the token registry callback.

The same public callback signature is repeated three times, and zdt: any loses the type-safety this API can provide. A shared alias also keeps Options/Config/Discovery from drifting.

♻️ Proposed refactor
 export namespace Internal {
 	export type Registry = Map<symbol, RegExp>
+	export type TokenFormatter = (
+		zdt: Temporal.ZonedDateTime,
+		context: { modifiers: string[], config: Config }
+	) => string | number | bigint
+	export type TokenRegistry = Record<string, TokenFormatter>
-		tokens?: Record<string, (zdt: any, context: { modifiers: string[], config: Internal.Config }) => string | number | bigint>;
+		tokens?: TokenRegistry;
-		registry: { formats: FormatRegistry, locales: Record<string, Record<string, string | Function>>, modifiers?: Record<string, string | string[]>, tokens?: Record<string, (zdt: any, context: { modifiers: string[], config: Internal.Config }) => string | number | bigint> };
+		registry: { formats: FormatRegistry, locales: Record<string, Record<string, string | Function>>, modifiers?: Record<string, string | string[]>, tokens?: TokenRegistry };
-		registry?: { formats?: Property<any>, locales?: Record<string, Record<string, string | Function>>, modifiers?: Record<string, string | string[]>, tokens?: Record<string, (zdt: any, context: { modifiers: string[], config: Internal.Config }) => string | number | bigint> };
+		registry?: { formats?: Property<any>, locales?: Record<string, Record<string, string | Function>>, modifiers?: Record<string, string | string[]>, tokens?: TokenRegistry };

Also applies to: 333-333, 348-348

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/tempo/src/tempo.type.ts` at line 247, The token registry callback
signature is duplicated across the public types and currently uses zdt: any,
which weakens type safety; extract that callback into a shared alias and reuse
it in the tokens definitions for Options/Config/Discovery so they stay aligned.
Update the type in tempo.type.ts where tokens is declared to reference the new
callback type, and strongly type zdt instead of any using the existing
Tempo/date-time type used by this API.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/tempo/src/module/module.format.ts`:
- Around line 217-219: The per-call token registry handling in module.format.ts
is replacing the base config tokens instead of merging them, so update the
options registry merge logic to deep-merge registry.tokens alongside formats and
locales. In the merge block where the config is built, preserve existing base
tokens from the merged config and combine them with options.registry.tokens so
customTokenFn lookup still works for both defaults and per-call additions. Use
the existing registry/config merge code near the config assembly and the token
resolution in the formatting path as the reference points.
- Around line 217-220: The custom token resolution in module.format.ts should
not invoke inherited prototype members from the registry. Update the lookup
around customTokenFn in the formatting logic to first verify the token exists as
an own property on config?.registry.tokens before treating it as a callback, and
keep the existing isFunction guard before calling it. Use the token handling
branch in the formatter where customTokenFn is read, so plain-object registries
cannot fall through to prototype functions like __defineGetter__.

In `@packages/tempo/test/instance/instance.format.test.ts`:
- Around line 113-124: The compound token formatting test in Tempo does not
actually verify `:year` as a distinct modifier because `{dmy:year}` currently
mirrors `{dmy:yy}` and the `mdy`/`ymd` cases omit `:year` entirely. Update the
`instance.format.test.ts` checks around `Tempo.format` so `:year` has its own
expected output and add matching assertions for `mdy:year` and `ymd:year`, using
the existing `dmy`, `mdy`, and `ymd` format branches to locate the test block.

---

Nitpick comments:
In `@packages/tempo/doc/releases/v3.x.md`:
- Around line 10-12: The Tempo.init configuration snippet has inconsistent
indentation, with one line using spaces while the surrounding lines use tabs.
Update the indentation in the Tempo.init block to use consistent tab-based
alignment throughout, keeping the locale and registry entries formatted
uniformly.

In `@packages/tempo/src/tempo.type.ts`:
- Line 247: The token registry callback signature is duplicated across the
public types and currently uses zdt: any, which weakens type safety; extract
that callback into a shared alias and reuse it in the tokens definitions for
Options/Config/Discovery so they stay aligned. Update the type in tempo.type.ts
where tokens is declared to reference the new callback type, and strongly type
zdt instead of any using the existing Tempo/date-time type used by this API.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1d468fc0-ff53-4a48-85b6-ebb00e193681

📥 Commits

Reviewing files that changed from the base of the PR and between 1765a09 and 63dfb21.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (12)
  • package.json
  • packages/library/package.json
  • packages/tempo/CHANGELOG.md
  • packages/tempo/doc/releases/v3.x.md
  • packages/tempo/doc/tempo.config.md
  • packages/tempo/doc/tempo.cookbook.md
  • packages/tempo/doc/tempo.format.md
  • packages/tempo/package.json
  • packages/tempo/src/module/module.format.ts
  • packages/tempo/src/tempo.type.ts
  • packages/tempo/src/tempo.version.ts
  • packages/tempo/test/instance/instance.format.test.ts

Comment thread packages/tempo/src/module/module.format.ts Outdated
Comment thread packages/tempo/src/module/module.format.ts Outdated
Comment thread packages/tempo/test/instance/instance.format.test.ts
@magmacomputing magmacomputing merged commit 440a0f1 into main Jun 26, 2026
2 checks passed
@magmacomputing magmacomputing deleted the feature/v3.3.2 branch June 26, 2026 05:17
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.

1 participant