Skip to content

🧹 [Refactor applyBatchUpdate to improve maintainability]#360

Closed
google-labs-jules[bot] wants to merge 1 commit into
mainfrom
refactor-apply-batch-update-13925686891959446430
Closed

🧹 [Refactor applyBatchUpdate to improve maintainability]#360
google-labs-jules[bot] wants to merge 1 commit into
mainfrom
refactor-apply-batch-update-13925686891959446430

Conversation

@google-labs-jules
Copy link
Copy Markdown
Contributor

🎯 What: Extracted validation, preparation, and local update logic from applyBatchUpdate into smaller helper functions.
💡 Why: applyBatchUpdate was too long and complex. Breaking it into cohesive pieces makes the logic easier to reason about, test, and maintain.
Verification: Verified by checking that no syntax errors were introduced (bun build), testing the project functionality via npm test, and receiving a positive code review that confirmed the safety and completeness of the patch.
Result: Improved codebase maintainability and readability without altering behavior.


PR created automatically by Jules for task 13925686891959446430 started by @zknpr

Extracts validation, update preparation, and local grid update logic
from the applyBatchUpdate function in core/ui/modules/sidebar.js into
separate helper functions to improve maintainability and readability.
@google-labs-jules
Copy link
Copy Markdown
Contributor Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sq-lite-explorer Ready Ready Preview, Comment May 27, 2026 1:10pm

@zknpr
Copy link
Copy Markdown
Owner

zknpr commented May 30, 2026

Closing — refactors applyBatchUpdate (batch-update internals). I runtime-verified the drivable UI refactors in the web demo, but the batch-update staging flow (select cells → updateBatchSidebar → applyBatchUpdate) isn't practical to exercise via automated browser testing, so I couldn't runtime-verify this one. It's a maintainability-only change to a sub-feature; best re-filed on current main with batch-update test coverage (or reviewed by Codex). Thanks, Jules.

@google-labs-jules
Copy link
Copy Markdown
Contributor Author

Closing — refactors applyBatchUpdate (batch-update internals). I runtime-verified the drivable UI refactors in the web demo, but the batch-update staging flow (select cells → updateBatchSidebar → applyBatchUpdate) isn't practical to exercise via automated browser testing, so I couldn't runtime-verify this one. It's a maintainability-only change to a sub-feature; best re-filed on current main with batch-update test coverage (or reviewed by Codex). Thanks, Jules.

Understood. Acknowledging that this work is now obsolete and stopping work on this task.

zknpr added a commit that referenced this pull request May 30, 2026
* refactor(ui): extract testable batch-update logic from sidebar.js

Reworks the closed #360/#361 (which couldn't be unit-tested as in-file
helpers — sidebar.js's import chain requires a DOM). Extracts the pure
value-processing logic into a DOM-free module so it can be unit-tested:

- core/ui/modules/batch-update-logic.js (+ .d.ts): groupSelectedCellsByColumn,
  summarizeColumnValue, prepareBatchUpdates (type coercion / NULL / json_patch
  / skip-empty rules)
- sidebar.js: updateBatchSidebar + applyBatchUpdate delegate to these
  (behavior unchanged); removed a now-unused escapeHtml import
- tests/unit/batch-update-logic.test.ts: 13 cases covering the rules

Verified: 324 unit tests pass (was 311); tsc --noEmit clean; full batch-update
flow runtime-checked in the web demo (select 2 cells -> panel shows the grouped
column with "(mixed values)" -> apply -> both cells update; zero console errors).

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* test(ui): harden batch-update logic against edge cases

Applies the defensive findings from Gemini's review of this PR:
- groupSelectedCellsByColumn / prepareBatchUpdates: skip cells whose colDef
  is missing (stale/out-of-bounds selection, e.g. after a column drop) rather
  than throwing
- summarizeColumnValue: return '' for an empty value set
- prepareBatchUpdates: tolerate an input without a `dataset`
- `dataset` made optional in the .d.ts
+ 4 edge-case unit tests (suite: 328 passing).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* test(ui): address remaining batch-update review nits

- batch-update-logic.js: normalize column type to upper-case before numeric
  coercion (Gemini — SQLite reports declared types verbatim, e.g. 'integer',
  so the case-sensitive check could miss lowercase numeric columns)
- sidebar.js: guard colDef?.name in the invalid-JSON validation path against a
  stale/out-of-bounds colIdx (Codex non-blocking caveat)
- tests: add NUMERIC + lowercase-type coercion cases (suite: 330 passing)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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