Skip to content

Read the desktop New chat button contract token by token - #12426

Merged
danielhanchen merged 3 commits into
mainfrom
fix/desktop-new-chat-button-contract
Oct 1, 2026
Merged

danielhanchen merged 3 commits into
mainfrom
fix/desktop-new-chat-button-contract

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Problem

Repo tests (CPU, studio) is red on main, and so on every PR based on it (for example #12393, and the post-merge run of #12406):

FAILED tests/studio/test_desktop_reliability_frontend_contract.py::test_collapsed_tauri_keeps_history_arrows_and_adds_new_chat_by_model_picker
assert 'className="!size-[30px] rounded-[10px] text-muted-foreground"' in '// SPDX-License-Identifier: AGPL-3.0-only ...

#12355 ("compact context usage ring when the chat header is squeezed") changed the desktop New chat button in chat-page.tsx to:

className="!size-[calc(30px*var(--ui-space-scale,1))] shrink-0 rounded-[10px] text-muted-foreground"

That is deliberate. It scales the 30px box with the UI font size, the same way #11458 did for the other chrome, and keeps the button from shrinking when the header is squeezed. It is still the same 30px rounded square with a muted icon. The test pinned the whole class string, so any change to how that size is written fails it.

Fix

The test now reads the className of the element carrying aria-label="New chat" and checks the tokens that make up the contract:

  • exactly one !size-[...] token, and it is 30px (scaled or not);
  • rounded-[10px];
  • text-muted-foreground.

The element is found by scanning its opening tag outside braces and quotes, so attribute order does not matter. The other assertions in the test are unchanged. No product change.

Verification

  • tests/studio/test_desktop_reliability_frontend_contract.py: 42 passed (the test fails on main).
  • Three sabotages of the button in chat-page.tsx each fail the test: 30px changed to 28px, rounded-[10px] changed to rounded-md, and text-muted-foreground changed to text-foreground.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 1, 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-10-01T11:55:11.601491Z cbeeba6 Manual request
🔒 Security Review ⚠️ Failed 2026-10-01T11:09:37.831355Z 5f91614 PR opened
ℹ️ 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 Summary

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

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-01T11:09:36.674231Z 5f91614 Manual request
🔒 Security Review ⚠️ Failed 2026-10-01T11:09:37.831355Z 5f91614 PR opened
ℹ️ 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 chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5f91614030

ℹ️ 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".

# square, rounded box and muted icon it always was.
new_chat_tokens = _new_chat_button_class_tokens(chat_page)
size_tokens = [t for t in new_chat_tokens if t.startswith("!size-[")]
assert len(size_tokens) == 1 and re.search(r"(?<![\d.])30px", size_tokens[0]), new_chat_tokens

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Require the size token to equal 30px

When the class is changed to something such as !size-[calc(30px+20px)], !size-[min(30px,1px)], or even the invalid !size-[30px, this assertion still passes because it only searches for a standalone 30px substring. The button therefore need not remain a 30px square despite this test's stated contract. Since _ui_source already normalizes the supported UI-scale wrapper to !size-[30px], this can require the complete token rather than accepting any token containing that substring.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in e0c8833: the size token must now equal !size-[30px] as read at the default UI scale.

@danielhanchen danielhanchen self-assigned this Oct 1, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e0c8833f86

ℹ️ 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".

Comment on lines +760 to +762
assert "!size-[30px]" in new_chat_tokens, new_chat_tokens
assert "rounded-[10px]" in new_chat_tokens, new_chat_tokens
assert "text-muted-foreground" in new_chat_tokens, new_chat_tokens

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reject utilities that override the required button styles

If a later conflicting utility is added, such as !size-[30px] !size-[50px], rounded-[10px] rounded-none, or text-muted-foreground text-red-500, all three assertions still pass even though Button sends the classes through cn/tailwind-merge, which retains the later utility and changes the rendered button. Fresh evidence after the exact-token fix is that twMerge('!size-[30px] !size-[50px]') produces !size-[50px]; validate the effective/conflicting utility groups rather than membership alone.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Not changing: this is a source contract test, and a second conflicting size, radius or colour utility on the same button is not a change anyone would make by accident; checking tailwind-merge groups here would be test hardening past the contract the test pins.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e0c8833f86

ℹ️ 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".

Comment on lines +694 to +695
label = chat_page.index('aria-label="New chat"')
start = chat_page.rindex("<Button", 0, label)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Bind the label to the parsed Button tag

If aria-label="New chat" is moved onto a child icon or an unrelated later element, label still points after this <Button, so rindex selects the button and the helper returns its classes even though the label is not in that opening tag. The separate global label assertion also passes, allowing the contract to stay green after the New chat button itself loses the required label; verify that the located label occurs before the parsed opening-tag terminator.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in cbeeba6. The helper now asserts that the located aria-label="New chat" falls inside the parsed <Button> opening tag. Moving the label onto the icon inside the button fails the test with that message; I checked it that way.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: cbeeba6a24

ℹ️ 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 813cee7 into main Oct 1, 2026
0 of 15 checks passed
@danielhanchen
danielhanchen deleted the fix/desktop-new-chat-button-contract branch October 1, 2026 12:21
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