Add to support number autofill with Ordinary Least Squares#85
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (9)
✅ Files skipped from review due to trivial changes (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds Google Sheets–style OLS linear-trend extrapolation for numeric autofill, helper utilities for numeric detection and regression, integrates predictions into Changes
Sequence DiagramsequenceDiagram
participant User
participant Autofill as Autofill Service
participant Scanner as isNumericValue()
participant TrendBuilder as Trend Builder
participant Extrapolator as computeLinearTrend()
participant Sheet as Sheet Model
User->>Autofill: request autofill(target)
Autofill->>Scanner: scan source range for numeric cells
Scanner-->>Autofill: numeric map per cell
Autofill->>TrendBuilder: build per-line (col/row) trend metadata
TrendBuilder-->>Autofill: eligible trend lines
loop for each destination cell
alt line eligible for OLS
Autofill->>Extrapolator: computeLinearTrend(xs, ys, targetX)
Extrapolator-->>Autofill: predicted value
Autofill->>Sheet: format (toPrecision(15)) & write value, preserve style
else fallback
Autofill->>Sheet: apply legacy tiling / cloneCellForAutofill
end
end
Autofill-->>User: complete
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Verification: verify:selfResult: ✅ PASS in 104.0s
Verification: verify:integrationResult: ✅ PASS |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
docs/tasks/active/20260326-number-autofill-ols-todo.md (1)
40-40: Clarify the status of the remaining precision drift investigation.This task item is still unchecked. Is this a known remaining issue that needs follow-up, or can it be closed? If there are known precision drift scenarios, consider documenting them or opening a tracking issue.
Would you like me to help identify any remaining precision edge cases that might cause drift?
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@docs/tasks/active/20260326-number-autofill-ols-todo.md` at line 40, Update the todo line "Investigate and fix remaining precision drift" to reflect the current state: if the investigation is complete, remove the checkbox and replace with a short resolution note; if unresolved, change to an actionable item that references a tracking issue (create one) and list known edge-case scenarios (e.g., float rounding in X/Y operations or conversion between units) in the task description; ensure the updated text includes either a link to the tracking issue or a short summary of remaining steps so the task is no longer ambiguous.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@docs/tasks/active/20260326-number-autofill-ols-todo.md`:
- Around line 25-27: The fenced code block containing the formula "y(t) = (n * A
* t + sumY * D - A * sumX) / (n * D)" needs a language specifier to satisfy
markdownlint MD040; update the triple-backtick fence to include a language such
as text or math (e.g., ```text or ```math) so the block is properly annotated.
In `@packages/sheets/src/model/worksheet/clipboard.ts`:
- Around line 100-106: The computeLinearTrend function should validate that xs
and ys have the same length before proceeding: check that xs.length ===
ys.length (in addition to the existing n < 2 check) and handle mismatches by
returning undefined or throwing an Error per project convention; update the
function (computeLinearTrend) to early-return/throw when lengths differ so
subsequent indexing over xs/ys cannot read past the shorter array and produce
NaN results.
---
Nitpick comments:
In `@docs/tasks/active/20260326-number-autofill-ols-todo.md`:
- Line 40: Update the todo line "Investigate and fix remaining precision drift"
to reflect the current state: if the investigation is complete, remove the
checkbox and replace with a short resolution note; if unresolved, change to an
actionable item that references a tracking issue (create one) and list known
edge-case scenarios (e.g., float rounding in X/Y operations or conversion
between units) in the task description; ensure the updated text includes either
a link to the tracking issue or a short summary of remaining steps so the task
is no longer ambiguous.
🪄 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: 4521470a-9ec5-4c60-b733-2d80d66902f6
📒 Files selected for processing (4)
docs/tasks/active/20260326-number-autofill-ols-todo.mdpackages/sheets/src/model/worksheet/clipboard.tspackages/sheets/src/model/worksheet/sheet.tspackages/sheets/test/sheet/autofill.test.ts
- Add language specifier to fenced code block in task doc - Add xs/ys length mismatch guard in computeLinearTrend Co-Authored-By: Claude Opus 4.6 <[email protected]>
TypeScript parameter properties and const enums are not supported in Node's --experimental-strip-types. Refactor TextEditor constructor to use explicit field declarations and replace const enum with an object literal. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Remove unused lineX parameter from renderListMarker, remove unused imports, and add missing textIndent/marginLeft fields to BlockStyle test fixtures. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Task completed and merged via PR #85. Move to archive and update task indexes. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Summary
Autofill number using Ordinary Least Squares(OLS) trend.
OLS result is formatted with
toPrecision(15)(IEEE 754 double, matching Excel/GoogleSheets). To avoid intermediate float error (e.g.
m * t + bwhereb = -7/3),computeLinearTrendcomputes the result as a single fraction:e.g. Autofill with selecting 2x2 blocks below.
e.g. Autofill with selecting 3x2 blocks below.
Why
Previously, it just autofill number repeatedly like string.
e.g. Autofill with selecting 2x2 blocks below.
Linked Issues
Fixes #
Verification
CI automatically posts a verification summary comment on this PR with
per-lane results for both
verify:selfandverify:integration.Skip reason (if applicable):
Risk Assessment
Notes for Reviewers
Summary by CodeRabbit
New Features
Bug Fixes / Precision
Tests
Refactor