Skip to content

Refactor AI chat message types and lint rules; update useChatShortcuts - #1835

Merged
durdana3105 merged 2 commits into
durdana3105:mainfrom
TanCodeX:refactor/typed-ai-chat-messages
Jul 22, 2026
Merged

Refactor AI chat message types and lint rules; update useChatShortcuts#1835
durdana3105 merged 2 commits into
durdana3105:mainfrom
TanCodeX:refactor/typed-ai-chat-messages

Conversation

@TanCodeX

@TanCodeX TanCodeX commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Description

Closes #1828

This Pull Request improves the type safety of the AI Matchmaking Assistant (src/pages/aipage.tsx) by replacing the loose any typing for chat messages with a strongly typed Message interface.

Previously, the messages state in the AI chat relied on any[], and the @typescript-eslint/no-explicit-any ESLint rule was disabled to bypass warnings. This update removes those bypasses, ensuring that all message data structures are strictly validated at compile time.

Changes Made

  • Added Message Interface: Introduced a strict Message interface to define the expected structure of a chat message (role: "user" | "assistant" and content: string).
  • Removed any Types: Updated the useState hook and all message-related iterations (e.g., mapping components, iterating over history) to utilize the new Message type instead of any.
  • Re-enabled Linting: Removed the /* eslint-disable @typescript-eslint/no-explicit-any */ directive from src/pages/aipage.tsx, thereby restoring the rule and improving long-term maintainability.

Impact

  • Type Safety: Prevents accidental structural modifications to messages that could cause runtime errors.
  • Developer Experience: Enables accurate IDE autocomplete, type inference, and immediate feedback during development.
  • Maintainability: Makes future refactoring of the chat interface safer and less error-prone.

Verification

  • Verified that TypeScript compilation (npm run typecheck) passes without errors.
  • Verified that ESLint (npm run lint) no longer reports issues regarding any types in aipage.tsx.
  • Ensured that the chat interface renders correctly and handles AI matchmaking queries as expected.

Summary by CodeRabbit

  • Bug Fixes
    • Improved keyboard shortcut handling in Chat, including more reliable user selection and returning to the conversation list with Escape.
    • Improved AI chat message handling for more consistent responses when users are logged out or when an AI request encounters an error.
  • Improvements
    • Enhanced reliability and consistency when displaying user and assistant messages in AI conversations.

@vercel

vercel Bot commented Jul 21, 2026

Copy link
Copy Markdown

@TanCodeX is attempting to deploy a commit to the durdana3105's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 42a68074-65f1-4a21-9bba-a3f846b5a537

📥 Commits

Reviewing files that changed from the base of the PR and between 3613ee1 and 15c2334.

📒 Files selected for processing (2)
  • src/pages/Chat.tsx
  • src/pages/aipage.tsx

📝 Walkthrough

Walkthrough

AI chat messages now use an explicit Message type across state updates and rendering. The useChatShortcuts hook invocation in Chat was moved to follow the selectUser callback definition while preserving its inputs and behavior.

Changes

AI message typing

Layer / File(s) Summary
Typed AI message flow
src/pages/aipage.tsx
Adds a Message interface and applies it to message state, outgoing messages, formatted API history, assistant and error responses, and rendering.

Chat shortcut hook ordering

Layer / File(s) Summary
Relocate chat shortcut hook
src/pages/Chat.tsx
Moves useChatShortcuts after selectUser is defined while retaining the existing shortcut configuration.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: gssoc26, gssoc:approved, quality:clean

Suggested reviewers: ali-imtiyazkhan, nyxsky404

🚥 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 clearly reflects the main AI chat typing refactor and the useChatShortcuts adjustment.
Linked Issues check ✅ Passed The AI chat state is strongly typed, the explicit any-disable comment was removed, and message handling was updated to use the new interface.
Out of Scope Changes check ✅ Passed The Chat.tsx hook reorder is aligned with the PR objectives and does not introduce unrelated scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@durdana3105
durdana3105 merged commit cefc1f8 into durdana3105:main Jul 22, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Usage of any Types and Disabled ESLint Rules in AI Chat

2 participants