fix(agent): drop unused SessionStatus type and redundant cast#666
Conversation
The local SessionStatus union mirrored what the OpenCode SDK already returns from session.status(). The 'as SessionStatus | undefined' cast was structurally redundant; the SDK's inferred type narrows the same way. Removing both eliminates a 'defined but never used' lint error that fires once @bfra.me/eslint-config 0.51.1 ships.
fro-bot
left a comment
There was a problem hiding this comment.
Verdict: PASS
The change is correct and well-motivated. The local SessionStatus type was a manual mirror of the SDK's inferred discriminated union, and the as SessionStatus | undefined cast was structurally redundant — the SDK already returns the same shape. Removing both is the right call.
Cast removal (line 165): statuses[sessionId] comes from statusResponse.data, whose type from the SDK already includes the discriminated union members. The downstream narrowing on sessionStatus.type === 'idle' / 'retry' / 'busy' continues to work correctly via the SDK's inferred types. The ESLint rule (no-unnecessary-type-assertion) correctly identified this.
Type removal: With the cast gone the local SessionStatus type had no remaining references, so removing it is correct — keeping it would cause TS6196 and an unused-vars lint error.
No behavioral change; this is a pure type-layer cleanup.
Blocking issues
None
Non-blocking concerns
None
Missing tests
None — no runtime behavior changed; type correctness is validated by tsc passing as noted in the PR description.
Risk assessment (LOW/MED/HIGH): LOW
Single-file, type-only change. Full test suite (1548 tests) and tsc both pass per PR description. No public API impact.
Run Summary
| Field | Value |
|---|---|
| Event | pull_request |
| Repository | fro-bot/agent |
| Run ID | 26340599476 |
| Cache | hit |
| Session | ses_1a9d85e46ffe70M8puosBT69VL |
The local
SessionStatusunion insrc/features/agent/session-poll.tsmirrored what the OpenCode SDK already returns fromsession.status(). Theas SessionStatus | undefinedcast on line 173 was structurally redundant — the SDK's inferred type provides the sametype === 'idle'/type === 'retry'/type === 'busy'discriminator and narrows the same way.The new
@typescript-eslint/no-unnecessary-type-assertionautofix in@bfra.me/eslint-config@0.51.1(incoming via Renovate PR #625) correctly flags the cast as redundant and removes it. With the cast gone, the localSessionStatustype becomes unused and tripsunused-imports/no-unused-vars(lint error) andTS6196(build error).This PR removes both — the unused type and the redundant cast — landing the cleanup on main proactively so Renovate's eslint bump merges without surface conflicts. Tested: full tsc passes, all 1548 tests pass, lint has 0 errors (42 pre-existing non-null-assertion warnings remain, unchanged).