Skip to content

TW-5464: support setting and updating agent account display name#105

Merged
qasim-nylas merged 1 commit into
mainfrom
feature/TW-5464-agent-account-name
Jun 17, 2026
Merged

TW-5464: support setting and updating agent account display name#105
qasim-nylas merged 1 commit into
mainfrom
feature/TW-5464-agent-account-name

Conversation

@qasim-nylas

Copy link
Copy Markdown
Collaborator

Summary

Adds an optional top-level name (display name) to Nylas-managed agent accounts:

  • nylas agent account create <email> --name "Support Bot"
  • nylas agent account update <id|email> --name "Support Bot"

name is a top-level grant field (POST /v3/connect/custom and PATCH /v3/grants/{id}), not a settings entry, and is omitted from the request when empty. This matches how the auth service parses and persists the grant name.

Why the preserve-on-update logic

The grant update replaces the full record, so an update that omits name would clear an existing display name. To prevent that, every update re-sends the existing name unless the caller explicitly overrides it — so rotating an app password (or renaming) never wipes the name. The create app-password fallback path re-sends the name for the same reason.

Validation: 1–256 characters, measured in runes (utf8.RuneCountInString) so multi-byte names aren't wrongly rejected. Clearing a name back to empty is not supported by the grant API and is documented as such.

Changes

  • domain (internal/domain/agent.go): AgentAccount.Name
  • port (internal/ports/agent.go): name added to CreateAgentAccount/UpdateAgentAccount
  • adapter (internal/adapters/nylas/agent.go, managed_grants.go): sends name top-level (omit when empty), parses it back; demo + mock updated
  • CLI (internal/cli/agent/create.go, update.go, helpers.go): --name flag on create and update, validateAgentName, resolveEffectiveName preservation, name shown in details
  • Air web (internal/studio/handlers_accounts.go): name accepted on create/patch with the same preservation + validation
  • docs: docs/commands/agent.md, agent-getting-started.md, COMMANDS.md

Testing

  • make ci green: fmt, vet, lint, unit, race, security, vuln, build
  • New unit/adapter/httptest coverage: top-level placement (not under settings), omit-when-empty, round-trip, rune-based length limits, and name preservation on app-password rotation (CLI fallback + Air handler)
  • make ci-full: quality gate, CLI regressions, and the full agent integration suite pass against the live API. (One unrelated failure: TestSlack_Workflow/list_users hit a Slack API rate limit — environmental, not from this change.)

Related docs

Add an optional top-level `name` (display name) to agent accounts,
settable on `nylas agent account create --name` and updatable via
`nylas agent account update --name`.

`name` is a top-level grant field (POST /v3/connect/custom and
PATCH /v3/grants/{id}), not a setting, and is omitted when empty.
Because the grant update replaces the full record, updates re-send
the existing name unless the caller overrides it, so an app-password
rotation (or rename) never wipes the display name. Validation is
1-256 runes.

Threaded through the domain model, ports.AgentClient, the HTTP/demo/
mock adapters, the CLI create/update commands (and the create
app-password fallback), and the Air web handler. Docs updated.
@qasim-nylas qasim-nylas requested a review from AaronDDM June 17, 2026 18:05

@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 ac21d3e into main Jun 17, 2026
7 checks passed
@qasim-nylas qasim-nylas deleted the feature/TW-5464-agent-account-name branch June 17, 2026 18:06
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