Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Composer: the failed-send rows move to their own component, so Composer.tsx stays under 1,000 lines (#7176)
Milind Soni31ea6fa6c092
diff --git a/src/components/Composer.tsx b/src/components/Composer.tsxindex b8d79e0f3b..fbbb0b658e 100644--- a/src/components/Composer.tsx+++ b/src/components/Composer.tsx@@ -3,7 +3,7 @@ import { TeamAudienceLabel } from "./TeamSideSwitch";import { useComposerDictation } from "@/lib/use-composer-dictation";import { ComposerForkError, useComposerFork } from "./ComposerFork";import { useCallback, useEffect, useMemo, useRef, useState, type SetStateAction } from "react";-import { Mic, Square, X } from "lucide-react";+import { Mic, Square } from "lucide-react";import { sameFields, useStoreDispatch, useStoreSelector } from "@/state/store-select"; import { useStoreRef } from "@/state/store-ref"; import { sameDrawnBots } from "@/lib/drawn-bots";import { visibleMessages, currentTaskBot, type Bot, type Group, type InstanceInfo, type Message } from "@/state/store";import { cn } from "@/lib/cn";@@ -36,7 +36,7 @@ import {type FailedComposerSend,} from "@/lib/drafts";import { DEVS_CHOICE, MentionMenu, teammateChoices, type MentionChoice } from "./MentionMenu"; import { useTeammates } from "@/state/team-people"; import { hiddenFromSidebar, useViewerEmail } from "@/lib/default-bot"; import { useMayAct } from "./SharedQueueLine";-import { SlashCommandMenu } from "./SlashCommandMenu";+import { SlashCommandMenu } from "./SlashCommandMenu"; import { ComposerFailedSends } from "./ComposerFailedSends";import { MentionTextarea } from "./MentionTextarea";import { ComposerAttachments, pathForFile } from "./ComposerAttachments";import { PointedChips } from "./app/PointedChips"; import { SetupRequestChip, setupRequestPlaceholder } from "./SetupOffer";@@ -716,34 +716,7 @@ export function Composer({)}<div className="pointer-events-auto relative w-full">{fork.error && <ComposerForkError message={fork.error} onRetry={() => { inputRef.current?.focus(); send(); }} />}- {failedSends.map((failed) => (- <div- key={failed.id}- className="mb-2 flex items-center gap-2 rounded-lg border border-danger/30 bg-danger/10 px-3 py-2 text-[13px] text-danger"- >- <span className="min-w-0 flex-1 truncate">- {t("composer.failed.notSent", {- text: failed.text.trim() || t("composer.failed.attachment"),- })}- </span>- <button- type="button"- onClick={() => retryFailedSend(failed)}- className="shrink-0 rounded px-2 py-1 font-medium hover:bg-danger/10"- >- {t("chat.retry")}- </button>- <button- type="button"- onClick={() => forgetFailedComposerSend(draftId, failed.id)}- aria-label={t("composer.failed.dismissAria")}- title={t("composer.failed.dismiss")}- className="flex size-5 shrink-0 items-center justify-center rounded hover:bg-danger/10"- >- <X size={13} strokeWidth={2.5} />- </button>- </div>- ))}+ <ComposerFailedSends draftId={draftId} failedSends={failedSends} onRetry={retryFailedSend} /><SlashCommandMenu listRef={commandListRef} motion={commandMotion} commands={commandCandidates} highlight={highlight}onPick={pickCommand} onHighlight={setHighlight} /><MentionMenu listRef={mentionListRef} motion={mentionMotion} choices={candidates} highlight={highlight}diff --git a/src/components/ComposerFailedSends.tsx b/src/components/ComposerFailedSends.tsxnew file mode 100644index 0000000000..5486fe8788--- /dev/null+++ b/src/components/ComposerFailedSends.tsx@@ -0,0 +1,39 @@+import { X } from "lucide-react";+import { t } from "@/lib/i18n";+import { forgetFailedComposerSend, type FailedComposerSend } from "@/lib/drafts";++/** A row per message that didn't send: its text, Retry, and dismiss. */+export function ComposerFailedSends({ draftId, failedSends, onRetry }: {+ draftId: string;+ failedSends: readonly FailedComposerSend[];+ onRetry: (failed: FailedComposerSend) => void;+}) {+ return failedSends.map((failed) => (+ <div+ key={failed.id}+ className="mb-2 flex items-center gap-2 rounded-lg border border-danger/30 bg-danger/10 px-3 py-2 text-[13px] text-danger"+ >+ <span className="min-w-0 flex-1 truncate">+ {t("composer.failed.notSent", {+ text: failed.text.trim() || t("composer.failed.attachment"),+ })}+ </span>+ <button+ type="button"+ onClick={() => onRetry(failed)}+ className="shrink-0 rounded px-2 py-1 font-medium hover:bg-danger/10"+ >+ {t("chat.retry")}+ </button>+ <button+ type="button"+ onClick={() => forgetFailedComposerSend(draftId, failed.id)}+ aria-label={t("composer.failed.dismissAria")}+ title={t("composer.failed.dismiss")}+ className="flex size-5 shrink-0 items-center justify-center rounded hover:bg-danger/10"+ >+ <X size={13} strokeWidth={2.5} />+ </button>+ </div>+ ));+}