Skip to content

Commit 02612c2

Browse files
authored
fix(mobile): allow starting a task with only an image (pingdotgg#17409)
1 parent 71f6f1d commit 02612c2

4 files changed

Lines changed: 26 additions & 4 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,7 +1244,7 @@ export function NewTaskDraftScreen(props: {
12441244
if (
12451245
attachmentBlockReason !== null ||
12461246
!modelSelection ||
1247-
initialMessageText.length === 0 ||
1247+
(initialMessageText.length === 0 && draft.attachments.length === 0) ||
12481248
flow.submitting ||
12491249
(workspaceMode === "worktree" && !selectedBranchName)
12501250
) {
@@ -1397,7 +1397,7 @@ export function NewTaskDraftScreen(props: {
13971397
!modelUnavailable &&
13981398
Boolean(flow.selectedProject) &&
13991399
Boolean(flow.selectedModel) &&
1400-
flow.prompt.trim().length > 0 &&
1400+
(flow.prompt.trim().length > 0 || flow.attachments.length > 0) &&
14011401
isIncomingShareReady &&
14021402
!isImportingShare &&
14031403
!flow.submitting &&

‎apps/mobile/src/features/threads/new-task-flow-provider.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1105,7 +1105,8 @@ export function NewTaskFlowProvider(props: React.PropsWithChildren) {
11051105
selectedEnvironmentServerConfig,
11061106
draft.modelSelection ?? null,
11071107
) ?? selectedModel;
1108-
if (text.length === 0 || !draftModelSelection) {
1108+
// A shared image or file is a task on its own; text is optional.
1109+
if ((text.length === 0 && draft.attachments.length === 0) || !draftModelSelection) {
11091110
return null;
11101111
}
11111112
// A saved choice from before the project went no-project must not

‎apps/mobile/src/state/thread-outbox-model.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,8 @@ export function isQueuedThreadCreationSendable(message: QueuedThreadMessage): bo
247247
if (!message.creation) {
248248
return false;
249249
}
250-
if (message.text.trim().length === 0 || message.modelSelection === undefined) {
250+
const hasContent = message.text.trim().length > 0 || message.attachments.length > 0;
251+
if (!hasContent || message.modelSelection === undefined) {
251252
return false;
252253
}
253254
return message.creation.workspaceMode !== "worktree" || Boolean(message.creation.branch);

‎apps/mobile/src/state/thread-outbox.test.ts‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,6 +1430,26 @@ describe("thread outbox", () => {
14301430
false,
14311431
);
14321432
expect(isQueuedThreadCreationSendable(base)).toBe(false);
1433+
expect(isQueuedThreadCreationSendable({ ...creationMessage, text: " " })).toBe(false);
1434+
expect(
1435+
isQueuedThreadCreationSendable({
1436+
...creationMessage,
1437+
text: "",
1438+
attachments: [
1439+
{
1440+
id: "image-1",
1441+
type: "image",
1442+
name: "photo.png",
1443+
mimeType: "image/png",
1444+
sizeBytes: 3,
1445+
fileUri: "file:///documents/t3-composer-attachments/photo.png",
1446+
previewUri: "file:///documents/t3-composer-attachments/photo.png",
1447+
uploadedAttachmentId: "pending-photo-png",
1448+
uploadEnvironmentId: EnvironmentId.make("environment-1"),
1449+
},
1450+
],
1451+
}),
1452+
).toBe(true);
14331453
});
14341454

14351455
it("retries transport failures but drops deterministic command failures", () => {

0 commit comments

Comments
 (0)