Skip to content

Commit fca5cab

Browse files
committed
feat(migrate): suppress plan log on embedding + add "Accept recommended" affordance
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).
1 parent b8bbe0e commit fca5cab

9 files changed

Lines changed: 99 additions & 291 deletions

‎src/commands/migrate.test.ts‎

Lines changed: 7 additions & 159 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ vi.mock("./backup.js", () => ({
6666
}));
6767

6868
const {
69-
MIGRATION_SKILL_SELECTION_SKIP,
69+
MIGRATION_SKILL_SELECTION_ACCEPT,
7070
MIGRATION_SKILL_SELECTION_TOGGLE_ALL_OFF,
7171
MIGRATION_SKILL_SELECTION_TOGGLE_ALL_ON,
7272
} = await import("./migrate/selection.js");
@@ -444,11 +444,11 @@ describe("migrateApplyCommand", () => {
444444
expect(selectionPrompt.initialValues).toStrictEqual(["skill:alpha", "skill:beta"]);
445445
expect(selectionPrompt.required).toBe(false);
446446
expect(selectionPrompt.options?.map(({ label, value }) => ({ label, value }))).toStrictEqual([
447-
{ value: MIGRATION_SKILL_SELECTION_SKIP, label: "Skip for now" },
448-
{ value: MIGRATION_SKILL_SELECTION_TOGGLE_ALL_ON, label: "Toggle all on" },
449-
{ value: MIGRATION_SKILL_SELECTION_TOGGLE_ALL_OFF, label: "Toggle all off" },
447+
{ value: MIGRATION_SKILL_SELECTION_ACCEPT, label: "Accept recommended" },
450448
{ value: "skill:alpha", label: "alpha" },
451449
{ value: "skill:beta", label: "beta" },
450+
{ value: MIGRATION_SKILL_SELECTION_TOGGLE_ALL_ON, label: "Toggle all on" },
451+
{ value: MIGRATION_SKILL_SELECTION_TOGGLE_ALL_OFF, label: "Toggle all off" },
452452
]);
453453
expect(mocks.promptYesNo).toHaveBeenCalledWith("Apply this migration now?", false);
454454
const appliedPlan = firstAppliedPlan();
@@ -504,11 +504,11 @@ describe("migrateApplyCommand", () => {
504504
expect(pluginPrompt.initialValues).toStrictEqual(["plugin:google-calendar", "plugin:gmail"]);
505505
expect(pluginPrompt.required).toBe(false);
506506
expect(pluginPrompt.options?.map(({ label, value }) => ({ label, value }))).toStrictEqual([
507-
{ value: MIGRATION_SKILL_SELECTION_SKIP, label: "Skip for now" },
508-
{ value: MIGRATION_SKILL_SELECTION_TOGGLE_ALL_ON, label: "Toggle all on" },
509-
{ value: MIGRATION_SKILL_SELECTION_TOGGLE_ALL_OFF, label: "Toggle all off" },
507+
{ value: MIGRATION_SKILL_SELECTION_ACCEPT, label: "Accept recommended" },
510508
{ value: "plugin:google-calendar", label: "google-calendar" },
511509
{ value: "plugin:gmail", label: "gmail" },
510+
{ value: MIGRATION_SKILL_SELECTION_TOGGLE_ALL_ON, label: "Toggle all on" },
511+
{ value: MIGRATION_SKILL_SELECTION_TOGGLE_ALL_OFF, label: "Toggle all off" },
512512
]);
513513
expect(mocks.promptYesNo).toHaveBeenCalledWith("Apply this migration now?", false);
514514
const appliedPlan = firstAppliedPlan();
@@ -652,59 +652,6 @@ describe("migrateApplyCommand", () => {
652652
expect(itemsById.get("plugin:gmail")?.status).toBe("planned");
653653
});
654654

655-
it("skips interactive Codex plugin migration before confirmation when Skip for now is selected", async () => {
656-
Object.defineProperty(process.stdin, "isTTY", {
657-
configurable: true,
658-
value: true,
659-
});
660-
const planned = codexPluginPlan();
661-
mocks.provider.plan.mockResolvedValue(planned);
662-
mocks.multiselect.mockResolvedValue([MIGRATION_SKILL_SELECTION_SKIP]);
663-
664-
const result = await migrateDefaultCommand(runtime, { provider: "codex" });
665-
666-
expect(result).toBe(planned);
667-
expect(mocks.promptYesNo).not.toHaveBeenCalled();
668-
expect(mocks.backupCreateCommand).not.toHaveBeenCalled();
669-
expect(mocks.provider.apply).not.toHaveBeenCalled();
670-
expect(runtime.log).toHaveBeenCalledWith("Codex plugin migration skipped for now.");
671-
});
672-
673-
it("returns without confirmation when both Codex skill and plugin selectors are skipped", async () => {
674-
Object.defineProperty(process.stdin, "isTTY", {
675-
configurable: true,
676-
value: true,
677-
});
678-
const skillPlan = codexSkillPlan();
679-
const pluginPlan = codexPluginPlan();
680-
const planned = codexSkillPlan({
681-
summary: {
682-
total: skillPlan.items.length + pluginPlan.items.length,
683-
planned: skillPlan.items.length + pluginPlan.items.length,
684-
migrated: 0,
685-
skipped: 0,
686-
conflicts: 0,
687-
errors: 0,
688-
sensitive: 0,
689-
},
690-
items: [...skillPlan.items, ...pluginPlan.items],
691-
});
692-
mocks.provider.plan.mockResolvedValue(planned);
693-
mocks.multiselect
694-
.mockResolvedValueOnce([MIGRATION_SKILL_SELECTION_SKIP])
695-
.mockResolvedValueOnce([MIGRATION_SKILL_SELECTION_SKIP]);
696-
697-
const result = await migrateDefaultCommand(runtime, { provider: "codex" });
698-
699-
expect(result).toBe(planned);
700-
expect(mocks.multiselect).toHaveBeenCalledTimes(2);
701-
expect(mocks.promptYesNo).not.toHaveBeenCalled();
702-
expect(mocks.backupCreateCommand).not.toHaveBeenCalled();
703-
expect(mocks.provider.apply).not.toHaveBeenCalled();
704-
expect(runtime.log).toHaveBeenCalledWith("Codex skill migration skipped for now.");
705-
expect(runtime.log).toHaveBeenCalledWith("Codex plugin migration skipped for now.");
706-
});
707-
708655
it("does not apply when interactive Codex plugin migration chooses no plugins", async () => {
709656
Object.defineProperty(process.stdin, "isTTY", {
710657
configurable: true,
@@ -821,105 +768,6 @@ describe("migrateApplyCommand", () => {
821768
expect(mocks.provider.apply).not.toHaveBeenCalled();
822769
});
823770

824-
it("continues to interactive Codex plugins when skill migration is skipped", async () => {
825-
Object.defineProperty(process.stdin, "isTTY", {
826-
configurable: true,
827-
value: true,
828-
});
829-
const skillPlan = codexSkillPlan();
830-
const pluginPlan = codexPluginPlan();
831-
const planned = codexSkillPlan({
832-
summary: {
833-
total: skillPlan.items.length + pluginPlan.items.length,
834-
planned: skillPlan.items.length + pluginPlan.items.length,
835-
migrated: 0,
836-
skipped: 0,
837-
conflicts: 0,
838-
errors: 0,
839-
sensitive: 0,
840-
},
841-
items: [...skillPlan.items, ...pluginPlan.items],
842-
});
843-
mocks.provider.plan.mockResolvedValue(planned);
844-
mocks.multiselect
845-
.mockResolvedValueOnce([MIGRATION_SKILL_SELECTION_SKIP])
846-
.mockResolvedValueOnce(["plugin:gmail"]);
847-
mocks.promptYesNo.mockResolvedValue(true);
848-
mocks.provider.apply.mockImplementation(async (_ctx, selectedPlan: MigrationPlan) => ({
849-
...selectedPlan,
850-
summary: { ...selectedPlan.summary, planned: 0, migrated: selectedPlan.summary.planned },
851-
items: selectedPlan.items.map((item) =>
852-
item.status === "planned" ? { ...item, status: "migrated" as const } : item,
853-
),
854-
}));
855-
856-
await migrateDefaultCommand(runtime, { provider: "codex" });
857-
858-
expect(mocks.multiselect).toHaveBeenCalledTimes(2);
859-
expect(runtime.log).toHaveBeenCalledWith("Codex skill migration skipped for now.");
860-
expect(mocks.promptYesNo).toHaveBeenCalledWith("Apply this migration now?", false);
861-
const appliedPlan = firstAppliedPlan();
862-
expect(appliedPlan.summary.planned).toBe(3);
863-
expect(appliedPlan.summary.skipped).toBe(3);
864-
expect(appliedPlan.summary.conflicts).toBe(0);
865-
const itemsById = new Map(appliedPlan.items.map((item) => [item.id, item]));
866-
expect(itemsById.get("skill:alpha")?.status).toBe("skipped");
867-
expect(itemsById.get("skill:alpha")?.reason).toBe("not selected for migration");
868-
expect(itemsById.get("skill:beta")?.status).toBe("skipped");
869-
expect(itemsById.get("skill:beta")?.reason).toBe("not selected for migration");
870-
expect(itemsById.get("plugin:gmail")?.status).toBe("planned");
871-
expect(itemsById.get("plugin:google-calendar")?.status).toBe("skipped");
872-
expect(itemsById.get("plugin:google-calendar")?.reason).toBe("not selected for migration");
873-
});
874-
875-
it("explains skipped plugin selection when Codex subscription auth is required", async () => {
876-
Object.defineProperty(process.stdin, "isTTY", {
877-
configurable: true,
878-
value: true,
879-
});
880-
const skillPlan = codexSkillPlan();
881-
const warning =
882-
"Codex app-backed plugin migration requires the Codex app-server source account to be logged in with a ChatGPT subscription account.";
883-
const planned = codexSkillPlan({
884-
summary: {
885-
total: skillPlan.items.length + 1,
886-
planned: skillPlan.summary.planned,
887-
migrated: 0,
888-
skipped: 1,
889-
conflicts: 0,
890-
errors: 0,
891-
sensitive: 0,
892-
},
893-
items: [
894-
...skillPlan.items,
895-
{
896-
id: "plugin:gmail:1",
897-
kind: "manual",
898-
action: "manual",
899-
status: "skipped",
900-
reason: "codex_subscription_required",
901-
details: { pluginName: "gmail" },
902-
},
903-
],
904-
warnings: [warning],
905-
});
906-
mocks.provider.plan.mockResolvedValue(planned);
907-
mocks.multiselect.mockResolvedValueOnce([MIGRATION_SKILL_SELECTION_SKIP]);
908-
909-
const result = await migrateDefaultCommand(runtime, { provider: "codex" });
910-
911-
expect(result.summary.planned).toBe(1);
912-
expect(result.summary.skipped).toBe(3);
913-
expect(mocks.multiselect).toHaveBeenCalledTimes(1);
914-
expect(mocks.promptYesNo).not.toHaveBeenCalled();
915-
expect(mocks.provider.apply).not.toHaveBeenCalled();
916-
expect(runtime.log).toHaveBeenCalledWith("Codex skill migration skipped for now.");
917-
expect(runtime.log).toHaveBeenCalledWith(warning);
918-
expect(runtime.log).toHaveBeenCalledWith(
919-
"No Codex skills selected; native Codex plugins are not eligible for migration in this run.",
920-
);
921-
});
922-
923771
it("does not apply archive-only Codex migration work after Toggle all off", async () => {
924772
Object.defineProperty(process.stdin, "isTTY", {
925773
configurable: true,

‎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;

0 commit comments

Comments
 (0)