@henryqw/pi-herdr-clone 0.2.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/extensions/clone-tab.ts +6 -14
- package/package.json +1 -1
package/extensions/clone-tab.ts
CHANGED
|
@@ -211,28 +211,20 @@ export default function herdrCloneExtension(pi: ExtensionAPI): void {
|
|
|
211
211
|
return { createdTab, cloneFile };
|
|
212
212
|
};
|
|
213
213
|
const { createdTab, cloneFile } = source.checkout ? await withWorktreeLock(source.checkout, mutate) : await mutate();
|
|
214
|
-
let
|
|
215
|
-
let rootPaneId: string | undefined;
|
|
214
|
+
let tab: ReturnType<typeof parseCreatedTab>;
|
|
216
215
|
try {
|
|
217
|
-
|
|
218
|
-
if (!tabResponse || typeof tabResponse !== "object" || Array.isArray(tabResponse)) {
|
|
219
|
-
throw new Error("Herdr tab create returned invalid JSON");
|
|
220
|
-
}
|
|
221
|
-
const result = (tabResponse as {
|
|
222
|
-
result?: { tab?: { tab_id?: unknown }; root_pane?: { pane_id?: unknown } };
|
|
223
|
-
}).result;
|
|
224
|
-
tabId = requiredString(result?.tab?.tab_id, "Herdr tab response tab_id");
|
|
225
|
-
rootPaneId = requiredString(result?.root_pane?.pane_id, `Herdr tab ${tabId} root pane_id`);
|
|
216
|
+
tab = parseCreatedTab(createdTab, source.workspaceId);
|
|
226
217
|
} catch (error) {
|
|
227
218
|
throw new Error(
|
|
228
|
-
`Clone launch could not be confirmed after creating a Herdr tab; retained
|
|
219
|
+
`Clone launch could not be confirmed after creating a Herdr tab; retained session ${cloneFile}: ${errorMessage(error)}`,
|
|
229
220
|
{ cause: error },
|
|
230
221
|
);
|
|
231
222
|
}
|
|
232
|
-
const
|
|
223
|
+
const { tabId, rootPaneId } = tab;
|
|
224
|
+
const agentName = await launchCloneAgent(herdr, ctx, rootPaneId, cloneFile, `Herdr tab ${tabId}, root pane ${rootPaneId}, and session ${cloneFile}`);
|
|
233
225
|
|
|
234
226
|
try {
|
|
235
|
-
await herdr.run(["tab", "focus", tabId
|
|
227
|
+
await herdr.run(["tab", "focus", tabId], { cwd: ctx.cwd });
|
|
236
228
|
} catch (error) {
|
|
237
229
|
ctx.ui.notify(
|
|
238
230
|
`Clone agent ${agentName} started in Herdr tab ${tabId} (root pane ${rootPaneId}), but focus failed: ${errorMessage(error)}`,
|