Skip to content

fix: read tool state from the composer the prompt is typed into - #86

Merged
youdie006 merged 1 commit into
mainfrom
fix/tool-state-visible-composer
Nov 3, 2026
Merged

youdie006 merged 1 commit into
mainfrom
fix/tool-state-visible-composer

Conversation

@youdie006

Copy link
Copy Markdown
Owner

Problem

activeComposerToolsExpression decides whether a --tool selection took effect. It read the first editor in the document. A new chat leaves the home page's composer mounted in a workspace with display: none, ahead of the conversation's composer. So a follow-up with --tool in the same tab turned the tool on in the visible composer but read the hidden one. The send was then refused with Selected "Web search" but the composer never showed it as active., and the tool was left on in the composer.

composerToolsButtonRectExpression took the first visible editor, as the model lookup did before #85. With "Edit message" open, a --tool send could not find the tools button.

Evidence (2026-11-03, WSL browser container, test conversation, no project)

  • Right after a new chat, the workspaces read HS (hidden, shown), and document.querySelector('#prompt-textarea,[contenteditable="true"]') returned the hidden workspace's editor (0x0). #prompt-textarea no longer exists on the page.
  • A follow-up with tools: ["Web search"] through the deployed container code was refused as above. Read afterwards, the visible composer showed Web search and the hidden form Thinking effortPro.
  • The container branch built with this change sent the same kind of follow-up from the same state, with status: done.
  • The tool tokens left in the test composer were cleared afterwards.

Change

Verification

  • New tests/composer-tool-state.test.ts, three cases: a hidden workspace's composer ahead of the visible one, a tool shown only by the hidden one, and an open message editor ahead of the composer. All three failed before the change and pass after.
  • npx tsc --noEmit clean.
  • npm test: 1858 passed, 3 skipped. Two package-bin tests failed only because the new worktree had no dist/; they pass after npm run build.

The container branch gets the same activeComposerToolsExpression change. Its tools button lookup is already covered by its composer exclusion fix (8ce48b9).

Claude-Session: https://claude.ai/code/session_01EMqNwnnhHXznd2P2PDsaDV

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

What this touches

  • browser adapter
  • tests

3 file(s), 177 line(s) changed. Tests changed.

This is an automated first pass, not a review. CI is the gate; a person decides.

@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-03T01:55:55.409800Z a39e12e 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.

youdie006 added a commit that referenced this pull request Nov 3, 2026
Port of main PR #86. activeComposerToolsExpression read the first editor in
the document. After a new chat that is the home page's composer, mounted in
a hidden workspace ahead of the conversation's, so a follow-up with --tool
turned the tool on in the visible composer, read the hidden one, and was
refused with "Selected "Web search" but the composer never showed it as
active." It now reads findChatGptComposerCandidate.

Measured 2026-11-03 in the WSL container on a test conversation: the
deployed code refused a Web search follow-up as above with the tool showing
in the visible composer; this branch built with the change, run from a temp
path inside the container, sent the same follow-up (status done).

The tools button case in tests/composer-tool-state.test.ts already passes
here through 8ce48b9's exclusion of message search units.

Verified: the two tool-state cases failed before the change and pass after;
npx tsc --noEmit clean; npm test 2175 passed, 3 skipped.

Claude-Session: https://claude.ai/code/session_01EMqNwnnhHXznd2P2PDsaDV
activeComposerToolsExpression read document.querySelector of the first
editor on the page. A new chat leaves the home page's composer mounted in a
workspace with display: none, ahead of the conversation's composer, so a
follow-up with --tool turned the tool on in the visible composer, read the
hidden one ("Thinking effortPro"), and was refused with "Selected "Web
search" but the composer never showed it as active." The tool stayed on in
the composer afterwards. It now reads findChatGptComposerCandidate, the
composer typing uses (visible, outside messages).

composerToolsButtonRectExpression took the first visible editor, the same
way the model lookup did before PR #85, so an open "Edit message" editor
made a --tool send fail to find the tools button. It now skips editors
inside a message.

Measured 2026-11-03 in the WSL browser container on a test conversation
(prompt "Reply with only the word OK", no project): after a new chat the
first editor in the document was the hidden workspace's (0x0), and a
follow-up with tools ["Web search"] was refused as above by the deployed
check while the visible composer showed the tool. The container branch
built with the same change sent that follow-up (status done).

Verified: tests/composer-tool-state.test.ts (three cases) failed before the
change and passes after; npx tsc --noEmit clean; npm test 1858 passed and
3 skipped, plus the 2 package-bin tests that need dist/, which pass after
npm run build.

Claude-Session: https://claude.ai/code/session_01EMqNwnnhHXznd2P2PDsaDV
@youdie006
youdie006 force-pushed the fix/tool-state-visible-composer branch from a39e12e to d959e44 Compare November 3, 2026 02:02
@youdie006
youdie006 merged commit e70e7af into main Nov 3, 2026
7 checks passed
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