fix(plugins): New workspace commands have the same effects as a pick, even from a mount effect

The screen attached the pick side effects (remembering the isolation, syncing the picker's PR
attachment) as listeners in its own useEffect, which runs after a child item's mount effect. A
mount-time setIsolation("worktree") switched the screen but was not saved, and setBaseRef skipped
the attachment sync. The effects are now injected when the setup model is built, so a command and
a pick run the same code from the first render. Closing the picker stays in the picker's handler.
This commit is contained in:
Mohamed Boudra
2026-11-04 14:05:15 +01:00
parent e5bc1fa823
commit cb6cc73683
7 changed files with 113 additions and 69 deletions
@@ -36,14 +36,16 @@ describe("the base ref a plugin reads", () => {
const origin = rows.find((row) => row.kind === "branch" && row.refName.includes("remotes"));
if (!origin) throw new Error("expected an origin row");
const setup = createNewWorkspaceSetup({
locked: false,
project: { id: "p", name: "repo" },
canCreateWorktree: true,
supportsMetadata: true,
});
const chosen: PickerItem[] = [];
setup.onBaseChosen((item) => chosen.push(item));
const setup = createNewWorkspaceSetup(
{
locked: false,
project: { id: "p", name: "repo" },
canCreateWorktree: true,
supportsMetadata: true,
},
{ persistIsolation: () => {}, syncBaseAttachment: (item) => chosen.push(item) },
);
const read = toPluginNewWorkspace({
host: HOST,
view: viewOf(origin),