Skip to content

Commit cf82adf

Browse files
fix(mobile): cancelling a share's project picker keeps the share draft
The first-picker cancel now closes only ordinary drafts; a share draft keeps main's behaviour so the shared content is not dropped. Adds a test that choosing a project in the picker keeps the draft. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 3ab1e9c commit cf82adf

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

‎apps/mobile/src/features/threads/new-task-project-selection.test.ts‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,25 @@ describe("resolveDraftProjectSelection", () => {
121121
}),
122122
).toEqual({ kind: "dismiss" });
123123
});
124+
125+
it("keeps the draft when the picker closes after a choice", () => {
126+
expect(
127+
resolveDraftProjectSelection("environment:t3code-2", projects, [makeScope(projects)], {
128+
...draft,
129+
pickerClosed: true,
130+
}),
131+
).toEqual({ kind: "preserve" });
132+
});
133+
134+
it("keeps a share draft asking for a project when its picker closes without a choice", () => {
135+
const scopes = [makeScope([projects[0]!]), makeScope([projects[1]!])];
136+
expect(
137+
resolveDraftProjectSelection(null, projects, scopes, {
138+
incomingShareId: "share",
139+
pickerClosed: true,
140+
}),
141+
).toEqual({ kind: "pick" });
142+
});
124143
});
125144

126145
describe("newTaskDestination", () => {

‎apps/mobile/src/features/threads/new-task-project-selection.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ export function resolveDraftProjectSelection(
9797
if (hasExplicitProjectSelection) {
9898
return { kind: "preserve" };
9999
}
100-
if (draft.pickerClosed && selectedProjectKey === null) {
100+
// A share draft holds content the user sent here, so cancelling the picker must not drop it.
101+
if (draft.pickerClosed && selectedProjectKey === null && draft.incomingShareId === undefined) {
101102
return { kind: "dismiss" };
102103
}
103104

0 commit comments

Comments
 (0)