Skip to content

Refactor chat layout and generation controls#25

Merged
CoolSpring8 merged 14 commits into
mainfrom
split-diagram-view
May 4, 2026
Merged

Refactor chat layout and generation controls#25
CoolSpring8 merged 14 commits into
mainfrom
split-diagram-view

Conversation

@CoolSpring8
Copy link
Copy Markdown
Owner

@CoolSpring8 CoolSpring8 commented May 4, 2026

Summary

  • Remove the side panel and move diagram browsing into a header toggle that switches the main chat area between linear chat and tree view.
  • Replace the settings modal’s diagram option with a draggable floating generation panel available in both Chat and Text modes.
  • Trim generation params to temperature, maxTokens, and logprobs, and update the supporting state and provider wiring.
  • Clean up the app layout so the main chat flow stays left-aligned instead of centered.
  • Update AGENTS.md to keep the repo guidance shorter and more focused.

Testing

  • Ran Biome formatting/checks on the touched files.
  • Ran TypeScript type-checking.
  • Ran the production build and verified the UI locally in the in-app browser, including the chat/tree toggle, Text-mode disabling, and the floating generation panel.

Summary by CodeRabbit

  • New Features

    • Floating generation settings panel (draggable) with temperature, max tokens, and logprobs controls
    • Chat tree visibility toggle in header for chat mode
  • Style

    • Improved diagram node styling and viewport fitting
    • Enhanced text completion view layout centering
  • Bug Fixes

    • Better error handling with user-friendly error messages
  • Documentation

    • Updated repository guidelines

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 4, 2026

Warning

Rate limit exceeded

@CoolSpring8 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 34 minutes and 59 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: dc1685ea-25aa-4a25-9ce3-434ad1c0b8f5

📥 Commits

Reviewing files that changed from the base of the PR and between ae26148 and e3e3911.

📒 Files selected for processing (5)
  • src/ai/sendMessage.ts
  • src/components/GenerationSettings.tsx
  • src/components/Header.tsx
  • src/state/useSettingsStore.ts
  • src/utils/errors.ts
📝 Walkthrough

Walkthrough

This 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.

Changes

Generation Settings Feature

Layer / File(s) Summary
Type Definitions
src/types.ts, src/state/useSettingsStore.ts
GenerationParams interface added with optional temperature, maxTokens, and logprobs fields. AppView narrowed to "chat" | "text". Store state extended with generationParams and setGenerationParams setter; DEFAULT_GENERATION_PARAMS and normalizeGenerationParams helper added for defaults and merging.
Error Handling Utility
src/utils/errors.ts
New errorToToastMessage function introduced to safely extract and format error messages from various SDK error types (APICallError, RetryError, TypeValidationError, etc.), with OpenAI-compatible payload parsing and fallback to string conversion.
Streaming and Message Core
src/ai/streamUtils.ts, src/ai/sendMessage.ts
processFullStream gains includeProviderMetadataLogprobs parameter (default true) to gate token-logprob extraction. Error handling changed from string conversion to direct throw. SendMessageContext accepts optional generationParams. Built-in, dummy, and OpenAI-compatible providers now read temperature (default 0.7), maxTokens, and logprobs from generationParams to conditionally enable logprob streaming and control assistant prefill behavior via isAssistantPrefill.
Floating Settings UI
src/components/FloatingGenerationSettings.tsx, src/components/GenerationSettings.tsx
FloatingGenerationSettings renders a draggable, fixed-position panel with pointer capture and viewport clamping. GenerationSettings renders provider-dependent controls (Mantine Slider, NumberInput, Switch) and reads/updates generationParams from store via useSettingsStore.
Header and View Wiring
src/components/Header.tsx, src/App.tsx
Header extends props to support chat-tree and generation-settings toggles; removes "Diagram" from view options. App wires UI state for floating settings panel, passes toggles to Header, and conditionally renders DiagramView or ChatView in chat mode based on isChatTreeVisible.
Hook Integration
src/hooks/useConversationController.ts, src/hooks/useTextCompletion.ts
Both hooks pull generationParams from useSettingsStore during message/completion requests and forward them to sendMessage or provider calls. Error handling standardized to use errorToToastMessage.
Styling and Configuration
src/components/DiagramView.tsx, src/components/TextCompletionView.tsx, rsbuild.config.mjs, AGENTS.md
DiagramView node styling updated (borderRadius 10, padding 10), fitViewOptions added. TextCompletionView wrapper centered with width constraint. Rsbuild config sets HTML title to "iaslate". AGENTS.md reorganized into sections (Project Shape, Commands, UI Verification, App Constraints).

Sequence Diagram

sequenceDiagram
    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
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested labels

codex

Poem

🐰 Settings float like whispered dreams,
Temperature tuned to perfect schemes,
With drag and drop and logprobs bound,
Chat and text views dance around,
Now generation parameters reign supreme!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: refactoring the chat layout (removing side panel, adding header toggles) and introducing generation controls (floating settings panel).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch split-diagram-view

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.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 34 minutes and 59 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@CoolSpring8 CoolSpring8 marked this pull request as ready for review May 4, 2026 13:32
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/ai/sendMessage.ts Outdated
Comment thread src/components/GenerationSettings.tsx
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 27b5fdf and ae26148.

📒 Files selected for processing (15)
  • AGENTS.md
  • rsbuild.config.mjs
  • src/App.tsx
  • src/ai/sendMessage.ts
  • src/ai/streamUtils.ts
  • src/components/DiagramView.tsx
  • src/components/FloatingGenerationSettings.tsx
  • src/components/GenerationSettings.tsx
  • src/components/Header.tsx
  • src/components/TextCompletionView.tsx
  • src/hooks/useConversationController.ts
  • src/hooks/useTextCompletion.ts
  • src/state/useSettingsStore.ts
  • src/types.ts
  • src/utils/errors.ts

Comment thread src/ai/sendMessage.ts Outdated
Comment thread src/components/Header.tsx
Comment thread src/components/Header.tsx
Comment thread src/state/useSettingsStore.ts
Comment thread src/utils/errors.ts
@CoolSpring8 CoolSpring8 merged commit cc55e8d into main May 4, 2026
1 check passed
@CoolSpring8 CoolSpring8 deleted the split-diagram-view branch May 4, 2026 14:07
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