Skip to content

Show warning in glue dev if old glue-runtime version is being used#30

Merged
Macil merged 2 commits into
masterfrom
chris/upgradeNotice
Apr 3, 2026
Merged

Show warning in glue dev if old glue-runtime version is being used#30
Macil merged 2 commits into
masterfrom
chris/upgradeNotice

Conversation

@Macil
Copy link
Copy Markdown
Contributor

@Macil Macil commented Apr 3, 2026

No description provided.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 3, 2026

Greptile Summary

This PR adds a warning in glue dev when the user's project is using an outdated version of @streak-glue/runtime. It also introduces a --verbose global CLI flag for surfacing otherwise-silenced errors.

How it works:

  1. A new lib/denoConfig.ts module extracts the findDenoConfigPaths / findFileInDirectoryOrAbove / parentDirectories utilities previously private to lib/getCreateDeploymentParams.ts, making them reusable.
  2. A new lib/runtimeVersionCheck.ts reads the project's deno.lock file (located by walking up from the glue entrypoint), extracts the resolved @streak-glue/runtime version from the specifiers map, then fetches https://jsr.io/@streak-glue/runtime/meta.json to get the published latest. If the two differ, it returns an OutdatedRuntimeInfo object.
  3. commands/dev.ts calls warnIfStreakRuntimeIsOutdated once at startup, stores the result in devProgressProps, and re-renders the UI. Errors are caught and suppressed unless --verbose is passed.
  4. ui/dev.tsx renders the OutdatedRuntimeWarning component at the top of the dev UI when outdatedRuntimeWarningInfo is present.
  5. A shared GLUE_RUNTIME_PACKAGE constant is added to common.ts to avoid string duplication.

Key things to verify:

  • The version comparison in getOutdatedStreakRuntimeVersion (latestVersion === currentVersion) is a plain string equality check and does not guard against the case where the locked version is newer than what JSR reports as latest. This can produce a false-positive "update available" warning with a confusing downgrade arrow (e.g., 0.3.0 -> 0.2.35). A semver greaterThan check is needed.
  • The version check only runs once at startup and is never repeated on file-change restarts, which is the right UX but worth being aware of.
  • The --verbose flag is global, so it now silently reaches commands/create.ts as well (via CommonCommandOptions), where it is unused — this is harmless but expected.

Confidence Score: 3/5

Mostly safe but has a correctness bug in the version comparison that can produce a misleading downgrade warning for users on newer/pre-release versions.

The refactoring of denoConfig utilities and the CLI plumbing are clean. The main risk is in lib/runtimeVersionCheck.ts: the latestVersion === currentVersion string equality does not prevent a false-positive warning when the user's locked version is strictly greater than JSR's latest. This could confuse users into downgrading their runtime.

lib/runtimeVersionCheck.ts — specifically the version comparison logic around line 29.

Important Files Changed

Filename Overview
lib/runtimeVersionCheck.ts New file implementing the outdated-runtime detection. Core logic has a bug: the version equality check (===) does not guard against false positives when the locked version is newer than JSR's latest; a proper semver greaterThan comparison is needed.
lib/denoConfig.ts Extraction of parentDirectories, findFileInDirectoryOrAbove, and findDenoConfigPaths from getCreateDeploymentParams.ts into a shared utility; logic is unchanged and correct.
lib/runtimeVersionCheck.test.ts Good test coverage for the happy-path and the lock-file parsing, but missing a test case for when the current version is newer than the latest (which would expose the false-positive bug). Test description on line 44 is inaccurate.
commands/dev.ts Correctly wires the new version check into the dev startup flow; errors are silently swallowed unless --verbose is passed, which is a reasonable UX choice.
ui/dev.tsx Adds OutdatedRuntimeWarning component and wires it into DevUI via the new outdatedRuntimeWarningInfo prop; implementation is clean and straightforward.
lib/getCreateDeploymentParams.ts Refactored to use the new shared findDenoConfigPaths utility; behaviour is identical to before.
commands/common.ts Adds CommonCommandOptions interface with verbose: boolean; clean addition with no issues.
glue.ts Adds a --verbose global option (default false) that propagates to all sub-commands via CommonCommandOptions.
common.ts Extracts GLUE_RUNTIME_PACKAGE as a shared constant to avoid string duplication across the codebase.
commands/create.ts Trivial update: _options type changed from void to CommonCommandOptions to satisfy the global option typing; options are still unused in the create flow.

Reviews (1): Last reviewed commit: "use ink to render warning so it doesn't ..." | Re-trigger Greptile

Comment on lines +29 to +32
if (latestVersion === currentVersion) {
return undefined;
}
return { currentVersion, latestVersion };
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 No semver comparison — false positive warning if user is on a newer version

The check latestVersion === currentVersion uses strict string equality, meaning getOutdatedStreakRuntimeVersion will return an OutdatedRuntimeInfo object whenever the two strings differ — including the case where the user's locked version is newer than the JSR-published latest (e.g., they previously locked a pre-release like 0.3.0-beta.1, or latest was temporarily rolled back on JSR). In that scenario the UI would show:

A newer @streak-glue/runtime version is available (0.3.0-beta.1 -> 0.2.35).
Update it with: deno update --latest @streak-glue/runtime

…which is both misleading and incorrect. A semantic version comparison (e.g., using the semver standard library) should be used so a warning is only shown when latestVersion is strictly greater than currentVersion.

Consider importing @std/semver and using greaterThan:

import { greaterThan, parse } from "@std/semver";

// ...
if (!greaterThan(parse(latestVersion), parse(currentVersion))) {
  return undefined;
}

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a background check to notify users when the @streak-glue/runtime version is outdated, along with a new utility for Deno configuration discovery and a global verbose flag. Feedback recommends making the version check non-blocking to improve startup performance, guarding UI updates to prevent errors after the UI has unmounted, and utilizing safer parsing for the Deno lockfile to enhance robustness.

Comment thread commands/dev.ts
const lifelineReconnectionEvents = pushableV<void>({ objectMode: true });

const glueName = await getGlueName(filename, options.name);
await warnIfStreakRuntimeIsOutdated(filename, options.verbose);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Awaiting warnIfStreakRuntimeIsOutdated here blocks the startup of the dev session until the network request to JSR completes. This can cause the CLI to feel unresponsive for several seconds on slower connections. It is better to trigger this check in the background to allow the dev server to start immediately.

Suggested change
await warnIfStreakRuntimeIsOutdated(filename, options.verbose);
warnIfStreakRuntimeIsOutdated(filename, options.verbose);

Comment thread commands/dev.ts
Comment on lines +514 to +527
async function warnIfStreakRuntimeIsOutdated(filename: string, verbose: boolean): Promise<void> {
try {
const outdatedRuntime = await getOutdatedStreakRuntimeVersion(filename);
if (!outdatedRuntime) {
return;
}
devProgressProps.outdatedRuntimeWarningInfo = outdatedRuntime;
renderUI();
} catch (e) {
if (verbose) {
console.error("Caught error:", e);
}
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

When running the version check in the background, we should ensure that renderUI() is only called if the UI is still active. This prevents a "zombie" UI from being rendered if the check completes after the setup phase has finished and the UI has been unmounted.

async function warnIfStreakRuntimeIsOutdated(filename: string, verbose: boolean): Promise<void> {
  try {
    const outdatedRuntime = await getOutdatedStreakRuntimeVersion(filename);
    if (!outdatedRuntime) {
      return;
    }
    devProgressProps.outdatedRuntimeWarningInfo = outdatedRuntime;
    if (inkInstance) {
      renderUI();
    }
  } catch (e) {
    if (verbose) {
      console.error("Caught error:", e);
    }
  }
}

Comment thread lib/runtimeVersionCheck.ts
@Macil Macil merged commit b06ab7e into master Apr 3, 2026
2 checks passed
@Macil Macil deleted the chris/upgradeNotice branch April 3, 2026 01:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant