Skip to content

fix: projects create disabling all platforms by default - #89

Closed
Henry Zhang (caezium) wants to merge 3 commits into
mainfrom
henry/eng-2058-fix-projects-create-disabling-all-platforms-by-default
Closed

fix: projects create disabling all platforms by default#89
Henry Zhang (caezium) wants to merge 3 commits into
mainfrom
henry/eng-2058-fix-projects-create-disabling-all-platforms-by-default

Conversation

@caezium

@caezium Henry Zhang (caezium) commented Jul 21, 2026

Copy link
Copy Markdown
Member

Summary

  • Omit platforms when --platforms is absent or blank, allowing the Dashboard API to apply its iMessage default.
  • Preserve explicit platform selections, including trimming and deduplication.
  • Clarify the interactive prompt’s blank-answer behavior.
  • Add contract coverage at the serialized HTTP request boundary through the CLI, getApi(), and Eden treaty.

Why

photon projects create previously serialized platforms: [] when no platform was provided. The server interprets an explicit empty array as no platforms enabled, while an omitted field defaults to ["imessage"]. This created projects that could subsequently return 403 when connecting.

Upstream version

  • (none)

Routes added/removed/changed

  • (none)

Snapshot changes

  • (none)

New runtime dependencies

  • (none)

Test plan

  • nvm use 24
  • ~/.bun/bin/bun run check — typecheck, 93 tests, and build passed
  • ~/.bun/bin/bun test tests/contract/projects.contract.test.ts
  • Production smoke test without --platforms

Checklist

  • API types were not changed or hand-edited
  • No new runtime dependencies
  • All snapshot diffs explained above
  • bun run check passes locally

View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.


Note

Low Risk
Scoped to project-create CLI serialization and prompt copy; behavior fix aligns with API defaults and is covered by new contract tests.

Overview
photon projects create no longer sends platforms: [] when --platforms is missing or only whitespace/commas. The create payload now leaves platforms out so the Dashboard API can apply its iMessage default instead of treating an empty array as “no platforms enabled.”

Non-interactive and interactive flows both go through normalizeOptionalPlatforms, which still parses, trims, dedupes, and validates explicit values. The interactive prompt now states that a blank answer uses the iMessage default.

Contract tests assert the serialized POST /api/projects body via the mock server (absent/empty --platforms omits the field; explicit lists are preserved).

Reviewed by Cursor Bugbot for commit 87763c7. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • Bug Fixes

    • Improved project creation platform handling.
    • Omitting --platforms or entering a blank value now preserves the default behavior instead of sending an empty platform list.
    • Explicit platform selections continue to be cleaned and de-duplicated.
  • Tests

    • Added coverage for omitted, blank, and explicitly provided platform selections.

CLI `projects create` serialized `platforms: []` when --platforms was
omitted, overriding the server's omitted-field default of ['imessage'] and
creating a project with no platform enabled (SDK then 403s on connect).

Make FilledCreate.platforms optional and send undefined (omitted) when the
user specifies nothing, in both the non-interactive and interactive paths;
the create body type already marks platforms optional. Adds unit coverage.

DX-REPORT #25.
The non-interactive create path only guarded the *absent* --platforms
flag; a blank or whitespace-only value (e.g. `--platforms ""` from a
script whose $PLATFORMS var is unset) still parsed to `[]`, which the
server reads as "disable every platform" — the exact footgun the
platform-default fix exists to avoid. Fold that normalization into a
shared resolvePlatformsFlag() used by both the interactive and
non-interactive paths, so empty input always omits the field.

Also make tests/unit/create-platforms.test.ts hermetic: it calls
fillCreateOpts() in-process, and `bun test` from a real terminal
attaches a TTY to stdin/stdout, sending the test into the interactive
path where it blocked on a clack prompt. Pin the non-interactive path
and add blank/whitespace edge-case coverage.
Copilot AI review requested due to automatic review settings July 21, 2026 20:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Project creation now treats omitted or blank platform selections as undefined, while explicit values remain validated and deduplicated. Contract tests capture project creation request bodies and verify both behaviors.

Changes

Project platform selection

Layer / File(s) Summary
Platform selection normalization
src/commands/projects.ts
The create flow normalizes omitted, blank, and comma-separated platform inputs, preserving explicit validated platforms while allowing the platforms field to be absent.
Request capture and contract validation
tests/helpers/mock-server.ts, tests/contract/projects.contract.test.ts
The mock server records project creation bodies, resets captured state between tests, and validates omitted versus explicit platform fields.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: copilot, lcandy2

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Title check ✅ Passed The title clearly matches the main fix: preventing projects create from disabling all platforms by default.
Description check ✅ Passed The description follows the template and fills the required sections, including version, routes, snapshots, deps, and checklist.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch henry/eng-2058-fix-projects-create-disabling-all-platforms-by-default

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

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