Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
3835c37 to
10fab1a
Compare
| ); | ||
| this.log(formatListening("Listening for occupancy events.")); | ||
| } | ||
| this.logJsonStatus( |
There was a problem hiding this comment.
Internally checks if json flag is enabled, if not, then it won't print anything.
10fab1a to
6163144
Compare
6147aae to
e456aa8
Compare
There was a problem hiding this comment.
Pull request overview
Adds standardized JSON status/progress signals for long-running subscribe and hold commands so --json consumers can distinguish “connecting” vs “ready”, and updates docs/tests accordingly.
Changes:
- Introduces
JsonStatusTypeenum and updateslogJsonStatuscall sites to use it. - Emits
status=subscribingandstatus=listeningJSON records across subscribe commands (including Chat room commands viasetupRoomStatusHandler). - Updates documentation/templates and adjusts affected unit tests for NDJSON output.
Reviewed changes
Copilot reviewed 35 out of 35 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/unit/commands/spaces/subscribe.test.ts | Adjusts JSON test to handle multi-line NDJSON output. |
| test/unit/commands/spaces/members/subscribe.test.ts | Adjusts JSON test to handle multi-line NDJSON output. |
| src/utils/json-status.ts | Adds enum for standardized JSON status values. |
| src/commands/spaces/subscribe.ts | Emits subscribing/listening JSON status for space updates subscribe. |
| src/commands/spaces/occupancy/subscribe.ts | Emits subscribing/listening JSON status for space occupancy subscribe. |
| src/commands/spaces/members/subscribe.ts | Emits subscribing/listening JSON status for members subscribe. |
| src/commands/spaces/members/enter.ts | Replaces raw "holding" with JsonStatusType.Holding. |
| src/commands/spaces/locks/subscribe.ts | Emits subscribing/listening JSON status for locks subscribe. |
| src/commands/spaces/locks/acquire.ts | Replaces raw "holding" with JsonStatusType.Holding. |
| src/commands/spaces/locations/subscribe.ts | Emits subscribing/listening JSON status for locations subscribe. |
| src/commands/spaces/locations/set.ts | Replaces raw "holding" with JsonStatusType.Holding. |
| src/commands/spaces/cursors/subscribe.ts | Emits subscribing/listening JSON status for cursors subscribe. |
| src/commands/spaces/cursors/set.ts | Replaces raw "holding" with JsonStatusType.Holding. |
| src/commands/rooms/typing/subscribe.ts | Adds subscribingMessage so room handler emits JSON subscribing status. |
| src/commands/rooms/reactions/subscribe.ts | Adds subscribingMessage so room handler emits JSON subscribing status. |
| src/commands/rooms/presence/subscribe.ts | Moves success/listening handling into room status handler and adds subscribing/listening messages. |
| src/commands/rooms/occupancy/subscribe.ts | Adds subscribingMessage so room handler emits JSON subscribing status. |
| src/commands/rooms/messages/subscribe.ts | Adds subscribingMessage so room handler emits JSON subscribing status. |
| src/commands/rooms/messages/reactions/subscribe.ts | Adds subscribingMessage so room handler emits JSON subscribing status. |
| src/commands/logs/subscribe.ts | Emits subscribing/listening JSON status for logs subscribe. |
| src/commands/logs/push/subscribe.ts | Emits subscribing/listening JSON status for push logs subscribe. |
| src/commands/logs/connection-lifecycle/subscribe.ts | Emits subscribing/listening JSON status for connection lifecycle logs subscribe. |
| src/commands/logs/channel-lifecycle/subscribe.ts | Emits subscribing/listening JSON status for channel lifecycle logs subscribe. |
| src/commands/channels/subscribe.ts | Emits subscribing/listening JSON status for channel subscribe. |
| src/commands/channels/presence/update.ts | Replaces raw "holding" with JsonStatusType.Holding. |
| src/commands/channels/presence/subscribe.ts | Emits subscribing/listening JSON status for channel presence subscribe. |
| src/commands/channels/presence/enter.ts | Replaces raw "holding" with JsonStatusType.Holding. |
| src/commands/channels/occupancy/subscribe.ts | Emits subscribing/listening JSON status for channel occupancy subscribe. |
| src/commands/channels/annotations/subscribe.ts | Emits subscribing/listening JSON status for annotations subscribe. |
| src/chat-base-command.ts | Extends room status handler to emit JSON subscribing/listening/disconnected statuses. |
| src/base-command.ts | Uses enum for timeout completion status. |
| AGENTS.md | Documents JsonStatusType usage rules and subscribe/hold patterns. |
| .claude/skills/ably-review/SKILL.md | Updates review checklist to match new JsonStatusType convention. |
| .claude/skills/ably-new-command/references/patterns.md | Updates command templates with new JSON status lifecycle. |
| .claude/skills/ably-codebase-review/SKILL.md | Updates codebase review checklist for JsonStatusType + subscribe lifecycle. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const lines = stdout.trim().split("\n").filter(Boolean); | ||
| const eventLine = lines.find((l) => { | ||
| const parsed = JSON.parse(l); | ||
| return parsed.type === "event"; | ||
| }); | ||
| expect(eventLine).toBeDefined(); | ||
| const result = JSON.parse(eventLine!); |
There was a problem hiding this comment.
This test parses each stdout line with JSON.parse inside find(). If any non-JSON line is present (Node warnings, accidental human output), JSON.parse will throw and fail the test. Prefer using the existing NDJSON helpers (e.g. parseNdjsonLines/captureJsonLogs) or wrap parsing in try/catch and skip non-JSON lines before filtering for type === "event".
| const lines = stdout.trim().split("\n").filter(Boolean); | ||
| const eventLine = lines.find((l) => { | ||
| const parsed = JSON.parse(l); | ||
| return parsed.type === "event"; | ||
| }); | ||
| expect(eventLine).toBeDefined(); | ||
| const result = JSON.parse(eventLine!); | ||
| expect(result.type).toBe("event"); |
There was a problem hiding this comment.
This test assumes every non-empty stdout line is valid JSON and calls JSON.parse during find(). That will throw if any non-JSON output appears (Node warnings, progress messages, etc.). Use the shared NDJSON test helpers (parseNdjsonLines/captureJsonLogs) or defensively skip non-JSON lines when searching for the event record.
| if (this.shouldOutputJson(flags)) { | ||
| this.logJsonStatus("complete", message, flags); | ||
| this.logJsonStatus(JsonStatusType.Complete, message, flags); | ||
| } else { |
There was a problem hiding this comment.
logJsonStatus is now documented/used with JsonStatusType, but the method signature still accepts status: string, so passing raw strings will continue to compile and can silently violate the new convention. Consider typing the parameter as status: JsonStatusType (or JsonStatusType | string temporarily) to enforce the rule at compile time.
There was no progress indicator for
subscribecommands injsonmode, so added relevant json logging for the same. Allsubscribecommands are well addressed.