@@ -2557,6 +2557,112 @@ assert_contains "Empty cli_args: tool identified" "$empty_log" "restoring openco
25572557
25582558kill_pane_children test-restore-empty true
25592559
2560+ # --- Test 10d2: Restore adds --model from sidecar model field ---
2561+ #
2562+ # When model is set in the sidecar JSON but NOT in cli_args (e.g., model
2563+ # was set via config/env, not --model flag), restore should add --model.
2564+
2565+ echo " "
2566+ echo " === Test 10d2: restore adds --model from sidecar field ==="
2567+ echo " "
2568+
2569+ tmux new-session -d -s test-restore-model -c /tmp 2> /dev/null || true
2570+ sleep 0.5
2571+
2572+ cat > " $HOME /.tmux/resurrect/assistant-sessions.json" << 'RMODEL '
2573+ {
2574+ "timestamp": "2026-01-01T00:00:00Z",
2575+ "sessions": [
2576+ {
2577+ "pane": "test-restore-model:0.0",
2578+ "tool": "claude",
2579+ "session_id": "ses_model_field",
2580+ "cwd": "/tmp",
2581+ "pid": "99999",
2582+ "model": "claude-opus-4-5-20250514",
2583+ "cli_args": "",
2584+ "env": {}
2585+ }
2586+ ]
2587+ }
2588+ RMODEL
2589+
2590+ > " $RESTORE_LOG "
2591+ just restore 2>&1
2592+ sleep 5
2593+
2594+ model_log=$( cat " $RESTORE_LOG " )
2595+ assert_contains " Model field: --model added to resume" " $model_log " " --model"
2596+ assert_contains " Model field: correct model value" " $model_log " " claude-opus-4-5-20250514"
2597+
2598+ # Verify --model is NOT duplicated when already in cli_args
2599+ tmux kill-session -t test-restore-model 2> /dev/null || true
2600+ tmux new-session -d -s test-restore-model -c /tmp 2> /dev/null || true
2601+ sleep 0.5
2602+
2603+ cat > " $HOME /.tmux/resurrect/assistant-sessions.json" << 'RMODELDUP '
2604+ {
2605+ "timestamp": "2026-01-01T00:00:00Z",
2606+ "sessions": [
2607+ {
2608+ "pane": "test-restore-model:0.0",
2609+ "tool": "claude",
2610+ "session_id": "ses_model_nodup",
2611+ "cwd": "/tmp",
2612+ "pid": "99999",
2613+ "model": "claude-opus-4-5-20250514",
2614+ "cli_args": "--model claude-opus-4-5-20250514",
2615+ "env": {}
2616+ }
2617+ ]
2618+ }
2619+ RMODELDUP
2620+
2621+ > " $RESTORE_LOG "
2622+ just restore 2>&1
2623+ sleep 5
2624+
2625+ nodup_log=$( cat " $RESTORE_LOG " )
2626+ # Count occurrences of --model — should be exactly 1 (from cli_args, not doubled)
2627+ nodup_count=$( echo " $nodup_log " | grep -o ' \-\-model' | wc -l | tr -d ' ' )
2628+ assert_eq " Model field: no duplicate --model when already in cli_args" " 1" " $nodup_count "
2629+
2630+ # Verify model is NOT added for non-Claude tools
2631+ tmux kill-session -t test-restore-model 2> /dev/null || true
2632+ tmux new-session -d -s test-restore-model -c /tmp 2> /dev/null || true
2633+ sleep 0.5
2634+
2635+ cat > " $HOME /.tmux/resurrect/assistant-sessions.json" << 'RMODELOC '
2636+ {
2637+ "timestamp": "2026-01-01T00:00:00Z",
2638+ "sessions": [
2639+ {
2640+ "pane": "test-restore-model:0.0",
2641+ "tool": "opencode",
2642+ "session_id": "ses_model_oc",
2643+ "cwd": "/tmp",
2644+ "pid": "99999",
2645+ "model": "some-model",
2646+ "cli_args": "",
2647+ "env": {}
2648+ }
2649+ ]
2650+ }
2651+ RMODELOC
2652+
2653+ > " $RESTORE_LOG "
2654+ just restore 2>&1
2655+ sleep 5
2656+
2657+ oc_model_log=$( cat " $RESTORE_LOG " )
2658+ if echo " $oc_model_log " | grep -q ' \-\-model' ; then
2659+ fail " Model field: --model should NOT be added for opencode"
2660+ else
2661+ pass " Model field: --model correctly skipped for opencode"
2662+ fi
2663+
2664+ kill_pane_children test-restore-model true
2665+
25602666# --- Test 10e: Restore filters out tmux_pane and shell from env prefix ---
25612667
25622668echo " "
0 commit comments