Skip to content

feat: add notifications for MacOS using Applescript - #160

Merged
tibo-openai merged 7 commits into
openai:mainfrom
kchro3:kchro3/add-notifs
Apr 17, 2025
Merged

tibo-openai merged 7 commits into
openai:mainfrom
kchro3:kchro3/add-notifs

Conversation

@kchro3

@kchro3 kchro3 commented Apr 17, 2025

Copy link
Copy Markdown
Contributor

yolo'ed it with codex. Let me know if this looks good to you.

#148

tested with:

npm run build:dev
Screenshot 2025-04-16 at 18 12 01

@github-actions

github-actions Bot commented Apr 17, 2025 •

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@kchro3

kchro3 commented Apr 17, 2025

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@kchro3

kchro3 commented Apr 17, 2025

Copy link
Copy Markdown
Contributor Author

recheck

@tibo-openai

Copy link
Copy Markdown
Collaborator

Contribution looks great, but there seems to be an issue with the CLA signature

kchro3 seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.

Could you check?

@kchro3

kchro3 commented Apr 17, 2025

Copy link
Copy Markdown
Contributor Author

recheck

@kchro3

kchro3 commented Apr 17, 2025

Copy link
Copy Markdown
Contributor Author

Hm, I've added my email to this account, but I can't seem to retrigger the bot

@kchro3

kchro3 commented Apr 17, 2025

Copy link
Copy Markdown
Contributor Author

@tibo-openai

Copy link
Copy Markdown
Collaborator

recheck

github-actions Bot added a commit that referenced this pull request Apr 17, 2025
@tibo-openai tibo-openai changed the title Add notifications for MacOS using Applescript feat: add notifications for MacOS using Applescript Apr 17, 2025
@tibo-openai

Copy link
Copy Markdown
Collaborator

very nice, ty for the contribution!

@tibo-openai

Copy link
Copy Markdown
Collaborator

two requests

  • could we make this only notify when a --notify arg is set (and set to false by default)
  • could we make this a configuration option so you can set it in your config file

not everyone will want to get notified

@kchro3

kchro3 commented Apr 17, 2025

Copy link
Copy Markdown
Contributor Author

not everyone will want to get notified

Just out of curiosity, are you using it with auto? I like that I can run it with multiple terminal sessions, but I'm bottlenecking every session with the suggestion mode.

@tibo-openai

Copy link
Copy Markdown
Collaborator

Yes, I run with full-auto and revert using git-fu if needed

@tibo-openai

Copy link
Copy Markdown
Collaborator

I see you've made some changes, let me know when it's ready for review.

@kchro3

kchro3 commented Apr 17, 2025

Copy link
Copy Markdown
Contributor Author

ok, ready! tested on my machine with

codex/codex-cli on  kchro3/add-notifs is 📦 0.1.2504161510 on 🐳 v24.0.2 took 2m 46.0s
➜ npm run build

> @openai/[email protected] build
> node build.mjs


codex/codex-cli on  kchro3/add-notifs is 📦 0.1.2504161510 on 🐳 v24.0.2
➜ node dist/cli.js --notify "Hello from dev branch"

@tibo-openai

Copy link
Copy Markdown
Collaborator

lgtm, ty! merging

@tibo-openai

Copy link
Copy Markdown
Collaborator

Could you fix the CI failure, see

Run npm run lint -- \

> @openai/[email protected][10](https://github.com/openai/codex/actions/runs/14506331599/job/40698992593?pr=160#step:7:11) lint
> eslint src tests --ext ts --ext tsx --report-unused-disable-directives --max-warnings 0 --rule no-console:error --rule no-debugger:error --max-warnings=-1


/home/runner/work/codex/codex/codex-cli/src/components/chat/terminal-chat.tsx
Error:   221:6  error  React Hook useEffect has a missing dependency: 'PWD'. Either include it or remove the dependency array  react-hooks/exhaustive-deps

✖ 1 problem (1 error, 0 warnings)

Error: Process completed with exit code 1.

@tibo-openai

Copy link
Copy Markdown
Collaborator

Still some issues

3s
Run npm run typecheck

> @openai/codex@0.[1](https://github.com/openai/codex/actions/runs/14507747581/job/40731297479?pr=160#step:8:1).2504161510 typecheck
> tsc --noEmit

Error: src/utils/config.ts(253,9): error TS2741: Property 'notify' is missing in type '{ model: string; instructions: string; }' but required in type 'AppConfig'.
Error: tests/agent-cancel-early.test.ts(98,7): error TS2741: Property 'notify' is missing in type '{ model: string; instructions: string; }' but required in type 'AppConfig'.
Error: tests/agent-cancel-prev-response.test.ts(10[6](https://github.com/openai/codex/actions/runs/14507747581/job/40731297479?pr=160#step:8:7),[7](https://github.com/openai/codex/actions/runs/14507747581/job/40731297479?pr=160#step:8:8)): error TS2741: Property 'notify' is missing in type '{ model: string; instructions: string; }' but required in type 'AppConfig'.
Error: tests/agent-cancel-race.test.ts([9](https://github.com/openai/codex/actions/runs/14507747581/job/40731297479?pr=160#step:8:10)7,7): error TS2741: Property 'notify' is missing in type '{ model: string; instructions: string; }' but required in type 'AppConfig'.
Error: tests/agent-cancel.test.ts(92,7): error TS2741: Property 'notify' is missing in type '{ model: string; instructions: string; }' but required in type 'AppConfig'.
Error: tests/agent-cancel.test.ts(141,7): error TS2741: Property 'notify' is missing in type '{ model: string; instructions: string; }' but required in type 'AppConfig'.
Error: tests/agent-terminate.test.ts([10](https://github.com/openai/codex/actions/runs/14507747581/job/40731297479?pr=160#step:8:11)7,7): error TS2741: Property 'notify' is missing in type '{ model: string; instructions: string; }' but required in type 'AppConfig'.
Error: tests/agent-terminate.test.ts(142,7): error TS2741: Property 'notify' is missing in type '{ model: string; instructions: string; }' but required in type 'AppConfig'.
Error: Process completed with exit code 2.

please ping me when these are all resolved (you can run them locally with npm run ...) and then I will have a look again!

@kchro3

kchro3 commented Apr 17, 2025

Copy link
Copy Markdown
Contributor Author

ok, should be passing now

@kchro3

kchro3 commented Apr 17, 2025

Copy link
Copy Markdown
Contributor Author

rebased to latest

@tibo-openai

Copy link
Copy Markdown
Collaborator

looking good now, merging, ty!!

@tibo-openai
tibo-openai merged commit 0a2e416 into openai:main Apr 17, 2025
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 17, 2025

// Notify desktop with a preview when an assistant response arrives
const prevLoadingRef = useRef<boolean>(false);
useEffect(() => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First, we should carve out a general notification abstraction rather than duping this logic into the middle of a UI component.

const safePreview = preview.replace(/"/g, '\\"');
const title = "Codex CLI";
const cwd = PWD;
exec(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Second, we should absolutely not be using exec() with a single string arg that appears to be subject to injection risks. At a minimum, we should be using spawn() with a list of strings.

@bolinfest

Copy link
Copy Markdown
Collaborator

Incidentally, I did look at implementing this feature using osascript prior to launch. On my laptop, running the following in iTerm:

osascript -e 'display notification "Hello" with title "My Title" subtitle "Here"'

Does not work. It is likely due to some combination of app notification settings, focus mode, etc. I didn't have enough time to debug my system and I felt that if I couldn't put something in the public docs that would help someone debug their own issues with this feature, then adding a feature like --notify was going to create a support burden for the team.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants