Skip to content

tui: migrate off deprecated Bubble Tea mouse Type API (SA1019)#214

Closed
gnanam1990 wants to merge 1 commit into
mainfrom
fix/tui-mouse-api
Closed

tui: migrate off deprecated Bubble Tea mouse Type API (SA1019)#214
gnanam1990 wants to merge 1 commit into
mainfrom
fix/tui-mouse-api

Conversation

@gnanam1990

@gnanam1990 gnanam1990 commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

Clears the 11 SA1019 deprecation findings in internal/tui (surfaced by the v16 audit) by migrating the mouse helpers off the deprecated msg.Type / tea.MouseLeft|MouseMotion|MouseRelease|MouseWheelUp|MouseWheelDown API to the current Button/Action pair.

Why it's safe (no behavior change)

Bubble Tea's mouse parser always sets Button+Action as the source of truth and merely derives the deprecated Type field from them (parseMouseButton's "backward compatibility" switch). So the || msg.Type == … fallbacks in the five helpers were pure redundancy. In particular a left-button drag is reported as Action==Motion (with Type derived to MouseLeft), which mouseMotion already matches via Action==Motion — so dropping Type changes nothing.

  • 5 helpers (mouseLeftPress, mouseMotion, mouseRelease, mouseWheelUp, mouseWheelDown) now use Button/Action only.
  • The left-drag test drops the deprecated Type: field and asserts the Action==Motion path directly (its 1 SA1019 too).

Verification

staticcheck ./internal/tui/ SA1019 count: 11 → 0. Existing mouse + transcript-selection tests pass under -race. gofmt · vet · build (host + linux + windows) · full go test ./... · deadcode (no new vs main) all green.

First of the audit-hygiene / remaining-backlog items.

Summary by CodeRabbit

  • Refactor
    • Removed deprecated event classification fallback logic, streamlining to use only current event fields.
    • Updated corresponding tests to reflect the updated behavior.

The mouse classification helpers checked both the current Button/Action pair and
the deprecated msg.Type / tea.Mouse* constants. Bubble Tea's parser always
populates Button+Action and only DERIVES Type from them, so the Type fallbacks
were pure redundancy (a left-button drag is Action==Motion, already covered by
mouseMotion). Drop them — clears all 11 SA1019 findings in internal/tui with no
behavior change. The left-drag test now asserts the Action==Motion path directly.

Gates: gofmt/vet/build(host+linux+windows)/test -race/staticcheck(SA1019 0)/
deadcode(no new) all pass.
@github-actions

Copy link
Copy Markdown
Contributor

Zero automated PR review

Verdict: No blockers found

Blockers

  • None found.

Validation

  • [pass] Diff hygiene: git diff --check
  • [pass] Tests: go test ./...
  • [pass] Build: go run ./cmd/zero-release build
  • [pass] Smoke build: go run ./cmd/zero-release smoke

Scope

Head: 8b7b8296acc2
Changed files (2): internal/tui/mouse.go, internal/tui/mouse_test.go

This deterministic review checks validation status and basic diff hygiene. A human reviewer still owns product judgment and design quality.

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 45242267-2b7a-431c-bd0c-0991ac8c152b

📥 Commits

Reviewing files that changed from the base of the PR and between f857c4a and 8b7b829.

📒 Files selected for processing (2)
  • internal/tui/mouse.go
  • internal/tui/mouse_test.go

Walkthrough

Mouse event classification helpers (mouseLeftPress, mouseMotion, mouseRelease, mouseWheelUp, mouseWheelDown) are updated to check only tea.MouseMsg.Button and Action fields, removing all legacy msg.Type fallback branches. A comment is added explaining the removal. The corresponding drag-motion test drops the Type field from its MouseMsg construction.

Changes

Remove deprecated msg.Type fallback from mouse event helpers

Layer / File(s) Summary
Drop msg.Type branches and align test
internal/tui/mouse.go, internal/tui/mouse_test.go
Five mouse classification helpers now check only Button+Action; a comment explains the removed Type fallback. The left-drag test constructs MouseMsg with Button: MouseButtonLeft + Action: MouseActionMotion and no Type field.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: migrating away from deprecated Bubble Tea mouse Type API while addressing SA1019 lint findings.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/tui-mouse-api

Comment @coderabbitai help to get the list of available commands and usage tips.

@gnanam1990

Copy link
Copy Markdown
Collaborator Author

Consolidating the audit-backlog work into a single PR with one commit per change (per request). This change is preserved verbatim as a commit there.

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.

1 participant