Skip to content

Commit bbf95ca

Browse files
Merge remote-tracking branch 'origin/main' into fix/issue-27348
2 parents 170af6f + a773dc3 commit bbf95ca

10 files changed

Lines changed: 133 additions & 3 deletions

File tree

‎apps/server/src/mcp/toolkits/core.test.ts‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,48 @@ it.effect("records only failed calls of tools that hand off no work", () => {
350350
);
351351
});
352352

353+
it.effect("rejects an unknown organize target instead of archiving the calling thread", () => {
354+
const dispatched: Array<unknown> = [];
355+
return Effect.gen(function* () {
356+
const server = yield* McpServer.McpServer;
357+
const outcome = yield* server
358+
.callTool({
359+
name: "t3_thread_organize",
360+
arguments: { action: "archive", threadIds: ["other-thread"] },
361+
})
362+
.pipe(
363+
Effect.provideService(McpInvocationContext.McpInvocationContext, scope),
364+
Effect.provideService(McpSchema.McpServerClient, client),
365+
Effect.result,
366+
);
367+
expect(dispatched).toEqual([]);
368+
expect(outcome).toMatchObject({
369+
_tag: "Failure",
370+
failure: { message: expect.stringContaining("Expected no excess property") },
371+
});
372+
}).pipe(
373+
Effect.provide(
374+
layerThreadToolkit.pipe(
375+
Layer.provideMerge(McpServer.McpServer.layer),
376+
Layer.provide(NodeCrypto.layer),
377+
Layer.provide(
378+
Layer.mock(ThreadManagement.ThreadManagementService)({
379+
getThreadShell: (id) => Effect.succeed(McpToolAccessTestkit.liveThreadShell(id)),
380+
getProjectThreadRecords: ({ threadId: id }) =>
381+
Effect.succeed(
382+
McpToolAccessTestkit.idleThreadProjection(McpToolAccessTestkit.liveThreadShell(id)),
383+
),
384+
dispatch: (command) => {
385+
dispatched.push(command);
386+
return Effect.succeed({ sequence: 1 } as never);
387+
},
388+
}),
389+
),
390+
),
391+
),
392+
);
393+
});
394+
353395
it.effect("keeps unexpected handler defects private through the production registration", () =>
354396
Effect.gen(function* () {
355397
const server = yield* McpServer.McpServer;

‎apps/server/src/mcp/toolkits/thread/tools.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ const ThreadOrganizeTool = Tool.make("t3_thread_organize", {
6161
],
6262
})
6363
.annotate(Tool.Title, "Organize a thread")
64+
.annotate(Tool.Strict, true)
6465
.annotate(Tool.Destructive, true);
6566

6667
const commandTool = {

‎apps/web/src/components/chat/ChatComposer.tsx‎

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ import {
133133
import { attachmentUploadBlockReason } from "../../lib/attachmentUploadState";
134134
import type { AssistantCitationSourceAnchor } from "~/lib/assistantTextSelection";
135135
import { shortcutLabelForCommand } from "../../keybindings";
136+
import { persistClientSettingsUpdate } from "../../hooks/useSettings";
136137
import {
137138
type TerminalContextDraft,
138139
type TerminalContextSelection,
@@ -198,6 +199,7 @@ import {
198199
ComposerRestingImagePreviews,
199200
} from "./ComposerAttachmentStrip";
200201
import { ComposerPrimaryActions } from "./ComposerPrimaryActions";
202+
import { ComposerRichTextToggle } from "./ComposerRichTextToggle";
201203
import { ComposerFooterPrimaryActions } from "./ComposerFooterControls";
202204
import { ComposerPendingUserInputPanel } from "./ComposerPendingUserInputPanel";
203205
import { ComposerPlanFollowUpBanner } from "./ComposerPlanFollowUpBanner";
@@ -304,6 +306,7 @@ export interface ChatComposerHandle {
304306
openModelPicker: () => void;
305307
stepReasoningEffort: (direction: 1 | -1) => void;
306308
toggleModelPicker: () => void;
309+
toggleRichText: () => void;
307310
openControl: (command: KeybindingCommand) => void;
308311
isModelPickerOpen: () => boolean;
309312
isCaretAtStart: () => boolean;
@@ -2852,6 +2855,13 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
28522855
openModelPickerStable();
28532856
}
28542857
},
2858+
toggleRichText: () => {
2859+
if (isLiteralPendingAnswer) return;
2860+
persistClientSettingsUpdate((current) => ({
2861+
...current,
2862+
composerRichTextEnabled: !current.composerRichTextEnabled,
2863+
})).catch(console.error);
2864+
},
28552865
openControl: (command) => {
28562866
if (composerBlurFrameRef.current !== null) {
28572867
window.cancelAnimationFrame(composerBlurFrameRef.current);
@@ -3429,7 +3439,23 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
34293439
showMobilePendingAnswerActions && "hidden sm:flex",
34303440
)}
34313441
>
3432-
{composerAttachButton ? <div className="me-2">{composerAttachButton}</div> : null}
3442+
{composerAttachButton || !isLiteralPendingAnswer ? (
3443+
<div className="me-2 flex items-center gap-0.5">
3444+
{composerAttachButton}
3445+
{isLiteralPendingAnswer ? null : (
3446+
<ComposerRichTextToggle
3447+
richTextEnabled={settings.composerRichTextEnabled}
3448+
shortcutLabel={shortcutLabelForCommand(
3449+
keybindings,
3450+
"composer.toggleRichText",
3451+
{
3452+
context: { terminalFocus: false, terminalOpen, modelPickerOpen: false },
3453+
},
3454+
)}
3455+
/>
3456+
)}
3457+
</div>
3458+
) : null}
34333459
<div
34343460
data-chat-composer-actions="right"
34353461
data-chat-composer-transition-actions="true"
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { FeatherIcon } from "lucide-react";
2+
3+
import { updateClientSettings } from "../../hooks/useSettings";
4+
import { Button } from "../ui/button";
5+
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
6+
7+
// Same setting as Settings → Chat → Rich text composer. Flipping it remounts the
8+
// editor; pointer-down is swallowed so a focused editor keeps its caret across that.
9+
export function ComposerRichTextToggle({
10+
richTextEnabled,
11+
shortcutLabel,
12+
}: {
13+
readonly richTextEnabled: boolean;
14+
readonly shortcutLabel: string | null;
15+
}) {
16+
const showingSource = !richTextEnabled;
17+
return (
18+
<Tooltip>
19+
<TooltipTrigger
20+
render={
21+
<Button
22+
type="button"
23+
variant="ghost"
24+
size="icon-sm"
25+
aria-label="Markdown source"
26+
aria-pressed={showingSource}
27+
data-pressed={showingSource ? "" : undefined}
28+
onPointerDown={(event) => event.preventDefault()}
29+
onClick={() => void updateClientSettings({ composerRichTextEnabled: showingSource })}
30+
/>
31+
}
32+
>
33+
<FeatherIcon />
34+
</TooltipTrigger>
35+
<TooltipPopup>
36+
{showingSource ? "Show formatting" : "Show Markdown source"}
37+
{shortcutLabel ? ` · ${shortcutLabel}` : null}
38+
</TooltipPopup>
39+
</Tooltip>
40+
);
41+
}

‎apps/web/src/components/chat/composerShortcuts.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ export function composerShortcutCommands(
1818
"modelPicker.toggle": ({ event }) => {
1919
if (!event.repeat) composerRef.current?.toggleModelPicker();
2020
},
21+
"composer.toggleRichText": ({ event }) => {
22+
// The flip remounts the editor, which would drop an unsaved citation comment.
23+
if (event.target instanceof Element && event.target.closest("[data-citation-comment-editor]"))
24+
return false;
25+
if (!event.repeat) composerRef.current?.toggleRichText();
26+
},
2127
"composer.increaseEffort": ({ event }) => {
2228
if (!event.repeat) composerRef.current?.stepReasoningEffort(1);
2329
},

‎apps/web/src/keybindings.test.ts‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,12 +768,21 @@ describe("composer and pull request shortcuts", () => {
768768
});
769769

770770
it.each(["MacIntel", "Win32", "Linux"])(
771-
"reserves the alternate send chord for the focused composer on %s",
771+
"resolves composer toggle and alternate send chords in their contexts on %s",
772772
(platform) => {
773773
const modifier = {
774774
metaKey: platform === "MacIntel",
775775
ctrlKey: platform !== "MacIntel",
776776
};
777+
for (const terminalFocus of [false, true]) {
778+
assert.strictEqual(
779+
resolveShortcutCommand(event({ key: "/", ...modifier }), DEFAULT_RESOLVED_KEYBINDINGS, {
780+
platform,
781+
context: { terminalFocus },
782+
}),
783+
terminalFocus ? null : "composer.toggleRichText",
784+
);
785+
}
777786
const shiftedEnter = event({ key: "Enter", shiftKey: true, ...modifier });
778787
for (const composerRequiresModifier of [false, true]) {
779788
const context = {

‎docs/user/composer.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ The composer writes Markdown and shows it styled as you type. Markers such as
1919
them. Lines starting with `- `, `1. `, `- [ ] `, `> `, `# ` or `---` become lists,
2020
task lists, quotes, headings and rules; ` ``` ` followed by Enter opens a code
2121
block. What you typed is what the agent receives, markers and numbering
22-
included, and `#1234` without a space still looks up a pull request.
22+
included, and `#1234` without a space still looks up a pull request. To see the
23+
plain Markdown instead, press the button beside attach; it is the same
24+
switch as **Settings → Chat → Rich text composer**.
2325

2426
Enter sends. In a list or quote, **Shift+Enter** continues it, and Shift+Enter
2527
on an empty line moves out one level, then leaves it; **Tab** nests a list item

‎docs/user/keybindings.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Use `mod+shift+e` for effort, `mod+shift+a` for permissions, `mod+shift+x` for t
2828
workspace, and `mod+shift+g` for the Git branch. The workspace menu includes the
2929
current checkout, a new worktree, and the previous worktree when available.
3030
Use `mod+shift+l` to reuse the previous worktree directly.
31+
Use `mod+/` to switch the composer between rich text and its Markdown source.
3132

3233
To change effort one step without opening the picker, bind
3334
**Composer: Increase Effort** and **Composer: Decrease Effort** in Keybindings.

‎packages/contracts/src/keybindings.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export const STATIC_KEYBINDING_COMMANDS = [
8787
"appearance.cycle",
8888
"themeEditor.toggle",
8989
"composer.stash",
90+
"composer.toggleRichText",
9091
"composer.sendAlternate",
9192
"composer.sendBackground",
9293
"composer.sendAndNewThread",

‎packages/shared/src/keybindings.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ export const DEFAULT_KEYBINDINGS: ReadonlyArray<KeybindingRule> = [
179179
{ key: "mod+alt+shift+a", command: "appearance.cycle", when: "!terminalFocus" },
180180
{ key: "mod+alt+shift+t", command: "themeEditor.toggle" },
181181
{ key: "mod+s", command: "composer.stash", when: "!terminalFocus" },
182+
{ key: "mod+/", command: "composer.toggleRichText", when: "!terminalFocus" },
182183
{ key: "mod+shift+enter", command: "thread.steerQueuedMessage", when: "!terminalFocus" },
183184
{ key: "alt+arrowup", command: "thread.editQueuedMessage", when: "composerFocus" },
184185
{ key: "mod+enter", command: "composer.sendAlternate", when: "composerFocus && turnRunning" },

0 commit comments

Comments
 (0)