Skip to content

Prepend emails to top of document instead of appending to bottom - #23

Merged
don-petry merged 10 commits into
mainfrom
copilot/fix-gmail-to-drive-order
Feb 8, 2026
Merged

Prepend emails to top of document instead of appending to bottom#23
don-petry merged 10 commits into
mainfrom
copilot/fix-gmail-to-drive-order

Conversation

Copilot AI commented Feb 8, 2026

Copy link
Copy Markdown
Contributor
  • Update README.md specifications to document prepend behavior
  • Add test for prepending behavior in document
  • Modify code.gs to prepend content instead of append
  • Update mocks to support insertParagraph
  • Create comprehensive integration test
  • Run full test suite (all tests pass)
  • Code review (addressed clarification needs)
  • Security check (no issues found)
  • Add clarifying comments to code
  • Fix message ordering to be explicit (sort by date)
  • Remove unused imports and variables
  • Add bounds checking to insertParagraph mock
  • Extract testable processing functions to src/index.js
  • Refactor integration tests to use real functions
  • Add copyBlob() support to mocks
  • Add deduplication test using production logic
  • Add clarifying comments for blob handling
  • Add comprehensive tests for 100% line coverage
Original prompt

This section details on the original issue you should resolve

<issue_title>gmail-to-drive adds new content to the bottom rather than top of document</issue_title>
<issue_description>When gmail-to-drive runs, it is appending the email content to the document rather than pre-pending. This forces the consumer of this content to scroll to the bottom of the document for the most recent and relevant content.

  • Add rule to specifications, tests and implementation that newer content should be added to the top of the document (prepended)</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits February 8, 2026 02:19
Co-authored-by: don-petry <36422719+don-petry@users.noreply.github.com>
Co-authored-by: don-petry <36422719+don-petry@users.noreply.github.com>
Co-authored-by: don-petry <36422719+don-petry@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix gmail-to-drive to prepend content to document Prepend emails to top of document instead of appending to bottom Feb 8, 2026
Copilot AI requested a review from don-petry February 8, 2026 02:23
@don-petry
don-petry marked this pull request as ready for review February 8, 2026 02:28
Copilot AI review requested due to automatic review settings February 8, 2026 02:28

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.

Pull request overview

Updates gmail-to-drive-by-labels so newly processed email content is inserted at the top of the target Google Doc, aiming to make the most recent content visible without scrolling.

Changes:

  • Switches document writes from appendParagraph(...) to insertParagraph(0/idx, ...) to prepend each email block.
  • Extends the DocumentApp test mock with insertParagraph(childIndex, text) support.
  • Adds new Jest tests intended to validate newest-first ordering and attachment listing with prepend behavior, and updates README wording.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
src/gmail-to-drive-by-labels/code.gs Changes message rendering to use insertParagraph with a per-message index to prepend content.
test-utils/mocks.js Adds insertParagraph support to the Document body mock for tests.
src/gmail-to-drive-by-labels/tests/prepend-behavior.test.js Adds unit-style tests around paragraph ordering when inserting at the top.
src/gmail-to-drive-by-labels/tests/integration.test.js Adds integration-style tests simulating the email processing flow with prepend behavior.
src/gmail-to-drive-by-labels/README.md Updates documentation to reflect prepend/newest-first behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/gmail-to-drive-by-labels/code.gs
Comment thread src/gmail-to-drive-by-labels/tests/integration.test.js Outdated
Comment thread src/gmail-to-drive-by-labels/tests/integration.test.js Outdated
Comment thread src/gmail-to-drive-by-labels/tests/prepend-behavior.test.js Outdated
Comment thread test-utils/mocks.js
Comment thread src/gmail-to-drive-by-labels/tests/integration.test.js Outdated
Comment thread src/gmail-to-drive-by-labels/tests/integration.test.js Outdated
Comment thread src/gmail-to-drive-by-labels/tests/integration.test.js Outdated
don-petry and others added 3 commits February 7, 2026 20:36
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…add bounds checking

Co-authored-by: don-petry <36422719+don-petry@users.noreply.github.com>
Copilot AI and others added 2 commits February 8, 2026 02:42
…tion

Co-authored-by: don-petry <36422719+don-petry@users.noreply.github.com>
Co-authored-by: don-petry <36422719+don-petry@users.noreply.github.com>
@don-petry

Copy link
Copy Markdown
Collaborator

@copilot - Code coverage test is failing. Add more tests until it passes.

Co-authored-by: don-petry <36422719+don-petry@users.noreply.github.com>

Copilot AI commented Feb 8, 2026

Copy link
Copy Markdown
Contributor Author

@copilot - Code coverage test is failing. Add more tests until it passes.

Fixed in commit e1098e4. Added 9 new comprehensive tests covering all previously uncovered code paths including:

  • Attachment name conflicts with timestamp renaming
  • File size and hash mismatch scenarios
  • Files without extensions
  • Logger, DocumentApp, Utilities, and Session option handling
  • DocumentApp setHeading fallback behavior
  • Duplicate detection with Logger

All coverage requirements now met:

  • Statements: 99.74% (required: 95%)
  • Branches: 90.70% (required: 85%)
  • Functions: 97.37% (required: 95%)
  • Lines: 100% (required: 100%)

@don-petry don-petry removed their assignment Feb 8, 2026
@don-petry
don-petry merged commit dccc306 into main Feb 8, 2026
4 checks passed
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.

gmail-to-drive-by-labels adds new content to the bottom rather than top of document

3 participants