Harden remote connect and subscription handling

- Scope cleartext mobile config to development
- Fix stale loads, ordering, and terminal reuse
- Clean up terminal metadata subscriptions on failure
This commit is contained in:
Julius Marminge committed 2026-05-20 11:05:37 +02:00
1 parent 4ac2618403
commit 7f03f4d19a
15 files changed
+276 -47

No files matched your search

@@ -1351,6 +1351,27 @@ it.layer(
}),
);
it.effect("removes terminal metadata subscriptions when initial delivery fails", () =>
Effect.gen(function* () {
const { manager } = yield* createManager();
yield* manager.open(openInput({ threadId: "existing-thread" }));
const leakedLiveEvents = yield* Ref.make(0);
const exit = yield* Effect.exit(
manager.subscribeMetadata((event) =>
event.type === "snapshot"
? Effect.die("snapshot listener failed")
: Ref.update(leakedLiveEvents, (count) => count + 1),
),
);
expect(Exit.isFailure(exit)).toBe(true);
yield* manager.open(openInput({ threadId: "new-thread" }));
expect(yield* Ref.get(leakedLiveEvents)).toBe(0);
}),
);
it.effect(
"streams attach snapshots followed by live events without duplicate start snapshots",
() =>
+11 -1
View File
@@ -2223,7 +2223,17 @@ export const makeTerminalManagerWithOptions = Effect.fn("makeTerminalManagerWith
unsubscribe?.();
unsubscribe = null;
};
});
}).pipe(
Effect.catchCause((cause) =>
Effect.flatMap(
Effect.sync(() => {
unsubscribe?.();
unsubscribe = null;
}),
() => Effect.failCause(cause),
),
),
);
};
const write: TerminalManagerShape["write"] = Effect.fn("terminal.write")(function* (input) {