Skip to content

Show a lobby notice when a newer release is out - #545

Merged
jserv merged 2 commits into
sysprog21:mainfrom
LJY2000-max:feature/update-notice
Oct 30, 2026
Merged

jserv merged 2 commits into
sysprog21:mainfrom
LJY2000-max:feature/update-notice

Conversation

@LJY2000-max

@LJY2000-max LJY2000-max commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

The macOS release binary can now tell the candidate when the rolling latest release is a newer build, in the scope agreed on #543.

How it is enabled: CODETRIAL_UPDATE_CHECK=true in config/codetrial.env.local. It is off by default, and documented in docs/install.md, the README configuration table and config/codetrial.env.example.

What it does: the server asks GitHub (GET /repos/sysprog21/codetrial/releases/tags/latest) which commit latest names, caches the answer for ten minutes (kept even when the lobby that asked goes away mid-request), and answers /api/update with whether that differs from the build. The lobby asks when it loads, which covers both starting the binary and coming back from an interview, since leaving an interview navigates to /, and on every hour it stays open. An interview replaces the lobby page, so nothing is checked during one. A newer release shows a card in the lobby's corner with both commits and a link to the release page; its message is a status line, written a frame after the card shows so it is announced without taking focus. A later answer that no longer names a newer release, or a release dismissed in another tab, takes the card down. Dismissing it stores that release's commit and hides the card until a different one is named. The page's connect-src is unchanged.

When nothing is compared: the setting is off, the build is not macOS, CODETRIAL_BUILD_COMMIT did not come from GITHUB_SHA, or the server was started with --no-update-check, which the desktop app passes because it is published as desktop-latest and latest never names its server. build.rs now records the last as CODETRIAL_RELEASE_COMMIT, empty for a local build. The server then answers enabled: false, asks GitHub nothing, and the lobby stops asking. Every GitHub failure (no network, an error status or rate limit, the 404 while latest is republished, a body without a full commit) answers "no update" and shows nothing, and the lobby keeps checking on the hour; a lobby that cannot reach its own server stops until the next load.

/api/update answers without a session, like /api/session: both commits are public, and the cache means a caller cannot make the server ask GitHub more often.

Tests: tests/unit/web/update.rs runs the lookup against a stub GitHub for the matching-commit, differing-commit and failed-check cases (500, 403, 429, 404, a missing, short or non-hex target_commitish, a closed port), for the cache, and for a lookup whose caller went away mid-request; tests/web/update.rs goes through the router and shows a server with the check off makes no request to the stub; tests/config.rs pins the opt-in, platform and CI-commit rule, and checks that a CI build records its GITHUB_SHA as the release commit, which fails with build.rs recording nothing; tests/unit/bin.rs and desktop/tests/unit/server.rs cover --no-update-check and the launcher passing it; tests/browser/update-notice.test.js covers what the lobby shows, when its message is written, following a later release, taking it down without moving focus that was elsewhere, dismissing, the hourly schedule staying single across a restored page, and the stops, plus one Chromium run of the real lobby by keyboard. Each new assertion was checked to fail with its change reverted. The route allowlists in tests/web/routes.rs and tests/web/accounts.rs list the new route.

Validation, on the single commit rebased onto 38d53a7: ./scripts/test.sh rust, ./scripts/test.sh portable and the three browser shards pass locally, cargo clippy --all-targets -- -D warnings is clean, and cargo test in desktop/ passes. cargo-mutants was not available here, so the four mutants the gate missed, and the new flag's comparison and override, were applied by hand: each fails a test. The same was done for every new branch in web/update-notice.js, which the mutation gate does not cover.

Manual check on an Apple Silicon Mac, against the real GitHub API, with builds from this branch:

  1. Older build, check on: built with GITHUB_SHA set to an older commit of main and CODETRIAL_UPDATE_CHECK=true. The notice shows both commits, and its link opens the release page.

VIDEO 1 HERE <<<

normal.mov
  1. Dismissed: after Dismiss and a reload, the notice stays hidden.

VIDEO 2 HERE <<<

dismiss.mov
  1. Current build: no notice shows when the build is the one latest names.
    • Read the commit latest names: git ls-remote https://github.com/sysprog21/codetrial refs/tags/latest.
    • With CODETRIAL_UPDATE_CHECK=true still set, start the server built from that commit: GITHUB_SHA=<that commit> make web.
    • Remove codetrial:updateDismissed from the page's local storage, so the dismissal from step 2 does not hide the result, and reload the lobby.
    • No notice shows, and curl -s http://127.0.0.1:3000/api/update answers {"available":false,"enabled":true}.

VIDEO 3 HERE <<<

Latest.mp4
  1. Check off: nothing is compared, even for an older build, when the setting is absent.
    • Remove CODETRIAL_UPDATE_CHECK=true from config/codetrial.env.local.
    • Start the server built from the older commit of step 1: GITHUB_SHA=<older commit> make web.
    • Reload the lobby: no notice shows, and curl -s http://127.0.0.1:3000/api/update answers {"enabled":false}.

VIDEO 4 HERE <<<

default.mp4

Close #543


Summary by cubic

The macOS release binary now shows a lobby notice when the rolling latest release names a newer build, behind CODETRIAL_UPDATE_CHECK=true (off by default). Closes #543.

How it works

  • The server asks GitHub which commit latest names, caches the answer for ten minutes, and answers /api/update; the lobby checks on load and hourly.
  • A newer release shows a card in the lobby corner with both commits and a link to the release page; dismissing it hides it until a different release is named.
  • The status line is written a frame after the card shows so screen readers announce it, and a later check that names no newer release takes the card down.
  • Every GitHub failure answers "no update" and shows nothing, and the page's connect-src is unchanged.

When nothing is compared

  • The check runs only in a macOS build CI made: build.rs records the GITHUB_SHA commit as CODETRIAL_RELEASE_COMMIT, and other builds answer enabled: false and ask GitHub nothing.
  • The desktop app always passes --no-update-check, overriding its config file, because it is published as desktop-latest.

Manual check on an Apple Silicon Mac, against the real GitHub API, with builds from this branch:

  1. Older build, check on: the notice shows both commits, and its link opens the release page.
  2. Dismissed: after Dismiss and a reload, the notice stays hidden.
  3. Current build: no notice shows when the build is the one latest names.
  4. Check off: nothing is compared, even for an older build, when the setting is absent.

Written for commit d4e1576. Summary will update on new commits.

View guided diff

Comment thread web/update-notice.js Resolved
Comment thread web/update-notice.js Resolved
Comment thread src/config.rs Resolved
jserv

This comment was marked as outdated.

@jserv
jserv requested review from ColtenOuO and alanhc October 29, 2026 13:54
Comment thread docs/install.md Resolved
Comment thread src/web/update.rs Resolved
Comment thread src/main.rs Resolved
@jserv

jserv commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Some review comments on this pull request are not settled yet. Please refine the change per the review comments listed below, reply on each thread with what you changed or why you did not, and mark each thread resolved yourself once it is settled (Resolve conversation, at the bottom of the thread). The pull request stays blocked while review threads are open.

Not addressed at the current head:

Checked at d883e8d.

jserv

This comment was marked as outdated.

@jserv

jserv commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Some review comments on this pull request are not settled yet. Please refine the change per the review comments listed below, reply on each thread with what you changed or why you did not, and mark each thread resolved yourself once it is settled (Resolve conversation, at the bottom of the thread). The pull request stays blocked while review threads are open.

Not addressed at the current head:

Addressed at the current head; reply with what changed and resolve:

Checked at d0fa163.

@jserv

jserv commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

此拉取請求中的一些審核意見尚未解決。請根據下方列出的審核意見完善更改,並在每個討論串中回覆說明您更改了什麼或未更改的原因,並在問題解決後自行將每個討論串標記為已解決(在討論串底部點擊「解決對話」)。審核討論串開放期間,拉取請求將維持阻塞狀態。

Always post in American English unless you are working on CJK-specific localization. As a computer science student, you should develop an international outlook and communicate your expertise to a global audience.

@LJY2000-max

LJY2000-max commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor Author

Always post in American English unless you are working on CJK-specific localization. As a computer science student, you should develop an international outlook and communicate your expertise to a global audience.

Thank you for the correction and advice! I have updated the previous comment back to American English and will keep this in mind going forward.

@ColtenOuO

Copy link
Copy Markdown
Collaborator

Commit d883e8d isn't the latest commit... please double-check the details before replying. Also, I suggest squashing your commits.

@LJY2000-max
LJY2000-max force-pushed the feature/update-notice branch from d0fa163 to 241afc5 Compare October 29, 2026 17:23
@sysprog21 sysprog21 deleted a comment from LJY2000-max Oct 30, 2026
@sysprog21 sysprog21 deleted a comment from LJY2000-max Oct 30, 2026
@jserv

jserv commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

@LJY2000-max, When using AI tools, don’t ask them to translate review comments into Chinese. Use English as your working language, including your prompts and follow-up interactions. This can make token use more efficient while giving you practical experience communicating in English with AI assistance.

Otherwise, you remain merely an AI tool operator, much like a convenience store clerk heating different foods in a microwave. You may appear to serve a variety of meals, but that does not mean you understand the food or even have the skills of a waiter.

In the AI era, make sure these tools help you grow as a person. Do not let yourself become a subject of alienation: someone who pays to sustain AI services and supplies data for them to mine, yet gains little personal growth in return.

Comment thread web/update-notice.js Resolved
Comment thread web/update-notice.js Resolved
@jserv

jserv commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Some review comments on this pull request are not settled yet. Please refine the change per the review comments listed below, reply on each thread with what you changed or why you did not, and mark each thread resolved yourself once it is settled (Resolve conversation, at the bottom of the thread). The pull request stays blocked while review threads are open.

Not addressed at the current head:

Checked at 241afc5.

@LJY2000-max
LJY2000-max force-pushed the feature/update-notice branch from 241afc5 to 5db4083 Compare October 30, 2026 08:09

@jserv jserv left a comment

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.

Rebase the current branch onto the upstream default branch and resolve any conflicts. Run /codetrial-review in AI agents (use $codetrial-review in Codex) and resolve all identified issues. Rework the series into minimal, logically coherent commits, squash closely related commits, and ensure all commit messages follow the project’s rules.

@sysprog21 sysprog21 deleted a comment from LJY2000-max Oct 30, 2026
@LJY2000-max

Copy link
Copy Markdown
Contributor Author

@LJY2000-max, When using AI tools, don’t ask them to translate review comments into Chinese. Use English as your working language, including your prompts and follow-up interactions. This can make token use more efficient while giving you practical experience communicating in English with AI assistance.

Otherwise, you remain merely an AI tool operator, much like a convenience store clerk heating different foods in a microwave. You may appear to serve a variety of meals, but that does not mean you understand the food or even have the skills of a waiter.

In the AI era, make sure these tools help you grow as a person. Do not let yourself become a subject of alienation: someone who pays to sustain AI services and supplies data for them to mine, yet gains little personal growth in return.

Thank you, Professor Jserv, for the thoughtful advice and guidance, as well as for sharing a practical tip on saving tokens that I was previously unaware of.

jserv
jserv previously requested changes Oct 30, 2026

@jserv jserv left a comment

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.

Rebase onto latest main branch and resolve conflicts.

@LJY2000-max
LJY2000-max force-pushed the feature/update-notice branch from 5db4083 to 94bdf55 Compare October 30, 2026 08:50
@jserv
jserv dismissed their stale review October 30, 2026 08:55

No merge conflicts at the current head.

@jserv

jserv commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

The title reads "Show a lobby notice when a newer release is outFeature/update notice", with the branch name appended. Please edit it to "Show a lobby notice when a newer release is out".

tests/web/accounts.rs sits at its 1900-line ceiling, so any route added
to the router, which this test has to classify, would push it over.
The test checks the router's shape rather than anything about accounts:
every declared route is owner-scoped or anonymous, and every
owner-scoped one refuses a request without a session. The router's
shape is tested in tests/web/routes.rs, so it moves there unchanged,
and the accounts ceiling ratchets down to what the file now holds.
A candidate running the macOS binary from the rolling latest release
had no way to learn that a newer build existed short of comparing
commits on the releases page by hand, since the package version never
changes. With CODETRIAL_UPDATE_CHECK=true the server asks GitHub which
commit latest names, caches the answer for ten minutes, and answers
/api/update with whether it differs from the build; the lobby asks when
it loads, which covers starting the binary and coming back from an
interview, and on every hour it stays open. A newer release shows a
notice linking to the release, written a frame after it appears so its
status line is announced; dismissing it hides it for that release, and
a later answer that no longer names a newer one takes it down. The
page's connect-src is unchanged and every failure shows nothing.

The check is off by default, since it reaches GitHub from the server
with nobody signing in, and runs only in a macOS build CI made: build.rs
now records whether the commit came from GITHUB_SHA, because a local
build's HEAD is a commit latest will never name, and a test holds that
record to the GITHUB_SHA CI sets. The desktop app starts its server
with the new --no-update-check, since it is published as
desktop-latest and latest never names the server inside it.

Close sysprog21#543
@jserv
jserv requested a review from Patriciaath999 October 30, 2026 09:19
@LJY2000-max
LJY2000-max force-pushed the feature/update-notice branch from 94bdf55 to d4e1576 Compare October 30, 2026 09:42
@LJY2000-max LJY2000-max changed the title Show a lobby notice when a newer release is outFeature/update notice Show a lobby notice when a newer release is out Oct 30, 2026
@LJY2000-max

Copy link
Copy Markdown
Contributor Author

The title reads "Show a lobby notice when a newer release is outFeature/update notice", with the branch name appended. Please edit it to "Show a lobby notice when a newer release is out".

I have updated the PR title.

@ColtenOuO ColtenOuO left a comment

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.

LGTM.

@jserv
jserv merged commit f9a7085 into sysprog21:main Oct 30, 2026
19 checks passed
@jserv

jserv commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Thank @LJY2000-max for contributing!

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.

Tell macOS binary users when a newer release is available

3 participants