Skip to content

Commit 389160e

Browse files
committed
chore: merge main into escaped math delimiter fix
2 parents 62ea7fe + 6fc9144 commit 389160e

284 files changed

Lines changed: 13175 additions & 1750 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/desktop/src/ipc/channels.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const SNAP_SHOT_EVENT_CHANNEL = "desktop:snap-shot-event";
1414
export const WEB_LINK_OPEN_CHANNEL = "desktop:web-link-open";
1515
export const WEB_LINK_READY_CHANNEL = "desktop:web-link-ready";
1616
export const QUIT_SHORTCUT_CHANNEL = "desktop:quit-shortcut";
17+
export const TRACKPAD_SCROLL_BEGIN_CHANNEL = "desktop:trackpad-scroll-begin";
1718
export const TRACKPAD_SCROLL_END_CHANNEL = "desktop:trackpad-scroll-end";
1819
export const GET_WINDOW_FULLSCREEN_STATE_CHANNEL = "desktop:get-window-fullscreen-state";
1920
export const WINDOW_FULLSCREEN_STATE_CHANNEL = "desktop:window-fullscreen-state";

‎apps/desktop/src/preload.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ contextBridge.exposeInMainWorld("desktopBridge", {
9191
ipcRenderer.on(IpcChannels.SET_NOTIFICATION_BADGE_CHANNEL, handler);
9292
return () => ipcRenderer.removeListener(IpcChannels.SET_NOTIFICATION_BADGE_CHANNEL, handler);
9393
},
94+
onTrackpadScrollBegin: (listener) => {
95+
const handler = () => listener();
96+
ipcRenderer.on(IpcChannels.TRACKPAD_SCROLL_BEGIN_CHANNEL, handler);
97+
return () => ipcRenderer.removeListener(IpcChannels.TRACKPAD_SCROLL_BEGIN_CHANNEL, handler);
98+
},
9499
onTrackpadScrollEnd: (listener) => {
95100
const handler = () => listener();
96101
ipcRenderer.on(IpcChannels.TRACKPAD_SCROLL_END_CHANNEL, handler);

‎apps/desktop/src/window/DesktopWindow.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
MENU_ACTION_CHANNEL,
2424
QUIT_SHORTCUT_CHANNEL,
2525
SNAP_SHOT_EVENT_CHANNEL,
26+
TRACKPAD_SCROLL_BEGIN_CHANNEL,
2627
TRACKPAD_SCROLL_END_CHANNEL,
2728
WINDOW_FULLSCREEN_STATE_CHANNEL,
2829
} from "../ipc/channels.ts";
@@ -652,7 +653,11 @@ export const make = Effect.gen(function* () {
652653
}
653654
});
654655
window.webContents.on("input-event", (_event, input) => {
655-
if (input.type === "gestureScrollEnd") window.webContents.send(TRACKPAD_SCROLL_END_CHANNEL);
656+
if (input.type === "gestureScrollBegin") {
657+
window.webContents.send(TRACKPAD_SCROLL_BEGIN_CHANNEL);
658+
} else if (input.type === "gestureScrollEnd") {
659+
window.webContents.send(TRACKPAD_SCROLL_END_CHANNEL);
660+
}
656661
});
657662
// Ctrl+wheel bypasses menus; guest contents emit their own zoom-changed event.
658663
window.webContents.on("zoom-changed", (_event, direction) => {

‎apps/mobile/src/components/MediaVideoPlayer.tsx‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ interface MediaVideoPlayerProps {
140140
readonly paused?: boolean;
141141
readonly onPlaybackStart?: () => void;
142142
readonly actionsSource?: MediaActionsSource;
143+
readonly borderRadius?: number;
143144
}
144145

145146
function MediaVideoPlayerContent(props: MediaVideoPlayerProps) {
@@ -152,7 +153,10 @@ function MediaVideoPlayerContent(props: MediaVideoPlayerProps) {
152153
<View
153154
collapsable={false}
154155
className="overflow-hidden rounded-[10px] bg-black"
155-
style={props.expanded ? { flex: 1 } : { width: "100%", maxWidth: 480, aspectRatio: 16 / 9 }}
156+
style={[
157+
props.expanded ? { flex: 1 } : { width: "100%", maxWidth: 480, aspectRatio: 16 / 9 },
158+
props.borderRadius === undefined ? null : { borderRadius: props.borderRadius },
159+
]}
156160
>
157161
{playbackUri ? (
158162
<LoadedMediaVideo

‎apps/mobile/src/features/pull-requests/PullRequestsScreen.tsx‎

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { useAtomValue } from "@effect/atom-react";
1111
import {
1212
Keyboard,
1313
Platform,
14+
Pressable,
1415
RefreshControl,
1516
ScrollView,
1617
View,
@@ -20,6 +21,7 @@ import { NativeScrollViewMarker as ScrollViewMarker } from "../../native/NativeS
2021
import { useSafeAreaInsets } from "react-native-safe-area-context";
2122

2223
import { AppText as Text } from "../../components/ui/AppText";
24+
import { SymbolView } from "../../components/ui/AppSymbol";
2325
import { EmptyState } from "../../components/ui/EmptyState";
2426
import { NativePrimaryColumnContext } from "../../native/v5-workspace-context";
2527
import { useNativeColumnLayoutMetrics } from "../../native/native-layout-metrics";
@@ -32,7 +34,6 @@ import {
3234
usePullRequestListFilters,
3335
type PullRequestFilterMenu,
3436
} from "./PullRequestListFilters";
35-
import { PullRequestCardRow } from "./PullRequestControls";
3637
import { usePullRequestList } from "./usePullRequestList";
3738
import { usePullRequestListControls } from "./usePullRequestListControls";
3839
import { usePullRequestListActions } from "./usePullRequestListActions";
@@ -58,26 +59,38 @@ function PullRequestScrollView(props: ScrollViewProps) {
5859
);
5960
}
6061

61-
function PullRequestListErrors(props: { readonly messages: readonly string[] }) {
62+
function PullRequestListError(props: { readonly message: string }) {
6263
const [expanded, setExpanded] = useState(false);
63-
const title = `${props.messages.length} ${props.messages.length === 1 ? "error" : "errors"} loading pull requests`;
6464
return (
65-
<View>
66-
<PullRequestCardRow
67-
title={title}
68-
icon="exclamationmark.triangle"
69-
compact
70-
last
71-
expanded={expanded}
72-
accessibilityLabel={`${title}. ${expanded ? "Hide" : "Show"} details`}
73-
onPress={() => setExpanded((value) => !value)}
65+
<Pressable
66+
accessibilityRole="button"
67+
accessibilityLabel={props.message}
68+
accessibilityState={{ expanded }}
69+
onPress={() => setExpanded((value) => !value)}
70+
// A long press selects the text; collapsing under that selection crashes Android's
71+
// smart-select animation, so it must not also count as a press.
72+
onLongPress={() => undefined}
73+
className="min-h-11 flex-row items-center gap-3 px-4 py-2.5 active:opacity-70"
74+
>
75+
<SymbolView
76+
name="exclamationmark.triangle"
77+
size={18}
78+
tintColorClassName="accent-icon-muted"
7479
/>
75-
{expanded ? (
76-
<Text selectable className="px-4 pb-3 text-sm text-foreground-muted">
77-
{props.messages.join("\n")}
78-
</Text>
79-
) : null}
80-
</View>
80+
<Text
81+
selectable={expanded}
82+
numberOfLines={expanded ? undefined : 1}
83+
ellipsizeMode="tail"
84+
className="min-w-0 flex-1 text-sm text-foreground-muted"
85+
>
86+
{props.message}
87+
</Text>
88+
<SymbolView
89+
name={expanded ? "chevron.up" : "chevron.down"}
90+
size={11}
91+
tintColorClassName="accent-icon-muted"
92+
/>
93+
</Pressable>
8194
);
8295
}
8396

@@ -334,13 +347,14 @@ export function PullRequestsScreen(
334347
<>
335348
<PullRequestListFilters sidebar={sidebar} filters={filters} />
336349
{result.data?.errors.length ? (
337-
<PullRequestListErrors
338-
key={JSON.stringify(targets)}
339-
messages={result.data.errors.map(
340-
(error) =>
341-
`${error.projectTitle || environments.find((environment) => environment.environmentId === error.environmentId)?.environmentLabel || "Environment"}: ${error.message}`,
342-
)}
343-
/>
350+
<View key={JSON.stringify(targets)}>
351+
{result.data.errors.map((error) => (
352+
<PullRequestListError
353+
key={`${error.environmentId} ${error.projectTitle} ${error.message}`}
354+
message={`${error.projectTitle || environments.find((environment) => environment.environmentId === error.environmentId)?.environmentLabel || "Environment"}: ${error.message}`}
355+
/>
356+
))}
357+
</View>
344358
) : null}
345359
</>
346360
}

‎apps/mobile/src/features/review/reviewModel.ts‎

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -534,17 +534,22 @@ export function buildReviewSectionItems(input: {
534534
},
535535
);
536536

537-
const gitItems = input.gitSections.map<ReviewSectionItem>((section) => ({
538-
id: `git:${section.kind}`,
539-
kind: section.kind,
540-
title: section.title,
541-
subtitle: gitSubtitle(section),
542-
diff: section.diff,
543-
source: section,
544-
...(section.files ? { files: section.files } : {}),
545-
truncated: section.truncated,
546-
isLoading: false,
547-
}));
537+
const gitItems = input.gitSections
538+
.filter(
539+
(section): section is typeof section & { kind: ReviewSectionKind } =>
540+
section.kind !== "commit",
541+
)
542+
.map<ReviewSectionItem>((section) => ({
543+
id: `git:${section.kind}`,
544+
kind: section.kind,
545+
title: section.title,
546+
subtitle: gitSubtitle(section),
547+
diff: section.diff,
548+
source: section,
549+
...(section.files ? { files: section.files } : {}),
550+
truncated: section.truncated,
551+
isLoading: false,
552+
}));
548553
const hasChangesItem = gitItems.some((item) => item.id === CHANGES_SECTION_ID);
549554
const visibleGitItems =
550555
input.loadingGitSections && !hasChangesItem

‎apps/mobile/src/features/settings/SettingsEnvironmentDetailRouteScreen.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,10 @@ function EnvironmentDetail({ environmentId }: { readonly environmentId: Environm
294294
void run("refresh", async () => {
295295
if (!readEnvironmentScope(environmentId, AuthOrchestrationReadScope))
296296
return;
297-
const result = await refreshProviders({ environmentId, input: {} });
297+
const result = await refreshProviders({
298+
environmentId,
299+
input: { reloadSecrets: true },
300+
});
298301
if (AsyncResult.isFailure(result)) throw squashAtomCommandFailure(result);
299302
setNotice("Provider status refreshed.");
300303
});

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

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import type {
4646
ScopedThreadRef,
4747
ServerConfig as T3ServerConfig,
4848
UsageLimitsReport,
49+
RunId,
4950
} from "@t3tools/contracts";
5051
import {
5152
appendCodexArtifactTemplateUsePrompt,
@@ -156,8 +157,10 @@ import {
156157
import { appAtomRegistry } from "../../state/atom-registry";
157158
import { threadStreamHaptics } from "./threadStreamHaptics";
158159
import { useAtomCommand } from "../../state/use-atom-command";
160+
import { orchestrationEnvironment } from "../../state/orchestration";
159161
import { useDelayedStatus } from "../../lib/useDelayedStatus";
160162
import type { PendingUserInputDraftAnswer } from "@t3tools/client-runtime/state/pending-user-input";
163+
import type { RunStopPresentation } from "@t3tools/client-runtime/state/thread-execution";
161164
import type {
162165
PendingApproval,
163166
PendingUserInput,
@@ -339,6 +342,9 @@ const threadVisitTracker = createThreadVisitTracker({
339342

340343
// Past the composer's 180 ms height animation.
341344
const COMPOSER_HEIGHT_SETTLE_MS = 220;
345+
const NO_RUN_STOP_ATOM = Atom.make<RunStopPresentation | null>(null).pipe(
346+
Atom.withLabel("mobile-thread-run-stop:empty"),
347+
);
342348

343349
// Anchors, the submitted message, follow state and pending scrolls belong to
344350
// one thread, so the body remounts when the thread changes.
@@ -528,6 +534,50 @@ function ThreadDetailBody(props: ThreadDetailScreenProps) {
528534
const unsettleThread = useAtomCommand(threadEnvironment.unsettle, { reportFailure: false });
529535
const updateMetadata = useAtomCommand(threadEnvironment.updateMetadata, { reportFailure: false });
530536
const visitThread = useAtomCommand(threadEnvironment.visit, { reportFailure: false });
537+
const anyRunStop = useAtomValue(
538+
props.selectedThreadDetailRef === null
539+
? NO_RUN_STOP_ATOM
540+
: environmentThreadDetails.runStopAtom(props.selectedThreadDetailRef),
541+
);
542+
// A background Stop matters only while that work is still pending.
543+
const runStop =
544+
anyRunStop?.background && props.selectedThread.pendingBackgroundTasks.length === 0
545+
? null
546+
: anyRunStop;
547+
const forceStopThread = useAtomCommand(orchestrationEnvironment.forceStopThread, {
548+
reportFailure: false,
549+
});
550+
const canForceStop =
551+
useAtomValue(orchestrationEnvironment.forceStopThread.permissionAtom(props.environmentId)) &&
552+
props.serverConfig?.environment.capabilities.threadForceStop === true;
553+
const [forceStoppingKey, setForceStoppingKey] = useState<string | null>(null);
554+
// The run that ignored Stop, so a confirmation left open cannot hit a newer run.
555+
const forceStop = async (runId: RunId | undefined) => {
556+
const threadKey = selectedThreadKey;
557+
setForceStoppingKey(threadKey);
558+
const result = await forceStopThread({
559+
environmentId: props.environmentId,
560+
input:
561+
runId === undefined
562+
? { threadId: props.selectedThread.id }
563+
: { threadId: props.selectedThread.id, runId },
564+
});
565+
setForceStoppingKey((current) => (current === threadKey ? null : current));
566+
if (result._tag === "Failure") {
567+
if (!isAtomCommandInterrupted(result)) Dialog.alert("Could not force stop the agent");
568+
return;
569+
}
570+
const others = result.value.sharedWithThreadIds.length;
571+
if (result.value.outcome === "releasing") {
572+
Dialog.alert("Turn stopped; the agent is still shutting down");
573+
}
574+
if (result.value.outcome === "shared") {
575+
Dialog.alert(
576+
"Turn stopped; the agent process kept running",
577+
`It is shared with ${others === 0 ? "other" : others} working ${others === 1 ? "thread" : "threads"}. Stop those to free it.`,
578+
);
579+
}
580+
};
531581
const [statusRequest, setStatusRequest] = useState<{ threadKey: string } | null>(null);
532582
const statusPending = statusRequest?.threadKey === selectedThreadKey;
533583
const [lifecycleNow, setLifecycleNow] = useState(() => new Date().toISOString());
@@ -619,6 +669,32 @@ function ThreadDetailBody(props: ThreadDetailScreenProps) {
619669
if (connectionStatus !== null && !props.draftMode) {
620670
return connectionStatus;
621671
}
672+
// Before the request check: an agent stuck on an approval may also ignore Stop.
673+
if (runStop !== null && contentPresentationKind === "ready") {
674+
const unresponsive = runStop.state === "unresponsive";
675+
return {
676+
kind: "stop",
677+
unresponsive,
678+
label: unresponsive ? "Not responding to Stop" : "Stopping…",
679+
action:
680+
unresponsive && canForceStop
681+
? {
682+
label: forceStoppingKey === selectedThreadKey ? "Force stopping..." : "Force stop",
683+
accessibilityLabel: "Force stop the agent",
684+
disabled: forceStoppingKey === selectedThreadKey,
685+
onPress: () =>
686+
Dialog.confirm({
687+
title: "Force stop the agent?",
688+
message:
689+
"It has not answered Stop. Force stop ends the turn and kills the agent's processes, unless other working threads share them.",
690+
confirmText: "Force stop",
691+
destructive: true,
692+
onConfirm: () => void forceStop(runStop.runId),
693+
}),
694+
}
695+
: null,
696+
};
697+
}
622698
if (props.activePendingApproval !== null || props.activePendingUserInput !== null) {
623699
return null;
624700
}

0 commit comments

Comments
 (0)