refactor(byethrow): update result handling for 0.11 - #1041
Conversation
Upgrade @praha/byethrow and @praha/byethrow-docs to 0.11.2 so the runtime package and local LLM docs stay aligned. The new byethrow API returns Result values directly from Result.try and provides Result.fn/Result.parse helpers. Update existing call sites to the direct Result.try shape, wrap reusable JSON parsing with Result.fn, and use Result.parse where Valibot validation was only branching on success. Switch the touched app/internal ESLint presets to app mode so these Result-returning helpers can rely on inference instead of spelling out byethrow return types.
|
Caution Review failedPull request was closed or merged during review No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (26)
📝 WalkthroughWalkthroughThis PR upgrades ChangesDependency upgrade and
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
apps/ccusage/src/adapter/amp/parser.ts[baseline-browser-mapping] The data in this module is over two months old. To ensure accurate Baseline data, please update: Oops! Something went wrong! :( ESLint: 9.35.0 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'eslint-plugin-format' imported from /node_modules/.pnpm/@antfu+eslint-config@4.19.0_@vue[email protected][email protected][email protected]_vit_670a2c5c75d4275eabd7bc195a173ee6/node_modules/@antfu/eslint-config/dist/index.js apps/ccusage/eslint.config.js[baseline-browser-mapping] The data in this module is over two months old. To ensure accurate Baseline data, please update: Oops! Something went wrong! :( ESLint: 9.35.0 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'eslint-plugin-format' imported from /node_modules/.pnpm/@antfu+eslint-config@4.19.0_@vue[email protected][email protected][email protected]_vit_670a2c5c75d4275eabd7bc195a173ee6/node_modules/@antfu/eslint-config/dist/index.js apps/ccusage/src/adapter/codex/pricing.ts[baseline-browser-mapping] The data in this module is over two months old. To ensure accurate Baseline data, please update: Oops! Something went wrong! :( ESLint: 9.35.0 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'eslint-plugin-format' imported from /node_modules/.pnpm/@antfu+eslint-config@4.19.0_@vue[email protected][email protected][email protected]_vit_670a2c5c75d4275eabd7bc195a173ee6/node_modules/@antfu/eslint-config/dist/index.js
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 |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
ccusage-guide | 6a3f414 | Commit Preview URL Branch Preview URL |
May 17 2026, 06:59 PM |
commit: |
ccusage performance comparisonThis compares the PR build against the base branch build on the same CI runner. Committed fixture performanceCommitted small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage. Fixtures: Claude
Large real-world-shaped fixture performanceGenerated fixtures shaped from aggregate local log statistics: thousands of JSONL files, many small sessions, and a long tail of larger sessions. No real prompts, paths, or outputs are stored in the fixtures. Fixtures: Claude
Package size
Lower medians and smaller packed package sizes are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees. |
Move additional recoverable try/catch sites onto Result.pipe so success and failure side effects are attached with inspect and inspectError. This covers report loading progress, Codex JSONL fallback parsing, timezone validation, OpenCode database discovery, and the statusline process liveness probe. The remaining try/finally in shared aggregation is kept for resource disposal.
|
@coderabbitai review this PR, please. I updated byethrow/docs to 0.11.2, migrated the Result.try API changes, and pushed an additional pass using Result.fn/parse/pipe where it fit. |
🧩 Analysis chain🏁 Script executed: Length of output: 103944
Review of
|
|
Thanks @coderabbitai. I reviewed the observations: packages/internal using ESLint type app is intentional for this PR per the requested inferred byethrow-facing types, and I am keeping that without an inline TODO to match the repository comment policy. The duplicated cleanup branches are behaviorally equivalent and small, so no follow-up change is needed. |
|
Tip For best results, initiate chat on the files or code changes.
The PR looks good to me. (ᵔᴥᵔ)🐇✨ ✏️ Learnings added
|
Restore direct Valibot safeParse calls for schema validation paths that only skip invalid records. This keeps byethrow focused on recoverable I/O, JSON parsing, and Result.pipe flows while avoiding a misleading Result.parse wrapper around plain Valibot validation.
|
@coderabbitai review this update, please. I restored Valibot schema checks to v.safeParse where the code only skips invalid records, and kept byethrow focused on recoverable I/O/JSON parsing and Result.pipe flows. |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 96015
✅ What's done well in this pass
The separation of concerns is now solid: byethrow handles recoverable I/O / JSON-parse failures and pipeline control flow; Valibot handles schema validation where invalid records are simply filtered. The PR is clean. [approve] |
Summary
Testing
Summary by CodeRabbit
Release Notes