refactor: remove dead StaticsMap code (#17)#118
Conversation
|
Review: LGTM This is a clean, safe dead-code removal. A few notes: Correctness — The claim that Backward compatibility — Even if an older server still emits Consistency — All seven internal helpers in One minor observation — No bugs, security issues, or quality concerns. Ready to merge. |
There was a problem hiding this comment.
Pull request overview
Removes the long-dead client-side StaticsMap (sm) plumbing that was kept as a no-op fallback after the server moved to fingerprint-based statics tracking, simplifying the range render/apply call chain.
Changes:
- Drop
staticsMapfromTargetedRangeOpand internal range state (RangeStateEntry), plus remove_sklookup logic fromTreeRenderer. - Update
RangeDomApplier’srenderItemcallback signature and internal helpers to no longer threadstaticsMap. - Adjust client wiring and tests to match the new
renderItem(item, idx, statics, statePath?)signature.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| types.ts | Removes staticsMap from the targeted range op type. |
| state/tree-renderer.ts | Eliminates sm persistence/reads and _sk statics selection; simplifies renderRangeItem/renderItemsWithStatics signatures. |
| state/range-dom-applier.ts | Removes staticsMap from renderItem plumbing and targeted-op application helpers. |
| livetemplate-client.ts | Updates RangeDomApplier callback wiring to the new renderItem signature. |
| tests/range-dom-applier.test.ts | Updates the test fixture callback to the new renderItem signature. |
Comments suppressed due to low confidence (1)
state/range-dom-applier.ts:200
TargetedRangeOp.staticsMapwas removed andapply()no longer receives/uses any StaticsMap, butcanApplyTargeted()in this same file still inspectsrangeStructure.smand folds those statics into thedata-keydetection. This leaves a lingering dependency on the deadsmfield and can makecanApplyTargeted()return true based on statics thatapply()will never use, which can enable the targeted-apply path incorrectly. Please remove therangeStructure.smbranch and base the decision solely onrangeStructure.s(or otherwise align the eligibility check with the data actually used byapply).
const { rangePath, ops, statics } = targetedOp;
const sampleKey = this.firstKnownKey(ops);
const container = this.findContainer(wrapper, rangePath, sampleKey);
if (!container) {
this.ctx.logger.debug(
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The server stopped emitting the "sm" (StaticsMap) field on TreeNode in v0.8.0 when fingerprint-based statics tracking replaced the per-path ClientStructureRegistry (#86). The client kept the read path and the parameter chain alive as a no-op fallback, but the underlying data has not flowed since v0.8.0 — every reachable codepath now passes undefined. Removed: - types.ts: staticsMap?: Record<string, string[]> field on TargetedRangeOp. - state/tree-renderer.ts: - staticsMap?: ... field on RangeStateEntry interface. - sm: existing.sm / value.sm / rangeStructure.sm reads (5 sites). - sm: ... writes into treeState and rangeState (3 sites). - The dead `_sk` lookup branch inside renderRangeItem. - staticsMap?: ... parameter from renderRangeItem and renderItemsWithStatics. - state/range-dom-applier.ts: - staticsMap parameter from RenderItemFn type and 6 internal helpers (apply, applyUpdateRow, applyInsertAfter, applyAppend, applyPrepend, renderItemsAtomic, renderAndParse). - Destructuring at apply() entry point. - livetemplate-client.ts: dropped sm arg in the renderItem callback wiring. - tests/range-dom-applier.test.ts: updated test renderItem callback to match the new 4-arg signature. No tests referenced StaticsMap, _sk, or "sm" — confirming the path was unreachable from any runtime scenario before this commit. All 529 tests pass; tsc --noEmit clean. Closes #17. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ReviewClean, mechanical dead-code removal with no bugs or security concerns. Two observations: Trivial redundancy in renderRangeItem (state/tree-renderer.ts): The line Backward-compatibility note: The Otherwise the change is consistent across all five files, the grep + tsc + test verification is solid, and the rationale is well documented. Good to merge once the alias is cleaned up. |
Summary
Closes #17. The server stopped emitting the
"sm"(StaticsMap) field on TreeNode in v0.8.0 when fingerprint-based statics tracking replaced the per-pathClientStructureRegistry(livetemplate/livetemplate#86). The client kept the read path and the parameter chain alive as a no-op fallback, but the underlying data has not flowed since v0.8.0 — every reachable codepath now passes `undefined`.Changes
Verification
No tests referenced `StaticsMap`, `_sk`, or `"sm"` before this commit, confirming the code path was unreachable.
Closes #17.
🤖 Generated with Claude Code