feat: migrate to scoped bus API (forService/forSession) - #41
Conversation
WalkthroughWalkthroughBoth ChangesFluent bus selector migration
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related issues
Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Tip: You can configure your own custom pre-merge checks in the settings. Finishing TouchesGenerate docstrings
Generate unit tests (beta)
Simplify code
Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/tui.tsx (1)
31-37:⚠️ Potential issue | 🟠 Major | ⚡ Quick winRemove
as anytype assertion - violates strict type safety guideline.Line 31 uses
as any, which explicitly violates the coding guideline: "Noanytype usage in TypeScript code; maintain strict type safety". The payload type should match the published structure fromsrc/bus-publisher.ts(lines 43-49).Proposed fix with proper typing
+interface StatusPayload { + sessionID: string; + cumulative: number; + softLimit: number; + hardLimit: number; + percentage: number; + status: string; +} + bus.forService("tbg").forSession(props.session_id).subscribe("status", (msg) => { - const p = msg.payload as any; + const p = msg.payload as StatusPayload; if (typeof p.cumulative === "number") { setTokens(p.cumulative); } if (typeof p.hardLimit === "number") { setLimit(p.hardLimit); } });Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/tui.tsx` around lines 31 - 37, Remove the `as any` type assertion on msg.payload at line 31 and replace it with the proper TypeScript type imported from src/bus-publisher.ts that defines the payload structure. The correct type should properly define the cumulative and hardLimit properties being accessed in the subsequent typeof checks, eliminating the need for type narrowing and maintaining strict type safety throughout the assignment to variable p.Source: Coding guidelines
Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/tui.tsx`:
- Around line 31-37: Remove the `as any` type assertion on msg.payload at line
31 and replace it with the proper TypeScript type imported from
src/bus-publisher.ts that defines the payload structure. The correct type should
properly define the cumulative and hardLimit properties being accessed in the
subsequent typeof checks, eliminating the need for type narrowing and
maintaining strict type safety throughout the assignment to variable p.
Review info
Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 0626c877-bbca-498d-b9f7-7750a79e21a1
Files selected for processing (2)
src/bus-publisher.tssrc/tui.tsx
Replaces manual channel string building with scoped bus API.
Summary by cubic
Migrated publishing and subscriptions to the scoped bus API (
forService/forSession) to replace manual topic strings. This standardizes channel construction and reduces routing mistakes.src/bus-publisher.ts:publishmoved fromtbg/${sessionID}/statustobus.forService("tbg").forSession(sessionID).publish("status", ...).src/tui.tsx:subscribemoved fromtbg/${session_id}/statustobus.forService("tbg").forSession(props.session_id).subscribe("status", ...).Written for commit 5f660a4. Summary will update on new commits.
Summary by CodeRabbit