Skip to content

TW-5658: fix drafts list timestamps and add drafts list --id flag#110

Merged
qasim-nylas merged 1 commit into
mainfrom
feature/TW-5658-drafts-timestamps-and-id-flag
Jun 21, 2026
Merged

TW-5658: fix drafts list timestamps and add drafts list --id flag#110
qasim-nylas merged 1 commit into
mainfrom
feature/TW-5658-drafts-timestamps-and-id-flag

Conversation

@qasim-nylas

@qasim-nylas qasim-nylas commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

nylas email drafts list rendered every draft's UPDATED column as "56 years ago". The Nylas v3 drafts API omits created_at/updated_at (or sends them as null) and carries the real timestamp in a date field (Unix seconds) — the CLI mapped the missing field to the Unix epoch / zero time. There was also no way to read a draft's full ID from the table without falling back to --json.

Fixes TW-5658.

Changes

  • internal/adapters/nylas/drafts.go — migrate draftResponse timestamp fields to domain.UnixTime; add firstSetTime(primary, fallback) so created_at/updated_at fall back to the date field when unset (handles both omitted → zero time and null → epoch).
  • internal/cli/common/time.goFormatTimeAgo now renders "unknown" for an unset timestamp (zero value or exact Unix epoch); a genuine pre-1970 time still formats normally.
  • internal/cli/email/drafts.go — add --id flag to drafts list to show full draft IDs (matches the email list / folders / threads convention); the ID column width and the separator line scale together; drafts show guards an unset UpdatedAt.
  • Tests added across the changed packages; docs/COMMANDS.md updated.

Verification

  • make ci green: fmt, vet, lint, unit, race, security scan, govulncheck (0), build.
  • Live: drafts now show correct relative/absolute times; table aligns in both default and --id modes.
  • Reviewed by Claude and Codex — both green.

Before / after

# before
r-5185231233... hn@ycombinator.com   Flagged Show HN...   56 years ago

# after (default)
r-5185231233... hn@ycombinator.com   Flagged Show HN...   8 minutes ago

# after (--id)
r-5185231233890164434  hn@ycombinator.com  Flagged Show HN...  8 minutes ago

Related docs

The Nylas v3 drafts API omits created_at/updated_at (or sends them as
null) and carries the real timestamp in a `date` field, so the CLI
rendered every draft's UPDATED column as "56 years ago" (Unix epoch).
The full draft ID was also unreachable from the table without --json.

- adapters/nylas/drafts: migrate draftResponse timestamps to
  domain.UnixTime; firstSetTime falls back to `date` when
  created_at/updated_at are unset (omitted -> zero time, null -> epoch).
- cli/common/time: FormatTimeAgo renders "unknown" for an unset
  timestamp (zero value or exact Unix epoch); pre-1970 times still format.
- cli/email/drafts: add `--id` flag to show full draft IDs (matches
  email list/folders/threads); ID column width and separator scale
  together; drafts show guards an unset UpdatedAt.
- Tests across the changed packages; docs/COMMANDS.md updated.
@qasim-nylas qasim-nylas requested a review from AaronDDM June 21, 2026 21:36

@AaronDDM AaronDDM left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@qasim-nylas qasim-nylas merged commit 11fdfcc into main Jun 21, 2026
7 checks passed
@qasim-nylas qasim-nylas deleted the feature/TW-5658-drafts-timestamps-and-id-flag branch June 21, 2026 21:50
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.

2 participants