Refactor chat layout and generation controls#25
Conversation
…w, and apply generation parameters to AI calls
…nd text completion views
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThis PR introduces user-configurable generation parameters (temperature, max tokens, logprobs) via a floating UI panel, persisted in the settings store. The feature integrates across message sending, streaming, and error handling, removing the "Diagram" view option in favor of "Chat" and "Text" views with a chat-tree toggle. ChangesGeneration Settings Feature
Sequence DiagramsequenceDiagram
participant User
participant App as App / Header UI
participant Store as useSettingsStore
participant Hook as useConversationController/<br/>useTextCompletion
participant AI as sendMessage / Streaming
User->>App: Open floating settings panel
App->>Store: Read generationParams
Store-->>App: temperature, maxTokens, logprobs
User->>App: Adjust temperature/logprobs
App->>Store: setGenerationParams(updated)
Store->>Store: Normalize and persist
User->>App: Send message / Request completion
App->>Hook: Trigger send/generate
Hook->>Store: getState().generationParams
Store-->>Hook: Current params
Hook->>AI: sendMessage / provider call<br/>(with generationParams)
AI->>AI: Apply temperature,<br/>gate logprobs per params
AI-->>Hook: Stream response<br/>(logprobs conditional)
Hook-->>App: Update chat/completion
Note over Store: Settings persisted<br/>for next session
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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. Review rate limit: 0/1 reviews remaining, refill in 34 minutes and 59 seconds.Comment |
There was a problem hiding this comment.
Code Review
This pull request introduces a floating generation settings panel that allows users to configure parameters such as temperature, max tokens, and logprobs for AI responses. It also refactors the application layout by integrating the diagram view as a toggleable 'Chat Tree' within the chat interface rather than a standalone view. Additionally, the PR improves error handling with a new utility for parsing AI SDK errors into user-friendly toast messages and updates the project documentation and UI styling for better consistency. I have no feedback to provide as there were no review comments to assess.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ae26148a4e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 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/ai/sendMessage.ts`:
- Around line 89-100: The code currently reuses a finalized assistant UUID
(assistantId when isAssistantPrefill is true) and then streams deltas into that
existing node, which risks mutating a final message; change the logic so that
when streaming continuations you create a fresh assistant node instead of
reusing the existing one (call createAssistantAfter(resolvedParentId) even when
lastMessage?.role === "assistant"), or alternatively snapshot the original node
before streaming and restore it on cancel/error; update uses of
assistantId/isAssistantPrefill and the subsequent compilePathTo call to refer to
the new assistant node (or to use the snapshot/restore flow) to avoid in-place
mutation via appendToNode.
In `@src/components/Header.tsx`:
- Around line 92-95: The segmented control's root class (classNames.root in
Header.tsx) uses the generic "border" utility without an explicit style, which
can make the outline disappear; update the root classes to include
"border-solid" (and ensure the explicit border color remains present) so the
segmented control always renders a solid border across this repo's Tailwind
setup.
- Around line 146-165: The four icon-only UnstyledButton instances lack
accessible names; update each UnstyledButton (the ones with classNames
"i-lucide-eraser", "i-lucide-file-input", "i-lucide-file-output",
"i-lucide-settings") to include an aria-label that matches their action (e.g.,
aria-label="Clear conversation" for the eraser button) alongside the existing
title and keep their onClick handlers (onClear, onImport, onExport,
onOpenSettings) unchanged so screen readers can reliably identify each action.
In `@src/state/useSettingsStore.ts`:
- Around line 175-183: The setGenerationParams setter currently calls
persistSettings immediately which causes write thrash and race conditions; keep
the in-memory set({ generationParams: updated }) as-is but replace the direct
await persistSettings call with a debounced persistence: add a module-scoped
timer (or use a debounce helper) that clears previous timeouts and schedules
calling persistSettings with the latest normalized generationParams after a
short delay (e.g., 200–500ms); ensure you reference normalizeGenerationParams,
get(), set(), setGenerationParams, and persistSettings so the scheduled job
reads the latest state (or passes updated) and handles async completion without
blocking the immediate set.
In `@src/utils/errors.ts`:
- Around line 32-39: The function messageFromResponseBody returns the raw
response body as a fallback (via body) which can produce oversized/noisy toasts
and leak internals; update messageFromResponseBody to sanitize and clamp the
fallback before returning (e.g., trim whitespace, strip or replace newlines,
limit to a safe max length like 200 chars, and append an ellipsis when
truncated) and prefer this sanitizedFallback instead of body; apply the same
sanitization/clamping logic to the analogous fallback returns in the other
related helpers (the functions that call
parseJson/messageFromOpenAICompatiblePayload at the other reported locations) so
no function (including messageFromResponseBody, parseJson callers, or any
function returning raw response text) returns unbounded raw response bodies to
the UI.
🪄 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: 4b85ba68-7bb2-4dea-a96d-18ac1265c9a6
📒 Files selected for processing (15)
AGENTS.mdrsbuild.config.mjssrc/App.tsxsrc/ai/sendMessage.tssrc/ai/streamUtils.tssrc/components/DiagramView.tsxsrc/components/FloatingGenerationSettings.tsxsrc/components/GenerationSettings.tsxsrc/components/Header.tsxsrc/components/TextCompletionView.tsxsrc/hooks/useConversationController.tssrc/hooks/useTextCompletion.tssrc/state/useSettingsStore.tssrc/types.tssrc/utils/errors.ts
… tokens management
Summary
temperature,maxTokens, andlogprobs, and update the supporting state and provider wiring.AGENTS.mdto keep the repo guidance shorter and more focused.Testing
Summary by CodeRabbit
New Features
Style
Bug Fixes
Documentation