Skip to content

feat(mobile): send the phone's chats to the computer and continue any chat - #279

Open
geoolekom wants to merge 2 commits into
soft-chat-deletefrom
continue-phone-chats
Open

geoolekom wants to merge 2 commits into
soft-chat-deletefrom
continue-phone-chats

Conversation

@geoolekom

Copy link
Copy Markdown
Contributor

Stacked on #277 (soft-chat-delete); the base moves to main when the ones below it merge.

What changed

The phone now writes to the computer, and a chat of the computer can be continued on the phone.

  • Sending. Each sync first sends what the person did on the phone, then copies from the computer as before. Deletes go first (sync-delete-chat, computer format 3 or later), then the turns of every chat that has some the computer does not hold (sync-push-chat, format 2 or later). Nothing is sent to an older computer. A push is one line of at most 15 KiB and 200 turns; a longer run goes in several pushes, each with the seen of the one before, and a turn too long for a line is split into turns of the same role a millisecond apart, as the command describes.
  • A sync that is cut. What was sent is written down after each answer, one push at a time. A push whose answer was lost is sent again with the same seen, and the computer, which knows the turns it holds, stores nothing for it. A turn is not sent twice and not lost.
  • What the computer answers. unknown seen for a chat started on the phone sends the chat again from its start, once in a sync. A refusal (invalid chat, time too far ahead, invalid sync request) leaves that chat and goes on with the others. Any other failure (chats unavailable, cannot save, …) stops the sending until the next sync. erasing cuts the sync, as it does for a copy being read.
  • A fork. When the computer holds lines after what the phone saw, it puts the phone's turns in a new chat. The phone moves its pending turns there; the new chat has the origin continued (new in the model). The chat of the computer keeps its lines, and both chats stay on the phone. A push the computer answers with deleted stores nothing, and the phone marks the chat deleted.
  • Continuing a chat of the computer. The copied lines of the chat become the history the chat core answers from: the user and assistant lines as turn records (tool lines are left out), with the phone's own model and key and no tools. A chat started on the phone answers from the records the core wrote, as before.
  • Deleted chats. The copy keeps the deleted flag and the time, and hides deleted chats. A chat the person deletes on the phone is sent to the computer as a delete; one the computer deleted is hidden on the phone and takes no more turns. "Delete everything" still empties the phone as before, and a chat started on the phone is removed only by it or by the person.
  • The copy (migration 6). conversation gets deleted_at, delete_pending and sent (how many lines the computer holds), and message gets a time. A copy made before keeps all it has: the lines of every chat the computer listed count as sent, a chat started on the phone has none sent, and old lines have no time. MigrationTest checks it.
  • The note on the key. The settings state carries it as keyNote: "Chats on the phone use your own API key. They are billed to it, apart from any subscription you have."
  • The test program. agent/examples/phone_pairing.rs now serves pushes and deletes with the agent's own rules, so the phone tests run against them. fork_id in agent/src/chat/from_phone.rs is made pub, so the program forks the way the agent does; nothing else changes in the agent.

Not in this change

The screens still show a chat of the computer as read-only: ChatThread.readOnly and ChatHolder are left alone. Removing that state, showing a forked chat as continued on the phone, showing the key note before the first chat and in the model setup, the build number and the simulator and emulator screenshots come in the next change.

What ran

  • ./gradlew check in mobile/ (ktlint, detekt, the shared and Android host tests, and the shared chat tests on the iOS Simulator): clean.
  • iosApp/check.sh: clean.
  • Against a fake computer: SyncPushTest, SyncEngineTest, PhoneChatSendTest, CopySyncTest, MigrationTest and the shared chat tests, which cover a phone chat, a turn in a chat of the computer and a delete reaching the computer once, a chat of the computer answering from its copied history, a fork leaving both chats, a cut sync, and "Delete everything".
  • Against the real agent, with RealAgentSyncTest and the built phone_pairing example (CONSTRUCT_PHONE_PAIRING_EXAMPLE; skipped without it): 15 of 16 pass, including the same cases as above. The sixteenth, theFirstCopyGivesTheFactsTheChatsAndTheNumbersTheAgentServes, gets no widgets from the agent's default dashboard. This change touches neither that test nor the dashboard code.
  • cargo fmt --all --check and cargo clippy --locked --all-targets -p construct-agent -- -D warnings: clean. cargo test --locked --no-fail-fast -p construct-agent: all pass except two timing tests (a_request_for_a_month_answers_within_a_second, which took 1.03 s against a limit of 1 s, and a_call_that_hangs_ends_as_an_unreachable_api_does) that failed once on a busy machine and passed in two reruns on their own. The --ignored tests were not run. pre-commit run --all-files: passes.

geoolekom and others added 2 commits December 3, 2026 23:42
Signed-off-by: Yehor Komarov <10210242+geoolekom@users.noreply.github.com>
… chat

Signed-off-by: Yehor Komarov <ekomarov@constructor.tech>
@coderabbitai

coderabbitai Bot commented Dec 3, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 94d29589-a194-4a7d-9f42-00debde39d69

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant