Skip to content

Commit c9ea4b0

Browse files
authored
Merge branch 'main' into pnpm-global-virtual-store
2 parents e212025 + 6fc9144 commit c9ea4b0

45 files changed

Lines changed: 1577 additions & 127 deletions

Some content is hidden

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

‎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/state/queued-run-edit.test.ts‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import { describe, expect, it, vi } from "vite-plus/test";
22
import { Atom } from "effect/reactivity";
3+
import {
4+
ATTACHMENT_ONLY_BOOTSTRAP_PROMPT,
5+
restoreAttachmentOnlyBootstrapPrompt,
6+
} from "@t3tools/shared/composerContextReferences";
37
import {
48
ChatAttachmentId,
59
ComposerContextId,
@@ -112,6 +116,30 @@ describe("resolveQueuedEditPayload", () => {
112116
});
113117

114118
describe("beginQueuedRunEdit", () => {
119+
it.each(["", "Ultrathink:\n"])(
120+
"opens attachment-only edits without the placeholder and treats them as untouched (%j)",
121+
(prefix) => {
122+
const threadKey = `env-exit:attachment-only-${prefix.length}`;
123+
const original = {
124+
...edit([image("kept")]),
125+
originalText: prefix + ATTACHMENT_ONLY_BOOTSTRAP_PROMPT,
126+
};
127+
const runs = Atom.make<ReadonlyArray<{ readonly id: RunId; readonly status: string }> | null>(
128+
[{ id: original.runId, status: "queued" }],
129+
);
130+
beginQueuedRunEdit(threadKey, original, runs);
131+
const draft = getComposerDraftSnapshot(queuedEditDraftKey(threadKey, original.runId));
132+
expect(draft.text).toBe(prefix.trimEnd());
133+
expect(
134+
restoreAttachmentOnlyBootstrapPrompt(draft.text, original.existingAttachments.length > 0),
135+
).toBe(original.originalText);
136+
expect(getQueuedRunEdit(threadKey)).toEqual({ ...original, originalText: prefix.trimEnd() });
137+
appAtomRegistry.set(runs, [{ id: original.runId, status: "running" }]);
138+
expect(getQueuedRunEdit(threadKey)).toBeNull();
139+
expect(appAtomRegistry.get(threadComposerErrorsAtom)[threadKey]?.message).toBeUndefined();
140+
},
141+
);
142+
115143
it("silently drops an untouched edit when its run starts", () => {
116144
const threadKey = "env-exit:thread-untouched";
117145
const runId = RunId.make("run-1");

‎apps/mobile/src/state/queued-run-edit.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type {
66
UploadChatAttachment,
77
} from "@t3tools/contracts";
88
import { useAtomValue } from "@effect/atom-react";
9+
import { stripAttachmentOnlyBootstrapPrompt } from "@t3tools/shared/composerContextReferences";
910
import {
1011
makeQueuedRunEditStore,
1112
resolveQueuedEditExit,
@@ -118,10 +119,15 @@ export function beginQueuedRunEdit(
118119
// The composer moves off the thread draft, so a paste or pick still running for it is dropped.
119120
abortComposerDraftOperations(threadKey);
120121
const draftKey = queuedEditDraftKey(threadKey, edit.runId);
122+
const originalText = stripAttachmentOnlyBootstrapPrompt(edit.originalText);
121123
clearComposerDraft(draftKey);
122-
setComposerDraftText(draftKey, edit.originalText);
124+
setComposerDraftText(draftKey, originalText);
123125
setComposerDraftContext(draftKey, edit.context);
124-
queuedRunEdits.begin(threadKey, edit, { runs, onRunLeftQueue: exitQueuedRunEdit });
126+
queuedRunEdits.begin(
127+
threadKey,
128+
{ ...edit, originalText },
129+
{ runs, onRunLeftQueue: exitQueuedRunEdit },
130+
);
125131
}
126132

127133
export function removeQueuedRunEditAttachment(threadKey: string, attachmentId: string): void {

‎apps/mobile/src/state/use-thread-composer-state.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {
3434
} from "@t3tools/client-runtime/state/threads";
3535
import { resolveThreadWorkingStartedAt } from "@t3tools/client-runtime/state/models";
3636
import { upgradeLegacyContextMessage } from "@t3tools/shared/composerContextLegacy";
37+
import { restoreAttachmentOnlyBootstrapPrompt } from "@t3tools/shared/composerContextReferences";
3738
import { composerContextSendBlockReason, reidentifyComposerContext } from "../lib/composerContext";
3839
import { uuidv4 } from "../lib/uuid";
3940

@@ -403,7 +404,11 @@ export function useThreadComposerState() {
403404
if (edit === null) return;
404405
const draft = getComposerDraftSnapshot(queuedEditDraftKey(threadKey, edit.runId));
405406
const text = draft.text.trim();
406-
if (text.length === 0) {
407+
if (
408+
text.length === 0 &&
409+
edit.existingAttachments.length === 0 &&
410+
draft.attachments.length === 0
411+
) {
407412
Dialog.alert("Add a message", "A queued message cannot be left empty.");
408413
return;
409414
}
@@ -457,7 +462,7 @@ export function useThreadComposerState() {
457462
input: {
458463
threadId: thread.id,
459464
runId: edit.runId,
460-
text,
465+
text: restoreAttachmentOnlyBootstrapPrompt(text, payload.attachments.length > 0),
461466
edit: {
462467
messageId: edit.messageId,
463468
attachments: payload.attachments,

0 commit comments

Comments
 (0)