Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/cli-run.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,22 @@ describe('hwip channel list', () => {
});
});

describe('hwip notify --auto', () => {
// A Codex Stop hook's stdout is parsed as JSON: "Push sent: …" failed the hook.
it('prints nothing on stdout when the push goes out', async () => {
const result = await runCli('notify', '--auto', '--pushmode-default', 'loud', '--title', 'Task done');

expect(result.status).toBe(0);
expect(result.stdout).toBe('');
});

it('still prints the JSON when --json asks for it', async () => {
const result = await runCli('notify', '--auto', '--pushmode-default', 'loud', '--title', 'Task done', '--json');

expect(JSON.parse(result.stdout)).toEqual({ pushId: 'sent', status: 'ok' });
});
});

describe('hwip notify --channel', () => {
it('sends to the channel a name resolves to, in the clear, and says so', async () => {
sentBodies.length = 0;
Expand Down
8 changes: 5 additions & 3 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,8 @@ const handleNotify = async (args: Record<string, string | boolean>): Promise<num
// dial now works for every hook-driven agent. Gated-out → silent success.
// With no dial the mode falls back to --pushmode-default, then to quiet.
// Quiet still pushes when the user has left the terminal (presence.ts).
if (flagOn(args, 'auto')) {
const isAuto = flagOn(args, 'auto');
if (isAuto) {
const marker = normalizeMarker(typeof args.marker === 'string' ? args.marker : undefined);
const pushMode = autoPushMode(projectDir, args[PUSHMODE_DEFAULT_FLAG]);
const verdict = decidePush({
Expand All @@ -503,7 +504,7 @@ const handleNotify = async (args: Record<string, string | boolean>): Promise<num

// Past the gates, this IS a push attempt — its outcome is recorded for
// `hwip verify` and the plugin (notify-failure.ts), since hooks discard stderr.
const hook = createHook(args, flagOn(args, 'auto') ? HOOK_REQUEST_TIMEOUT_MS : undefined);
const hook = createHook(args, isAuto ? HOOK_REQUEST_TIMEOUT_MS : undefined);
if (!hook) {
recordNotifyFailure({ kind: 'no-key', status: null, code: null });
return 3;
Expand Down Expand Up @@ -533,9 +534,10 @@ const handleNotify = async (args: Record<string, string | boolean>): Promise<num
sessionId,
}));

// Hook mode: stdout is the hook's response (Codex parses it as JSON), so stay silent.
if (isJson) {
printJson({ pushId: result.pushId, status: 'ok' });
} else {
} else if (!isAuto) {
console.log(`Push sent: ${result.pushId}`);
}
return 0;
Expand Down
Loading