Skip to content

feat(remote-peer): compact a remote conversation's context - #960

Merged
huichen merged 1 commit into
mainfrom
feat/remote-conv-compact
Oct 10, 2026
Merged

huichen merged 1 commit into
mainfrom
feat/remote-conv-compact

Conversation

@huichen

@huichen huichen commented Oct 10, 2026

Copy link
Copy Markdown
Collaborator

What this does

The host has always been able to compact a conversation's context, and the desktop exposes it for its own chats. A desktop acting as a client could not ask a paired host to do it. This is the missing client half.

The answer is an acknowledgement, not a result

compact_context resolves when the host takes the request. Whether it then commits, fails, or finds nothing to do arrives only as the host's own events — so the state the UI shows is derived from those events, never from the fact that we asked:

  • compacting starts on compaction_started and ends on any terminal outcome, including compaction_unchanged ("nothing worth compacting" is still the end of the operation).
  • It also ends on a settled run: nothing can still be compacting once a run has finished, and a terminal frame lost over at-most-once NATS must not leave the composer waiting forever.
  • An ack without an operationId is rejected. The host uses that id to correlate the events that follow, so resolving on it would report success for a request that was never taken.

The action sits in the conversation header and is gated on the host's own state: a host answering a prompt does not also compact, and a host compacting refuses a prompt. A draft has no conversation on the host, so it is not offered one to compact.

Tests

15 new tests; 3427 desktop tests pass. tsc --noEmit, full eslint (0 errors), stylelint, and the shared shell-projection test all pass — the same scope CI runs. 0 uncovered lines added by this branch.

Where the assertions sit:

  • Every terminal outcome clears the state — compaction_failed, compaction_unchanged, and compaction_end are each asserted, not just the happy path, because a lifecycle that only recognises success is how a composer ends up permanently waiting.
  • A compaction is not a run: it sets compacting without setting streaming, so the composer does not offer Stop for something there is no run to stop. (This is the complement of the fix in feat(remote-peer): branch a remote conversation, and stop a compaction from looking like a run #959, which made sure a run's events do not clear a compaction's counterpart.)
  • The acknowledgement is validated, not trusted: six malformed acks are each asserted to reject.
  • The action is separate from the per-reply fork — two controls on different things, asserted not to fire each other.
  • A draft is never compacted, and no error is raised for it (it is a no-op, not a failure).

Not in this PR

Remote file browsing/download. It is a separate surface with its own list/download/save flow rather than another conversation action, and it is the last piece of the client role I know to be missing.

Related

Follows #955 (client role + merged lists), #956 (client runtime + multi-host e2e), #957 (a prompt names a conversation), #958 (manage/start a remote conversation), #959 (branch a remote conversation; a compaction is not a run).

The host has always been able to compact a conversation's context, and the
desktop exposes it for its own chats; a desktop acting as a client could not
ask a paired host to do it. This is the missing client half.

The answer to the command is an *acknowledgement*, not a result: the host
accepts the request and then commits, fails, or finds nothing to do, and
reports which only through its own events. So a resolving call means "the host
took it", and the state shown is derived from those events rather than from
the fact that we asked:

- `compacting` starts on `compaction_started` and ends on any terminal
  outcome, including `compaction_unchanged` ("nothing worth compacting" is
  still the end of the operation) -- and on a settled *run*, because nothing
  can still be compacting once a run has finished, and a terminal frame lost
  over at-most-once NATS must not leave the composer waiting forever.
- An ack without an `operationId` is rejected: the host uses that id to
  correlate the events that follow, so resolving on it would report success
  for a request that was never taken.

The action sits in the conversation header and is gated on the host's own
state: a host answering a prompt does not also compact, and a host compacting
refuses a prompt. A draft has no conversation on the host, so it is not
offered one to compact.
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