feat: expose update check state#530
Conversation
📝 WalkthroughWalkthroughAdded update check status tracking functionality by introducing Changes
Sequence DiagramsequenceDiagram
actor Consumer as Context Consumer
participant Provider as UpdateProvider
participant Client as Pushy Client
participant API as Update API
Consumer->>Provider: calls checkUpdate()
Provider->>Provider: setCheckState(CHECKING)
Provider->>Client: checkUpdate()
Client->>API: fetch /checkUpdate/
alt Check Succeeds
API-->>Client: response
Client->>Client: lastCheckError = undefined
Client-->>Provider: { upToDate, ... }
else Check Fails
API-->>Client: error
Client->>Client: normalize to Error<br/>lastCheckError = Error
Client-->>Provider: throw Error
end
Provider->>Provider: read Client.lastCheckError
alt Success
Provider->>Provider: setCheckState(COMPLETED)
else Failure
Provider->>Provider: setCheckState(ERROR, error)
end
Provider-->>Consumer: updated checkState available
Consumer->>Consumer: render with current checkState.status
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/provider.tsx`:
- Around line 200-201: The spread of a possibly undefined result from
client.checkUpdate() into rootInfo causes rootInfo to become {} (truthy) and
bypass the early return; change the assignment so that rootInfo remains falsy
when checkUpdate returns undefined (e.g., assign rootInfo = result ? { ...result
} : undefined) and ensure any downstream logic that builds versions (the array
filtered with .filter(Boolean)) relies on that falsy rootInfo to short-circuit;
update references around client.checkUpdate, rootInfo, and the versions
processing so empty objects are not treated as valid version entries.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: b1b1886a-165b-4ac7-85fa-50f2e158cbe0
📒 Files selected for processing (6)
src/__tests__/client.test.tssrc/client.tssrc/context.tssrc/index.tssrc/provider.tsxsrc/type.ts
说明
为
useUpdate()增加checkState导出,用于统一提供最近一次检查更新的状态、结果和错误信息。目的
让业务侧在任何时候都可以明确知道“最近一次检查是否已经执行完成”,从而更方便地实现一些依赖检查完成时机的后续功能。
例如:
包含内容
checkState包含以下字段:statusresulterror支持的状态:
idlecheckingcompletedskippederror验证
bun test src/__tests__bun lintSummary by CodeRabbit
New Features
Bug Fixes
Tests