Skip to content

fix(agent): drop unused SessionStatus type and redundant cast#666

Merged
marcusrbrown merged 1 commit into
mainfrom
fix/drop-unused-session-status-type
May 23, 2026
Merged

fix(agent): drop unused SessionStatus type and redundant cast#666
marcusrbrown merged 1 commit into
mainfrom
fix/drop-unused-session-status-type

Conversation

@marcusrbrown
Copy link
Copy Markdown
Collaborator

The local SessionStatus union in src/features/agent/session-poll.ts mirrored what the OpenCode SDK already returns from session.status(). The as SessionStatus | undefined cast on line 173 was structurally redundant — the SDK's inferred type provides the same type === 'idle' / type === 'retry' / type === 'busy' discriminator and narrows the same way.

The new @typescript-eslint/no-unnecessary-type-assertion autofix 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 local SessionStatus type becomes unused and trips unused-imports/no-unused-vars (lint error) and TS6196 (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).

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.
Copy link
Copy Markdown
Owner

@fro-bot fro-bot left a comment

Choose a reason for hiding this comment

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

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

@marcusrbrown marcusrbrown merged commit 0e7da24 into main May 23, 2026
10 checks passed
@marcusrbrown marcusrbrown deleted the fix/drop-unused-session-status-type branch May 23, 2026 19:09
@fro-bot fro-bot mentioned this pull request May 24, 2026
48 tasks
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