Skip to main content

restore_window

Function restore_window 

Source
pub fn restore_window(
    messages: &[SharedMessage],
    state: &SharedContinuation,
    binding: &MemoryBinding,
)
Expand description

Resume restores only window metadata from a verified source reference. It never enables mode or reconstructs capability/consent from model text.

The reference is the archive the head’s marker names, and it is looked up in the file store of binding: the project of the folder the chat runs in now, which under the daemon is not the project of the process folder. That is the store the chat’s rollover sealed the archive into (MemoryBinding::history_seal_window) only if the chat is resumed in the project it rolled over in. A chat continued from a folder of another project (--continue takes the folder of the client that resumes it) is looked up in that project, where the archive is not.

  • Found: the window number and the archive link are restored.
  • Not there (no project, no archive store, no such archive): the chat goes on at window 1 without an archive link, and a warning says which archive was looked for, in which project’s store, and which of the three it was.
  • The lookup failed for another reason (a busy store, something that could not be read): nothing is settled. A warning says why, the chat goes on at window 1, and the next call looks again. That is once at each turn start, until a lookup answers or the chat rolls over: a committed rollover settles the state by itself (PreparedRollover::commit), with the window it made, numbered from where the chat then was.

The lookup reads a file and can wait for a busy store, so the state lock is not held across it. A head that lists several parts (_synaps_context.archives) has its other parts checked afterwards ([warn_unavailable_parts]), which nothing waits for.