Skip to content

Conversation

@feifei325
Copy link
Collaborator

@feifei325 feifei325 commented Jan 4, 2026

Summary

  • Fix sidebar showing infinite loading spinner for invited group chat members
  • Remove visible "Group chat created" message when creating new group chats

Changes

  1. taskContext.tsx: Change task status from RUNNING to COMPLETED in handleTaskInvited callback

    • Set progress to 100 and completed_at to creation time
    • This prevents the sidebar from showing an indefinite spinning indicator for invited users
  2. CreateGroupChatDialog.tsx: Replace initial message with system marker __SYSTEM_GROUP_CREATED__

    • This marker is used internally but filtered out from display
  3. useUnifiedMessages.ts: Add system message filtering

    • Add isSystemMessage() helper function to identify internal markers
    • Filter out system messages before returning to UI

Root Cause Analysis

  1. Sidebar spinning issue: When a user is invited to a group chat via WebSocket (task:invited event), the task was created with status: 'RUNNING' and progress: 0. Since group chat tasks are typically already complete when the invitation is sent, this caused the sidebar to show an infinite loading spinner.

  2. Initial message issue: The group chat creation flow required sending an initial message. This message ("群聊已创建,欢迎大家!" / "Group chat created, welcome everyone!") was displayed as a regular user message, which is not desirable.

Test plan

  • Create a new group chat and verify no initial message appears
  • Invite a user to the group chat
  • Verify the invited user's sidebar shows the group chat without spinning indicator
  • Verify normal chat messages still display correctly
  • Verify message export still works correctly (system messages should not appear)

Summary by CodeRabbit

  • Improvements
    • Group chat creation tasks now display as immediately completed for clearer progress feedback.
    • System/internal markers are filtered out of chat so redundant "group created" notifications no longer appear.
    • Task completion indicators for group chat invitations have been clarified to better reflect final state.

✏️ Tip: You can customize this high-level summary in your review settings.

- Change task status to COMPLETED instead of RUNNING in handleTaskInvited
  callback to prevent sidebar from showing indefinite spinning indicator
  for invited group chat members
- Replace group chat creation initial message with system marker
  '__SYSTEM_GROUP_CREATED__' that gets filtered out in useUnifiedMessages
- Add isSystemMessage filter to hide internal system markers from UI

Fixes:
1. Group chat members sidebar no longer shows infinite loading spinner
2. No visible "Group chat created" message appears when creating new group
@coderabbitai
Copy link

coderabbitai bot commented Jan 4, 2026

📝 Walkthrough

Walkthrough

Group-chat creation now emits an internal system marker message instead of a localized visible message; the unified message hook filters system messages before returning messages. The invited-group-chat task creation via WebSocket is marked immediately completed (status COMPLETED, progress 100, completed_at set).

Changes

Cohort / File(s) Summary
System message definition
frontend/src/features/tasks/constants/systemMessages.ts
Adds SYSTEM_MESSAGE_MARKERS with GROUP_CHAT_CREATED, SystemMessageMarker type, and isSystemMessage helper.
Group chat creation UI
frontend/src/features/tasks/components/group-chat/CreateGroupChatDialog.tsx
Replaces localized initial message with SYSTEM_MESSAGE_MARKERS.GROUP_CHAT_CREATED when creating a group chat; adds explanatory comments.
Unified message handling
frontend/src/features/tasks/hooks/useUnifiedMessages.ts
Imports isSystemMessage; applies post-sort filter to remove system messages (e.g., group-created marker) from the returned messages list.
Task context / WebSocket flow
frontend/src/features/tasks/contexts/taskContext.tsx
Adjusts invited-task creation to set status = COMPLETED, progress = 100, and completed_at = data.created_at for immediate completion semantics.

Sequence Diagram(s)

sequenceDiagram
    participant UX as User
    participant Dialog as CreateGroupChatDialog
    participant WS as TaskContext (WebSocket)
    participant Messages as useUnifiedMessages
    participant UI as Messages UI

    UX->>Dialog: Submit "create group chat"
    Dialog->>WS: sendMessage(payload with SYSTEM_GROUP_CREATED marker)
    WS->>Messages: emit message into unified stream
    Messages->>Messages: sort messages
    Messages->>Messages: filter out system messages (isSystemMessage)
    Messages->>UI: return filtered message list
    UI->>UX: display messages (system marker hidden)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • qdaxb
  • Micro66

Poem

🐰 A quiet marker tucked away in code,

I plant a seed where group chats grow.
Hidden words that tell the tale,
Tasks complete — no progress trail.
Hop, chat, flourish — softly so.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main fixes: resolving loading spinner issues and removing unwanted initial messages in group chat invites, matching the primary changes throughout the changeset.
✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 66218ea and 56b833a.

📒 Files selected for processing (3)
  • frontend/src/features/tasks/components/group-chat/CreateGroupChatDialog.tsx
  • frontend/src/features/tasks/constants/systemMessages.ts
  • frontend/src/features/tasks/hooks/useUnifiedMessages.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/src/features/tasks/hooks/useUnifiedMessages.ts
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{py,ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{py,ts,tsx,js,jsx}: All code comments MUST be written in English
File size MUST NOT exceed 1000 lines - split into multiple sub-modules if exceeded
Function length SHOULD NOT exceed 50 lines (preferred)

Files:

  • frontend/src/features/tasks/components/group-chat/CreateGroupChatDialog.tsx
  • frontend/src/features/tasks/constants/systemMessages.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

TypeScript/React MUST use strict mode, functional components, Prettier for formatting, ESLint for linting, single quotes, and no semicolons

Files:

  • frontend/src/features/tasks/components/group-chat/CreateGroupChatDialog.tsx
  • frontend/src/features/tasks/constants/systemMessages.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

TypeScript MUST use const over let, never use var

Files:

  • frontend/src/features/tasks/components/group-chat/CreateGroupChatDialog.tsx
  • frontend/src/features/tasks/constants/systemMessages.ts
frontend/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

frontend/src/**/*.{ts,tsx}: MUST use useTranslation hook imported from @/hooks/useTranslation, not from react-i18next
MUST use single namespace with useTranslation() - never use array format like useTranslation(['common', 'groups'])
Frontend message data MUST always use messages from useUnifiedMessages() hook as the single source of truth for displaying messages - never use selectedTaskDetail.subtasks
Frontend i18n translation keys MUST use current namespace format t('key.subkey') for keys within namespace and t('namespace:key.subkey') for cross-namespace keys

Files:

  • frontend/src/features/tasks/components/group-chat/CreateGroupChatDialog.tsx
  • frontend/src/features/tasks/constants/systemMessages.ts
frontend/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Frontend MUST only use NEXT_PUBLIC_* environment variables for client-safe values

Files:

  • frontend/src/features/tasks/components/group-chat/CreateGroupChatDialog.tsx
  • frontend/src/features/tasks/constants/systemMessages.ts
🧠 Learnings (1)
📚 Learning: 2025-12-31T03:47:12.173Z
Learnt from: CR
Repo: wecode-ai/Wegent PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-31T03:47:12.173Z
Learning: Applies to frontend/src/**/*.{ts,tsx} : Frontend message data MUST always use `messages` from `useUnifiedMessages()` hook as the single source of truth for displaying messages - never use `selectedTaskDetail.subtasks`

Applied to files:

  • frontend/src/features/tasks/components/group-chat/CreateGroupChatDialog.tsx
  • frontend/src/features/tasks/constants/systemMessages.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Test wegent CLI Integration
  • GitHub Check: E2E Tests (Shard 3/3)
  • GitHub Check: E2E Tests (Shard 1/3)
  • GitHub Check: E2E Tests (Shard 2/3)
🔇 Additional comments (3)
frontend/src/features/tasks/constants/systemMessages.ts (1)

1-24: LGTM! Clean and type-safe system message marker implementation.

The constant definition with as const, the derived union type, and the helper function are well-designed. The documentation clearly explains the purpose, and the implementation follows TypeScript best practices.

frontend/src/features/tasks/components/group-chat/CreateGroupChatDialog.tsx (2)

34-34: LGTM! Import is correct and necessary.

The import statement correctly brings in the SYSTEM_MESSAGE_MARKERS constant for use in the message creation logic.


106-111: Implementation verified - message filtering is correctly in place.

The system marker SYSTEM_MESSAGE_MARKERS.GROUP_CHAT_CREATED is properly defined and integrated with useUnifiedMessages(). The hook correctly imports isSystemMessage and filters out these markers at line 318 before returning the message list, ensuring system messages are never displayed to users. The comments accurately explain the filtering behavior.


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.

Copy link

@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: 0

🧹 Nitpick comments (1)
frontend/src/features/tasks/hooks/useUnifiedMessages.ts (1)

36-46: Extract system marker to a shared constant file.

The system marker '__SYSTEM_GROUP_CREATED__' is duplicated in CreateGroupChatDialog.tsx (line 110). Consider extracting it to a shared constants file (e.g., features/tasks/constants/systemMessages.ts) to ensure consistency and easier maintenance.

🔎 Proposed refactor

Create a new file frontend/src/features/tasks/constants/systemMessages.ts:

// System message markers for internal use only
// These messages should be filtered out from user-facing message lists
export const SYSTEM_MESSAGE_MARKERS = {
  GROUP_CHAT_CREATED: '__SYSTEM_GROUP_CREATED__',
} as const

export type SystemMessageMarker = typeof SYSTEM_MESSAGE_MARKERS[keyof typeof SYSTEM_MESSAGE_MARKERS]

export function isSystemMessage(content: string): boolean {
  return Object.values(SYSTEM_MESSAGE_MARKERS).includes(content as SystemMessageMarker)
}

Then import and use in both files:

-const SYSTEM_GROUP_CREATED_MARKER = '__SYSTEM_GROUP_CREATED__';
-
-function isSystemMessage(content: string): boolean {
-  return content === SYSTEM_GROUP_CREATED_MARKER;
-}
+import { isSystemMessage } from '@/features/tasks/constants/systemMessages'

In CreateGroupChatDialog.tsx:

+import { SYSTEM_MESSAGE_MARKERS } from '@/features/tasks/constants/systemMessages'
...
-        message: '__SYSTEM_GROUP_CREATED__',
+        message: SYSTEM_MESSAGE_MARKERS.GROUP_CHAT_CREATED,
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 20dc87c and 66218ea.

📒 Files selected for processing (3)
  • frontend/src/features/tasks/components/group-chat/CreateGroupChatDialog.tsx
  • frontend/src/features/tasks/contexts/taskContext.tsx
  • frontend/src/features/tasks/hooks/useUnifiedMessages.ts
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{py,ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{py,ts,tsx,js,jsx}: All code comments MUST be written in English
File size MUST NOT exceed 1000 lines - split into multiple sub-modules if exceeded
Function length SHOULD NOT exceed 50 lines (preferred)

Files:

  • frontend/src/features/tasks/components/group-chat/CreateGroupChatDialog.tsx
  • frontend/src/features/tasks/contexts/taskContext.tsx
  • frontend/src/features/tasks/hooks/useUnifiedMessages.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

TypeScript/React MUST use strict mode, functional components, Prettier for formatting, ESLint for linting, single quotes, and no semicolons

Files:

  • frontend/src/features/tasks/components/group-chat/CreateGroupChatDialog.tsx
  • frontend/src/features/tasks/contexts/taskContext.tsx
  • frontend/src/features/tasks/hooks/useUnifiedMessages.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

TypeScript MUST use const over let, never use var

Files:

  • frontend/src/features/tasks/components/group-chat/CreateGroupChatDialog.tsx
  • frontend/src/features/tasks/contexts/taskContext.tsx
  • frontend/src/features/tasks/hooks/useUnifiedMessages.ts
frontend/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

frontend/src/**/*.{ts,tsx}: MUST use useTranslation hook imported from @/hooks/useTranslation, not from react-i18next
MUST use single namespace with useTranslation() - never use array format like useTranslation(['common', 'groups'])
Frontend message data MUST always use messages from useUnifiedMessages() hook as the single source of truth for displaying messages - never use selectedTaskDetail.subtasks
Frontend i18n translation keys MUST use current namespace format t('key.subkey') for keys within namespace and t('namespace:key.subkey') for cross-namespace keys

Files:

  • frontend/src/features/tasks/components/group-chat/CreateGroupChatDialog.tsx
  • frontend/src/features/tasks/contexts/taskContext.tsx
  • frontend/src/features/tasks/hooks/useUnifiedMessages.ts
frontend/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Frontend MUST only use NEXT_PUBLIC_* environment variables for client-safe values

Files:

  • frontend/src/features/tasks/components/group-chat/CreateGroupChatDialog.tsx
  • frontend/src/features/tasks/contexts/taskContext.tsx
  • frontend/src/features/tasks/hooks/useUnifiedMessages.ts
🧠 Learnings (1)
📚 Learning: 2025-12-31T03:47:12.173Z
Learnt from: CR
Repo: wecode-ai/Wegent PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-31T03:47:12.173Z
Learning: Applies to frontend/src/**/*.{ts,tsx} : Frontend message data MUST always use `messages` from `useUnifiedMessages()` hook as the single source of truth for displaying messages - never use `selectedTaskDetail.subtasks`

Applied to files:

  • frontend/src/features/tasks/components/group-chat/CreateGroupChatDialog.tsx
  • frontend/src/features/tasks/contexts/taskContext.tsx
  • frontend/src/features/tasks/hooks/useUnifiedMessages.ts
🧬 Code graph analysis (1)
frontend/src/features/tasks/components/group-chat/CreateGroupChatDialog.tsx (1)
frontend/src/features/tasks/service/messageService.ts (1)
  • sendMessage (90-154)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Test Frontend
  • GitHub Check: Test wegent CLI Integration
  • GitHub Check: E2E Tests (Shard 3/3)
  • GitHub Check: E2E Tests (Shard 1/3)
  • GitHub Check: E2E Tests (Shard 2/3)
🔇 Additional comments (3)
frontend/src/features/tasks/hooks/useUnifiedMessages.ts (1)

327-332: LGTM! Filtering logic is correctly applied.

The system message filtering is properly placed after sorting and before returning, ensuring internal markers are hidden from the UI while maintaining correct message order.

frontend/src/features/tasks/contexts/taskContext.tsx (1)

372-399: LGTM! Status change correctly addresses the infinite spinner issue.

Setting invited group chat tasks to COMPLETED status with progress: 100 and completed_at: data.created_at is the right approach. This ensures invited users don't see an indefinite loading spinner in the sidebar, as the group chat creation is already complete when the invitation is received.

frontend/src/features/tasks/components/group-chat/CreateGroupChatDialog.tsx (1)

105-110: LGTM! System marker correctly replaces the visible initial message.

The change from a localized message to the system marker ensures no initial "Group chat created" message appears to users, as the marker will be filtered out by useUnifiedMessages.

Note: The string duplication concern is addressed in the review comment for useUnifiedMessages.ts lines 36-46.

- Create systemMessages.ts constant file for system message markers
- Import SYSTEM_MESSAGE_MARKERS and isSystemMessage from shared module
- Replace inline constant with imported constant for better maintainability

This addresses CodeRabbit review feedback to avoid code duplication
Copy link

@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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
frontend/src/features/tasks/components/group-chat/CreateGroupChatDialog.tsx (1)

109-169: Remove the unused translation key groupChat.create.initialMessage from locale files.

The translation key exists in frontend/src/i18n/locales/en/common.json and corresponding locale files but is not referenced anywhere in the codebase. The system message marker approach correctly filters this message using isSystemMessage() in the useUnifiedMessages() hook, which is the proper single source of truth for displaying messages. Remove the unused initialMessage key from all locale files to keep translations clean.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 66218ea and 56b833a.

📒 Files selected for processing (3)
  • frontend/src/features/tasks/components/group-chat/CreateGroupChatDialog.tsx
  • frontend/src/features/tasks/constants/systemMessages.ts
  • frontend/src/features/tasks/hooks/useUnifiedMessages.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/src/features/tasks/hooks/useUnifiedMessages.ts
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{py,ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{py,ts,tsx,js,jsx}: All code comments MUST be written in English
File size MUST NOT exceed 1000 lines - split into multiple sub-modules if exceeded
Function length SHOULD NOT exceed 50 lines (preferred)

Files:

  • frontend/src/features/tasks/components/group-chat/CreateGroupChatDialog.tsx
  • frontend/src/features/tasks/constants/systemMessages.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

TypeScript/React MUST use strict mode, functional components, Prettier for formatting, ESLint for linting, single quotes, and no semicolons

Files:

  • frontend/src/features/tasks/components/group-chat/CreateGroupChatDialog.tsx
  • frontend/src/features/tasks/constants/systemMessages.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

TypeScript MUST use const over let, never use var

Files:

  • frontend/src/features/tasks/components/group-chat/CreateGroupChatDialog.tsx
  • frontend/src/features/tasks/constants/systemMessages.ts
frontend/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

frontend/src/**/*.{ts,tsx}: MUST use useTranslation hook imported from @/hooks/useTranslation, not from react-i18next
MUST use single namespace with useTranslation() - never use array format like useTranslation(['common', 'groups'])
Frontend message data MUST always use messages from useUnifiedMessages() hook as the single source of truth for displaying messages - never use selectedTaskDetail.subtasks
Frontend i18n translation keys MUST use current namespace format t('key.subkey') for keys within namespace and t('namespace:key.subkey') for cross-namespace keys

Files:

  • frontend/src/features/tasks/components/group-chat/CreateGroupChatDialog.tsx
  • frontend/src/features/tasks/constants/systemMessages.ts
frontend/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Frontend MUST only use NEXT_PUBLIC_* environment variables for client-safe values

Files:

  • frontend/src/features/tasks/components/group-chat/CreateGroupChatDialog.tsx
  • frontend/src/features/tasks/constants/systemMessages.ts
🧠 Learnings (1)
📚 Learning: 2025-12-31T03:47:12.173Z
Learnt from: CR
Repo: wecode-ai/Wegent PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-31T03:47:12.173Z
Learning: Applies to frontend/src/**/*.{ts,tsx} : Frontend message data MUST always use `messages` from `useUnifiedMessages()` hook as the single source of truth for displaying messages - never use `selectedTaskDetail.subtasks`

Applied to files:

  • frontend/src/features/tasks/components/group-chat/CreateGroupChatDialog.tsx
  • frontend/src/features/tasks/constants/systemMessages.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Test wegent CLI Integration
  • GitHub Check: E2E Tests (Shard 3/3)
  • GitHub Check: E2E Tests (Shard 1/3)
  • GitHub Check: E2E Tests (Shard 2/3)
🔇 Additional comments (3)
frontend/src/features/tasks/constants/systemMessages.ts (1)

1-24: LGTM! Clean and type-safe system message marker implementation.

The constant definition with as const, the derived union type, and the helper function are well-designed. The documentation clearly explains the purpose, and the implementation follows TypeScript best practices.

frontend/src/features/tasks/components/group-chat/CreateGroupChatDialog.tsx (2)

34-34: LGTM! Import is correct and necessary.

The import statement correctly brings in the SYSTEM_MESSAGE_MARKERS constant for use in the message creation logic.


106-111: Implementation verified - message filtering is correctly in place.

The system marker SYSTEM_MESSAGE_MARKERS.GROUP_CHAT_CREATED is properly defined and integrated with useUnifiedMessages(). The hook correctly imports isSystemMessage and filters out these markers at line 318 before returning the message list, ensuring system messages are never displayed to users. The comments accurately explain the filtering behavior.

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