mirror of
https://github.com/multica-ai/multica.git
synced 2026-06-17 11:48:42 +02:00
Chat input had `submitOnEnter` enabled while the comment editor used `Mod+Enter`. Two consequences: - Inconsistent muscle memory between the two inputs. - In chat, bare Enter sending stole the only key that continues a TipTap bullet/ordered list. Shift+Enter falls through to HardBreak (a <br> inside the same list item), so bullet lists were stuck at one item. Drop `submitOnEnter` from the chat input so it follows the editor default. Mod+Enter (⌘↵ / Ctrl+Enter) sends in both places; bare Enter now continues lists and inserts paragraphs as users expect. Surface the shortcut on the SubmitButton via a new optional `tooltip` prop, and route the comment input through SubmitButton instead of an ad-hoc Button — same affordance, deduped. Add unit coverage for the submit-shortcut extension that pins Mod-Enter, the submitOnEnter=false case, IME, and code-block guards. Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com> Co-authored-by: multica-agent <github@multica.ai>
68 lines
1.7 KiB
TypeScript
68 lines
1.7 KiB
TypeScript
"use client";
|
|
|
|
import type { ReactNode } from "react";
|
|
import { ArrowUp, Loader2, Square } from "lucide-react";
|
|
import { Button } from "@multica/ui/components/ui/button";
|
|
import {
|
|
Tooltip,
|
|
TooltipContent,
|
|
TooltipTrigger,
|
|
} from "@multica/ui/components/ui/tooltip";
|
|
|
|
interface SubmitButtonProps {
|
|
onClick: () => void;
|
|
disabled?: boolean;
|
|
loading?: boolean;
|
|
running?: boolean;
|
|
onStop?: () => void;
|
|
/**
|
|
* Tooltip shown over the send button when idle. Pass a string or a node
|
|
* (e.g. `Send · ⌘↵`). Omit to render no tooltip.
|
|
* Callers compose the shortcut hint themselves to keep this component
|
|
* free of `@multica/core` (platform-detection) and i18n imports.
|
|
*/
|
|
tooltip?: ReactNode;
|
|
/** Tooltip shown over the stop button while a run is in progress. */
|
|
stopTooltip?: ReactNode;
|
|
}
|
|
|
|
function SubmitButton({
|
|
onClick,
|
|
disabled,
|
|
loading,
|
|
running,
|
|
onStop,
|
|
tooltip,
|
|
stopTooltip,
|
|
}: SubmitButtonProps) {
|
|
if (running) {
|
|
const stopButton = (
|
|
<Button size="icon-sm" onClick={onStop}>
|
|
<Square className="fill-current" />
|
|
</Button>
|
|
);
|
|
if (!stopTooltip) return stopButton;
|
|
return (
|
|
<Tooltip>
|
|
<TooltipTrigger render={stopButton} />
|
|
<TooltipContent side="top">{stopTooltip}</TooltipContent>
|
|
</Tooltip>
|
|
);
|
|
}
|
|
|
|
const submitButton = (
|
|
<Button size="icon-sm" disabled={disabled || loading} onClick={onClick}>
|
|
{loading ? <Loader2 className="animate-spin" /> : <ArrowUp />}
|
|
</Button>
|
|
);
|
|
if (!tooltip) return submitButton;
|
|
return (
|
|
<Tooltip>
|
|
<TooltipTrigger render={submitButton} />
|
|
<TooltipContent side="top">{tooltip}</TooltipContent>
|
|
</Tooltip>
|
|
);
|
|
}
|
|
|
|
export { SubmitButton, type SubmitButtonProps };
|