@@ -216,6 +216,11 @@ function ToClaudePtTurnsFile() : string
216216 return "claude_pt_turns.txt";
217217}
218218
219+ function ToClaudePtSessionFile() : string
220+ {
221+ return "claude_pt_session.txt";
222+ }
223+
219224function ToClaudePtStateScope(string stateScope) : string
220225{
221226 string sessionKey = stateScope;
@@ -478,6 +483,7 @@ prototype ToStartScopedClaudeConversation : ClaudeCodeSkillAction
478483 return "Error: stateScope is required for scoped Claude state.";
479484
480485 ToClaudePtWriteState(ToClaudePtConvIdFile(), "none", stateScope);
486+ ToClaudePtWriteState(ToClaudePtSessionFile(), "none", stateScope);
481487 ToClaudePtWriteState(ToClaudePtTurnsFile(), "0", stateScope);
482488 if (!StringUtil.IsEmpty(model))
483489 ToClaudePtWriteState(ToClaudePtModelFile(), model, stateScope);
@@ -627,7 +633,10 @@ This is the main pass-through action. It automatically manages model selection,
627633
628634 // Build claude arguments
629635 string exe = ToClaudeDefaultExePath();
636+ string currentSessionId = ToClaudePtReadState(ToClaudePtSessionFile(), stateScope);
630637 string args = "-p " + ToClaudeQuoted(actualPrompt) + " --model " + model + " --output-format text --permission-mode bypassPermissions";
638+ if (!StringUtil.IsEmpty(currentSessionId) && currentSessionId != "none")
639+ args = args + " --resume " + ToClaudeQuoted(currentSessionId);
631640 if (!StringUtil.IsEmpty(system))
632641 args = args + " --append-system-prompt " + ToClaudeQuoted(system);
633642
@@ -651,6 +660,13 @@ This is the main pass-through action. It automatically manages model selection,
651660 return "Error: " + errorType + "`n`n" + result;
652661 }
653662
663+ // Extract session ID from the most recent Claude JSONL session file
664+ string sessionScript = "Write-Output (Get-ChildItem -Path (Join-Path $env:USERPROFILE '.claude/projects') -Recurse -Filter '*.jsonl' -ErrorAction SilentlyContinue | Sort-Object LastWriteTime -Descending | Select-Object -First 1 -ExpandProperty BaseName)";
665+ string sessionResult = SystemOperations.RunPowerShellStreamingToRuntimeUi(sessionScript, "", 10, _opsAgent, "", "Claude Session ID");
666+ string newSessionId = ToClaudeCleanOutput(sessionResult);
667+ if (!StringUtil.IsEmpty(newSessionId))
668+ ToClaudePtWriteState(ToClaudePtSessionFile(), newSessionId, stateScope);
669+
654670 // Store model
655671 ToClaudePtWriteState(ToClaudePtModelFile(), model, stateScope);
656672
0 commit comments