Skip to content

Port latest Sheets changes from standalone frappe/sheets#98

Open
AsifMulani1 wants to merge 6 commits into
developfrom
sheets/port-latest-from-standalone
Open

Port latest Sheets changes from standalone frappe/sheets#98
AsifMulani1 wants to merge 6 commits into
developfrom
sheets/port-latest-from-standalone

Conversation

@AsifMulani1

Copy link
Copy Markdown
Collaborator

Ports everything frappe/sheets gained since the Phase-5 monorepo cutoff
(rename: spreadsheet → sheets, 2026-06-15) into suite/sheets. ~20
substantive commits, grouped here into 4 thematic commits.

Path/namespace adaptation matches the original port: frontend/src/*
frontend/src/apps/sheets/* (the pages/SheetEditor/ dir → components/SheetEditor/),
backend sheets/*suite/sheets/* (nested sheets/sheets/doctype flattened),
sheets.api.*/sheets.versioning.*suite.sheets.*, and the frappe-ui
beta.9 design-token renames (--surface-white--surface-base, etc.).

What's included

  • perf — compact row-major sheet codec, compressed sheets_data, clone-free
    chunked autosave, async pivot/chart aggregation + downsampling, lazy-viewport
    canvas render (switch/load no longer scale with cell count).
  • AI Assist (Claude)sheets/ai package + ai_assist/get_ai_settings/
    save_ai_settings endpoints, Sheets AI Settings doctype, AskBar +
    AISettingsDialog, www boot gating. Adds anthropic>=0.40. The key never
    reaches the client; the model returns formulas/ranges, never computed values.
  • editor features — column/row formats with cascade, validation chips with
    per-option colors, Frappe-styled color picker, pivot copy/paste → live pivot,
    pivot drill-down to source rows.
  • fixes — clipboard cut/paste overlap, op-based undo history repair, home
    list-first view + shorter topbar.

Not included (deliberate)

  • Built frontend bundle (sheets/public/sheets/) — gitignored; suite builds its own.
  • Frontend .test.js files — the original Phase-5 port dropped sheets frontend
    tests; not reintroduced here. Backend Python tests (e.g. test_cell_codec.py)
    are included.

Verification done

Static: adaptation transform proven complete against all 161 ported files, no
leftover un-prefixed sheets. backend refs, all design tokens resolve, Python
compiles, JS syntax checks pass, new-module imports + AI endpoint wiring confirmed.

Verification still needed

A frontend build was not run (full monorepo install). Please build and do
the Phase-6 smoke test per PORT-NOTES.md: log in at suite.localhost/sheets,
confirm listing/open/edit/persist, charts, version history, validation chips,
color picker, and AI Assist (with a key configured). Run bench migrate to
create the Sheets AI Settings doctype.

…wport render

Port performance work from frappe/sheets since the Phase-5 cutoff:
- compact row-major sheet codec (pack/unpack) + compressed sheets_data shipped
  to the client and decompressed there
- clone-free, chunked autosave; faster load path
- async pivot/chart aggregation with single-pass + downsampling
- lazy-viewport canvas render so switch/load no longer scale with cell count;
  cheap sheet-add and single-paint switch
Backend: cell_codec, storage row-major codec, op-log + versioning save tweaks.
Port the AI Assist feature from frappe/sheets:
- backend sheets/ai package (Claude client, sheet context, heuristics, validate)
  and ai_assist / get_ai_settings / save_ai_settings whitelisted endpoints
- Sheets AI Settings single doctype (api key, enabled, model)
- AskBar + AISettingsDialog in the editor; www/sheets boot seeds the
  ai_assist_enabled / ai_assist_can_configure flags (key never reaches client)
- add anthropic>=0.40 dependency

The model is forced to emit a structured action plan via a tool; it returns
formulas/ranges and never computes values (the engine does that client-side).
…ot drill-down

Port editor features from frappe/sheets:
- column/row-level formatting with cascade (format-scope) and a Frappe-styled
  color picker replacing the native input
- data-validation dropdowns rendered as Sheets-style chips with per-option
  colors (chip-geometry)
- pivot: copy/paste mints a live pivot; double-click drills down to source rows
- date-string parsing when applying date/time number formats
Port fixes from frappe/sheets:
- clipboard: don't wipe pasted cells when the cut source overlaps the
  destination; route common edits through op-based undo
- repair snapshot-undo, cut+paste, comment & validation history
- home: shorter topbar and default to the list view
@greptile-apps

greptile-apps Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 4/5

This is close, but these issues should be fixed before merging.

  • Chart data can remain stale after row or column insert/delete operations.
  • AI Assist can still return a server error for malformed compact row containers.

frontend/src/apps/sheets/components/SheetEditor/useChartIntegration.js, suite/sheets/doctype/sheet/cell_codec.py

Important Files Changed

Filename Overview
frontend/src/apps/sheets/components/SheetEditor/useChartIntegration.js Adds chart data cache invalidation, but structural sheet edits still need to bump it.
suite/sheets/doctype/sheet/cell_codec.py Improves compact row decoding, but still needs container type checks.
Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
frontend/src/apps/sheets/components/SheetEditor/useChartIntegration.js:43
**Structural edits stay stale** The chart data version is bumped for cell edits and manual refresh, but row and column insert/delete paths shift the source cells without changing this value. A chart over `A1:A10` can keep rendering the old matrix after rows or columns are inserted or deleted until another cell edit or manual refresh invalidates the cache.

### Issue 2 of 2
suite/sheets/doctype/sheet/cell_codec.py:26
**Malformed containers still crash** This guard only handles falsy `rows`; a truthy non-dict like a list or string still reaches `_unpack_rows`, where `.items()` raises. `ai_assist` does not catch that decoder error, so one malformed compact `rows` container can still turn AI Assist into a 500 instead of ignoring the bad stored data.

Reviews (3): Last reviewed commit: "fix: keep charts/pivots fresh on bulk ed..." | Re-trigger Greptile

Comment thread frontend/src/apps/sheets/components/SheetEditor/ChartOverlay.vue
Comment thread suite/sheets/doctype/sheet/cell_codec.py Outdated
Replace the inline cyan chart icon in the SheetEditor topbar with the new
green (#278F5E) spreadsheet mark, matching the refreshed brand assets.
Comment thread suite/sheets/doctype/sheet/cell_codec.py Outdated
Addresses code-review feedback on the Sheets port:

- Bump chartDataVersion on cell-change callbacks so the overlay matrix
  cache invalidates on edits (drag/scroll still hit the cache).
- Recompute pivots in the incremental onCellsChanged path so paste/fill
  no longer leave pivot output stale; drop the now-redundant explicit
  recompute in _doPaste.
- Skip malformed rows in cell_codec._unpack_rows so a bad stored row
  can't 500 AI Assist.
// move/resize/scroll. The overlay keys its matrix cache on this so dragging a
// chart over a 100k-row source doesn't re-materialise the matrix every frame,
// while edits to the source range still refresh the chart.
const chartDataVersion = ref(0)

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.

P1 Structural edits stay stale The chart data version is bumped for cell edits and manual refresh, but row and column insert/delete paths shift the source cells without changing this value. A chart over A1:A10 can keep rendering the old matrix after rows or columns are inserted or deleted until another cell edit or manual refresh invalidates the cache.

Prompt To Fix With AI
This is a comment left during a code review.
Path: frontend/src/apps/sheets/components/SheetEditor/useChartIntegration.js
Line: 43

Comment:
**Structural edits stay stale** The chart data version is bumped for cell edits and manual refresh, but row and column insert/delete paths shift the source cells without changing this value. A chart over `A1:A10` can keep rendering the old matrix after rows or columns are inserted or deleted until another cell edit or manual refresh invalidates the cache.

How can I resolve this? If you propose a fix, please make it concise.

return {}
if sheet_slice.get("v") != PACK_VERSION:
return sheet # legacy: already a {cellId: value} map
return _unpack_rows(sheet.get("rows") or {})

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.

P1 Malformed containers still crash This guard only handles falsy rows; a truthy non-dict like a list or string still reaches _unpack_rows, where .items() raises. ai_assist does not catch that decoder error, so one malformed compact rows container can still turn AI Assist into a 500 instead of ignoring the bad stored data.

Prompt To Fix With AI
This is a comment left during a code review.
Path: suite/sheets/doctype/sheet/cell_codec.py
Line: 26

Comment:
**Malformed containers still crash** This guard only handles falsy `rows`; a truthy non-dict like a list or string still reaches `_unpack_rows`, where `.items()` raises. `ai_assist` does not catch that decoder error, so one malformed compact `rows` container can still turn AI Assist into a 500 instead of ignoring the bad stored data.

How can I resolve this? If you propose a fix, please make it concise.

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