Add JSON response format for full SDK/CLI coverage#2675
Conversation
There was a problem hiding this comment.
Pull request overview
Adds JSON responses across multiple controllers/views to support full SDK/CLI coverage, including JSON endpoints for search, settings/config, exports status polling, access tokens, and card steps.
Changes:
- Add
respond_toJSON branches for multiple “void response” actions (returning 204/201/200 as appropriate). - Introduce JSON endpoints/views for searches, paginated card lists (stream/not-now/closed), settings/config, exports, access tokens, and card steps index.
- Expand controller tests to cover JSON behaviors and response codes (including deduped search results and export status polling).
Reviewed changes
Copilot reviewed 48 out of 48 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| test/controllers/users/roles_controller_test.rb | Adds JSON update test expecting 204 |
| test/controllers/users/push_subscriptions_controller_test.rb | Adds JSON create/dedup/destroy status coverage |
| test/controllers/users/avatars_controller_test.rb | Adds JSON destroy test expecting 204 |
| test/controllers/searches_controller_test.rb | Adds JSON search tests incl. deduping |
| test/controllers/notifications/settings_controller_test.rb | Adds JSON show/update tests |
| test/controllers/my/access_tokens_controller_test.rb | Adds JSON create/id/created_at, index, destroy tests |
| test/controllers/columns/right_positions_controller_test.rb | Adds JSON move-right test expecting 204 |
| test/controllers/columns/left_positions_controller_test.rb | Adds JSON move-left test expecting 204 |
| test/controllers/cards/steps_controller_test.rb | Adds JSON steps index test |
| test/controllers/cards/readings_controller_test.rb | Adds JSON create/destroy tests expecting 204 |
| test/controllers/cards/publishes_controller_test.rb | Adds JSON publish test expecting 204 |
| test/controllers/boards/involvements_controller_test.rb | Adds JSON involvement update test expecting 204 |
| test/controllers/boards/entropies_controller_test.rb | Adds JSON entropy update test expecting 204 |
| test/controllers/boards/columns/streams_controller_test.rb | Adds JSON stream list test |
| test/controllers/boards/columns/not_nows_controller_test.rb | Adds JSON not-now list test |
| test/controllers/boards/columns/closeds_controller_test.rb | Adds JSON closed list test |
| test/controllers/accounts/settings_controller_test.rb | Adds JSON show/update tests |
| test/controllers/accounts/join_codes_controller_test.rb | Adds JSON show/update/invalid/destroy tests |
| test/controllers/accounts/exports_controller_test.rb | Adds JSON create/show/missing export tests |
| test/controllers/accounts/entropies_controller_test.rb | Adds JSON entropy update test |
| app/views/searches/show.json.jbuilder | JSON array rendering of paginated card search results |
| app/views/notifications/settings/show.json.jbuilder | JSON settings payload for notification settings |
| app/views/my/access_tokens/index.json.jbuilder | JSON list view for access tokens |
| app/views/my/access_tokens/_access_token.json.jbuilder | JSON access token partial (id/desc/permission/created_at) |
| app/views/cards/steps/index.json.jbuilder | JSON list view for card steps |
| app/views/boards/columns/streams/show.json.jbuilder | JSON list view for stream cards |
| app/views/boards/columns/not_nows/show.json.jbuilder | JSON list view for not-now cards |
| app/views/boards/columns/closeds/show.json.jbuilder | JSON list view for closed cards |
| app/views/account/settings/show.json.jbuilder | JSON account settings payload |
| app/views/account/join_codes/show.json.jbuilder | JSON join code payload incl. URL/active |
| app/views/account/exports/show.json.jbuilder | JSON export status payload incl. download URL when ready |
| app/controllers/users/roles_controller.rb | Adds JSON 204 response for role update |
| app/controllers/users/push_subscriptions_controller.rb | Adds JSON create 201/200 and destroy 204 responses |
| app/controllers/users/avatars_controller.rb | Adds JSON 204 response for avatar destroy |
| app/controllers/searches_controller.rb | Adds JSON search pagination via distinct cards relation |
| app/controllers/notifications/settings_controller.rb | Adds JSON 204 response for update |
| app/controllers/my/access_tokens_controller.rb | Extends JSON create payload; adds JSON destroy behavior |
| app/controllers/columns/right_positions_controller.rb | Adds JSON 204 response for move-right |
| app/controllers/columns/left_positions_controller.rb | Adds JSON 204 response for move-left |
| app/controllers/cards/steps_controller.rb | Adds steps index action (intended for .json) |
| app/controllers/cards/readings_controller.rb | Adds JSON 204 responses for create/destroy |
| app/controllers/cards/publishes_controller.rb | Adds JSON 204 response for publish create |
| app/controllers/boards/involvements_controller.rb | Adds JSON 204 response for involvement update |
| app/controllers/boards/entropies_controller.rb | Adds JSON 204 response for entropy update |
| app/controllers/account/settings_controller.rb | Adds JSON 204 response for settings update |
| app/controllers/account/join_codes_controller.rb | Adds JSON 204 and JSON error payload on 422 |
| app/controllers/account/exports_controller.rb | Adds JSON show/create semantics and pending export visibility for JSON |
| app/controllers/account/entropies_controller.rb | Adds JSON 204 response for entropy update |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e09dbf506f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 48 out of 48 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 49 out of 49 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Add respond_to blocks with JSON format to 14 controllers that previously only rendered HTML or Turbo Stream responses. JSON callers get head :no_content (or :created/:ok for push subscriptions, distinguishing new vs existing). Covers: board involvements, board/account entropies, column reordering, card readings, card publishing, user roles, user avatars, account settings, notification settings, join codes (with 422 error branch), and push subscriptions.
Add index action to Cards::StepsController so SDK/CLI callers can list all steps for a card. Reuses the existing _step.json partial.
Add show.json.jbuilder for stream, not-now, and closed column endpoints. No controller changes needed — set_page_and_extract_ portion_from and fresh_when already work format-agnostically.
JSON search paginates distinct Card records (via the existing Card.mentioning scope with .distinct) rather than Search::Record objects. This ensures page boundaries, Link headers, and counts reflect unique cards — no short pages from post-pagination dedup. ID-match searches return a uniform single-element Card[] array through the same pagination path.
Add show.json.jbuilder for account settings (name), join codes (code, usage_count, usage_limit, url, active), and notification settings (bundle_email_frequency). Tests for show and update were added in the void-response commit.
Create returns 201 with export id, status, and created_at so callers can poll. Show returns any-status exports for JSON (not just completed) with a download_url when ready, or 404 for missing/other-user exports.
Add index.json and _access_token.json partial for listing tokens. Add JSON format to destroy. Include id and created_at in the create response alongside the existing token/description/permission fields.
- Guard steps index against HTML requests (redirect to card) - Normalize created_at to UTC in access token and export JSON - Add deterministic ordering (.latest) to search JSON pagination
Five controllers infer the wrong wrapper key from their class
name, so flat JSON bodies like {"role":"admin"} fail with 400.
Add explicit wrap_parameters declarations:
- Users::RolesController → :user
- Notifications::SettingsController → :user_settings
- Account::JoinCodesController → :account_join_code
- Account::SettingsController → :account
- Boards::EntropiesController → :board
Add integration tests that send flat (unwrapped) JSON payloads
for all seven param-bearing endpoints to prove SDK compatibility.
- Use 201 Created (not 204) for all create actions: publishes, readings, left/right positions, push subscriptions - Simplify push subscription to always return :created (no 200/201 variance) - Remove superfluous respond_to block from steps#index - Merge exports#show into single respond_to block - Move export download_url conditional out of inline args - Ensure join code active is explicitly boolean - Remove extra parens from search controller assignment - Add blank lines between format blocks for readability
Create actions for boards, cards, columns, comments, and steps now render the resource as JSON (via their show views) instead of returning empty 201 responses with only a Location header. SDKs expect a JSON body they can deserialize into the created resource.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 57 out of 57 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Card and comment reaction creates now render the reaction as JSON instead of returning empty 201 responses, consistent with the other resource-creating endpoints.
Access tokens are identity-level (not account-scoped), so the controller needs to work with bearer token auth and no account slug in the URL. Skip require_account so the bearer token auth path can proceed. Also fix involvement test to send params in JSON body (not query string) to match real SDK usage.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 62 out of 62 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
* Add JSON response format to void-response controller actions
Add respond_to blocks with JSON format to 14 controllers that
previously only rendered HTML or Turbo Stream responses. JSON
callers get head :no_content (or :created/:ok for push
subscriptions, distinguishing new vs existing).
Covers: board involvements, board/account entropies, column
reordering, card readings, card publishing, user roles, user
avatars, account settings, notification settings, join codes
(with 422 error branch), and push subscriptions.
* Add steps index endpoint with JSON view
Add index action to Cards::StepsController so SDK/CLI callers
can list all steps for a card. Reuses the existing _step.json
partial.
* Add JSON views for paginated card list endpoints
Add show.json.jbuilder for stream, not-now, and closed column
endpoints. No controller changes needed — set_page_and_extract_
portion_from and fresh_when already work format-agnostically.
* Add JSON search endpoint with distinct-card pagination
JSON search paginates distinct Card records (via the existing
Card.mentioning scope with .distinct) rather than Search::Record
objects. This ensures page boundaries, Link headers, and counts
reflect unique cards — no short pages from post-pagination dedup.
ID-match searches return a uniform single-element Card[] array
through the same pagination path.
* Add JSON views for settings and configuration endpoints
Add show.json.jbuilder for account settings (name), join codes
(code, usage_count, usage_limit, url, active), and notification
settings (bundle_email_frequency). Tests for show and update
were added in the void-response commit.
* Add JSON response format to data exports
Create returns 201 with export id, status, and created_at so
callers can poll. Show returns any-status exports for JSON (not
just completed) with a download_url when ready, or 404 for
missing/other-user exports.
* Extend access token JSON API
Add index.json and _access_token.json partial for listing tokens.
Add JSON format to destroy. Include id and created_at in the
create response alongside the existing token/description/permission
fields.
* Fix ambiguous precedence warning in export JSON view
* Assert X-Total-Count pagination header in streams JSON test
* Address review feedback
- Guard steps index against HTML requests (redirect to card)
- Normalize created_at to UTC in access token and export JSON
- Add deterministic ordering (.latest) to search JSON pagination
* Return 406 for HTML requests to steps index instead of redirect
* Add wrap_parameters for flat SDK JSON payload compatibility
Five controllers infer the wrong wrapper key from their class
name, so flat JSON bodies like {"role":"admin"} fail with 400.
Add explicit wrap_parameters declarations:
- Users::RolesController → :user
- Notifications::SettingsController → :user_settings
- Account::JoinCodesController → :account_join_code
- Account::SettingsController → :account
- Boards::EntropiesController → :board
Add integration tests that send flat (unwrapped) JSON payloads
for all seven param-bearing endpoints to prove SDK compatibility.
* Address PR review feedback
- Use 201 Created (not 204) for all create actions: publishes, readings,
left/right positions, push subscriptions
- Simplify push subscription to always return :created (no 200/201 variance)
- Remove superfluous respond_to block from steps#index
- Merge exports#show into single respond_to block
- Move export download_url conditional out of inline args
- Ensure join code active is explicitly boolean
- Remove extra parens from search controller assignment
- Add blank lines between format blocks for readability
* Return JSON bodies on create actions
Create actions for boards, cards, columns, comments, and steps now
render the resource as JSON (via their show views) instead of returning
empty 201 responses with only a Location header. SDKs expect a JSON
body they can deserialize into the created resource.
* Return JSON bodies on reaction create actions
Card and comment reaction creates now render the reaction as JSON
instead of returning empty 201 responses, consistent with the other
resource-creating endpoints.
* Allow access tokens API without account scope
Access tokens are identity-level (not account-scoped), so the
controller needs to work with bearer token auth and no account slug
in the URL. Skip require_account so the bearer token auth path
can proceed.
Also fix involvement test to send params in JSON body (not query
string) to match real SDK usage.
Summary
Add JSON response formats across the API surface so the SDK (fizzy-sdk#9) and CLI can call every operation.
respond_toblocks to 14 void-response controller actions (involvements, entropies, column reordering, readings, publishes, roles, avatars, settings, join codes, push subscriptions)GET /cards/:id/steps.json)Cardrecords viaCard.mentioning+.distinctrather than dedupingSearch::Recordobjects after paginationpreviously_new_record?Test plan
bin/rails test— 1167 tests, 0 failuresX-Total-CountandLinkheaders