Skip to content

Tray status test: end the listener slice at its own close - #16600

Merged
danielhanchen merged 1 commit into
mainfrom
dh/tray-listener-slice
Nov 3, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
dh/tray-listener-slice

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

studio/frontend/tests/tray-server-status.test.ts misreads the tray listener whenever the listener contains a nested });. It fails #16581, which only adds a .catch to the tray stop. That failure breaks both Frontend unit tests (Windows) and Frontend build + bundle sanity:

not ok - the tray offers a click exactly when the listener would act on it
  a tray toggle is clickable for a status the renderer silently drops, or greyed for one it would have handled
  actual (main.rs enables):        ['error', 'running', 'stopped']
  expected (listener acts on):     ['running']

The listener in #16581 still handles running, stopped and error, exactly as on main:

register<void>("tray-toggle-server", () => {
  if (statusRef.current === "running") {
    stopServer().catch((e) => {
      toast.error("Could not stop the server", { description: String(e) });
    });
  } else if (
    statusRef.current === "stopped" ||
    statusRef.current === "error"
  ) {

actionableStatuses cut the listener at the first }); after register<void>("tray-toggle-server". With the .catch in place, that is the end of the .catch call, so the stopped / error branch was never read. The guard itself is useful: the tray item in main.rs and the renderer's listener must agree on the statuses. Only the slice was fragile, and the PR is fine.

Change

studio/frontend/tests/tray-server-status.test.ts, actionableStatuses only: the slice now ends at the }); on the register call's own indentation, which is the same indent-matching approach hookFunction in this file already uses. If the call stops starting its own line, the test throws a clear error instead of silently reading too little.

Testing

node --test tests/tray-server-status.test.ts:

hook old test this branch
main's use-tauri-backend.ts 6 pass 6 pass
#16581's use-tauri-backend.ts 5 pass, 1 fail (above) 6 pass
#16581's hook with its error check pointed at a status that does not exist n/a 5 pass, 1 fail

The last row shows the guard still catches a listener that drops a status the tray enables.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-03T23:39:49.441016Z 93fbee5 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 93fbee5083

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen
danielhanchen merged commit 6f79197 into main Nov 3, 2026
@danielhanchen
danielhanchen deleted the dh/tray-listener-slice branch November 3, 2026 23:45
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