Repository navigation
Conversation
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Native workbook snapshots apps/gridcraft-web/src/native_document.rs, apps/gridcraft-web/src/main.rs |
The app exports validated JSON workbook bytes with document and revision identifiers. Validation checks JSON input, engine errors, warnings, and a 32 MiB size limit. Tests cover exports, validation, and draft behavior. |
Managed-save acknowledgment apps/gridcraft-web/src/managed_save.rs |
ManagedSaves tracks the latest snapshot. It updates the active workbook’s saved baseline only when the acknowledgment and active document match. Tests cover stale or mismatched acknowledgments and document switching. |
Parent bridge requests and notifications apps/gridcraft-web/src/host.rs, apps/gridcraft-web/src/web.rs, apps/gridcraft-web/src/main.rs, README.md |
The parent bridge queues native export, validation, and managed-save work for sync. It checks message origin, request fields, queue limits, and byte payloads. It reports document changes and closure. The Web app enables managed mode with save=managed, and the README documents the protocol. |
Priority:
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Feature
Sequence Diagram(s)
sequenceDiagram
participant ParentWindow
participant Bridge
participant SheetApp
participant NativeDocument
participant ManagedSaves
ParentWindow->>Bridge: Send native export request
Bridge->>SheetApp: Process queued request during sync
SheetApp->>NativeDocument: Export active workbook
NativeDocument-->>Bridge: Return bytes, document, and revision
Bridge-->>ParentWindow: Post native export response
Bridge->>ParentWindow: Post managed save request
ParentWindow->>Bridge: Send matching save acknowledgment
Bridge->>ManagedSaves: Acknowledge request, document, and revision
Suggested reviewers: claude, echelon
Merge Risk: 
Minimal · up to 4d22c
-
Managed Ctrl+S reaches the parent save request, and acknowledgments report dirty-state changes. The change is mergeable after normal checks.
Security architecture risk: 
Low · up to 4d22c
-
The new save flow preserves unsaved edits and rejects stale or foreign acknowledgements. Access remains restricted to the same-origin parent. Host-side durable storage and recovery behavior remain integration dependencies that could not be verified here.
Retained concerns
No architecture-level concerns identified.Security review details
-
Security Blast Radius
- inferred — The new browser-facing authority is confined to the framed editor and its accepted same-origin parent. That parent can request workbook export, submit validation input and attest to persistence; the inspected paths do not grant those operations to other origins or unrelated windows.
Trust Boundaries and Controls
- observed — Every new incoming message branch follows exact origin and parent-window source checks, and replies target the captured origin. Acknowledgement identity checks bind the saved baseline to an exported snapshot, but do not independently prove storage durability: the authenticated parent remains trusted to make that assertion.
Resilience and Maintainability Implications
- observed — The saved-state transition uses the retained workbook snapshot rather than the current edited workbook. Later edits remain dirty, and document identity guards prevent acknowledgement from modifying a replacement document. This preserves state ownership during delayed or repeated messages.
Hardening Proposals
- proposed — Specify host retry and acknowledgement-admission behavior, including queue saturation and frame reloads, so recovery does not depend on undocumented assumptions while retaining the current fail-closed dirty-state behavior.
-
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passedFull details: Docstring Coverage
-
Explanation
Docstring coverage is 31.82% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 22 functions across 5 files. (1 skipped: 1 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
|
Static source review of
One uncovered request/export race: I checked |
FredApps
left a comment
There was a problem hiding this comment.
ReviewerA — source-read COMMENT (not an approval)
I read the head of the doc comments: the web app's host bridge gains gridcraft:changed ({ document, revision, dirty }, sent whenever the active workbook changes, even when it is already dirty, so the host can debounce a fresh native export), gridcraft:export-native (from the parent: { requestId }; replies with the native JSON without claiming a durable save) and gridcraft:save-ack (the parent, after storing the export durably, sends { requestId, document, revision }, and a matching acknowledgement records that export as the saved baseline; edits after the export stay unsaved; old or foreign acknowledgements are ignored). The design is careful about the one hard point of such a bridge: "saved" is claimed only after the host says it stored exactly that revision. In the code I read, the messages are accepted only from the same-origin parent and answered with post_message to that origin (never *). Check that the revision is checked against the current state at acknowledgement time (an edit during the export is not marked saved), that a request id used twice is refused, and that memory for pending exports is bounded. This uses the same host protocol as deckcraft#983 and soundcraft#866, so the three should share the message names and rules (soundcraft#866 also allows a vouched cross-origin embedder; this one and deckcraft#983 are same-origin only). I did not read the rest. Add tests for a stale acknowledgement, a wrong document, an edit after export, and a message from another origin. Nothing was run.
I ran nothing and have no exact-head CI result for this PR, so this is not an approval. Where a diff was long I read its code hunks rather than every generated or documentation line.
Status: waiting_author.
|
We confirmed the save-state gap from #1020 in a real browser on the official GridCraft v0.19.1 web build. In a same-origin iframe with Thanks for adding the managed native-save path in this PR. Our embedding needs the host to persist the actual XLSX file. Is there a supported way to bind an XLSX export to the same document and revision as the managed save, so the host can acknowledge it only after that exact file is written? The regression we would like to cover is that failed or delayed XLSX storage leaves the workbook pending and allows retry, and that acknowledging an older XLSX never clears a newer edit. |
With an embedded editor, Ctrl+S currently marks the workbook saved immediately after posting bytes to the parent, before durable storage has succeeded. A host can now opt into
?host=parent&save=managed: Save requests a native snapshot save, and only an acknowledgement identifying the latest exported request, document, and revision records that exact workbook as the saved baseline. Edits made while storage is pending remain dirty; stale or foreign acknowledgements cannot clear them. Legacy host saves remain unchanged.Builds on #2736 and relates to #2730. The follow-up also caps native validation input at 32 MiB before copying it and reports when no workbook is active, addressing the two minor review findings on #2736. Same-origin parent and source checks remain in force.
Validation: regression tests first reproduced the missing acknowledgement state and the real Chromium Ctrl+S premature dirty reset. Rust tests cover an older snapshot acknowledged after a new edit, exact latest acknowledgement, stale/foreign/new-document acknowledgements, and allocation-free 31/32/32 MiB + 1 length boundaries. Full
cargo xtask cipassed all 10 gates, with the pinned craft-fonts input and an existing Chromium SwiftShader Vulkan driver for the headless screenshot test. Independent source review checked the exact Arc baseline, acknowledgement identity guards, bounded latest pending snapshot, and before-copy length check. The browser fixture contains two sheets, formulas, formats, row height, merged cells and more than 4 MiB of native state; browser checks cover the managed lifecycle, oversized validation, and unchanged legacy save.Browser scope: Ctrl+S was exercised with a 4,304,375-byte native workbook, an intervening edit, stale/foreign acknowledgements, exact latest acknowledgement, oversized validation, and a reload into legacy mode. Web Save As and other XLSX workbook download paths use the same
Services.downloadcallback and therefore the same managed-save guard (source checked); their separate menus/dialogs were not browser driven. Non-workbook exports retain their existing behavior.Summary by CodeRabbit