Skip to content

fix: avoid reapplying unchanged styled tables - #561

Merged
Songmu merged 5 commits into
mainfrom
fix/table-style-noop-comparison
Oct 13, 2026
Merged

Songmu merged 5 commits into
mainfrom
fix/table-style-noop-comparison

Conversation

@Songmu

@Songmu Songmu commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Resolve each selected Markdown table once into a reusable render containing expected comparison content and prepared API requests. Reuse it for comparison and upload, binding actual table object IDs only when emitting requests.
  • Fetch the current presentation at the start of each Apply and take a deep snapshot of text, shape, and table styles. Intermediate presentation refreshes do not replace this snapshot; the next Apply reloads styles, including in watch mode. Removed template styles are cleared, and errors release the frozen state.
  • Preserve original Markdown flags so automatic header bold cannot trigger the named bold inline style.
  • Preserve unchanged tables during other slide edits and leave unselected API-derived slides untouched during partial applies.
  • Keep the intentionally limited comparison scope: structure, text, horizontal alignment, bold, italic, link, and inferred code. Do not compare authoring style names, colors, font sizes, backgrounds, borders, placement, or sizing; changes limited to those properties may intentionally produce no update.
  • Merge equivalent adjacent fragments and normalize only the single API-added cell terminator. Preserve leading, internal, trailing, and newline-only user text, including soft line breaks. Treat user whitespace as content when clearing or refilling tables.
  • Preserve existing table request ordering and batching.

Regression coverage

Unchanged styled tables require one initial presentation GET per Apply and zero writes, including partial page applies with an unselected styled slide.

Additional cases cover custom styles that unset bold, explicit bold addition/removal, named styles, template alignment, merged text runs, actual content changes, insertion/deletion/reordering, and retaining original Markdown styles in generated actions.

Render-reuse tests cover immutable prepared output, independent object-ID binding, UTF-16 ranges, request counts, and upload reuse. Mocked Apply lifecycle tests verify nested style values remain fixed across intermediate refreshes and source-layout mutations, reload on the next Apply, clear removed styles, and release the snapshot on errors.

Text tests cover leading and trailing newlines, multiple trailing newlines, separately styled API terminators, paragraph boundaries, soft line breaks, newline-only cells, and whitespace content. Removing a user newline must still trigger an update.

Validation

  • go test -race ./... -count=1
  • golangci-lint run ./...
  • git diff --check

No live Google Slides presentation was modified during verification.

Account for table and inline styles without changing the Markdown used for rendering. Avoid unnecessary slide updates and table rewrites, including partial page applies.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 73f03903-f3f5-4f68-ba46-b9f550a79c8c
@github-actions

This comment has been minimized.

@Songmu
Songmu marked this pull request as ready for review October 13, 2026 04:56
@Songmu
Songmu requested a balanced review from Copilot October 13, 2026 04:56

Copilot AI left a comment

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.

🟡 Changes recommended

Comparison snapshots discard supported style fields, potentially suppressing required table updates.

1 open finding
What changed in this PR

Improves styled-table comparisons to avoid unnecessary Google Slides updates while preserving Markdown formatting.

Changes:

  • Compares tables using rendered style snapshots.
  • Normalizes selected pages and merged text fragments.
  • Adds regression tests and documentation.
File Description
action.go Adds style-aware action generation.
apply.go Normalizes selected pages during partial applies.
compare.go Compares rendered tables and merged fragments.
README.md Documents table comparison behavior.
slide.go Stores comparison-only table snapshots.
table.go Renders expected table styles for comparison.
table_comparison_test.go Adds styled-table regression coverage.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread table.go Resolved

Copilot AI left a comment

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.

🔵 Needs a closer look

The comparison discards several supported text-style properties, allowing stale styled tables to compare as unchanged.

1 open finding

🧠 Review effort: Balanced

Resolve table styles once into a reusable render containing expected content and prepared API requests. Reuse it during action selection, structural updates, and content upload; bind table IDs without resolving styles again.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 73f03903-f3f5-4f68-ba46-b9f550a79c8c
@Songmu
Songmu requested a balanced review from Copilot October 13, 2026 05:07
@github-actions

This comment has been minimized.

Copilot AI left a comment

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.

🟡 Changes recommended

Comparison loses supported styles and line breaks, while cached requests retain mutable style aliases.

2 open findings
Previously missed (2)

In code that hasn't changed since last review

Medium severity Include all emitted style properties in table comparisons

table.go:456

The comparison render only stores a Table, which represents horizontal alignment and the limited Fragment flags. Styles that are emitted solely as requests—cell background, vertical alignment, borders, and text properties such as font size, arbitrary font/color, underline, or strikethrough—are absent from both this expected value and convertSlidesToTable. Consequently, changing any of those supported template styles leaves the tables equal and suppresses the update, so the new style is never applied. Include all emitted style properties in the comparison representation (and extract the corresponding current properties) before using it to skip updates.

Medium severity Preserve trailing and newline-only fragments during comparison

table.go:545

Rendering the expected fragment through convertTextRunToFragment applies API-response normalization to Markdown input. In particular, it trims a trailing newline and drops a newline-only fragment, so a table cell containing <br> or a hard line break is rendered for comparison without that break, while the uploaded request still includes it. The refreshed Slides table therefore never equals this render and is rewritten on every apply. Preserve the original fragment value while deriving only its effective style (or split style extraction from API text normalization).

🧠 Review effort: Balanced

Comment thread table.go
Comment on lines +582 to +584
requests = append(requests, d.applyTableBorderStyles("", table)...)

return requests, nil
rendered.requests = requests
Songmu and others added 2 commits October 13, 2026 14:41
Reload the presentation at the start of each apply, deep-copy text, shape, and table styles, and keep them fixed through intermediate refreshes. Reload edits and remove stale styles on the next apply, including watch mode.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 73f03903-f3f5-4f68-ba46-b9f550a79c8c
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 73f03903-f3f5-4f68-ba46-b9f550a79c8c
@github-actions

This comment has been minimized.

Copilot AI left a comment

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.

🟢 Approval recommended

The implementation is coherent, preserves request behavior, and includes comprehensive regression coverage for the affected lifecycle and comparison paths.

1 open finding
1 resolved since last review

🧠 Review effort: Balanced

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 73f03903-f3f5-4f68-ba46-b9f550a79c8c
@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Code Metrics Report

main (d94bdb3) main (d94bdb3) +/-
Coverage 65.0% 67.5% +2.4%
Code to Test Ratio 1:0.9 1:1.0 +0.0
Test Execution Time 9m1s 9m5s +4s
Details
  |                     | main (d94bdb3) | main (d94bdb3) |  +/-  |
  |---------------------|----------------|----------------|-------|
+ | Coverage            |          65.0% |          67.5% | +2.4% |
  |   Files             |             32 |             33 |    +1 |
  |   Lines             |           3469 |           3561 |   +92 |
+ |   Covered           |           2258 |           2405 |  +147 |
+ | Code to Test Ratio  |          1:0.9 |          1:1.0 |  +0.0 |
  |   Code              |           7120 |           7264 |  +144 |
+ |   Test              |           7063 |           7930 |  +867 |
- | Test Execution Time |           9m1s |           9m5s |   +4s |

Code coverage of files in pull request scope (77.2% → 81.6%, patch 95.0%)

Files Coverage +/- Patch Coverage Status
action.go 81.6% +0.2% 100.0% modified
apply.go 72.0% +0.7% 88.2% modified
compare.go 89.5% +6.7% 100.0% modified
convert.go 90.9% +0.7% 93.9% modified
deck.go 73.4% -0.1% 100.0% modified
slide.go 95.2% 0.0% - modified
style.go 91.0% +8.9% - affected
style_snapshot.go 92.8% +92.8% 89.4% added
table.go 90.0% +17.0% 97.8% modified

Reported by octocov

@Songmu
Songmu merged commit 380afd4 into main Oct 13, 2026
1 check passed
@Songmu
Songmu deleted the fix/table-style-noop-comparison branch October 13, 2026 06:01
@github-actions github-actions Bot mentioned this pull request Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

⌂ 换网址