Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/features/composer/components/Composer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@ export function Composer({
const textareaRef = externalTextareaRef ?? internalRef;
const isDictationBusy = dictationState !== "idle";
const canSend = text.trim().length > 0 || attachedImages.length > 0;
const isMac =
typeof navigator !== "undefined" &&
((navigator as Navigator & { userAgentData?: { platform?: string } })
.userAgentData?.platform ?? navigator.platform ?? "")
.toLowerCase()
.includes("mac");
const sendShortcutLabel = isMac ? "⌘+Enter" : "Ctrl+Enter";

useEffect(() => {
setText((prev) => (prev === draftText ? prev : draftText));
Expand Down Expand Up @@ -244,6 +251,7 @@ export function Composer({
canStop={canStop}
canSend={canSend}
isProcessing={isProcessing}
sendShortcutLabel={sendShortcutLabel}
onStop={onStop}
onSend={handleSend}
dictationEnabled={dictationEnabled}
Expand All @@ -262,7 +270,9 @@ export function Composer({
onTextChange={handleTextChange}
onSelectionChange={handleSelectionChange}
onKeyDown={(event) => {
if (event.key === "Enter" && event.shiftKey) {
const isEnter = event.key === "Enter";
const isSendShortcut = isMac ? event.metaKey : event.ctrlKey;
if (isEnter && !isSendShortcut) {
event.preventDefault();
Comment on lines 272 to 276

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve Enter to accept autocomplete

When autocomplete is open, useComposerAutocompleteState.handleInputKeyDown uses Enter to apply the highlighted suggestion. The new early branch for isEnter && !isSendShortcut runs before handleInputKeyDown and returns after inserting a newline, so Enter never reaches the autocomplete handler; users can no longer accept suggestions with Enter (only Tab works). Consider skipping the newline path when isAutocompleteOpen (or deferring Enter handling until after handleInputKeyDown) so the existing suggestion behavior remains intact.

Useful? React with 👍 / 👎.

const textarea = textareaRef.current;
if (!textarea) {
Expand Down Expand Up @@ -295,7 +305,7 @@ export function Composer({
if (event.defaultPrevented) {
return;
}
if (event.key === "Enter" && !event.shiftKey) {
if (isEnter && isSendShortcut) {
if (isDictationBusy) {
event.preventDefault();
return;
Expand Down
59 changes: 33 additions & 26 deletions src/features/composer/components/ComposerInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type ComposerInputProps = {
canStop: boolean;
canSend: boolean;
isProcessing: boolean;
sendShortcutLabel: string;
onStop: () => void;
onSend: () => void;
dictationState?: "idle" | "listening" | "processing";
Expand Down Expand Up @@ -46,6 +47,7 @@ export function ComposerInput({
canStop,
canSend,
isProcessing,
sendShortcutLabel,
onStop,
onSend,
dictationState = "idle",
Expand Down Expand Up @@ -317,33 +319,38 @@ export function ComposerInput({
>
{isDictating ? <Square aria-hidden /> : <Mic aria-hidden />}
</button>
<button
className={`composer-action${canStop ? " is-stop" : " is-send"}${
canStop && isProcessing ? " is-loading" : ""
}`}
onClick={handleActionClick}
disabled={disabled || isDictationBusy || (!canStop && !canSend)}
aria-label={canStop ? "Stop" : sendLabel}
<span
className="composer-action-wrap"
data-tooltip={canStop ? "Stop" : `Send (${sendShortcutLabel})`}
>
{canStop ? (
<>
<span className="composer-action-stop-square" aria-hidden />
{isProcessing && (
<span className="composer-action-spinner" aria-hidden />
)}
</>
) : (
<svg viewBox="0 0 24 24" fill="none" aria-hidden>
<path
d="M12 5l6 6m-6-6L6 11m6-6v14"
stroke="currentColor"
strokeWidth="1.7"
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
)}
</button>
<button
className={`composer-action${canStop ? " is-stop" : " is-send"}${
canStop && isProcessing ? " is-loading" : ""
}`}
onClick={handleActionClick}
disabled={disabled || isDictationBusy || (!canStop && !canSend)}
aria-label={canStop ? "Stop" : sendLabel}
>
{canStop ? (
<>
<span className="composer-action-stop-square" aria-hidden />
{isProcessing && (
<span className="composer-action-spinner" aria-hidden />
)}
</>
) : (
<svg viewBox="0 0 24 24" fill="none" aria-hidden>
<path
d="M12 5l6 6m-6-6L6 11m6-6v14"
stroke="currentColor"
strokeWidth="1.7"
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
)}
</button>
</span>
</div>
);
}
29 changes: 29 additions & 0 deletions src/styles/composer.css
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,35 @@
position: relative;
}

.composer-action-wrap {
display: inline-flex;
position: relative;
}

.composer-action-wrap::after {
content: attr(data-tooltip);
position: absolute;
left: 50%;
bottom: calc(100% + 6px);
transform: translateX(-50%) translateY(4px);
padding: 4px 8px;
border-radius: 999px;
font-size: 10px;
color: var(--text-emphasis);
background: var(--surface-command);
border: 1px solid var(--border-subtle);
white-space: nowrap;
opacity: 0;
pointer-events: none;
transition: opacity 120ms ease, transform 120ms ease;
z-index: 2;
}

.composer-action-wrap:hover::after {
opacity: 1;
transform: translateX(-50%) translateY(0);
}

.composer-action--mic.is-active {
border-color: rgba(120, 235, 190, 0.6);
background: rgba(120, 235, 190, 0.12);
Expand Down