Skip to content

Commit 89a6f90

Browse files
authored
Merge branch 'main' into issue-watch/23760
2 parents 2d4ec84 + fe507c5 commit 89a6f90

26 files changed

Lines changed: 545 additions & 330 deletions

‎apps/mobile/src/features/threads/ThreadDetailScreen.tsx‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import type { ComposerTextPaste } from "../../native/T3ComposerEditor.types";
2626
import { type EnvironmentConnectionPhase } from "@t3tools/client-runtime/connection";
2727
import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell";
2828
import type { HandoffEndpoints } from "@t3tools/client-runtime/handoff";
29+
import { queuedRunEditBlockedReason } from "@t3tools/client-runtime/queued-run-edit";
2930
import {
3031
childThreadInputsTitle,
3132
type CodexFeedbackSubmission,
@@ -777,6 +778,9 @@ function ThreadDetailBody(props: ThreadDetailScreenProps) {
777778
const activeUserInputRequestId = props.activePendingUserInput?.requestId ?? null;
778779
const composerSlotHidden =
779780
activeUserInputRequestId !== null || props.creationState?.kind === "failed";
781+
const pendingMessageEditBlocked =
782+
queuedRunEditBlockedReason({ openQuestionCount: activeUserInputRequestId === null ? 0 : 1 }) !==
783+
null;
780784
const [usageLimitsPanel, setUsageLimitsPanel] = useState<{
781785
readonly key: string;
782786
readonly threadKey: string;
@@ -1167,6 +1171,7 @@ function ThreadDetailBody(props: ThreadDetailScreenProps) {
11671171
};
11681172

11691173
const handleEditPendingMessage = async (message: QueuedThreadMessage) => {
1174+
if (pendingMessageEditBlocked) return;
11701175
const scope = threadScope.current.signal;
11711176
const edited = await settlePromise(() => editPendingThreadMessage(message));
11721177
if (AsyncResult.isFailure(edited)) {
@@ -1296,7 +1301,9 @@ function ThreadDetailBody(props: ThreadDetailScreenProps) {
12961301
dispatchingMessageId={props.dispatchingMessageId}
12971302
// A native subagent has no composer to edit a pending message in;
12981303
// Cancel on the edit banner would discard it.
1299-
onEditPendingMessage={isProviderSubagent ? null : handleEditPendingMessage}
1304+
onEditPendingMessage={
1305+
isProviderSubagent || pendingMessageEditBlocked ? null : handleEditPendingMessage
1306+
}
13001307
contentPresentation={props.contentPresentation}
13011308
agentLabel={agentLabel}
13021309
threadTitle={props.selectedThread.title}

‎apps/mobile/src/features/threads/ThreadQueueControl.tsx‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { type StaticScreenProps, useNavigation } from "@react-navigation/native";
22
import { useAtomValue } from "@effect/atom-react";
3-
import { makeQueuedRunsAtom } from "@t3tools/client-runtime/queued-run-edit";
3+
import {
4+
makeQueuedRunsAtom,
5+
queuedRunEditBlockedReason,
6+
} from "@t3tools/client-runtime/queued-run-edit";
47
import type { ChatAttachment, EnvironmentId, RunId, ThreadId } from "@t3tools/contracts";
58
import { Atom } from "effect/reactivity";
69
import { Image } from "expo-image";
@@ -75,6 +78,10 @@ export function ThreadQueueSheet({ route }: StaticScreenProps<QueueTarget>) {
7578
const workflow = useThreadQueueWorkflow(target);
7679
const threadKey = scopedThreadKey(target.environmentId, target.threadId);
7780
const editing = useQueuedRunEdit(threadKey);
81+
const pendingRequests = useAtomValue(environmentThreadDetails.pendingRequestsAtom(target));
82+
const editBlockedReason = queuedRunEditBlockedReason({
83+
openQuestionCount: pendingRequests?.userInputs.length ?? 0,
84+
});
7885
const reorder = useAtomCommand(threadEnvironment.reorderQueuedRun, "reorder queued message");
7986
const promote = useAtomCommand(threadEnvironment.promoteQueuedRun, "promote queued message");
8087
const cancel = useAtomCommand(threadEnvironment.cancelQueuedRun, "remove queued message");
@@ -127,6 +134,7 @@ export function ThreadQueueSheet({ route }: StaticScreenProps<QueueTarget>) {
127134
return;
128135
}
129136
if (action === "edit") {
137+
if (editBlockedReason !== null) return;
130138
const entry = queuedRuns[index]!;
131139
void Haptics.selectionAsync();
132140
beginQueuedRunEdit(
@@ -212,6 +220,9 @@ export function ThreadQueueSheet({ route }: StaticScreenProps<QueueTarget>) {
212220
/>
213221
</View>
214222
) : null}
223+
{editBlockedReason !== null && queuedRuns.length > 0 ? (
224+
<Text className="py-3 text-sm text-foreground-muted">{editBlockedReason}</Text>
225+
) : null}
215226
{queuedRuns.length === 0 ? (
216227
<Text className="pt-6 text-center text-sm text-foreground-muted">
217228
No messages waiting in this queue.
@@ -231,6 +242,7 @@ export function ThreadQueueSheet({ route }: StaticScreenProps<QueueTarget>) {
231242
canPromoteToSteer: workflow?.canPromoteToSteer ?? false,
232243
canSendNow: workflow?.canSendNow ?? false,
233244
canReorder: workflow?.canReorder ?? false,
245+
editBlocked: editBlockedReason !== null,
234246
index,
235247
isEditing: editing?.runId === run.id,
236248
isGuestMessage: context?.guest !== undefined,
@@ -372,7 +384,7 @@ export function ThreadQueueSheet({ route }: StaticScreenProps<QueueTarget>) {
372384
accessibilityHint={
373385
controls.canEdit
374386
? "Opens this message in the composer for editing"
375-
: undefined
387+
: (editBlockedReason ?? undefined)
376388
}
377389
disabled={!controls.canEdit}
378390
onPress={() => void act(run.id, "edit")}

‎apps/mobile/src/features/threads/threadQueueControlPresentation.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ export function resolveThreadQueueRowControls(input: {
1919
readonly canPromoteToSteer: boolean;
2020
readonly canSendNow: boolean;
2121
readonly canReorder: boolean;
22+
/** Something else holds the composer, such as an open question. */
23+
readonly editBlocked?: boolean;
2224
readonly index: number;
2325
readonly isEditing?: boolean;
2426
/** A guest's message keeps the guest's words; the owner can cancel it, not rewrite it. */
@@ -33,7 +35,8 @@ export function resolveThreadQueueRowControls(input: {
3335
canDismiss: !input.busy,
3436
// Re-opening the row already in the composer would reload it and throw
3537
// away whatever has been typed since.
36-
canEdit: mutationEnabled && !isEditing && input.isGuestMessage !== true,
38+
canEdit:
39+
mutationEnabled && !isEditing && input.isGuestMessage !== true && input.editBlocked !== true,
3740
canMoveDown: mutationEnabled && input.canReorder && input.index < input.queuedCount - 1,
3841
canMoveUp: mutationEnabled && input.canReorder && input.index > 0,
3942
canSend: mutationEnabled && (input.canPromoteToSteer || input.canSendNow) && !isEditing,

‎apps/web/src/appInit.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import { startProviderAuthDelivery } from "./providerAuthDelivery";
4242
import { getRouter, type AppRouter } from "./router";
4343
import { appAtomRegistry } from "./rpc/atomRegistry";
4444
import { primaryServerConfigAtom } from "./state/server";
45+
import { installChatRouteCommands } from "./shortcuts/chatRouteCommands";
4546
import { resolveThreadRouteTarget } from "./threadRoutes";
4647

4748
/** Writes appearance settings onto the document, touching only the groups that changed. */
@@ -168,6 +169,7 @@ export function startAppServices(): AppRouter {
168169
if (isElectron) startElectronBrowserHost();
169170
startPreviewTitleRecording();
170171
startBrowserProfileReporting();
172+
installChatRouteCommands(router);
171173
startThreadOverlayRetention(router);
172174
startMainAppLocationTracking(router);
173175
startBackgroundThreadAnnouncements(appAtomRegistry, router);

‎apps/web/src/components/ChatMarkdown.browser.test.tsx‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { EnvironmentId, ThreadId } from "@t3tools/contracts";
22
import { AsyncResult } from "effect/reactivity";
33
import { type ReactElement } from "react";
44
import { describe, expect, it, vi } from "vite-plus/test";
5+
import { page, userEvent } from "vite-plus/test/browser";
56

67
import { act, render } from "../../test/render";
78
import "../index.css";
@@ -260,6 +261,37 @@ describe("ChatMarkdown workspace file opens", () => {
260261
});
261262
});
262263

264+
describe("ChatMarkdown skill chips", () => {
265+
it("shows the skill's details and opens its instructions", async () => {
266+
setup();
267+
const threadRef = {
268+
environmentId: EnvironmentId.make("workspace"),
269+
threadId: ThreadId.make("thread"),
270+
};
271+
await using screen = await renderText("Run $review now", {
272+
threadRef,
273+
skills: [
274+
{
275+
name: "review",
276+
displayName: "Review",
277+
description: "Reviews the current branch.",
278+
path: "/skills/review/SKILL.md",
279+
enabled: true,
280+
},
281+
],
282+
});
283+
using openFile = vi
284+
.spyOn(useRightPanelStore.getState(), "openFile")
285+
.mockImplementation(() => {});
286+
287+
await userEvent.click(screen.getByRole("button", { name: "Skill Review. Show details" }));
288+
await expect.element(page.getByText("Reviews the current branch.")).toBeVisible();
289+
await userEvent.click(page.getByRole("button", { name: "View instructions" }));
290+
291+
expect(openFile).toHaveBeenCalledExactlyOnceWith(threadRef, "/skills/review/SKILL.md");
292+
});
293+
});
294+
263295
describe("ChatMarkdown headings", () => {
264296
it("never gives two headings the same id, even when a suffix matches another heading", async () => {
265297
setup();

‎apps/web/src/components/ChatMarkdown.tsx‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ interface ChatMarkdownProps {
227227
environmentId?: EnvironmentId | undefined;
228228
onTaskListChange?: ((input: { markerOffset: number; checked: boolean }) => void) | undefined;
229229
isStreaming?: boolean;
230-
skills?: ReadonlyArray<Pick<ServerProviderSkill, "name" | "displayName">>;
230+
skills?: ReadonlyArray<ServerProviderSkill>;
231231
className?: string;
232232
lineBreaks?: boolean;
233233
parseRawHtml?: boolean;
@@ -250,7 +250,7 @@ export interface ChatMarkdownContextReference {
250250
label: string;
251251
}
252252

253-
const EMPTY_MARKDOWN_SKILLS: ReadonlyArray<Pick<ServerProviderSkill, "name" | "displayName">> = [];
253+
const EMPTY_MARKDOWN_SKILLS: ReadonlyArray<ServerProviderSkill> = [];
254254
const EMPTY_REMARK_PLUGINS: NonNullable<ReactMarkdownOptions["remarkPlugins"]> = [];
255255

256256
const ARTIFACT_TEMPLATE_ICON_BY_KIND = {
@@ -958,8 +958,8 @@ const CHAT_MARKDOWN_COMPONENTS = {
958958
return <div {...props}>{children}</div>;
959959
},
960960
p: function MarkdownParagraph({ node: _node, children, ...props }) {
961-
const { skills } = use(ChatMarkdownRendererContext);
962-
return <p {...props}>{renderSkillInlineMarkdownChildren(children, skills)}</p>;
961+
const { skills, threadRef } = use(ChatMarkdownRendererContext);
962+
return <p {...props}>{renderSkillInlineMarkdownChildren(children, skills, threadRef)}</p>;
963963
},
964964
blockquote: function MarkdownBlockquote({ node: _node, children, ...props }) {
965965
const alert =
@@ -994,12 +994,12 @@ const CHAT_MARKDOWN_COMPONENTS = {
994994
);
995995
},
996996
li: function MarkdownListItem({ node, children, ...props }) {
997-
const { skills } = use(ChatMarkdownRendererContext);
997+
const { skills, threadRef } = use(ChatMarkdownRendererContext);
998998
// Resolve checkbox markers by offset to avoid rerendering list items on every streamed token.
999999
const isTaskItem = String(props.className ?? "").includes("task-list-item");
10001000
return (
10011001
<li {...props} data-list-item-offset={isTaskItem ? node?.position?.start.offset : undefined}>
1002-
{renderSkillInlineMarkdownChildren(children, skills)}
1002+
{renderSkillInlineMarkdownChildren(children, skills, threadRef)}
10031003
</li>
10041004
);
10051005
},

‎apps/web/src/components/ChatView.tsx‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { sourceControlClients } from "@t3tools/client-runtime/source-control-clients";
2+
import { queuedRunEditBlockedReason } from "@t3tools/client-runtime/queued-run-edit";
23
import { ScrollToEndButton, WorkspaceFileDropOverlay } from "./chat/TimelineOverlays";
34
import { usePasteToFocusComposer } from "./chat/usePasteToFocusComposer";
45
import { announcedRun, isDetailBehindShell } from "./chat/threadActivityAnnouncement";
@@ -2924,6 +2925,9 @@ export default function ChatView(props: ChatViewProps) {
29242925
threadId={activeThread.id}
29252926
optimisticMessages={optimisticUserMessages}
29262927
editingRunId={queuedRunEdit.editingRunId}
2928+
editBlockedReason={queuedRunEditBlockedReason({
2929+
openQuestionCount: pendingUserInputs.length,
2930+
})}
29272931
onEditQueuedRun={queuedRunEdit.beginEdit}
29282932
onCancelEdit={queuedRunEdit.cancelEdit}
29292933
/>

‎apps/web/src/components/ComposerPromptEditorTiptap.tsx‎

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,9 @@ import { cn, isMacPlatform } from "~/lib/utils";
108108
import { basenameOfPath } from "~/pierre-icons";
109109
import { WorkspaceEntryTooltip } from "./chat/WorkspaceEntryIcon";
110110
import { FileTagChipContent } from "./chat/FileTagChip";
111-
import { SkillChipIcon } from "./chat/SkillInlineText";
111+
import { SkillChipPopover, skillPopoverDescription } from "./chat/SkillInlineText";
112112
import { AssistantCitationChip } from "./chat/AssistantCitationChip";
113113
import { getTimelinePageScrollKey } from "./chat/pageScrollController";
114-
import { ContextChipPopover } from "./contextChipParts";
115-
import { Button } from "./ui/button";
116114
import { ContextChip } from "./ContextChip";
117115
import {
118116
ComposerContextActionsContext,
@@ -348,31 +346,19 @@ function ComposerSkillNodeView({ node }: NodeViewProps) {
348346
const skill = skills.find(
349347
(candidate) => candidate.name === skillName && isProviderSkillUserInvocable(candidate),
350348
);
351-
const description = skill
352-
? skill.description?.trim() || skill.shortDescription?.trim()
353-
: skillDescription;
354349
// The node outlives a provider switch, so its stored label can be another provider's.
355350
const skillLabel = skill
356351
? formatProviderSkillDisplayName(skill)
357352
: (node.attrs.skillLabel as string) || skillName;
358353
return (
359354
<NodeViewWrapper as="span" className={CHIP_NODE_SELECTION_CLASS_NAME}>
360-
<ContextChipPopover
361-
kind="skill"
362-
icon={<SkillChipIcon />}
355+
<SkillChipPopover
363356
label={skillLabel}
364-
accessibleLabel={`Skill ${skillLabel}`}
365-
>
366-
<div className="space-y-3 p-2 text-sm">
367-
<p className="font-medium">{skillLabel}</p>
368-
<p>{description || "No description is available for this skill."}</p>
369-
{skill?.path && actions.environmentId ? (
370-
<Button variant="outline" size="sm" onClick={() => actions.openMention(skill.path)}>
371-
View instructions
372-
</Button>
373-
) : null}
374-
</div>
375-
</ContextChipPopover>
357+
description={skill ? skillPopoverDescription(skill) : skillDescription}
358+
onViewInstructions={
359+
skill?.path && actions.environmentId ? () => actions.openMention(skill.path) : undefined
360+
}
361+
/>
376362
</NodeViewWrapper>
377363
);
378364
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ function TimelineListFooter({
157157
);
158158
}
159159

160-
const EMPTY_TIMELINE_SKILLS: ReadonlyArray<Pick<ServerProviderSkill, "name" | "displayName">> = [];
160+
const EMPTY_TIMELINE_SKILLS: ReadonlyArray<ServerProviderSkill> = [];
161161
const TIMELINE_MAINTAIN_SCROLL_AT_END = {
162162
animated: false,
163163
on: {
@@ -253,7 +253,7 @@ interface MessagesTimelineProps {
253253
resolvedTheme: "light" | "dark";
254254
timestampFormat: TimestampFormat;
255255
workspaceRoot: string | undefined;
256-
skills?: ReadonlyArray<Pick<ServerProviderSkill, "name" | "displayName">>;
256+
skills?: ReadonlyArray<ServerProviderSkill>;
257257
runs: ReadonlyArray<HandoffTimelineRun>;
258258
anchorMessageId: MessageId | null;
259259
onAnchorReady: (messageId: MessageId, anchorIndex: number) => void;

‎apps/web/src/components/chat/QueuedRunsControl.browser.test.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ const baseProps = {
4343
optimisticMessages: [],
4444
threadId: "thread:test" as never,
4545
editingRunId: null,
46+
editBlockedReason: null,
4647
onEditQueuedRun: () => undefined,
4748
onCancelEdit: () => undefined,
4849
} satisfies ComponentProps<typeof QueuedRunsControl>;

0 commit comments

Comments
 (0)