Repository navigation
Edit tables in a directly bound Google Doc - #1069
Maximo-Guk wants to merge 3 commits into
Conversation
| if (first.link === undefined) { | ||
| requests.push({ style: [start, end, textStyle, UNLINKED_FIELDS] }); | ||
| } else { | ||
| requests.push({ style: [start, end, textStyle, FOUR_FIELDS] }); |
There was a problem hiding this comment.
[P2] Preserve non-link styling when clearing an existing link. Google documents that removing a link resets the range to the preceding text's style unless those styles are explicitly supplied (TextStyle.link). These requests supply only the three shown styles, so removing a link, or changing the destination of part of one, can also change its font size/family and other unshown formatting. I reproduced this with the PR's applyDocsRequests(..., { unlinkRestyles: true }): removing the anchor around 10pt Docs after a 20pt Prefix changes Docs to 20pt. This contradicts the preservation contract in packages/gatekeeper-google/README.md:377-379 that unlinking changes nothing else of the text's look. Carry the original non-link styling through to the clearing request so a link-only edit preserves it.
There was a problem hiding this comment.
This was checked against Google before the requests were written. In a live probe, clearing a link left the text with its own size, font and bold beside a neighbour that differed, whether the request named four fields or six: only the link, its underline and its colour went. So the reference's "reset to the preceding text's style" is not what the API does today, and the README sentence describes what it does. unlinkRestyles in the test model is the documented behaviour, there so some requests are checked under both; the requests are not written to be safe under it in every case, and yours is one. Restating every style of the run in the clearing request would turn styles the text inherits from its paragraph into styles set on it, so I would rather not do that for a behaviour Google does not show.
|
Review: 2 findings. Posted 2 actionable inline comments, verified with targeted reproductions. Additional read-only checks covered 10,000 cell-text replacements and 6,958 structural changes against the PR’s document model. |
Preview:
|
|
Since last review: 1 resolved, 1 still open, 0 new.
Both conclusions were confirmed with targeted, read-only reproductions. No additional actionable findings. |
A directly bound Google Doc can now change its tables; on main a table can be read but any edit that touches one is refused. `replaceText()` now works inside a table: it changes the text, and the bold, italic, strikethrough and links, of the paragraphs, headings and list items a table's cells hold, written in the HTML `getContent()` shows. Six methods change structure: `insertTable`, `insertTableRows`, `insertTableColumns`, `deleteTableRows`, `deleteTableColumns` and `deleteTable`. Adding tables, rows and columns is a new auto-approvable kind. Deleting a table or its rows or columns always waits for approval, since it deletes content. A queued change to an existing table remembers how its table read and applies only while exactly one table of the tab reads so. While another table reads the same, such a change is refused. Every change replays over the tab's Markdown, so a read shows queued changes as they will apply. The engine is checked against a model of a Google Docs body built from live probes of the API. What cannot be applied exactly is refused: merged cells, a table inside a cell, a table that holds suggested rows, columns or cells, a row beside a cell that holds only a smart chip (Google copies the chip into the new row), and an addition that would take a tab's tables past 5,000 cells. The document read now asks Google for compact JSON: the client refuses an answer over 10 MiB, and Google's default indentation makes a table-heavy document about four times larger. Co-Authored-By: Claude Code <noreply@anthropic.com>
The Workshop cuts a long approval card short, and the row, column and table cards led with the text before the table and its first row, so the rows a deletion removes sat below the cut. Those fields now follow the one that shows the change. Co-Authored-By: Claude Code <noreply@anthropic.com>
Deleting a table, or a row or column of it, deletes the tables its cells hold, and with them any row, column or cell suggested there. The outer table's map did not record those, so its deletion card said nothing of them and a deletion queued before such a suggestion appeared still applied. The map now looks through nested tables. Co-Authored-By: Claude Code <noreply@anthropic.com>
02614bf to
3675372
Compare
|
Since last review: 1 resolved, 0 still open, 0 new. LGTM! |
WIP -
Lets agents edit tables in a directly bound Google Doc: change the text in cells, insert a table, add and remove rows and columns, and delete a table. On main a table can be read, as HTML in the tab's Markdown, but any edit that touches one is refused.
API
replaceText()now works inside a table. A replacement that lies inside one table changes the text, and the bold, italic, strikethrough and links, of the paragraphs, headings and list items its cells hold, written in the HTMLgetContent()shows. It cannot add or remove paragraphs, cells, rows or columns.insertTable(table, tabId?), which returns the new table's position,insertTableRows,insertTableColumns,deleteTableRows,deleteTableColumnsanddeleteTable. A table is named by its position among the tab's tables, and its rows and columns by index.Approvals
How a queued change stays on its table
New cells
Refused, never approximated
Simulation
docs-tables.ts,docs-table-actions.tsand the converter) and is tested against a model of a Google Docs body built from live probes of the API (__tests__/docs-body-model.ts).Also changes main's read path
documents.getnow asks Google for compact JSON (prettyPrint=false). The client refuses an answer over 10 MiB, and Google's default indentation makes a table-heavy document three and a half times larger: 1,000 empty cells are 4.7 MB by default and 1.3 MB compact.Known gaps (in the README)
insertTable()leaves an empty paragraph there.Not in this PR
Checked against Google, and not
prettyPrint=false, and a table cell costs 1.3 to 1.4 KB in compact JSON against 4.7 to 5.1 KB with the default indentation. 5,000 cells are about 7 MiB compact, inside the client's 10 MiB limit; with the default indentation the limit is reached near 2,100 cells.Testing
pnpm --filter @gadgets/google-gatekeeper test:run: 2115 Node, 597 worker and 487 docs-worker cases pass.tscrun directly for both configs, andpnpm lint.Screenshots
Text replaced in a cell.
A row added, with its text.
A table added.
A row deleted. Deletions offer no "Always approve".
A column deleted.
A table deleted, shown as the column deletion queued before it leaves it.
🤖 Generated with Claude Code