Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

refactor(ui): move LoadingIndicator into MessageList

Naiyuan Qing430f2c177ed2
diff --git a/packages/ui/src/components/chat-view.tsx b/packages/ui/src/components/chat-view.tsx
index 92c2cb7953..7bd6cffb35 100644
--- a/packages/ui/src/components/chat-view.tsx
+++ b/packages/ui/src/components/chat-view.tsx
@@ -8,7 +8,6 @@ import { MessageList } from "@multica/ui/components/message-list";
import { MemoizedMarkdown } from "@multica/ui/components/markdown";
import { MulticaIcon } from "@multica/ui/components/multica-icon";
import { ExecApprovalItem } from "@multica/ui/components/exec-approval-item";
-import { LoadingIndicator } from "@multica/ui/components/loading-indicator";
import { useScrollFade } from "@multica/ui/hooks/use-scroll-fade";
import { useAutoScroll } from "@multica/ui/hooks/use-auto-scroll";
import type { Message } from "@multica/store";
@@ -209,14 +208,12 @@ export function ChatView({
</div>
</div>
)}
- <MessageList messages={messages} streamingIds={streamingIds} />
- {isLoading && pendingApprovals.length === 0 && (
- <div className="container relative px-6">
- <LoadingIndicator
- variant={streamingIds.size > 0 ? "streaming" : "generating"}
- />
- </div>
- )}
+ <MessageList
+ messages={messages}
+ streamingIds={streamingIds}
+ isLoading={isLoading}
+ hasPendingApprovals={pendingApprovals.length > 0}
+ />
{pendingApprovals.length > 0 && (
<div className="container relative px-4">
{pendingApprovals.map((approval) => (
diff --git a/packages/ui/src/components/message-list.tsx b/packages/ui/src/components/message-list.tsx
index 5d4599caf2..84e712a5af 100644
--- a/packages/ui/src/components/message-list.tsx
+++ b/packages/ui/src/components/message-list.tsx
@@ -7,6 +7,7 @@ import { ToolCallItem } from "@multica/ui/components/tool-call-item";
import { ThinkingItem } from "@multica/ui/components/thinking-item";
import { CompactionItem } from "@multica/ui/components/compaction-item";
import { MessageSourceIcon } from "@multica/ui/components/message-source-icon";
+import { LoadingIndicator } from "@multica/ui/components/loading-indicator";
import { cn, getTextContent } from "@multica/ui/lib/utils";
import type { Message } from "@multica/store";
import type { ContentBlock, ToolCall, ThinkingContent } from "@multica/sdk";
@@ -62,9 +63,16 @@ function toRunningMessage(tc: ToolCall, agentId: string): Message {
interface MessageListProps {
messages: Message[]
streamingIds: Set<string>
+ isLoading?: boolean
+ hasPendingApprovals?: boolean
}
-export const MessageList = memo(function MessageList({ messages, streamingIds }: MessageListProps) {
+export const MessageList = memo(function MessageList({
+ messages,
+ streamingIds,
+ isLoading = false,
+ hasPendingApprovals = false,
+}: MessageListProps) {
// Build a set of toolCallIds that already have a toolResult message,
// so we don't render duplicate items from the assistant's toolCall blocks
const resolvedToolCallIds = useMemo(() => {
@@ -125,7 +133,7 @@ export const MessageList = memo(function MessageList({ messages, streamingIds }:
)}
<div
className={cn(
- msg.role === "user" ? "bg-muted rounded-md max-w-[60%] p-2 px-4" : "w-full p-2 my-1"
+ msg.role === "user" ? "bg-muted rounded-md max-w-[60%] p-2 px-4 my-2" : "w-full p-2 my-2"
)}
>
{isStreaming ? (
@@ -155,6 +163,12 @@ export const MessageList = memo(function MessageList({ messages, streamingIds }:
</div>
)
})}
+ {isLoading && !hasPendingApprovals && (
+ <LoadingIndicator
+ variant={streamingIds.size > 0 ? "streaming" : "generating"}
+ className="px-2"
+ />
+ )}
</div>
)
})