Repository navigation
feat: notify when a newer version is available - #333
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
|
I have read the CLA Document and I hereby sign the CLA |
|
recheck |
|
I'm just thinking out loud.. but does it make sense to download the update in background and ask user to reload the app? |
I’d personally lean toward keeping updates manual. Feels more in line with typical CLI behavior. Just my take! |
|
This is a great change and very well structured. Agreed with keeping things without auto update for now, especially as it's still early days and updates might introduce breaking changes. |
|
|
||
| const UPDATE_CHECK_FREQUENCY = 1000 * 60 * 60 * 24; // 1 day | ||
|
|
||
| export async function getNPMCommandPath(): Promise<string | undefined> { |
There was a problem hiding this comment.
Sure! I’ll need a bit of time to look into it. I’ll follow up once I have a better understanding
| npmCommandPath: string, | ||
| ): Promise<UpdateCheckInfo | undefined> { | ||
| return new Promise((resolve, _reject) => { | ||
| // TODO: support local installation |
There was a problem hiding this comment.
Please leave a little bit more information here with some ideas for implementation or why this is important to support.
There was a problem hiding this comment.
fixed in e3a04e9. Since users might install Codex locally, I think we should check the project-level install first, then global as a fallback.
| } | ||
| cp.execFile(commandPath, args, options, (_error, stdout) => { | ||
| try { | ||
| // TODO parse from package.json |
There was a problem hiding this comment.
Please document the limitations related to not parsing package.json
There was a problem hiding this comment.
I noticed a comment on tsconfig.json#L14 mentioned that ESM doesn't yet support JSON modules, so I added a TODO there.
Line 14 in 82f5abb
That said, when building the TypeScript code, I found that importing package.json actually works. The bundler transforms the JSON import into a CommonJS-style require(...), and then wraps it with __toESM(...) so it behaves correctly in an ESM context. Here's an example from the build output:
const { name: packageName } = await Promise.resolve().then(() => __toESM(require_package2(), 1));While JSON modules are no longer experimental in Node.js 23.1.0+, we’re still using Node.js 22, so native support isn’t available yet — but the build behavior makes this approach work just fine.
Implemented in 2d9b707
| import { join } from "node:path"; | ||
| import which from "which"; | ||
|
|
||
| interface State { |
There was a problem hiding this comment.
Could you scope this to update state only, similar for the file name
There was a problem hiding this comment.
Just to double check — are you suggesting moving the state logic into a separate file, or just to keep this PR focused on state only?
There was a problem hiding this comment.
Suggesting to not call this State, but UpdateState and have the file name also be named after what it is storing (update state) and not generically be about state.
There was a problem hiding this comment.
Thanks! I've renamed State to UpdateState, and updated the file name to update-state.json to reflect its purpose more clearly in 396691b
|
Please resolve the merge conflicts and I will then merge. This is looking good after the changes, ty! |
|
Resolved, merging. Thank you for this great change! |
Summary
This change introduces a new startup check that notifies users if a newer
@openai/codexversion is available. To avoid spamming, it writes a small state file recording the last check time and will only re‑check once every 24 hours.What’s Changed
src/utils/check-updates.tsnpm outdated --global @openai/codexcodex-state.jsonunderCONFIG_DIRUPDATE_CHECK_FREQUENCY = 24h)boxenfor a styled alert andwhichto locate the npm binarysrc/cli.tsxentrypoint:boxen@^8.0.1,which@^5.0.0,@types/which@^3.0.4tests/check-updates.test.ts__snapshots__/check-updates.test.ts.snapMotivation
Addresses issue #244. Users running a stale global install will now see a friendly reminder—at most once per day—to upgrade and enjoy the latest features.
Test Plan
getNPMCommandPath()resolves npm correctlycheckOutdated()parsesnpm outdatedJSONRelated Issue
try resolves #244
Preview

Prompt a pnpm‑style alert when outdated
Let me know if you’d tweak any of the messaging, throttle frequency, placement in the startup flow, or anything else.