Skip to content

feat(docs): add --tab-id flag to editing commands#330

Closed
ignacioreyna wants to merge 1 commit intoopenclaw:mainfrom
ignacioreyna:ignacioreyna/tab-id-flag-support
Closed

feat(docs): add --tab-id flag to editing commands#330
ignacioreyna wants to merge 1 commit intoopenclaw:mainfrom
ignacioreyna:ignacioreyna/tab-id-flag-support

Conversation

@ignacioreyna
Copy link
Copy Markdown

Summary

  • Adds --tab-id flag to write, insert, delete, find-replace, and update commands to target specific document tabs
  • Markdown write with --tab-id uses Docs API batch approach (Drive API can't target tabs)
  • Plain text write/replace with --tab-id fetches tab-aware content for correct endIndex calculation
  • find-replace uses TabsCriteria on ReplaceAllTextRequest per the API contract
  • Includes setTabIdOnRequests helper to stamp TabId on all Location/Range/EndOfSegmentLocation in batch requests

Closes #323

Design decisions

  • --tab-id (raw ID, no title resolution): Clients get tab IDs via gog docs list-tabs. No extra API call, no business logic for name matching on write paths. cat --tab stays as-is since it already fetches the doc so title resolution is free there.
  • docs update included: Same pattern as other editing commands — tab-aware doc fetch + setTabIdOnRequests on formatting requests.
  • Markdown + tab-id: Uses Docs API BatchUpdate (delete tab content → insert markdown-converted requests with TabId stamped) instead of Drive API Files.Update.

What's NOT included

  • docs update refactoring to support new markdown features (separate issue)

Also fixes

  • Pre-existing bug in contacts_crud.go: function parameter types were incorrectly typed as bool due to Go's shorthand syntax (given, familySet bool instead of given string, familySet bool)

Test plan

  • 12 new unit tests covering all 5 commands with/without --tab-id
  • Tab-not-found error cases tested
  • make fmt passes
  • make test passes (all packages)
  • make lint passes for our changes (5 pre-existing issues in contacts code)
  • Full E2E integration test against live Google Doc with multi-tab document
    • write, insert, delete, find-replace, update (all modes)
    • markdown write + replace to specific tab
    • bad tab ID error handling
    • backward compat (no --tab-id)
    • tab isolation verified (non-targeted tabs untouched)

🤖 Generated with Claude Code

Add --tab-id flag to write, insert, delete, find-replace, and update
commands to target specific document tabs. Markdown write with --tab-id
uses Docs API batch approach instead of Drive API.

Closes openclaw#323

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@steipete
Copy link
Copy Markdown
Collaborator

steipete commented Mar 8, 2026

Landed directly on main as a current-main port of the PR intent.

  • Gate: make fmt && go test ./internal/cmd -run 'TestDocsWriteUpdate_WithTabID|TestDocsEditingCommands_WithTabID|TestDocsWriteUpdate_WithTabID_TabNotFound|TestDocsWriteUpdate_' && make lint && make test && make worker-ci && make ci\n- Land commit: 5c20921\n- Main commit: 5c20921\n\nFixups included: port to the current --text / --file docs commands, tab-aware end-index lookup for write/update, --tab-id support for insert/delete/find-replace, README updates, and focused multi-tab regression coverage.\n\nThanks @ignacioreyna!

@steipete steipete closed this Mar 8, 2026
klodr pushed a commit to klodr/gogcli that referenced this pull request Apr 22, 2026
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.

feat(docs): add --tab flag to editing commands (write, insert, delete, find-replace)

2 participants