Skip to content

refactor: 减少防御性代码 - #46

Merged
surfine merged 2 commits into
cleanup/dead-codefrom
cleanup/defensive
Dec 2, 2026
Merged

surfine merged 2 commits into
cleanup/dead-codefrom
cleanup/defensive

Conversation

@surfine

@surfine surfine commented Dec 2, 2026 •

Copy link
Copy Markdown
Owner

接在 #45 之后(base 为 cleanup/dead-code),合并 #45 后改 base 为 main。

改了什么

  • 删掉值永远不变的开关及其分支:shelfEnabled、writesUserHome、requireCalibratedThreshold、deliverMain、showsMoreButton、wantsKeyboardLight。
  • 删掉没人接的回调与功能:加速度计状态刷新(设置页从没订阅)、onBlocked、motionX/Y(从没赋值)、DualSense 扳机阻力反馈(注释自认无调用方,已记入内部待办)。
  • 去掉调用方已保证的夹值与空检查:网格列数、p95 下标、音量二次夹值、ArrangeController 的兜底、NotchRow 负宽度、缩略图尺寸 isFinite 等。
  • 测试删掉只验证这些兜底的断言;删掉 fileDrag.reason.shelfOff 本地化键。

没动的

restTuckAdmitted、WS2FocusWindowPort.admitted 是有意的功能闸门,留待决定;系统 API 读数的夹值保留。

检查

  • scripts/local-gate.sh check 全过
  • scripts/local-gate.sh unit --jobs 6:261 个全过
  • 未跑真机探针(加速度计、截屏镜像、手柄路径只改了不可达分支)

🤖 Generated with Claude Code


Note

Medium Risk
Focus-rest window tucking and global “any key click to return” are removed; widespread ! assumes invariants—wrong inputs could trap, though unit tests passed.

Overview
Strips constants and branches that never varied in practice: file-drag shelfEnabled, hook preview writesUserHome, identity requireCalibratedThreshold (threshold is always required), capture deliverMain, window-browser showsMoreButton, notch keyboard-light probing, and related tests/localization (fileDrag.reason.shelfOff).

Removes unused or unwired behavior: FocusRestReturnMonitor and its tests/run script (rest no longer installs global key/mouse to restore windows—tap the focus card only); DualSense trigger feedback; fold renderer motionX/motionY; accelerometer onStatusTick; WS2FocusEffectExecutor.onBlocked.

Focus window effects: rest-phase tuckAll is a no-op (count only); WS2FocusWindowPort drops admitted / restTuckAdmitted gates—chat tuck runs when the port has an owner.

Simplifies math/UI paths where callers already guarantee valid inputs: many ??/max(0, …) clamps become force unwraps or direct math (ArrangeController, NotchRow, Launchpad pager, volume stepping, calendar progress ring always strokes, etc.).

Reviewed by Cursor Bugbot for commit 268d657. Bugbot is set up for automated code reviews on this repo. Configure here.

- 删掉值永远不变的开关:FileDragSensor.shelfEnabled、
  WS2HookConfigPreview.writesUserHome、IdentityEvidenceBar.requireCalibratedThreshold、
  ScreenCaptureBridge.deliverMain、ActionBar.showsMoreButton、NotchLevelControl.wantsKeyboardLight
- 删掉没人接的回调与功能:加速度计设置页状态刷新、WS2FocusEffectExecutor.onBlocked、
  FoldRenderer.motionX/Y、手柄扳机阻力反馈
- 去掉调用方已保证的夹值与空检查:网格列数 max(1,…)、p95 下标、音量二次夹值、
  ArrangeController 的 ?? 兜底、NotchRow 负宽度、缩略图尺寸 isFinite 等
- 测试同步删掉只验证这些兜底的断言

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cursor

cursor Bot commented Dec 2, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: 21e94b95-c638-42ad-b65d-12b1ddde3bc6)

restTuckAdmitted 恒为 false,休息时整屏收起与任意键放回的全局监听从未运行:
.tuckAll 改为直接跳过,删掉 FocusRestReturnMonitor 及其测试与隐私登记。
admitted 恒为 true,删掉两处永远通过的检查。行为不变。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@surfine
surfine merged commit e21dd02 into cleanup/dead-code Dec 2, 2026
3 checks passed
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