Skip to content

fix(mobile): keep the chosen project when saving a new draft - #30096

Open
voltcrash wants to merge 2 commits into
pingdotgg:mainfrom
voltcrash:fix/mobile-draft-project
Open

voltcrash wants to merge 2 commits into
pingdotgg:mainfrom
voltcrash:fix/mobile-draft-project

Conversation

@voltcrash

Copy link
Copy Markdown
Contributor

New mobile drafts can display the chosen project but be saved under No project. After Back and reopening, the text survives but the project selection is lost. Selecting the project again works.

Fixes #30095.

The child screen's mount effect creates the chosen project's draft before the parent's creation effect runs. Check the live flow binding in that parent effect so its stale render cannot replace the draft with one stamped to the fallback project. A focused regression exercises mount-time selection, saving, and reopening with the same project and prompt.

This qualifies as a small, focused obvious-bug fix under CONTRIBUTING.md: it preserves the selection already shown in the composer, without changing picker defaults or navigation. Only mobile draft initialization and its existing provider test file change; web, desktop, provider adapters, and wire contracts are unaffected.

Proof: observed the regression fail on unmodified source (displayed two/b, saved one/a), then pass with the fix; provider + flow-state tests pass 13/13. vp run check:changed passes format, lint, both knip stages, affected typechecks, adjacent tests, and React Compiler checks.

Native verification limitation: test-t3-mobile was attempted, but Agent device access is disabled in this environment. No native before/after screenshots or recording are available, and no device-level verification is claimed. The linked issue describes the reporter's recording and the source-level reproduction.

Reviewed with review-loop: 1 round with GPT-6.1 Sol on xhigh. Reviewer verdict: approved.

Created with GPT-6.1 Sol in Codex through T3 Code.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Nov 3, 2026
@macroscopeapp

macroscopeapp Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at e587c13

Macroscope's review found this PR approvable — The mobile draft flow now checks its current draft binding before creating another draft, preserving the user's chosen project. The change is narrowly scoped and retains the existing activation and route guards.

You can add or adjust custom eligibility rules. Learn more.

@juliusmarminge juliusmarminge added the bugfix Fix PR opened by an issue lead; enters the PR loop label Nov 3, 2026
@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The provider now checks the current flow state before creating a draft. A regression test selects a project on mount, saves the draft, and verifies that reopening it restores the project and prompt.

Changes: Mobile draft project binding

Layer / File(s) Summary
Guard draft creation and verify project restoration
apps/mobile/src/features/threads/new-task-flow-provider.tsx, apps/mobile/src/features/threads/new-task-flow-provider.test.tsx
The provider checks the live flow state before creating a draft. The test harness can select a project on mount and open a draft by route ID. The new test verifies that the saved draft retains the project and prompt after reopening.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Possibly related PRs

  • pingdotgg/t3code#30845: Fixes the mobile draft race with a mount-time project-selection test and a guard that checks the live flow binding.
  • pingdotgg/t3code#25812: Introduced per-route flow state, flowKey, and route-draft binding used by this change.
  • pingdotgg/t3code#24827: Introduced the keyed mobile new-task flow and provider draft-creation logic changed here.

Suggested reviewers: saphid

Merge Risk: Minimal · up to 11496

The draft-binding change is mergeable after normal checks; no actionable risk remains from the reviewed behavior.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title clearly and concisely describes the main fix: preserving the chosen project when saving a new mobile draft.
Description check Passed The description covers the problem, fix, scope rationale, linked issue, focused regression test, verification results, and native verification limitation. It satisfies the required template.
Linked Issues check Passed Issue #30095 requires the selected project and prompt to persist after saving and reopening a mobile draft. NewTaskFlowProvider now reads the live flow state before creating the fallback draft, so t…
Out of Scope Changes check Passed The changes are limited to mobile draft initialization and its existing provider test. The test changes support the linked regression. The implementation does not change picker defaults, navigation, p…
Full details: Linked Issues check

Explanation

Issue #30095 requires the selected project and prompt to persist after saving and reopening a mobile draft. NewTaskFlowProvider now reads the live flow state before creating the fallback draft, so the child mount selection cannot be overwritten by stale parent state. The added regression test selects a project on mount, saves the prompt, reopens the draft by ID, and verifies both values.

Full details: Out of Scope Changes check

Explanation

The changes are limited to mobile draft initialization and its existing provider test. The test changes support the linked regression. The implementation does not change picker defaults, navigation, provider adapters, wire contracts, web code, or desktop code.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 40d52e4 and 1149632.

Files selected for processing: 2

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

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

@saphid

saphid commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Note

🤖 GPT-6.1 Sol responding on behalf of saphid

Independent validation confirms the draft-binding race fixed by this PR. On main at 4cb6945, applying only this PR's regression test fails: the displayed project is two/b, but the saved draft is stamped one/a. Applying the unchanged source fix makes the provider and flow-state suites pass 13/13.

On the exact PR head e587c13, I also ran both focused suites (13/13 pass) and CI=true vp run check:changed cefb544af3c98224874419198c0359b652ca3c94 (pass). Current CI has no failed or pending checks; neither changed file has changed on the inspected main revision.

Native proof remains incomplete. GPT-6 Astra tested an iPhone 17 Pro simulator on iOS 27.2 against disposable local projects, with only the provider source reverted to the PR base. New chat → choose a nonfallback project → type → Back → Unsent → reopen retained both project and prompt; the failure did not reproduce in that sequence. An AgentDevice alert-state probe then repeatedly returned ALERT_NOT_FOUND, so native testing stopped before the candidate run. This is neither a native before/after validation nor evidence that the app failed to load. Native verification of the failing mount-time path is still needed before calling this device-verified.

@voltcrash
voltcrash force-pushed the fix/mobile-draft-project branch from e587c13 to 2734960 Compare November 7, 2026 11:00
@saphid

saphid commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Note

🤖 GPT-6.1 Sol responding on behalf of saphid

The Build and Typecheck failure on 2734960 is also present on its base beaeeff. Both the PR job and base job fail with the same TS2345 at packages/effect-acp/src/protocol.ts:817: routeDecodedMessage expects AcpDecodedWireMessage, while the stream element type is the RPC protocol union.

This PR changes only mobile draft initialization and its existing test file. The shared ACP failure is outside that diff. CodeRabbit's latest update skipped the rebase review and reports no new actionable findings. Earlier native-verification limits remain unchanged.

Copy link
Copy Markdown
Member

Evidence

Native iOS proof: iPhone 18 Pro, iOS 27.2, 402×874, light theme; separate fresh server databases with identical synthetic projects.

Establish Chosen project as the remembered project, then tap New chat to mount a fresh composer directly in Chosen project. Enter Hello! without sending → Back → inspect the newest Unsent draft → reopen it. Do not reselect the project during this sequence.

Before After
b3fdf2b10f 1149632ea0
Before: reopened draft uses Fallback project while retaining Hello! After: reopened draft retains Chosen project and Hello!
Before recording After recording

Base initially displayed Chosen project but reopened under Fallback project. Head retained Chosen project. Both retained Hello!.

Seed script · Reproduction and automation notes

AI-assisted; verified with the tests and tools listed above.

Not shown:

  • Android was not exercised; the visual proof covers native iOS.
  • The literal first-use project-picker sequence was not completed as a clean comparison. The successful proof establishes the affected mount-time path through a fresh composer opening in its remembered project.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Fix PR opened by an issue lead; enters the PR loop pr:gate-failed A land gate failed size:XS 0-9 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mobile drafts lose the initially selected project

3 participants