Skip to content

Commit 03a1427

Browse files
committed
feat(migrate): suppress plan log on embedding + add "Accept recommended" affordance (#81219)
Two related improvements to the interactive `openclaw migrate <provider>` flow, both surfaced by the onboarding post-install migration prompt that landed in #81192. 1. `suppressPlanLog?: boolean` on `MigrateCommonOptions` (`src/commands/migrate/types.ts`). When set, `migratePlanCommand` skips the up-front `runtime.log(formatMigrationPlan(plan))` dump. The interactive Codex selection picker and the "Apply this migration now?" confirm still run. Wired from the wizard helper at `src/wizard/setup.post-install-migration.ts` so that path no longer shows the plan dump after the user has already confirmed at the wizard prompt. 2. New "Accept recommended" sentinel row at the top of both Codex selection pickers, with "Toggle all on" and "Toggle all off" moved to the bottom. The cursor starts on "Accept recommended" so pressing Enter at the default position submits the picker's `initialValues` (the recommended set) — matching the visual state of the checkboxes. Implemented in `skill-selection-prompt.ts`: - Enter on the Accept sentinel sets `prompt.value` to `opts.initialValues` and lets clack submit. - Space on the Accept sentinel snaps `prompt.value` to `opts.initialValues` so the visible checkboxes flip to the recommended state. The user can then Enter to commit or continue toggling individual rows. The Accept row itself is never persisted in the submitted value list. The existing Enter handler for "Toggle all on" / "Toggle all off" stays unchanged. 3. Removed the "Skip for now" sentinel entirely. It was a single- keystroke trap: with the picker cursor wrapping from Accept to Skip via up-arrow (or via accidental down-arrows), Enter on Skip wiped `prompt.value` to `[MIGRATION_SELECTION_SKIP]` and abandoned the whole migration — including any items the user had already confirmed in the previous picker. To exit without migrating, users now navigate to "Toggle all off" (or use the `a` / `i` keyboard shortcuts) to clear the selection; the apply phase then sees no planned work and skips itself via the existing `shouldSkipCodexApplyAfterInteractiveSelection` path. Cleanup spans `migrate/selection.ts` (constants, `{ action: "skip" }` variant, and the reconcile/resolve SKIP branches), `migrate.ts` (the picker option rows and the `if (selection.action === "skip")` handler blocks in both pickers), and the corresponding tests. 4. Plugin selection hint relabelled from "Activate every recommended plugin" to "Migrate every recommended plugin" so it matches the skill hint and the prompt's own verb ("Migrate ... into this agent now?"). Tests: - `src/commands/migrate/skill-selection-prompt.test.ts` — Accept sentinel cases (Enter and Space + Enter both submit initialValues); Skip-related test removed; Skip row dropped from the picker fixture. - `src/commands/migrate/selection.test.ts` — Skip-related sub- assertions trimmed from the resolve/reconcile tests; the "skip + toggle-off precedence" test renamed to "toggle-off precedence over toggle-on" and Skip cases removed. - `src/commands/migrate.test.ts` — four Skip-driven scenarios removed (plugin-only skip, both-pickers skip, skip-skills-continue-to-plugins, Codex subscription warning + skip). - `src/wizard/setup.post-install-migration.test.ts` — call-args assertion expects the new `suppressPlanLog` option. Verification: - `pnpm lint` clean - `pnpm tsgo:core` + `pnpm tsgo:core:test` clean - Touched test suites green (migrate 32/32, selection 17/17, skill-selection-prompt 6/6, setup.post-install-migration 10/10). (cherry picked from commit a197e31)
1 parent 6926481 commit 03a1427

5 files changed

Lines changed: 59 additions & 55 deletions

File tree

‎src/commands/migrate.ts‎

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import {
3030
getMigrationSkillSelectionValue,
3131
getSelectableMigrationPluginItems,
3232
getSelectableMigrationSkillItems,
33-
MIGRATION_SELECTION_SKIP,
33+
MIGRATION_SELECTION_ACCEPT,
3434
MIGRATION_SELECTION_TOGGLE_ALL_OFF,
3535
MIGRATION_SELECTION_TOGGLE_ALL_ON,
3636
resolveInteractiveMigrationPluginSelection,
@@ -135,16 +135,9 @@ async function promptCodexMigrationSkillSelection(
135135
message: stylePromptMessage("Select Codex skills to migrate into this agent"),
136136
options: [
137137
{
138-
value: MIGRATION_SELECTION_SKIP,
139-
label: "Skip for now",
140-
},
141-
{
142-
value: MIGRATION_SELECTION_TOGGLE_ALL_ON,
143-
label: "Toggle all on",
144-
},
145-
{
146-
value: MIGRATION_SELECTION_TOGGLE_ALL_OFF,
147-
label: "Toggle all off",
138+
value: MIGRATION_SELECTION_ACCEPT,
139+
label: "Accept recommended",
140+
hint: "Migrate every recommended skill",
148141
},
149142
...skillItems.map((item) => {
150143
const hint = formatMigrationSkillSelectionHint(item);
@@ -154,21 +147,26 @@ async function promptCodexMigrationSkillSelection(
154147
hint: hint === undefined ? undefined : stylePromptHint(hint),
155148
};
156149
}),
150+
{
151+
value: MIGRATION_SELECTION_TOGGLE_ALL_ON,
152+
label: "Toggle all on",
153+
},
154+
{
155+
value: MIGRATION_SELECTION_TOGGLE_ALL_OFF,
156+
label: "Toggle all off",
157+
},
157158
],
158159
initialValues: getDefaultMigrationSkillSelectionValues(skillItems),
159160
required: false,
160161
selectableValues: skillItems.map(getMigrationSkillSelectionValue),
162+
cursorAt: MIGRATION_SELECTION_ACCEPT,
161163
});
162164
if (isCancel(selected)) {
163165
cancel(stylePromptTitle("Migration cancelled.") ?? "Migration cancelled.");
164166
runtime.log("Migration cancelled.");
165167
return null;
166168
}
167169
const selection = resolveInteractiveMigrationSkillSelection(skillItems, selected ?? []);
168-
if (selection.action === "skip") {
169-
runtime.log("Codex skill migration skipped for now.");
170-
return applyMigrationSelectedSkillItemIds(plan, new Set());
171-
}
172170
const selectedPlan = applyMigrationSelectedSkillItemIds(plan, selection.selectedItemIds);
173171
runtime.log(
174172
`Selected ${selection.selectedItemIds.size} of ${skillItems.length} Codex skills for migration.`,
@@ -198,16 +196,9 @@ async function promptCodexMigrationPluginSelection(
198196
message: stylePromptMessage("Select native Codex plugins to activate in this agent"),
199197
options: [
200198
{
201-
value: MIGRATION_SELECTION_SKIP,
202-
label: "Skip for now",
203-
},
204-
{
205-
value: MIGRATION_SELECTION_TOGGLE_ALL_ON,
206-
label: "Toggle all on",
207-
},
208-
{
209-
value: MIGRATION_SELECTION_TOGGLE_ALL_OFF,
210-
label: "Toggle all off",
199+
value: MIGRATION_SELECTION_ACCEPT,
200+
label: "Accept recommended",
201+
hint: "Migrate every recommended plugin",
211202
},
212203
...pluginItems.map((item) => {
213204
const hint = formatMigrationPluginSelectionHint(item);
@@ -217,21 +208,26 @@ async function promptCodexMigrationPluginSelection(
217208
hint: hint === undefined ? undefined : stylePromptHint(hint),
218209
};
219210
}),
211+
{
212+
value: MIGRATION_SELECTION_TOGGLE_ALL_ON,
213+
label: "Toggle all on",
214+
},
215+
{
216+
value: MIGRATION_SELECTION_TOGGLE_ALL_OFF,
217+
label: "Toggle all off",
218+
},
220219
],
221220
initialValues: getDefaultMigrationPluginSelectionValues(pluginItems),
222221
required: false,
223222
selectableValues: pluginItems.map(getMigrationPluginSelectionValue),
223+
cursorAt: MIGRATION_SELECTION_ACCEPT,
224224
});
225225
if (isCancel(selected)) {
226226
cancel(stylePromptTitle("Migration cancelled.") ?? "Migration cancelled.");
227227
runtime.log("Migration cancelled.");
228228
return null;
229229
}
230230
const selection = resolveInteractiveMigrationPluginSelection(pluginItems, selected ?? []);
231-
if (selection.action === "skip") {
232-
runtime.log("Codex plugin migration skipped for now.");
233-
return null;
234-
}
235231
const selectedPlan = applyMigrationSelectedPluginItemIds(plan, selection.selectedItemIds);
236232
runtime.log(
237233
`Selected ${selection.selectedItemIds.size} of ${pluginItems.length} native Codex plugins for activation.`,
@@ -334,7 +330,7 @@ export async function migratePlanCommand(
334330
const plan = await createMigrationPlanWithProgress(runtime, { ...opts, provider: providerId });
335331
if (opts.json) {
336332
writeRuntimeJson(runtime, redactMigrationPlan(plan));
337-
} else {
333+
} else if (opts.suppressPlanLog !== true) {
338334
runtime.log(formatMigrationPlan(plan).join("\n"));
339335
}
340336
return plan;

‎src/commands/migrate/selection.ts‎

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ import type { MigrationItem, MigrationPlan } from "../../plugins/types.js";
44

55
export const MIGRATION_SKILL_NOT_SELECTED_REASON = "not selected for migration";
66
export const MIGRATION_PLUGIN_NOT_SELECTED_REASON = "not selected for migration";
7+
export const MIGRATION_SELECTION_ACCEPT = "__openclaw_migrate_accept_recommended__";
78
export const MIGRATION_SELECTION_TOGGLE_ALL_ON = "__openclaw_migrate_toggle_all_on__";
89
export const MIGRATION_SELECTION_TOGGLE_ALL_OFF = "__openclaw_migrate_toggle_all_off__";
910
export const MIGRATION_SELECTION_SKIP = "__openclaw_migrate_skip_for_now__";
11+
export const MIGRATION_SKILL_SELECTION_ACCEPT = MIGRATION_SELECTION_ACCEPT;
1012
export const MIGRATION_SKILL_SELECTION_TOGGLE_ALL_ON = MIGRATION_SELECTION_TOGGLE_ALL_ON;
1113
export const MIGRATION_SKILL_SELECTION_TOGGLE_ALL_OFF = MIGRATION_SELECTION_TOGGLE_ALL_OFF;
1214
export const MIGRATION_SKILL_SELECTION_SKIP = MIGRATION_SELECTION_SKIP;
1315

14-
type InteractiveMigrationSelection =
15-
| { action: "skip" }
16-
| { action: "select"; selectedItemIds: Set<string> };
16+
type InteractiveMigrationSelection = { action: "select"; selectedItemIds: Set<string> };
1717
export type InteractiveMigrationSkillSelection = InteractiveMigrationSelection;
1818
export type InteractiveMigrationPluginSelection = InteractiveMigrationSelection;
1919

@@ -425,10 +425,6 @@ function resolveInteractiveMigrationSelection(
425425
}
426426

427427
const selectedValueSet = new Set(selectedValues);
428-
if (selectedValueSet.has(MIGRATION_SELECTION_SKIP)) {
429-
return { action: "skip" };
430-
}
431-
432428
if (selectedValueSet.has(MIGRATION_SELECTION_TOGGLE_ALL_OFF)) {
433429
return { action: "select", selectedItemIds: new Set() };
434430
}
@@ -469,9 +465,6 @@ export function reconcileInteractiveMigrationSkillToggleValues(
469465
activatedValue: string | undefined,
470466
selectableValues: readonly string[],
471467
): string[] {
472-
if (activatedValue === MIGRATION_SELECTION_SKIP) {
473-
return selectedValues.includes(MIGRATION_SELECTION_SKIP) ? [MIGRATION_SELECTION_SKIP] : [];
474-
}
475468
if (activatedValue === MIGRATION_SELECTION_TOGGLE_ALL_ON) {
476469
return [MIGRATION_SELECTION_TOGGLE_ALL_ON, ...selectableValues];
477470
}
@@ -481,9 +474,7 @@ export function reconcileInteractiveMigrationSkillToggleValues(
481474
if (activatedValue !== undefined && selectableValues.includes(activatedValue)) {
482475
return selectedValues.filter(
483476
(value) =>
484-
value !== MIGRATION_SELECTION_TOGGLE_ALL_ON &&
485-
value !== MIGRATION_SELECTION_TOGGLE_ALL_OFF &&
486-
value !== MIGRATION_SELECTION_SKIP,
477+
value !== MIGRATION_SELECTION_TOGGLE_ALL_ON && value !== MIGRATION_SELECTION_TOGGLE_ALL_OFF,
487478
);
488479
}
489480
return selectedValues.filter(
@@ -499,9 +490,6 @@ export function reconcileInteractiveMigrationEnterValues(
499490
selectableValues: readonly string[],
500491
opts: { preserveDeselectedActivatedValue?: boolean } = {},
501492
): string[] {
502-
if (activatedValue === MIGRATION_SELECTION_SKIP) {
503-
return [MIGRATION_SELECTION_SKIP];
504-
}
505493
if (activatedValue === MIGRATION_SELECTION_TOGGLE_ALL_ON) {
506494
return [MIGRATION_SELECTION_TOGGLE_ALL_ON, ...selectableValues];
507495
}
@@ -511,9 +499,7 @@ export function reconcileInteractiveMigrationEnterValues(
511499
if (activatedValue !== undefined && selectableValues.includes(activatedValue)) {
512500
const selectedSelectableValues = selectedValues.filter(
513501
(value) =>
514-
value !== MIGRATION_SELECTION_TOGGLE_ALL_ON &&
515-
value !== MIGRATION_SELECTION_TOGGLE_ALL_OFF &&
516-
value !== MIGRATION_SELECTION_SKIP,
502+
value !== MIGRATION_SELECTION_TOGGLE_ALL_ON && value !== MIGRATION_SELECTION_TOGGLE_ALL_OFF,
517503
);
518504
if (opts.preserveDeselectedActivatedValue && !selectedValues.includes(activatedValue)) {
519505
return selectedSelectableValues;
@@ -530,11 +516,7 @@ export function reconcileInteractiveMigrationShortcutValues(
530516
key: "a" | "i",
531517
): string[] {
532518
const previousSelectable = previousValues.filter((value) => selectableValues.includes(value));
533-
if (
534-
key === "a" &&
535-
!previousValues.includes(MIGRATION_SELECTION_SKIP) &&
536-
previousSelectable.length === selectableValues.length
537-
) {
519+
if (key === "a" && previousSelectable.length === selectableValues.length) {
538520
return [MIGRATION_SELECTION_TOGGLE_ALL_OFF];
539521
}
540522

‎src/commands/migrate/skill-selection-prompt.ts‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
symbolBar,
1212
} from "@clack/prompts";
1313
import {
14+
MIGRATION_SELECTION_ACCEPT,
1415
reconcileInteractiveMigrationEnterValues,
1516
reconcileInteractiveMigrationShortcutValues,
1617
reconcileInteractiveMigrationSkillToggleValues,
@@ -181,6 +182,15 @@ export function promptMigrationSkillSelectionValues(
181182
return;
182183
}
183184
const activatedValue = prompt.options[prompt.cursor]?.value;
185+
// Space on the "Accept recommended" sentinel snaps the visual selection
186+
// back to the recommended set so the user can see what would be submitted
187+
// by Enter. The sentinel itself is never persisted in the value list.
188+
if (activatedValue === MIGRATION_SELECTION_ACCEPT) {
189+
prompt.value = [...(opts.initialValues ?? [])];
190+
lastSpaceDeselectedValue = undefined;
191+
lastSelectedValues = [...(prompt.value ?? [])];
192+
return;
193+
}
184194
const previousValues = lastSelectedValues;
185195
const selectedValuesAfterClack = prompt.value ?? [];
186196
prompt.value = reconcileInteractiveMigrationSkillToggleValues(
@@ -202,6 +212,14 @@ export function promptMigrationSkillSelectionValues(
202212
if (info.name === "return") {
203213
const activatedOption = prompt.options[prompt.cursor];
204214
const activatedValue = activatedOption?.disabled ? undefined : activatedOption?.value;
215+
// Enter on "Accept recommended" submits with the picker's initialValues
216+
// (the recommended set) regardless of any toggles the user made.
217+
if (activatedValue === MIGRATION_SELECTION_ACCEPT) {
218+
prompt.value = [...(opts.initialValues ?? [])];
219+
lastSpaceDeselectedValue = undefined;
220+
lastSelectedValues = [...(prompt.value ?? [])];
221+
return;
222+
}
205223
prompt.value = reconcileInteractiveMigrationEnterValues(
206224
prompt.value ?? [],
207225
activatedValue,

‎src/commands/migrate/types.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ export type MigrateCommonOptions = {
99
plugins?: string[];
1010
verifyPluginApps?: boolean;
1111
json?: boolean;
12+
// Suppress the formatted plan dump that `migrate plan` normally prints
13+
// before any interactive selection. Used by onboarding flows that have
14+
// already secured user consent and do not want to re-render the plan.
15+
// The interactive selection picker and apply confirmation still run.
16+
suppressPlanLog?: boolean;
1217
};
1318

1419
export type MigrateApplyOptions = MigrateCommonOptions & {

‎src/wizard/setup.post-install-migration.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,10 @@ export async function offerPostInstallMigrations(
148148
}
149149
try {
150150
const { migrateDefaultCommand } = await import("../commands/migrate.js");
151-
await migrateDefaultCommand(params.runtime, { provider: candidate.provider.id });
151+
await migrateDefaultCommand(params.runtime, {
152+
provider: candidate.provider.id,
153+
suppressPlanLog: true,
154+
});
152155
} catch (error) {
153156
params.runtime.log(
154157
`${candidate.provider.label} migration failed: ${formatErrorMessage(error)}. ` +

0 commit comments

Comments
 (0)