Skip to content

feat: chasing gets a tail and a delta, like every other wave - #11

Merged
DoodleBears merged 1 commit into
mainfrom
fix/chasing-envelope-gradient
Sep 30, 2026
Merged

DoodleBears merged 1 commit into
mainfrom
fix/chasing-envelope-gradient

Conversation

@DoodleBears

@DoodleBears DoodleBears commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Why

"chasing 还是没那么平滑,应该有差值和 smooth 那些才对,和其他几个对齐。"

它两样都没有,原因是一行代码。

Cause

chase 带着 steps: 3,所以 level() 在整个周期里只返回三个亮度值之一:0.16、0.58、1.00。

一个周期内的不同亮度层数
chase(修复前) 3
comet(对照) 78

环上 spread: 0.34 时,同一帧里有多格跨过同一个台阶 —— 所以这个动效几乎处处差值为零,只在台阶处是断崖。这就是"不 smooth"的字面含义。

而且这不是审美问题:envelope.ts 顶部自己写着规则 —— "Never quantise brightness into shelves. Shelves are visible as steps and read as cheap." chase 是唯一违反它、也是唯一用到 steps 的 envelope。

Change outline

改成"快升 + 六段衰减"的 stop 表:

亮度层数 相邻采样最大跳变
chase 之前 3 ~0.42
chase 之后 173 0.03
comet(对照) 155 —

波峰后面那道仍然亮着的拖尾是新增的。

实际渲染(9×9,一行一个时刻,. 到 @ 是亮度):

t=0.2  |....................+++++....+%%%+....+%*%+....+%%%+....+++++....................|
t=0.3  |..........*******..*#####*..*#+++#*..*#+=+#*..*#+++#*..*#####*..*******..........|
t=0.4  |%%%%%%%%%%#######%%#+++++#%%#+---+#%%#+-:-+#%%#+---+#%%#+++++#%%#######%%%%%%%%%%|

同一帧里能同时读出 + / % / * 三层梯度;修复前只有三级硬台阶。

Special things to note

  • Reversibility: one envelope's stop table, plus the removal of the steps mechanism.
    This changes published engine behaviour — @botharness/botui-core@0.1.1 ships the old
    chasing. A revert restores it exactly; the version is not yet bumped, so nothing
    published has changed yet.
  • The steps mechanism went with it, in all four places: the field on Envelope, the
    level() branch, the data-timing="steps-N" switch, and the steps(3, end) CSS rule.
    chase was the only user, so every one of them described a deleted behaviour.
    steps?: number was never in the documented option vocabulary and is not exported, so
    this is a source-level cleanup rather than an API change — but anyone constructing a
    custom Envelope with steps would need to move to stops.
    Flagging it rather than
    burying it.
  • Two tests replaced two. One asserts no envelope is quantised and every one has ≥24
    levels; one asserts chasing has a peak, a visible tail, and no step above 0.05 between
    neighbours. The pair that described the deleted mechanism — "a stepped envelope spans
    rest…peak"
    and "flips to stepped timing when the envelope is quantised" — are gone
    rather than rewritten
    , because a test for a mechanism that no longer exists is a test
    that would pass if someone re-added the shelves.
  • Needs a version bump and a publish before it reaches users. The registry item carries
    this source, so the site and the installed component change together — but npm is still
    on 0.1.1 with the old envelope.
  • 158 tests (was 154), oxlint 0, oxfmt clean, registry ok.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Visual Updates

    • Updated the chasing animation with a fast rise and smooth, gradual decay.
  • Bug Fixes

    • Fixed playground preset-card interactions, including a crash with the off preset.
    • Improved preview and card layering, scrolling, and control accessibility.
    • Corrected slider scaling and radius limits, and fixed stagger reset behavior.
    • Improved Chinese locale resolution.

"`chasing` is not smooth, it should have the trailing and the delta like the others."

It had neither, and the cause was one line. `chase` carried `steps: 3`, so `level()`
returned one of exactly three brightness values across the whole cycle: 0.16, 0.58,
1.00. Measured against `comet`:

    chase   3 distinct brightness levels across a cycle
    comet  78

With `spread: 0.34` around a ring, several cells crossed the same shelf in the same
frame, so the motion had a delta of zero almost everywhere and a cliff where it was
not — which is what "not smooth" is. And it was not a matter of taste: the envelope
file's own rule, written at the top, is "never quantise brightness into shelves.
Shelves are visible as steps and read as cheap." `chase` was the one envelope that
broke it, and the only preset using it.

It is now a stop table with a fast rise and a six-stop decay:

    chase 173 levels   (was 3)      comet 155
    largest step between neighbouring samples  0.03   (was ~0.42)

The trailing lit tail behind the crest is new, and `chasing` now reads like the comet
it always looked like it should be.

The `steps` mechanism went with it, in all four places it existed: the field on
`Envelope`, the `level()` branch that read it, the `data-timing="steps-N"` switch in
`field.ts`, and the `steps(3, end)` rule in the stylesheet. `chase` was the only user,
so every one of them was a description of a deleted behaviour — dead code of exactly
the kind this repo's rules call out. Every envelope is one shape again: a stop table,
or a gaussian. `steps?: number` was never in the documented option vocabulary and is
not exported, so this is a source-level cleanup rather than an API change; anyone who
constructed a custom `Envelope` with `steps` would need to move to `stops`.

Two tests replaced two: one asserting no envelope is quantised and every one has at
least 24 levels, one asserting `chasing` has a peak, a visible tail and no step above
0.05 between neighbours. The pair that described the deleted mechanism — "a stepped
envelope spans rest…peak" and "flips to stepped timing when the envelope is
quantised" — are gone rather than rewritten, because a test for a mechanism that no
longer exists is a test that will pass if someone re-adds the shelves.
@coderabbitai

coderabbitai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 17f32dfd-94be-4634-88ec-8910ccec27c7

📥 Commits

Reviewing files that changed from the base of the PR and between d8427c4 and 42b582a.

📒 Files selected for processing (8)
  • CHANGELOG.md
  • CHANGELOG.zh.md
  • packages/core/src/dot-matrix/css.ts
  • packages/core/src/dot-matrix/envelope.ts
  • packages/core/src/dot-matrix/field.ts
  • packages/core/src/types.ts
  • packages/core/test/dom.test.ts
  • packages/core/test/dot-matrix.test.ts
💤 Files with no reviewable changes (2)
  • packages/core/src/types.ts
  • packages/core/src/dot-matrix/css.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.


📝 Walkthrough

Walkthrough

The dot-matrix chase envelope now uses a stop-based rise and decay curve. The Envelope.steps property and stepped brightness and timing paths are removed. CSS-rendered matrices use linear timing, and tests check the updated envelope behavior.

Changes

Chase envelope and timing

Layer / File(s) Summary
Stop-based envelope and linear timing
packages/core/src/types.ts, packages/core/src/dot-matrix/envelope.ts, packages/core/src/dot-matrix/field.ts, packages/core/src/dot-matrix/css.ts, packages/core/test/*, CHANGELOG*.md
The chase envelope now uses a stop-based rise and decay curve. The steps property, brightness quantization, and stepped CSS timing are removed. Tests check envelope sampling and linear timing. The changelog records these changes and other fixes.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~15 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 42b58

The chase animation now uses a continuous rise and decay with linear CSS timing. No actionable merge-blocking issue is identified; the change is mergeable subject to normal checks.

Security Architecture Review

Security architecture risk: ⚪ Minimal · up to 42b58

The exported animation contract changes, which can affect consumers of custom stepped envelopes. The reviewed change does not expand renderer access or authority, and no introduced security risk was identified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The relevant rendering scope remains the supplied DOM element and a shared stylesheet in its owner document. Stylesheet changes can affect other matching CSS-rendered instances in that document; this sharing mechanism predates the PR rather than representing newly gained authority.

Trust Boundaries and Controls

  • inferred — Direct access to mutable envelope tables and low-level evaluators already exists. The PR removes a rendering capability without adding a caller, sensitive sink, or trust transition; the removed steps handling was an animation rule, not an authorization control.

Resilience and Maintainability Implications

  • inferred — The existing envelope cache computes a replacement before publishing it synchronously, and the matrix handle retains animation cancellation and mount cleanup. The changed stop table and timing rules introduce no new state owner, interruption window, or recovery requirement.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: the chasing envelope gains a trailing tail and smoother brightness changes. It is concise and related to the pull request.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 4 files. (2 skipped: 2 …
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
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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

@DoodleBears
DoodleBears merged commit ef281c8 into main Sep 30, 2026
2 checks passed
@DoodleBears
DoodleBears deleted the fix/chasing-envelope-gradient branch September 30, 2026 13:51
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