aboutsummaryrefslogtreecommitdiff
path: root/src/integration/assets/herdr-agent-state.test.ts
diff options
context:
space:
mode:
authorRhys <105699450+rhjoh@users.noreply.github.com>2026-08-03 10:44:44 +1000
committerGitHub <noreply@github.com>2026-08-03 03:44:44 +0300
commit5eab32da81b403c2a277222ab97417a8bf90c35f (patch)
tree73cfbad865e949e48ea93b4bd58d482b2806e447 /src/integration/assets/herdr-agent-state.test.ts
parent10eb0bc744165ae91dfce9fd731fe170410b34ec (diff)
fix(pi): restrict state reporting to tui sessions (#2159)
Co-authored-by: Can Celik <ogulcancelik@gmail.com>
Diffstat (limited to 'src/integration/assets/herdr-agent-state.test.ts')
-rw-r--r--src/integration/assets/herdr-agent-state.test.ts25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/integration/assets/herdr-agent-state.test.ts b/src/integration/assets/herdr-agent-state.test.ts
index f54332ce..94081e6d 100644
--- a/src/integration/assets/herdr-agent-state.test.ts
+++ b/src/integration/assets/herdr-agent-state.test.ts
@@ -171,6 +171,7 @@ for (const integration of integrations) {
{ reason: "startup" },
{
hasUI: true,
+ mode: "tui",
isIdle: () => true,
sessionManager: {
getSessionFile: () => undefined,
@@ -197,6 +198,7 @@ for (const integration of integrations) {
{ reason: "reload" },
{
hasUI: true,
+ mode: "tui",
isIdle: () => false,
sessionManager: {
getSessionFile: () => undefined,
@@ -268,6 +270,25 @@ test("Pi reports idle only after the agent settles", async () => {
expect(requestStates(requests)).toEqual(["idle", "working", "idle"]);
});
+test("Pi ignores RPC sessions even when UI APIs are available", async () => {
+ const requests = await startRecordingServer("pi-rpc");
+ const { handlers, pi } = createExtensionHarness();
+ const { default: install } = await importFresh("./pi/herdr-agent-state.ts");
+ install(pi);
+
+ const context = {
+ ...piContext(() => true),
+ hasUI: true,
+ mode: "rpc",
+ };
+ await handlers.get("session_start")?.({ reason: "startup" }, context);
+ handlers.get("agent_start")?.({}, context);
+ handlers.get("agent_settled")?.({}, context);
+ await Bun.sleep(25);
+
+ expect(requests).toEqual([]);
+});
+
test("Pi settlement preserves explicit blocked-state precedence", async () => {
const requests = await startRecordingServer("pi-settled-blocked");
const { eventHandlers, handlers, pi } = createExtensionHarness();
@@ -307,6 +328,7 @@ test("Pi reports the session replacement source", async () => {
{ reason: "new" },
{
hasUI: true,
+ mode: "tui",
isIdle: () => true,
sessionManager: {
getSessionFile: () => "/tmp/pi-new.jsonl",
@@ -370,6 +392,7 @@ test("Pi waits for a replacement session report before publishing state", async
{ reason: "new" },
{
hasUI: true,
+ mode: "tui",
isIdle: () => false,
sessionManager: {
getSessionFile: () => "/tmp/pi-new.jsonl",
@@ -489,6 +512,7 @@ test("Pi retries working state after an unanswered socket attempt", async () =>
{ reason: "startup" },
{
hasUI: true,
+ mode: "tui",
isIdle: () => false,
sessionManager: {
getSessionFile: () => undefined,
@@ -524,6 +548,7 @@ function completionHandlers(handlers: Map<string, Handler>): string[] {
function piContext(isIdle: () => boolean) {
return {
hasUI: true,
+ mode: "tui",
isIdle,
sessionManager: {
getSessionFile: () => undefined,