Skip to main content

fix_cancelled_model_state

Function fix_cancelled_model_state 

Source
pub fn fix_cancelled_model_state(path: &Path) -> Result<bool>
Expand description

Fix cancelled modelState values in a compacted (single-line) JSONL session file.

VS Code determines lastResponseState from the file content, not the index. If the last request’s modelState.value is 2 (Cancelled) or missing entirely, VS Code refuses to load the session. This function:

  1. Finds the last request in the requests array
  2. If modelState.value is 2 (Cancelled), changes it to 1 (Complete)
  3. If modelState is missing entirely, adds {"value":1,"completedAt":<now>}

Returns true if the file was modified.