Skip to content

feat(mobile): trigger manual context compaction from the slash menu - #719

Merged
huichen merged 2 commits into
mainfrom
feat/mobile-compact-context
Sep 18, 2026
Merged

huichen merged 2 commits into
mainfrom
feat/mobile-compact-context

Conversation

@huichen

@huichen huichen commented Sep 18, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Mobile can now start manual context compaction, the way the Desktop input box already could: the / menu offers a "Compact context" action above skills, reachable by /compact, /compress or /压缩. It lives in the menu rather than the toolbar (a low-frequency operation must not cost a composer row).
  • The Desktop remote host accepts a new compact_context command (advertised as compaction_v1), forwarding to the same session-scoped compact RPC the GUI uses and relaying its operation id — one shared compact_agent_session path, so both clients accept and validate the operation identically.
  • The phone waits for the terminal compaction_* event behind that operation id and reports only what the in-transcript divider cannot: a rejected request, a no-op compaction that leaves no marker, the Agent's failure reason, or a missing result. A lost terminal event is reported as a missing result, never as a failure.
  • Running the action clears its own /query token before dispatching, so the command is never left in the draft to be sent as a message (found while verifying in the real UI).

Verification

  • Desktop backend (Rust 1.97): cargo fmt --check, cargo clippy --all-targets, cargo test --lib (1283 passed) — plus a compact_context bridge test covering the acceptance, an Agent rejection (busy run) and a missing session. Two unrelated pre-existing flakes appeared once each in the full local run (instance::tests::excludes_second_owner_and_releases_on_drop, remote_host::files::flow_tests::prune_preview_cache_removes_expired_files); both pass in isolation and neither touches this diff.
  • Desktop frontend: npm run lint (eslint + tsc), vitest run (1164 passed).
  • Mobile: tsc --noEmit, eslint, jest --runInBand (1639 passed), including new tests for the waiter (matching id, buffered early event, timeout, malformed frames), the request, the action gating, the draft cleanup, and every outcome toast.
  • Real RN Web harness: new compact-context scenario opens the menu, asserts the action exists, clicks it, then asserts the draft is empty and the outcome is on screen (m-compact-menu.png, m-compact-outcome.png). Mock data and a mock Desktop host — not a native-device or live-Agent E2E.

Docs (compaction + remote connection, en/zh) updated for the phone entry point and the new capability.

@huichen
huichen enabled auto-merge (squash) September 18, 2026 03:36
@huichen
huichen merged commit c7c4eba into main Sep 18, 2026
12 checks passed
@huichen
huichen deleted the feat/mobile-compact-context branch September 18, 2026 03:56
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