fix(kugetsu): destroy --base and --pm-agent actually delete opencode sessions
Previously destroy only removed local session files but didn't delete the sessions from opencode's database. This caused init to reuse the same session with old context. Now destroy calls 'opencode session delete <id>' to properly remove the session from opencode.
This commit is contained in:
@@ -1548,6 +1548,7 @@ cmd_destroy() {
|
|||||||
|
|
||||||
if [ "$target" = "base" ]; then
|
if [ "$target" = "base" ]; then
|
||||||
if [ "$force" = true ]; then
|
if [ "$force" = true ]; then
|
||||||
|
local base_session_id=$(get_base_session_id)
|
||||||
rm -f "$SESSIONS_DIR/base.json"
|
rm -f "$SESSIONS_DIR/base.json"
|
||||||
local pm_agent=$(get_pm_agent_session_id)
|
local pm_agent=$(get_pm_agent_session_id)
|
||||||
if [ -n "$pm_agent" ] && [ "$pm_agent" != "null" ]; then
|
if [ -n "$pm_agent" ] && [ "$pm_agent" != "null" ]; then
|
||||||
@@ -1556,6 +1557,10 @@ cmd_destroy() {
|
|||||||
else
|
else
|
||||||
echo '{"base": null, "pm_agent": null, "issues": {}}' > "$INDEX_FILE"
|
echo '{"base": null, "pm_agent": null, "issues": {}}' > "$INDEX_FILE"
|
||||||
fi
|
fi
|
||||||
|
if [ -n "$base_session_id" ] && [ "$base_session_id" != "null" ]; then
|
||||||
|
echo "Deleting opencode session: $base_session_id"
|
||||||
|
opencode session delete "$base_session_id" 2>/dev/null || echo "Warning: Could not delete session from opencode (may already be deleted)"
|
||||||
|
fi
|
||||||
echo "Base session destroyed"
|
echo "Base session destroyed"
|
||||||
else
|
else
|
||||||
echo "Error: destroying base session requires --base -y" >&2
|
echo "Error: destroying base session requires --base -y" >&2
|
||||||
@@ -1566,6 +1571,7 @@ cmd_destroy() {
|
|||||||
|
|
||||||
if [ "$target" = "pm-agent" ]; then
|
if [ "$target" = "pm-agent" ]; then
|
||||||
if [ "$force" = true ]; then
|
if [ "$force" = true ]; then
|
||||||
|
local pm_session_id=$(get_pm_agent_session_id)
|
||||||
rm -f "$SESSIONS_DIR/pm-agent.json"
|
rm -f "$SESSIONS_DIR/pm-agent.json"
|
||||||
local base=$(get_base_session_id)
|
local base=$(get_base_session_id)
|
||||||
if [ -n "$base" ] && [ "$base" != "null" ]; then
|
if [ -n "$base" ] && [ "$base" != "null" ]; then
|
||||||
@@ -1573,6 +1579,10 @@ cmd_destroy() {
|
|||||||
else
|
else
|
||||||
write_index "null" "null" "{}"
|
write_index "null" "null" "{}"
|
||||||
fi
|
fi
|
||||||
|
if [ -n "$pm_session_id" ] && [ "$pm_session_id" != "null" ]; then
|
||||||
|
echo "Deleting opencode session: $pm_session_id"
|
||||||
|
opencode session delete "$pm_session_id" 2>/dev/null || echo "Warning: Could not delete session from opencode (may already be deleted)"
|
||||||
|
fi
|
||||||
echo "PM agent session destroyed"
|
echo "PM agent session destroyed"
|
||||||
else
|
else
|
||||||
echo "Error: destroying pm-agent session requires --pm-agent -y" >&2
|
echo "Error: destroying pm-agent session requires --pm-agent -y" >&2
|
||||||
|
|||||||
Reference in New Issue
Block a user