refactor(runtime): converge desktop session lifecycle#1638
Merged
limityan merged 1 commit intoJul 20, 2026
Conversation
limityan
force-pushed
the
yanzhn/desktop-session-application
branch
from
July 19, 2026 18:56
a443a37 to
3edf1e6
Compare
limityan
marked this pull request as ready for review
July 20, 2026 00:05
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This refactor establishes a framework-neutral Desktop session application boundary and turns the existing Tauri commands into transport adapters for the selected session lifecycle. Stable lifecycle operations now flow through the Agent Runtime SDK, while rich Desktop-only persistence views remain behind one Core compatibility facade.
The change also adds narrowly typed, additive support for explicit archive state and exact-turn fork operations. Existing latest-turn fork behavior, request shapes, provider compatibility, and Core ownership remain intact.
Why
Desktop session commands had accumulated direct access to persistence, coordinator, scheduler, ACP, relay synchronization, remote workspace lookup, and Tauri state. That coupling made behavior equivalence hard to review and made the session lifecycle difficult to reuse safely from GUI, CLI/TUI, headless, remote, and SDK surfaces.
This PR converges the current production behavior behind a Desktop-owned application service without claiming a universal product profile or moving concrete lifecycle ownership out of Core. It reduces framework coupling while retaining the existing compatibility paths that still carry Desktop-specific views and persistence semantics.
Product and compatibility behavior
Scope boundaries
Included in this PR are the existing Desktop session history and lifecycle flows: listing, paging, archived views, restore variants, metadata reads and UI-owned updates, usage reporting, rename, ensure-loaded, exact-turn fork, explicit archive state, and single-session deletion.
The PR intentionally does not absorb session creation, compaction, Thread Goal behavior, raw turn writes, transcript export, bulk archive/delete, extension execution, product customization, or a complete Desktop delivery profile. It also does not add a service locator, generic command bus, or parallel session owner.
Architecture and stability
Independent review
A separate senior architecture and product-design review was performed over the complete diff. The review initially blocked on four issues: latest-turn fork path misuse, deleted-workspace history compatibility, an application-to-host adapter dependency inversion, and restore trace timing. All four were fixed, covered by focused regressions, and independently re-reviewed. Final result: APPROVE with no remaining architecture, product-semantics, or compatibility blockers.
Verification
cargo check --workspacecargo test -p bitfun-core product_runtime::tests:: --lib -- --nocapture(15 passed)cargo test -p bitfun-desktop runtime::session_application::tests:: --lib -- --nocapture(9 passed)cargo test -p bitfun-desktop runtime::tests:: --lib -- --nocapture(2 passed)cargo test -p bitfun-runtime-ports(all unit, integration, and doc tests passed)cargo test -p bitfun-agent-runtime --test session_operation_ports(2 passed)node scripts/check-core-boundaries.mjsgit diff --check