Ollama format 修正 + web データ取得フック共通化・サイドバー配色修正#423
Conversation
ローカル Ollama(LLM_LOCAL_OLLAMA=1)経路で /api/chat が "Failed to initialize samplers: failed to parse grammar" の 400 を返し、 Agent チャットが 502 になっていた。原因は format に渡す JSON Schema の maxLength / maxItems を llama.cpp の GBNF 文法変換が解釈できないこと (oneOf は無罪。実機 curl で maxLength/maxItems 除去後は 200 を確認)。 - ollama_client: format に to_portable_schema(..., drop_additional_properties=False) を渡す(maxLength/maxItems 除去・oneOf→enum 平坦化)。Gemini/OpenAI と同じ移植経路に揃える - output_schema: 「Ollama は maxLength を助言扱い/生スキーマを使う」誤コメントを実態へ修正 - test_llm_clients: format に oneOf/maxLength/maxItems が残らないことの回帰テストを追加 文字数上限の実強制は従来どおり _parse_response が担う(二重防衛)。 Anthropic/Gemini/OpenAI 経路は無変更。make lint-backend / make test-backend(633 passed) green。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- enabled-gated fetch の定型(loading/error/refresh + seq ガード)を useAsyncResource に 集約し、useCreditBalance / useAgentUsageSummary / useModelRates / useBillingPage を載せ替え (競合上書き防止を全フックへ波及) - CareerResumeForm のバリデーション/フォーカス/送信分岐を useCareerFormValidationFocus に 切り出し、本体を UI 構成に純化 - career サンプル fixture を test/factories/careerForm.ts に一本化 - AgentChatWidget のチャット履歴を安定 id キー化、useAgentChat.test の反復 arrange を sendChat ヘルパへ集約 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
サイドバー背景は両テーマで暗色だが、AgentModelBadge / CreditBalanceBadge が本文用の --text-primary / --text-secondary(ライトでは暗色)を使っていたため暗背景に暗文字で 読めなかった。サイドバー専用の --sidebar-text / --sidebar-title に差し替える。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Warning Review limit reached
More reviews will be available in 20 minutes and 48 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR adds ChangesOllama Portable Schema
Frontend: Async Resource Hook, Validation Focus Hook, Chat IDs, CSS, and Test Factories
Sequence Diagram(s)sequenceDiagram
participant Consumer
participant useAsyncResource
participant API
Consumer->>useAsyncResource: configure(fetcher, enabled, initialData, fallbackMessage)
useAsyncResource->>API: fetcher()
alt success
API-->>useAsyncResource: data
useAsyncResource->>Consumer: data, loading=false, error=null
else failure
API-->>useAsyncResource: error
useAsyncResource->>Consumer: error fallback or message
end
Consumer->>useAsyncResource: refresh()
useAsyncResource->>API: fetcher() with requestSeq guard
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)
✨ 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: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@web/src/hooks/career/useCareerFormValidationFocus.ts`:
- Around line 104-114: The guest-submit branch in useCareerFormValidationFocus
currently relies on a pending effect to save the latest form state before login,
which can miss the last edit. Update this hook to accept a synchronous
persistDraft(form) callback and call it immediately before requestLogin() in the
isAuthenticated false path, using the existing validation and focus-reset flow
unchanged.
In `@web/src/hooks/useAsyncResource.ts`:
- Around line 60-64: The enabled-gated flow in useAsyncResource still allows an
in-flight refresh started by refresh() to update state after enabled flips to
false because the true-to-false transition never invalidates requestSeqRef.
Update the useEffect that watches enabled and refresh so that disabling the hook
also bumps requestSeqRef (or otherwise marks the current request stale) before
any pending async work can commit state, keeping the existing refresh() and
requestSeqRef logic aligned with the enabled contract.
- Around line 51-54: The error handling in useAsyncResource currently uses
Error.message even when it is an empty string, which bypasses the intended
fallback behavior. Update the catch block in useAsyncResource so that when the
caught value is an Error with a blank message, it uses fallbackMessage instead
of storing an empty error string; keep the existing seq and
requestSeqRef.current guard intact while adjusting the setError logic.
🪄 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 Plus
Run ID: 7524683b-b07c-4950-b8a4-412c6b9a5e92
📒 Files selected for processing (20)
backend/app/services/agent/llm/ollama_client.pybackend/app/services/agent/output_schema.pybackend/tests/test_llm_clients.pyweb/src/components/agent/AgentModelBadge.module.cssweb/src/components/billing/CreditBalanceBadge.module.cssweb/src/components/forms/AgentChatWidget.tsxweb/src/components/forms/CareerResumeForm.tsxweb/src/hooks/career/useAgentChat.test.tsweb/src/hooks/career/useAgentChat.tsweb/src/hooks/career/useCareerDirty.test.tsweb/src/hooks/career/useCareerFormValidationFocus.test.tsweb/src/hooks/career/useCareerFormValidationFocus.tsweb/src/hooks/useAgentUsageSummary.tsweb/src/hooks/useAsyncResource.test.tsweb/src/hooks/useAsyncResource.tsweb/src/hooks/useBillingPage.tsweb/src/hooks/useCreditBalance.tsweb/src/hooks/useModelRates.tsweb/src/test/factories/careerForm.tsweb/src/utils/careerDiff.test.ts
- useAsyncResource: enabled が true→false に変わった瞬間に requestSeqRef を進め、 進行中リクエストの後追い応答が state を上書きしないようにする(無効中は更新しない契約を遵守) - useAsyncResource: Error でも message が空文字なら fallback を使う - useCareerFormValidationFocus: ゲストのログイン遷移直前に persistDraft で現在のフォームを 同期退避し、effect 未反映による最後の入力の取りこぼしを防ぐ - 上記を保護するユニットテストを追加 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@web/src/hooks/useAsyncResource.test.ts`:
- Around line 97-125: The test for useAsyncResource should verify that the
enabled=true path actually triggers the fetcher before toggling enabled to
false, otherwise it can pass even if auto-fetch is broken. In
useAsyncResource.test.ts, add an assertion on the fetcher mock (or another
explicit check tied to the renderHook setup) after the initial render and before
rerendering, so the test confirms the fetcher was called and the in-flight
request is what gets invalidated when enabled changes.
🪄 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 Plus
Run ID: a244a15f-09c6-40a4-9337-94d7dd1eba56
📒 Files selected for processing (5)
web/src/components/forms/CareerResumeForm.tsxweb/src/hooks/career/useCareerFormValidationFocus.test.tsweb/src/hooks/career/useCareerFormValidationFocus.tsweb/src/hooks/useAsyncResource.test.tsweb/src/hooks/useAsyncResource.ts
🚧 Files skipped from review as they are similar to previous changes (4)
- web/src/hooks/useAsyncResource.ts
- web/src/hooks/career/useCareerFormValidationFocus.ts
- web/src/components/forms/CareerResumeForm.tsx
- web/src/hooks/career/useCareerFormValidationFocus.test.ts
loading 初期値が enabled 由来で true のため、自動 fetch が退行してもテストが通ってしまう 弱点を修正。enabled→false に切り替える前に fetcher の呼び出しを waitFor で確認し、 「進行中リクエストが無効化される」ことを確実に検証する。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
概要
このブランチには 3 つの変更 が含まれます(うち Ollama 修正は既存コミット)。
1. fix(agent): Ollama の format に移植スキーマを渡し文法変換失敗を解消 (fa75ff1)
formatに移植スキーマを渡し、文法変換失敗を解消。2. refactor(web): データ取得フックの共通化とフォーム制御の分離
useAsyncResourceに集約し、useCreditBalance/useAgentUsageSummary/useModelRates/useBillingPageを載せ替え。これまで残高フックだけが持っていた競合上書き防止(seq ガード)を全フックへ波及。CareerResumeFormのバリデーション/フォーカス/送信分岐をuseCareerFormValidationFocusに切り出し、本体を UI 構成 + フック配線に純化。test/factories/careerForm.tsに一本化。AgentChatWidgetのチャット履歴を index → 安定 id キー化。useAgentChat.testの反復 arrange をsendChatヘルパへ集約。useAsyncResourceの enabled/seq ガード、useCareerFormValidationFocusの隠れフィールド自動展開など)。3. fix(web): ライトモードでサイドバーのモデル/残高バッジが読めない配色を修正
AgentModelBadge/CreditBalanceBadgeが本文用の--text-primary/--text-secondary(ライトでは暗色)を使っていたため暗背景に暗文字で読めなかった。サイドバー専用の--sidebar-text/--sidebar-titleに差し替え。検証
make ci: pass(backend lint/test + web lint/test/build)補足
report/WEB_report_20260628_1533.md/report/WEB_pr_20260628_1602.mdを参照。🤖 Generated with Claude Code
Summary by CodeRabbit