Skip to content

refactor: remove loadingStore and move the state into chat context#1593

Merged
mfortman11 merged 2 commits into
mainfrom
remove-loading-store
May 13, 2026
Merged

refactor: remove loadingStore and move the state into chat context#1593
mfortman11 merged 2 commits into
mainfrom
remove-loading-store

Conversation

@mfortman11

@mfortman11 mfortman11 commented May 12, 2026

Copy link
Copy Markdown
Contributor

loadingStore was only used by the chat so moved that state into the ChatContext

Summary by CodeRabbit

  • Refactor
    • Consolidated loading state into the chat context to centralize behavior and simplify state flow.
  • Bug Fixes / UI
    • Made loading indicators and disabled UI states consistent across navigation and chat, reducing duplicate or stale loading displays.

@mfortman11
mfortman11 requested review from Wallgau and lucaseduoli May 12, 2026 21:19
@github-actions github-actions Bot added the frontend 🟨 Issues related to the UI/UX label May 12, 2026
@coderabbitai

coderabbitai Bot commented May 12, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

Migrates loading state from a standalone Zustand store (useLoadingStore) into the chat context. ChatContextType adds loading and setLoading; ChatProvider holds the state. Consumers (frontend/app/chat/page.tsx, frontend/components/navigation.tsx) now use useChat() for loading. Streaming flag renamed isStreamLoadingisChatStreaming.

Changes

Loading state consolidation and consumer updates

Layer / File(s) Summary
Context contract and provider wiring
frontend/contexts/chat-context.tsx
Adds loading: boolean and setLoading(loading: boolean) to ChatContextType; ChatProvider creates const [loading, setLoading] = useState(false) and exposes both in the memoized context value; updates useMemo deps to include loading.
Store removal
frontend/stores/loadingStore.ts
Deletes the useLoadingStore Zustand hook and its LoadingState and updater (setLoading), removing the global loading store export.
Chat page consumer migration
frontend/app/chat/page.tsx
Removes useLoadingStore import and an unused useIsCloudBrand() call inside inner ChatPage; destructures loading and setLoading from useChat(); renames streaming hook flag isStreamLoadingisChatStreaming; updates timeout/effect guards and dependency arrays to use isChatStreaming.
Navigation consumer migration
frontend/components/navigation.tsx
Removes useLoadingStore import and related effect; destructures loading from useChat() and uses that for UI disable/placeholder behavior.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

refactor

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 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 change: removing the loadingStore and moving its state into ChatContext, which aligns with all four modified files.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch remove-loading-store

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

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

@lucaseduoli lucaseduoli left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM!

@github-actions github-actions Bot added the lgtm label May 13, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 `@frontend/app/chat/page.tsx`:
- Around line 51-53: The PR moved the UI "loading" state into
ChatContext/useChat, which violates the repo policy to keep frontend state in
Zustand stores; revert ownership by removing loading and setLoading from the
ChatContext consumer usage and instead read/write that boolean from the
appropriate Zustand store (e.g., stores/chatStore) in this component and any
other components that relied on useChat for loading. Update useChat/ChatContext
to stop exposing loading/setLoading (or keep them but delegate to the store),
add or reuse a selector like useChatStore(state => state.loading) and an updater
like useChatStore(state => state.setLoading) in page.tsx, and adjust any
handlers that toggle loading to call the store setter; ensure imports reference
the store instead of ChatContext/useChat and keep other ChatContext APIs
unchanged.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 05f84369-cfa3-4d54-b967-d6a46305d4a2

📥 Commits

Reviewing files that changed from the base of the PR and between 99be19f and 6ef4bd2.

📒 Files selected for processing (1)
  • frontend/app/chat/page.tsx

Comment thread frontend/app/chat/page.tsx
@mfortman11
mfortman11 merged commit c6e3f37 into main May 13, 2026
17 checks passed
@github-actions
github-actions Bot deleted the remove-loading-store branch May 13, 2026 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community frontend 🟨 Issues related to the UI/UX lgtm refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants