Skip to content

feat(docs comments): resolve which tab a comment belongs to in one fetch - #965

Merged
steipete merged 3 commits into
openclaw:mainfrom
ryo-touch:feat/961-docs-comments-locate
Aug 9, 2026
Merged

feat(docs comments): resolve which tab a comment belongs to in one fetch#965
steipete merged 3 commits into
openclaw:mainfrom
ryo-touch:feat/961-docs-comments-locate

Conversation

@ryo-touch

Copy link
Copy Markdown
Contributor

closes #961

What

Adds two opt-in flags to gog docs comments list:

  • --locate attaches a per-comment location object (matches, orphaned), resolved from a single documents.get(includeTabsContent=true) shared by every comment.
  • --tab <title|id> implies --locate and keeps comments with at least one match in that tab. Resolved through the existing resolveTabArg path, so the hidden deprecated --tab-id works like it does on the sibling commands.

Today docs comments locate answers this for one comment per invocation, each paying its own document fetch — annotating a 23-comment doc costs 23 fetches.

$ gog docs comments list <docId> --tab "Planning" --all --plain
TYPE     ID           AUTHOR  QUOTED  CONTENT  CREATED  RESOLVED  ACTION  TAB
comment  AAACANyRdjw  ...                                                 Planning
{
  "docId": "",
  "tab": { "id": "t.abc", "title": "Planning" },   // only with --tab
  "comments": [
    { "id": "AAA…", "quotedFileContent": {},
      "location": { "matches": [{"startIndex": 1, "endIndex": 19, "paragraphIndex": 0, "tabId": "t.abc"}],
                    "orphaned": false } }
  ],
  "nextPageToken": ""
}

Design notes

  • Strictly opt-in. Without the new flags not a line of the new code runs: same Drive-only path, same bytes on stdout, no Docs scope. A test installs a Docs service factory that calls t.Fatal to keep it that way.
  • Ambiguity stays visible. matches always spans every tab, never truncated to the target tab, so a quote appearing in two tabs is detectable by the caller. --tab passes a comment when any match lands in the tab.
  • --tab drops anything that resolves to no tab — orphaned quotes and comments with no quoted text (e.g. document-level ones). --locate alone reports them with orphaned: true rather than dropping them.
  • Exit codes unchanged. list --locate deliberately does not inherit locate's exitCodeOrphaned (11); orphaned is per-item state here. Only --fail-empty (3) and the usual auth codes apply.
  • Pagination. With --tab and no --all, filtering can empty a page, so the command walks pages until one yields a match — mirroring the existing scan-for-open loop in listDriveComments, and reusing the one already-fetched document (with a seen-token guard against a repeating nextPageToken).
  • driveCommentWithLocation embeds *drive.Comment and overrides MarshalJSON: the generated type declares MarshalJSON on a value receiver, so the promoted method would silently drop location. Same pattern as eventWithCalendar in calendar_list.go; there's a unit test that fails if the override is removed.

Option A vs B

The issue asked which shape you'd prefer and I didn't want to sit on the patch, so this is Option A. The batch resolution lives behind docsCommentLocator in its own file, so Option B (docs comments locate --all) would only need a different command layer — no change to the resolver. Happy to reshape it, or to close this if you'd rather own the design.

Testing

  • make ci green.
  • 11 new tests: default-path-unchanged (asserts no Docs service is created), single-fetch proof, orphaned/unquoted handling, --tab filtering and implied --locate, cross-tab matches preserved, page scanning, --fail-empty, unknown tab, tabless documents, plain-table columns, and the MarshalJSON regression guard.
  • Verified the default table/plain rendering is byte-identical to main by running the same fixture (replies, truncation, nil entries) through both implementations.
  • Live, against a 20+ tab doc with 23 comments: --locate resolved all 23 in one fetch (21 located across 5 tabs, 2 orphaned, 2 matching in more than one tab), and every matches array was identical to running docs comments locate per comment. --tab by ID and by (Japanese) title returned the same 5 comments.

`docs comments list` gave no hint which tab a comment belongs to, and
`docs comments locate` answers that for one comment per invocation, each
paying its own documents.get. Annotating a 30-comment doc cost 30 fetches.

Add opt-in `--locate` and `--tab` that share a single
documents.get(includeTabsContent=true) across every comment, reusing the
matching path `docs comments locate` already uses. Without the new flags
the command is unchanged and still needs only the Drive scope.

`matches` always spans every tab so callers can detect an ambiguous quote;
`--tab` keeps a comment when any match falls in the target tab, which drops
orphans and unquoted comments.

closes openclaw#961
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. labels Aug 7, 2026
@clawsweeper

clawsweeper Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 9, 2026, 12:10 AM ET / 04:10 UTC.

ClawSweeper review

What this changes

Adds opt-in --locate and --tab flags to gog docs comments list, resolving comment quotes against one shared Docs document fetch and optionally filtering by tab.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep open for normal merge: the maintainer explicitly adopted Option A, and the current head has sufficient redacted signed-binary proof for the opt-in behavior. No blocking patch defect was found.

Priority: P3
Reviewed head: 3f261ff0540d57e7ca072dc3b4ea324bb427a062

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused opt-in implementation with substantial focused tests and maintainer-provided real-behavior proof.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): A maintainer posted redacted signed-binary terminal proof of the after-fix default, locate, tab-filter, empty-selector, and one-fetch behaviors.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): A maintainer posted redacted signed-binary terminal proof of the after-fix default, locate, tab-filter, empty-selector, and one-fetch behaviors.
Evidence reviewed 4 items Existing matching boundary: Current main already has the per-comment quote matcher that searches every tab; the PR reuses that behavior for batch resolution rather than introducing a parallel matching algorithm.
Opt-in implementation: The PR head fetches the document once with tab content and attaches locations from that shared document, while the unchanged default path remains Drive-only.
Prior blocker resolved: The current head rejects explicitly supplied empty tab selectors, covering the previous P2 review finding.
Findings None None.
Security None None.

How this fits together

The Docs comments command normally lists file-scoped Drive comments. With the new flags, it obtains one Google Docs document view, matches each comment’s quoted text across tabs, and returns enriched JSON or table output.

flowchart LR
A[CLI flags] --> B[Drive comment list]
B --> C{Locate or tab requested?}
C -->|No| D[Existing Drive-only output]
C -->|Yes| E[One Google Docs fetch]
E --> F[Resolve quotes across tabs]
F --> G[Filtered JSON or table output]
Loading

Before merge

  • Complete next step (P2) - The approved implementation is proof-positive and has no concrete repair to delegate; it only needs the normal merge path.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Implementation and coverage production +340/-8; tests +464/-2; docs +22 The new batch resolver is accompanied by focused coverage for the default path, single fetch, tab filtering, pagination, output, and empty-selector behavior.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #961
Summary: This PR is the accepted implementation candidate for the open request in the linked issue.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Land the approved strictly opt-in batch resolver once the normal required checks complete.

Do we have a high-confidence way to reproduce the issue?

Not applicable as a bug reproduction; the maintainer’s redacted signed-binary run directly demonstrates the new real command behavior after the fix.

Is this the best way to solve the issue?

Yes. The approved list-command surface reuses the established quote-matching behavior, preserves the default Drive-only path, and avoids one Docs fetch per comment.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against e32b1f73a73a.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. A maintainer posted redacted signed-binary terminal proof of the after-fix default, locate, tab-filter, empty-selector, and one-fetch behaviors.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): A maintainer posted redacted signed-binary terminal proof of the after-fix default, locate, tab-filter, empty-selector, and one-fetch behaviors.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P3: This is an approved opt-in CLI ergonomics feature with limited blast radius.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): A maintainer posted redacted signed-binary terminal proof of the after-fix default, locate, tab-filter, empty-selector, and one-fetch behaviors.
  • proof: sufficient: Contributor real behavior proof is sufficient. A maintainer posted redacted signed-binary terminal proof of the after-fix default, locate, tab-filter, empty-selector, and one-fetch behaviors.

Evidence

What I checked:

  • Existing matching boundary: Current main already has the per-comment quote matcher that searches every tab; the PR reuses that behavior for batch resolution rather than introducing a parallel matching algorithm. (internal/cmd/docs_comments_locate.go:75, 4747fb05a429)
  • Opt-in implementation: The PR head fetches the document once with tab content and attaches locations from that shared document, while the unchanged default path remains Drive-only. (internal/cmd/docs_comments_locate_batch.go:100, 3f261ff0540d)
  • Prior blocker resolved: The current head rejects explicitly supplied empty tab selectors, covering the previous P2 review finding. (internal/cmd/docs_comments.go:58, 3f261ff0540d)
  • Maintainer decision and live proof: The maintainer selected Option A and posted a redacted signed-binary terminal transcript showing default behavior unchanged, location output, tab filtering, explicit-empty validation, and the one-fetch invariant. (833dd764ce0d)

Likely related people:

  • steipete: Current-main blame attributes the existing Docs comment-location behavior to Peter Steinberger’s released work, and he merged main into this branch, fixed the prior review concern, selected the product direction, and supplied current-head proof. (role: current feature-history contributor and reviewer; confidence: high; commits: 4747fb05a429, 833dd764ce0d, 3f261ff0540d; files: internal/cmd/docs_comments_locate.go, internal/cmd/docs_comments.go, internal/cmd/docs_comments_locate_batch.go)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (16 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-08T13:04:48.686Z sha b25d995 :: needs real behavior proof before merge. :: [P2] Reject explicitly empty tab values
  • reviewed 2026-08-08T13:08:34.406Z sha b25d995 :: needs real behavior proof before merge. :: [P2] Reject explicitly empty tab values
  • reviewed 2026-08-08T14:56:16.752Z sha b25d995 :: needs real behavior proof before merge. :: [P2] Reject explicitly empty tab selectors
  • reviewed 2026-08-08T16:04:58.104Z sha b25d995 :: needs real behavior proof before merge. :: [P2] Reject explicitly empty tab selectors | [P2] Leave the changelog entry to the release owner
  • reviewed 2026-08-08T17:22:21.118Z sha b25d995 :: needs real behavior proof before merge. :: [P2] Reject explicitly empty tab selectors
  • reviewed 2026-08-08T18:41:27.320Z sha b25d995 :: needs real behavior proof before merge. :: [P2] Reject explicitly empty tab selectors
  • reviewed 2026-08-08T20:14:48.686Z sha b25d995 :: needs real behavior proof before merge. :: [P2] Reject explicitly empty tab selectors
  • reviewed 2026-08-08T23:21:29.839Z sha b25d995 :: needs real behavior proof before merge. :: [P2] Reject explicitly empty tab selectors

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 8, 2026
@steipete

steipete commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator

Maintainer decision: adopt Option A (docs comments list --locate/--tab). The combined listing is the right ownership boundary for the stated review-feedback workflow, and both flags remain strictly opt-in.

Current-head signed-binary proof (833dd764ce0d08c52daa6810890f2a62107826bf), with account/document/tab/comment identities and all content redacted:

document_tabs=3; default_comments=15; located_comments=15; matched_comments=3
default_location_keys=0; located_location_keys=15
tab_filter_count=3; all_results_touch_target_tab=true
plain_tab_column=true
explicit_empty_tab_rejected=true; explicit_empty_tab_id_rejected=true; pre_auth=true
one_docs_fetch_invariant=focused-http-test-pass
behavior-validator: clauses 1-6 PASS; default/locate comparison and derived-tab filter probes PASS

The real --tab value was derived from a located match, then every filtered comment was checked to contain that tab in its full match array. The focused HTTP-level test separately proves one documents.get(includeTabsContent=true) across all comments and page scanning.

Full local make ci and final Codex autoreview are clean. The contributor-owned changelog edit was removed; the maintainer will add the credited entry after landing.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete
steipete marked this pull request as ready for review August 9, 2026 04:05
@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 9, 2026
@steipete
steipete merged commit 6ff1627 into openclaw:main Aug 9, 2026
12 checks passed
@steipete

steipete commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator

Landed in 6ff1627e14ea5320569afab3c61a92f1987ce58b; maintainer changelog follow-up is b57df1c41.

Maintainer work before landing:

  • Adopted Option A (docs comments list --locate/--tab).
  • Merged current main, removed the contributor-owned changelog edit for maintainer follow-up, and rejected explicit empty --tab / --tab-id values before service creation.
  • Added regression coverage and documentation for that validation.

Proof:

  • GOCACHE=<lane-private-cache> make ci — passed the complete local gate.
  • Signed current-head binary ran read-only against a real three-tab document with identities/content redacted: default listing returned 15 comments with zero location keys; --locate returned the same 15 with 15 location objects and three real range matches; a tab derived from those matches returned three comments, all touching the selected tab; plain output added TAB.
  • Focused HTTP-level tests prove exactly one Docs fetch across all comments and page scanning, while the default path never creates a Docs service.
  • Empty --tab and --tab-id values failed before auth/service access.
  • Final Codex autoreview: clean, no accepted/actionable findings; ClawSweeper marked proof sufficient with no patch findings.
  • First-time contributor gates were approved for exact runs 31293888385 and 31293888410; Linux, worker, Windows, Darwin, and Docker all passed.

Thanks @ryo-touch for the unusually thorough proposal, tests, and original live validation.

@ryo-touch

Copy link
Copy Markdown
Contributor Author

@steipete Thank you for reviewing and merging this pr. I am looking forward to release!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(docs comments): resolve which tab a comment belongs to — --tab filter / --locate on docs comments list

2 participants