@gethmy/harness 1.6.0 → 1.7.0

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/src/worktree.ts CHANGED
@@ -16,7 +16,7 @@ export interface RescueCommentClient {
16
16
  addComment(
17
17
  cardId: string,
18
18
  body: string,
19
- opts?: { commentType?: string },
19
+ opts?: { commentType?: string; agentSessionId?: string },
20
20
  ): Promise<unknown>;
21
21
  }
22
22
 
@@ -836,6 +836,8 @@ export async function rescueUnpushedBranch(
836
836
  cardId: string,
837
837
  branchName: string,
838
838
  repoRoot = resolveRepoRoot(),
839
+ /** The run's own `card_agent_context.id`, for the rescue notice (#1035). */
840
+ agentSessionId?: string | null,
839
841
  ): Promise<boolean> {
840
842
  // Imported lazily to keep git-pr.ts's ~600 lines of PR/provider logic out of
841
843
  // worktree.ts's static dependency graph. git-pr.ts no longer does any work
@@ -873,7 +875,15 @@ export async function rescueUnpushedBranch(
873
875
  const body =
874
876
  `⚠ Run ended before completion. Committed work was push-rescued to ` +
875
877
  `\`origin/${branchName}\` so it isn't lost. ${recover}`;
876
- await client.addComment(cardId, body, { commentType: "message" });
878
+ await client.addComment(cardId, body, {
879
+ commentType: "message",
880
+ // Named, not inferred (#1035): the API stopped picking a session off the
881
+ // caller's account, so without this the rescue notice is attributed to no
882
+ // run. An ENDED session is fine here — the explicit branch accepts any of
883
+ // the caller's own sessions on the card regardless of `ended_at`, which is
884
+ // what this path needs, since a rescue happens as the run is torn down.
885
+ ...(agentSessionId ? { agentSessionId } : {}),
886
+ });
877
887
  } catch (err) {
878
888
  log.warn(
879
889
  TAG,
@@ -910,6 +920,12 @@ export async function teardownWorktree(
910
920
  cardId: string | null | undefined,
911
921
  worktreePath: string,
912
922
  branchName?: string,
923
+ /**
924
+ * The run's own `card_agent_context.id`, forwarded to the rescue notice
925
+ * (#1035). Optional because one caller genuinely has none: orphan recovery
926
+ * tears down a worktree whose run died with the daemon.
927
+ */
928
+ agentSessionId?: string | null,
913
929
  ): Promise<void> {
914
930
  let skipBranchDelete = false;
915
931
 
@@ -930,6 +946,7 @@ export async function teardownWorktree(
930
946
  cardId,
931
947
  branchName,
932
948
  repoRoot,
949
+ agentSessionId,
933
950
  );
934
951
  if (!ok) {
935
952
  skipBranchDelete = true;