Skip to content

feat(spectrum): users / lines / platforms / profile / avatar#8

Merged
citron (lcandy2) merged 2 commits into
mainfrom
feat/spectrum
Apr 29, 2026
Merged

feat(spectrum): users / lines / platforms / profile / avatar#8
citron (lcandy2) merged 2 commits into
mainfrom
feat/spectrum

Conversation

@lcandy2
Copy link
Copy Markdown
Member

@lcandy2 citron (lcandy2) commented Apr 29, 2026

Phase 7 — `spectrum` command group with five sub-resources, each defaulting to the linked project via `resolveProject()`. Largest sub-surface in the CLI.

New commands

  • `spectrum users` — `ls` / `add [--invite]` / `remove [-y]`. Interactive prompts in TTY for first/last/email/phone; required flags in non-TTY.
  • `spectrum lines` — `ls` / `add [--platform imessage]` / `remove [-y]`. Server currently only accepts `platform=imessage`; CLI rejects other values up front with a hint.
  • `spectrum platforms` — `ls` / `enable ` / `disable `. Both wrap `POST .../platforms/toggle`. Surfaces server's "Unsupported platform" error with a hint pointing at `platforms ls`.
  • `spectrum profile` — `show` / `update [--first-name --last-name --avatar-url]`. Only sends fields the user passes (server tolerates partial PATCH here).
  • `spectrum avatar upload ` — three-step flow:
    1. `GET .../spectrum/avatar-upload-url` → presigned PUT URL + final avatar URL.
    2. `PUT` file body with Content-Type from `Bun.file().type`.
    3. `PATCH .../spectrum/profile` with the new avatarUrl (skip with `--no-update-profile`).
      Partial-failure path: if upload succeeded but PATCH failed, prints the URL and the manual recovery command.

All commands accept the standard `--project / --env / --token / --json` flags and route errors through the central handler.

Layout

`src/commands/spectrum/{users,lines,platforms,profile,avatar}.ts` — one file per sub-resource. `spectrum/index.ts` wires them together via `registerSpectrumCommands(program)`.

Test plan

  • `photon --help` lists `spectrum`.
  • `photon spectrum --help` lists all 5 sub-resources.
  • Each sub-resource without `--project` / linked → friendly "No project linked" + hint.
  • `spectrum avatar upload /nonexistent` → "File not found".
  • `bunx tsc --noEmit` clean.
  • Live: real project with Spectrum tenant — exercise create user → list users → enable iMessage → add line → upload avatar.

Phase 6 + 7 status

🤖 Generated with Claude Code

Made with Orca 🐋

Summary by CodeRabbit

  • New Features
    • Added Spectrum avatar upload functionality
    • Added Spectrum profile management commands (show and update)
    • Added Spectrum user management commands (list, add, remove)
    • Added Spectrum phone line management commands (list, add, remove)
    • Added Spectrum platform integration commands (list, enable, disable)

Phase 7. The largest sub-surface — a `spectrum` command group with five
sub-resources, each defaulting to the linked project via resolveProject().

`spectrum users`
  ls            — table of all Spectrum users on the project
  add           — POST /api/projects/:id/spectrum/users (interactive
                  prompts for first/last/email/phone in TTY; --invite
                  triggers server-side onboarding email)
  remove <id>   — DELETE; confirmDestructive

`spectrum lines`
  ls            — table of phone lines with platform/number/status
  add           — POST /api/projects/:id/lines (server currently
                  accepts platform="imessage" only; CLI rejects other
                  values up-front with a hint)
  remove <id>   — DELETE; confirmDestructive

`spectrum platforms`
  ls                — Record<platform, on/off> rendered as a table
  enable <name>     — POST /api/projects/:id/platforms/toggle {enabled:true}
  disable <name>    — same with {enabled:false}
  (server returns "Unsupported platform" for unknown names; CLI surfaces
   that with a hint pointing at `platforms ls`)

`spectrum profile`
  show           — fetches the Spectrum-side metadata (firstName,
                   lastName, avatarUrl, etc.)
  update [...]   — PATCH; sends only the fields the user passed
                   (server tolerates partial)

`spectrum avatar upload <file>`
  Three-step flow:
    1. GET /api/projects/:id/spectrum/avatar-upload-url for the
       presigned PUT url + final avatar URL.
    2. PUT the local file body with Content-Type from Bun.file().type.
    3. PATCH the Spectrum profile with the new avatarUrl (skip with
       --no-update-profile).
  Surfaces upload-success / patch-failure separately so a partial
  failure prints the URL and the manual recovery command.

All commands accept the standard --project / --env / --token / --json
flags and route errors through the central handler.

src/index.ts: register the spectrum group via
registerSpectrumCommands(program). Layout uses a per-resource file
(src/commands/spectrum/{users,lines,platforms,profile,avatar}.ts) +
an index.ts that wires them together — keeps each file focused.

Verified:
- `photon --help` lists `spectrum`.
- `spectrum --help` lists all 5 sub-resources.
- Each sub-resource without a linked project / --project → friendly
  "No project linked" error with hint.
- avatar upload with missing file → "File not found".
- `bunx tsc --noEmit` clean.

Live verification deferred — needs a real project with a Spectrum
tenant set up to exercise create user / toggle imessage / list lines /
upload avatar end-to-end.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

Co-authored-by: Orca <help@stably.ai>
Copilot AI review requested due to automatic review settings April 29, 2026 09:45
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 29, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR introduces a comprehensive Spectrum CLI command suite with subcommands for managing avatars, profiles, users, phone lines, and platform integrations. Each subcommand handles project/environment resolution, authentication, API interactions, error handling, and formatted output.

Changes

Cohort / File(s) Summary
Spectrum Subcommands
src/commands/spectrum/avatar.ts, src/commands/spectrum/profile.ts, src/commands/spectrum/users.ts, src/commands/spectrum/lines.ts, src/commands/spectrum/platforms.ts
New command modules implementing five distinct Spectrum management features: avatar upload with optional profile patching, profile show/update with JSON/formatted output, user list/add/remove with interactive prompts, lines list/add/remove with destructive confirmation, and platform list/enable/disable. All include consistent API error handling (401 → SessionExpiredError), structured output formatting, and validation logic specific to each operation.
Command Registration
src/commands/spectrum/index.ts, src/index.ts
Main Spectrum command group registration that wires all five subcommand modules; integration into root CLI to expose the Spectrum command surface.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • photon-hq/dashboard#28: Corrects Spectrum endpoint paths that the new CLI commands invoke (avatar upload, platforms, profile).
  • photon-hq/dashboard#47: Implements backend Spectrum lines API and services that the new lines CLI command calls.
  • photon-hq/dashboard#22: Implements Spectrum platforms API and server actions that the new platforms CLI command uses.

Poem

🐰 Hopping through commands with joy and delight,
Avatars upload and profiles shine bright,
Users and lines and platforms aligned,
Spectrum adventures—all perfectly designed!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately summarizes the main change: adding a new spectrum command group with five sub-resources (users, lines, platforms, profile, avatar), which directly matches the substantial additions across multiple files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Warning

Review ran into problems

🔥 Problems

These MCP integrations need to be re-authenticated in the Integrations settings: Linear


Review rate limit: 2/5 reviews remaining, refill in 30 minutes and 36 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new spectrum command group to the Photon CLI, providing project-scoped Spectrum management (users, lines, platforms, profile, avatar) with consistent --project/--env/--token/--json support via resolveProject() and the central API client.

Changes:

  • Wire up photon spectrum command registration in the CLI entrypoint.
  • Implement spectrum users / lines / platforms / profile subcommands for CRUD-style operations.
  • Implement spectrum avatar upload with presigned URL upload flow and optional profile update.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/index.ts Registers the new spectrum command group in the root CLI.
src/commands/spectrum/index.ts Adds registerSpectrumCommands() and wires all Spectrum sub-resources.
src/commands/spectrum/users.ts Implements spectrum users list/add/remove with TTY prompting for required fields.
src/commands/spectrum/lines.ts Implements spectrum lines list/add/remove, with client-side platform validation.
src/commands/spectrum/platforms.ts Implements spectrum platforms list/enable/disable via platforms toggle endpoint.
src/commands/spectrum/profile.ts Implements spectrum profile show/update with partial PATCH support.
src/commands/spectrum/avatar.ts Implements avatar upload (presigned PUT) and optional profile patch, with partial-failure messaging.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/commands/spectrum/avatar.ts Outdated
Comment thread src/commands/spectrum/avatar.ts Outdated
Comment thread src/commands/spectrum/users.ts Outdated
3 substantive findings:

- spectrum/avatar.ts: replaced direct process.exit(1) on PATCH failure
  with die() so output goes through the central formatter (consistency
  with the rest of the CLI). Also rebuilds the manual-recovery hint to
  include the original --project / --env / --token context the user
  passed, and shell-quotes the avatar URL via a new shellQuote() helper
  so URLs with `&`, `?`, `;` etc. don't break shell copy-paste.
- spectrum/users.ts add: resolveProject() + getApi() now run BEFORE
  fillAddOpts(). Previously a user could fill out 4 interactive
  prompts (first/last/email/phone) only to learn they're not logged
  in or have no linked project. Now fails fast.

tsc clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

Co-authored-by: Orca <help@stably.ai>
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