Skip to content

Tech322/desktop#2

Merged
techeng322 merged 7 commits into
mainfrom
tech322/desktop
Oct 7, 2024
Merged

Tech322/desktop#2
techeng322 merged 7 commits into
mainfrom
tech322/desktop

Conversation

@techeng322

@techeng322 techeng322 commented Oct 7, 2024

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Updated messaging in the chat component to "What can I help you ship?" for improved user engagement.
    • Enhanced chat input prompt to "Ask me anything about the music industry..." for better clarity.
  • Bug Fixes

    • Adjusted component layouts for better visual consistency by centering elements and limiting maximum widths.
  • Refactor

    • Modified prop types for the SubmitButton component for improved type handling.

@vercel

vercel Bot commented Oct 7, 2024

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
luh-tyler-chat ✅ Ready (Inspect) Visit Preview Oct 7, 2024 3:42pm

@coderabbitai

coderabbitai Bot commented Oct 7, 2024

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@techeng322 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 24 minutes and 48 seconds before requesting another review.

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

📥 Commits

Files that changed from the base of the PR and between 72cc6e5 and d731dab.

Walkthrough

The pull request introduces several modifications to the Chat component and its related files. Key changes include updates to class names for styling purposes, specifically adding max-w-3xl mx-auto to center content and limit width. The placeholder text in the chat input has been revised to reflect a new prompt. Additionally, the SubmitButton component's canSubmit prop type has been changed from boolean to Boolean. Overall, these changes enhance the layout and user interaction without altering the underlying functionality.

Changes

File Path Change Summary
components/Chat/Chat.tsx Updated className of main <div>, added mx-auto max-w-3xl for no messages, changed <p> text.
components/Chat/ChatInput.tsx Added max-w-3xl mx-auto class to outer div, updated placeholder text in textarea.
components/Chat/Messages.tsx Added max-w-3xl mx-auto to outer <div>, adjusted maximum width and centering.
components/Chat/SubmitButton.tsx Changed canSubmit prop type from boolean to Boolean.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Chat
    participant ChatInput
    participant Messages
    participant SubmitButton

    User->>Chat: Open chat interface
    Chat->>Messages: Render messages
    Chat->>ChatInput: Render input field
    ChatInput->>User: Display placeholder "Ask me anything about the music industry..."
    User->>ChatInput: Type message
    ChatInput->>SubmitButton: Check if can submit
    SubmitButton->>Chat: Submit message
    Chat->>Messages: Update message list
Loading

🐇 "In the chat, we now can see,
A prompt to ask, so joyfully!
With messages centered, clear and bright,
Our conversations take new flight!
So hop along, don't be late,
The music chat awaits your fate!" 🎶


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@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

🧹 Outside diff range and nitpick comments (1)
components/Chat/ChatInput.tsx (1)

Line range hint 19-32: Consider these suggestions for improved maintainability and performance:

  1. To enhance maintainability, consider moving all styles to a separate CSS file or using a CSS-in-JS solution. This would make the component more readable and easier to maintain.

  2. The textarea might benefit from a rows prop to control its initial height. For example:

    <textarea
      rows={3}
      // ... other props
    />
  3. The Boolean() wrapper in the SubmitButton prop is unnecessary. You can simplify it to:

    <SubmitButton canSubmit={!!input} />

    Or even:

    <SubmitButton canSubmit={input.length > 0} />

    This would be more explicit about the condition for submission.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between fd45567 and 72cc6e5.

📒 Files selected for processing (4)
  • components/Chat/Chat.tsx (1 hunks)
  • components/Chat/ChatInput.tsx (1 hunks)
  • components/Chat/Messages.tsx (1 hunks)
  • components/Chat/SubmitButton.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • components/Chat/Messages.tsx
🧰 Additional context used
🪛 Biome
components/Chat/SubmitButton.tsx

[error] 3-3: Don't use 'Boolean' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'boolean' instead

(lint/complexity/noBannedTypes)

🔇 Additional comments (5)
components/Chat/SubmitButton.tsx (1)

Line range hint 4-15: LGTM for the rest of the implementation.

The component's logic and rendering are implemented correctly. The conditional styling based on the canSubmit prop is appropriate, and the use of aria-label for accessibility is commendable.

🧰 Tools
🪛 Biome

[error] 3-3: Don't use 'Boolean' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'boolean' instead

(lint/complexity/noBannedTypes)

components/Chat/Chat.tsx (2)

10-10: Improved layout for better content presentation.

The addition of mx-auto max-w-3xl classes for the case when there are no messages is a good improvement. It centers the content and limits its maximum width, which should enhance readability and visual appeal on larger screens.


13-13: Updated prompt text for broader applicability.

The change from "How is Luh Tyler's 3D Game Performing?" to "What can I help you ship?" makes the prompt more generic and potentially applicable to a wider range of scenarios. This aligns well with making the component more versatile.

Could you please clarify if this change in context is intentional and if it affects the overall purpose or use case of the chat component? To assist in verifying the impact, I can run the following script:

✅ Verification successful

Updated search commands to correctly target TypeScript files.


No references to the old prompt text found in the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for references to the old prompt text in other files

# Test: Search for the old prompt text
rg --type typescript --type javascript "How is Luh Tyler's 3D Game Performing?"

# Test: Search for any mentions of Luh Tyler or 3D Game
rg --type typescript --type javascript "Luh Tyler|3D Game"

Length of output: 215


Script:

#!/bin/bash
# Description: Search for references to the old prompt text in other files

# Test: Search for the old prompt text
rg --glob '*.ts' --glob '*.tsx' "How is Luh Tyler's 3D Game Performing?"

# Test: Search for any mentions of Luh Tyler or 3D Game
rg --glob '*.ts' --glob '*.tsx' "Luh Tyler|3D Game"

Length of output: 131

components/Chat/ChatInput.tsx (2)

19-19: LGTM: Improved layout with centered, width-constrained input area.

The addition of max-w-3xl mx-auto classes enhances the chat input's layout by centering it horizontally and limiting its maximum width. This change improves readability and user experience, especially on larger screens.


25-25: LGTM: Updated placeholder text for better user guidance.

The placeholder text has been updated to "Ask me anything about the music industry...", which provides more specific guidance to users about the kind of questions they can ask. This change aligns well with the purpose of the chat interface and should improve user engagement.

Comment thread components/Chat/SubmitButton.tsx Outdated
import { ArrowUpRightIcon } from "lucide-react";

const SubmitButton = ({ canSubmit }: { canSubmit: boolean }) => {
const SubmitButton = ({ canSubmit }: { canSubmit: Boolean }) => {

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.

💡 Codebase verification

⚠️ Potential issue

Revert the type change from Boolean to boolean.

The type of the canSubmit prop in SubmitButton.tsx is currently set to Boolean. This should be changed back to the primitive boolean type for the following reasons:

  1. boolean is the appropriate primitive type in TypeScript, while Boolean refers to the object wrapper type.
  2. Using the primitive boolean ensures better performance and type safety.
  3. This change aligns with TypeScript best practices and common conventions.

Location:

  • components/Chat/SubmitButton.tsx, line 3
-const SubmitButton = ({ canSubmit }: { canSubmit: Boolean }) => {
+const SubmitButton = ({ canSubmit }: { canSubmit: boolean }) => {
🔗 Analysis chain

Revert the type change from Boolean to boolean.

The type of the canSubmit prop has been changed from boolean to Boolean. This change is not recommended in TypeScript for the following reasons:

  1. boolean is the primitive type, while Boolean is the object wrapper type.
  2. Using primitive types is generally preferred for better performance and type inference.
  3. This change goes against TypeScript best practices and common conventions.

Please apply the following fix:

-const SubmitButton = ({ canSubmit }: { canSubmit: Boolean }) => {
+const SubmitButton = ({ canSubmit }: { canSubmit: boolean }) => {

Let's verify if this change impacts other parts of the codebase:

This will help us understand if the type change was intentional and if it affects other parts of the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for usage of SubmitButton component and its prop types

# Search for SubmitButton usage
echo "Searching for SubmitButton usage:"
rg --type typescript --type typescriptreact "SubmitButton" -C 2

# Search for any Boolean type usage in the codebase
echo "Searching for Boolean type usage:"
rg --type typescript --type typescriptreact "\: Boolean" -C 2

Length of output: 393


Script:

#!/bin/bash
# Description: Check for usage of SubmitButton component and its prop types

# Search for SubmitButton usage
echo "Searching for SubmitButton usage:"
rg --glob '*.{ts,tsx}' "SubmitButton" -C 2

# Search for any Boolean type usage
echo "Searching for Boolean type usage:"
rg --glob '*.{ts,tsx}' ": Boolean" -C 2

Length of output: 1485

🧰 Tools
🪛 Biome

[error] 3-3: Don't use 'Boolean' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'boolean' instead

(lint/complexity/noBannedTypes)

Comment thread components/Chat/Chat.tsx Outdated
>
<p className="font-sans font-semibold text-2xl mb-2 text-center">
{`How is Luh Tyler's 3D Game Performing?`}
What can I help you ship?

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.

Please keep the text as it was in your previous PR.

Comment thread components/Chat/ChatInput.tsx Outdated
onChange={handleInputChange}
onKeyDown={handleKeyDown}
placeholder="Ask recoupable a question..."
placeholder="Ask me anything about the music industry..."

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.

Same feedback here.

@techeng322 techeng322 merged commit cc3046e into main Oct 7, 2024
sweetmantech added a commit that referenced this pull request Nov 11, 2024
sweetmantech added a commit that referenced this pull request Nov 11, 2024
sweetmantech pushed a commit that referenced this pull request Nov 11, 2024
sidneyswift added a commit that referenced this pull request Nov 19, 2025
- Add google/gemini-3-pro-preview as top featured model
- Display as 'Gemini 3 Pro' with 'New' badge
- Move Claude Sonnet 4.5 to position #2
- Mark as pro model (requires subscription)

New featured models order:
1. Gemini 3 Pro (New)
2. Claude Sonnet 4.5
3. GPT-5
4. Nano Banana
5. Gemini 2.5 Flash
6. GPT-5 Mini
7. Gemini 2.5 Pro
8. Grok 4
arpitgupta1214 added a commit that referenced this pull request Jun 1, 2026
… gates the bootstrap

E2E found two POSTs on initial mount: one with `artist_id: null`, one
with `artist_id: <saved-selection>`. Cause: in react-query v5
`isLoading` is `isPending && isFetching` — it's false when the query
is disabled. While `useArtistsRoster` waits for `userData` from
`UserProvider` to land, `enabled: false`, `isLoading: false`. The
bootstrap effect saw "settled, empty roster" and fired POST #1 with
`artistId: undefined`. Once `userData` arrived, the query enabled,
artists resolved, selection moved to the saved artist, and the
mutation effect re-fired with the real `artistId` (POST #2).

Switch to `isPending` (true while disabled OR fetching) so the loading
flag stays true through the entire "we don't know the roster yet"
window. Surfaced as `isLoading` to keep the consumer interface stable.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
sweetmantech added a commit that referenced this pull request Jun 1, 2026
…1759)

* feat(chat): stamp sessions with selected artist; refactor useArtists

Tags every newly-provisioned session with `selectedArtist.account_id`
via `POST /api/sessions { artistId }` (api#628 already accepts it), so
the sidebar's artist filter (#1756) groups chats under the right
artist. Each artist switch mints a fresh session under the new
context.

The hard part wasn't passing the field — it was making the bootstrap
fire exactly once per (artistId, orgId). Earlier iterations stacked
refs on top of `useState` to police a duplicate POST that fired
because `useArtists` resolved `selectedArtist` across two renders
(commit A: `isLoading` flips false with `selectedArtist=null`; commit
B: saved selection restored). Both commits independently satisfied
the bootstrap's effect gate, both started a POST, both wrote to
`sessions.artist_id`. Refs guarded the symptom; the real fix is to
make `selectedArtist` resolve in a single render.

### `useArtists` — react-query + derived selection

- Roster comes from `useQuery`, keyed on `(accountId, orgId)`. No
  imperative `getArtists` effect, no `setIsLoading` lifecycle.
- `selectedArtist` is a single `useMemo` deriving from
  `(artists, savedSelections, orgKey, userOverride)`. Precedence:
  user override (this session) → saved (localStorage, per-org) →
  artists[0] auto-pick → null.
- The race is gone *by construction*. There is no longer a render
  where `artists` is populated but `selectedArtist` is still null.
- `useInitialArtists` deleted — its restoration effect folds into
  the memo; the sync-on-org-change effect is implicit (memo
  recomputes when `orgKey` changes).
- `setArtists` mirrors React's `setState` signature
  (array | updater) so `useArtistPinToggle` and `useDeleteArtist`
  keep working without changes; under the hood it's
  `queryClient.setQueryData`.
- `getArtists(artistId?)` becomes `queryClient.fetchQuery` + an
  optional `setSelectedArtist` post-fetch, preserving the existing
  call sites in `useArtistPinToggle`, `useDeleteArtist`, the
  `CreateArtistToolResult` / `UpdateArtistInfoSuccess` /
  `UpdateArtistSocialsSuccess` tool result components, and
  `saveSetting`.

### `useNewChatBootstrap` — useMutation, no refs

- POST is semantically a mutation. `useMutation` owns the in-flight
  / success / error state instead of a hand-rolled state machine.
- Effect gates on `mutation.variables` (react-query's own
  last-mutated args) plus `isPending` / `isSuccess`. Incidental
  re-renders re-enter the effect but bail idempotently. No refs.
- Artist or org change → mutation.variables no longer matches →
  fresh `mutate()` fires under the new context. Orphan session from
  the old context is accepted (rare in practice).

### `Artist.tsx` — narrow the hard-nav

- Hard-navigates to `/chat` only when switching artists from a
  tagged chat URL (`/sessions/{sid}/chats/{cid}` or legacy
  `/chat/{roomId}`). On bare `/chat` the bootstrap re-fires in
  place when `artistId` changes — no nav, no remount flicker.
- `window.location.href` (not `router.replace`) because
  `useVercelChat`'s `silentlyUpdateUrl` writes via
  `history.replaceState`, leaving Next's internal router state out
  of sync with the URL bar — a client-side replace can no-op.

### `lib/sessions/createSession.ts`

- `CreateSessionInput` gains optional `artistId`. Wire-compatible
  with `api/lib/sessions/validateCreateSessionBody.ts`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* refactor(chat): extract artist selection + chat-session provisioning per OCP

Addresses sweetmantech's review comments on lines `useArtists.tsx:80`
and `useNewChatBootstrap.ts:107` — net-new logic was being added inline
to existing hooks instead of being given its own module.

Two extractions:

1. `hooks/artists/useArtistSelection.ts` — owns the per-org artist
   selection: `useLocalStorage` for saved picks, `userOverride` state
   for explicit this-session pick/deselect, and the derived
   `selectedArtist` memo (precedence: override → saved → first).
   `useArtists.tsx` now just calls it with `(orgKey, artists)`.

2. `lib/sessions/provisionChatSession.ts` — combines `createSession`
   + `createSandbox` into one function. `useNewChatBootstrap.ts` now
   wraps that in `useMutation` and owns the trigger / input-change
   re-fire logic only.

No behavior change — both hooks return the same shape and respond to
the same inputs. Just smaller files with clearer single responsibility.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(chat): throw on missing Privy token in useArtists queryFn

Addresses CodeRabbit feedback on `hooks/useArtists.tsx:61`. The
previous shape silently resolved to `[]` when `getAccessToken()` came
back null transiently — `useQuery` marked the query successful,
`isLoading` flipped false, and `useNewChatBootstrap` saw a "settled,
empty roster" and POSTed a session with `artistId: undefined`. Throw
so the query goes to `isError` and the bootstrap stays gated.

Same fix on the imperative `getArtists` callback for consistency.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* refactor(chat): extract roster + provisioner hooks per OCP

Two more OCP extractions, addressing the remaining inline-net-new-code
comments on `useArtists.tsx` and `useNewChatBootstrap.ts`:

1. `hooks/artists/useArtistsRoster.ts` — owns the react-query fetch
   keyed on `(userId, orgId)`, the `setArtists` optimistic-update
   helper, and the `refetchArtists` imperative refetch. `useArtists`
   now consumes it via `useArtistsRoster({ userId, orgId })`.

2. `hooks/sessions/useProvisionChatSession.ts` — owns the mutation
   lifecycle: the `useMutation` setup, the `useEffect` with
   `sameInputs` guard, and the state-mapping from mutation state to
   the discriminated `ProvisionChatSessionState`. `useNewChatBootstrap`
   shrinks to a thin provider-wiring shim (~30 LOC).

Each existing hook now has a single clear responsibility:
- `useArtists` composes roster + selection + per-artist settings
- `useNewChatBootstrap` wires Privy/Org/Artist providers into the
  provisioner

No behavior change.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(chat): gate useArtistsRoster on authenticated, drop the throw

Matches `useConversations` / `useCredits` — they gate the query on
Privy's `authenticated` rather than throwing inside the queryFn for
the transient-null-token case. Now this hook does the same: the
query won't fire until Privy is ready, and if the token is still
null in some pathological case the network call 401s and the query
goes to `isError` (same outcome the throw produced).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(chat): use isPending in useArtistsRoster so disabled-query window gates the bootstrap

E2E found two POSTs on initial mount: one with `artist_id: null`, one
with `artist_id: <saved-selection>`. Cause: in react-query v5
`isLoading` is `isPending && isFetching` — it's false when the query
is disabled. While `useArtistsRoster` waits for `userData` from
`UserProvider` to land, `enabled: false`, `isLoading: false`. The
bootstrap effect saw "settled, empty roster" and fired POST #1 with
`artistId: undefined`. Once `userData` arrived, the query enabled,
artists resolved, selection moved to the saved artist, and the
mutation effect re-fired with the real `artistId` (POST #2).

Switch to `isPending` (true while disabled OR fetching) so the loading
flag stays true through the entire "we don't know the roster yet"
window. Surfaced as `isLoading` to keep the consumer interface stable.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: Sweets Sweetman <sweetmantech@gmail.com>
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.

2 participants