Add label workflows to the CLI and TUI - #207
Conversation
There was a problem hiding this comment.
Pull request overview
Adds label workflows across the CLI and Mail TUI using HEY’s typed folder APIs.
Changes:
- Adds label listing, pagination, creation, assignment, and removal commands.
- Adds TUI label navigation, pagination, and management picker.
- Updates output sanitization, documentation, tests, and SDK dependency.
Tip
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.
Reviewed changes
Copilot reviewed 24 out of 25 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
.surface |
Registers the label command surface. |
API-COVERAGE.md |
Documents covered label endpoints. |
README.md |
Documents CLI and TUI label workflows. |
go.mod |
Pins HEY SDK v0.6.1. |
go.sum |
Updates SDK checksums. |
skills/hey/SKILL.md |
Adds label guidance and triggers. |
tests/smoke/labels_test.go |
Adds label read and validation smoke tests. |
internal/cmd/drafts_test.go |
Generalizes formatted-command test helpers. |
internal/cmd/help.go |
Adds labels to curated help. |
internal/cmd/help_test.go |
Updates help expectations. |
internal/cmd/label.go |
Implements label CLI commands. |
internal/cmd/label_test.go |
Tests label commands and pagination. |
internal/cmd/root.go |
Registers label commands. |
internal/folders/navigation.go |
Discovers labels from navigation. |
internal/folders/navigation_test.go |
Tests label discovery. |
internal/models/box.go |
Adds folder metadata to postings. |
internal/output/writer.go |
Sanitizes Markdown cells. |
internal/output/writer_test.go |
Tests Markdown sanitization. |
internal/tui/folders.go |
Implements the label picker. |
internal/tui/mail.go |
Integrates labels into Mail. |
internal/tui/mail_test.go |
Tests label TUI workflows. |
internal/tui/move.go |
Excludes labels from move destinations. |
internal/tui/nav.go |
Adds collision-safe label navigation. |
internal/tui/tui.go |
Handles background Mail loading. |
internal/tui/tui_test.go |
Tests inactive loading and collisions. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 27 out of 28 changed files in this pull request and generated no new comments.
Suppressed comments (2)
internal/output/writer.go:362
- A value that already contains
\|is transformed into\\|: Markdown consumes the first pair as a literal backslash, leaving the pipe to split the table cell. Escape backslashes before escaping pipes so arbitrary values cannot still change the table layout.
value = strings.ReplaceAll(value, "|", `\|`)
tests/smoke/labels_test.go:44
- This compares a decoded label name with raw HTML, so a valid name such as
Travel & Expensesappears asTravel & Expensesand fails the smoke test. Compare against decoded page text (the existingbrowserPageTexthelper) or unescape the HTML before asserting.
html := fetchHTML(t, baseURL+"/folders")
if !strings.Contains(html, folder.Name) {
t.Errorf("folder page does not contain %q", folder.Name)
Sensitive Change Detection (shadow mode)This PR modifies control-plane files:
|
ce6aa07 to
469f539
Compare
469f539 to
824032f
Compare
Summary
Add HEY label workflows to both the CLI and the Mail TUI, using the same Labels terminology as the web UI while retaining the server and SDK's internal folder resource names.
hey labelsandhey label <id>with cursor pagination, limits, complete traversal, and structured/styled outputhey label add|create|removefor existing labels, new labels, individual removal, and removing every labeln/plabel paginationglabel picker for adding, creating, and removing labelshey-sdk/go@v0.6.1pagination APIBehavior
CLI commands:
Label reads expose posting IDs, derived topic IDs,
next_page, andtotal_count. Mutations validate positive, unique thread IDs before making requests.Scope and compatibility
/my/navigation.jsonand reads them through the SDKFolders()service.hey-sdkand wire-level folder names such as/foldersandfolder_idas implementation details.Validation
Unit coverage includes CLI request contracts, validation-before-request behavior, pagination, styled/Markdown sanitization, TUI navigation and picker workflows, retry and stale-response handling, pagination key scoping, and box/label identity collisions. Independent and Copilot reviews identified actionable CLI, TUI, output-contract, and smoke-cleanup edge cases. This head resolves every finding and both suggestions suppressed by Copilot’s follow-up review; all review threads are resolved, and focused re-review found no remaining P0/P1/P2 issues.
Reviewer focus
internal/cmd/label.goandinternal/folders/navigation.go: command contracts, opaque pagination cursors, and label discovery.internal/tui/mail.goandinternal/tui/folders.go: source lifecycle,n/pscoping, stale-response guards, and label picker behavior.internal/output/writer.go: shared Markdown sanitization and escaping.Traceability
This PR must not be merged without explicit approval.
Summary by cubic
Adds Labels to the CLI and Mail TUI so users can list and manage labels without the web app. Previously labels were unavailable; now Mail shows labels after HEY boxes, supports per‑label n/p pagination, and a height‑aware g picker to add, create, or remove labels. Markdown output now sanitizes terminal controls, escapes table pipes while preserving backslashes, and renders newlines as
.
hey labels;hey label <id>with cursor pagination (--limit,--all,--page);hey label add|create|removewith positive, unique thread ID validation./my/navigation.json; reads label pages with SDKFolders().GetPage; g manages add/create/remove; n/p paginates per label; guards reject stale navigation, keep known labels on transient failures; preserves boxes alongside labels on ID/name collisions; move picker excludes labels from destinations.Postings().File/Unfile; create viaPostings().CreateFolder; “folders” remain an internal term. Fixeshey boxthread ID display to prefer topic ID and fall back to posting ID. Pinsgithub.com/basecamp/hey-sdk/gotov0.6.1. Help,.surface, README,skills/hey, API coverage, and tests (unit and smoke) updated. No server changes, migrations, or flags; rollback is a revert.Reviewer focus
internal/cmd/label.gofor command contracts, validation, pagination; curated help ininternal/cmd/help.go.internal/folders/navigation.gofor label discovery;internal/tui/mail.goandinternal/tui/folders.gofor per‑label pagination, picker behavior, and stale‑response guards;internal/tui/move.goandinternal/tui/nav.gofor excluding labels from move destinations and preserving boxes when IDs/names collide.internal/output/writer.goMarkdown sanitization and escaping.Written for commit 824032f. Summary will update on new commits.