Repository navigation
Show the reasoning level of the running turn - #777
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bf76138402
ℹ️ 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".
| // would invite clicks that do nothing. It still answers the question | ||
| // that matters while a turn runs, which budget is this one spending. | ||
| <span | ||
| title={t("chat.currentReasoning", { level: thinkingDisplayLabel })} |
There was a problem hiding this comment.
Show the effective reasoning level instead of
auto
When an existing session previously used an explicit level and the user selects “Use pi default,” handleThinkingLevelChange sets the client state to auto but returns without updating the runtime, so the agent retains the previous level. On the next prompt this new badge therefore reports auto as the current turn's level even though, for example, high is actually being used. Capture or synchronize the runtime's effective level when the turn starts rather than rendering the selector state directly.
Useful? React with 👍 / 👎.
|
Addressed in 37b6553. When a turn starts, the client reads the runtime's thinking level from the agent state and adopts it, so the label reports the level actually in effect even after "Use pi default" left an earlier explicit level in place. The dropdown reflects the same value once the turn ends. |
The reasoning control is hidden while a turn streams because the level cannot be changed mid-turn. That also hides the level itself, exactly when it decides how long the turn runs and how much budget it spends. Render the active level as a read-only label in the same slot while streaming. It is not a button: nothing can change until the turn ends, so a clickable control would only invite clicks that do nothing. The label reuses the existing display label, icon, padding, height, and mobile collapse rule, so the control row keeps its spacing next to Stop.
Choosing "Use pi default" sets the selector to "auto" without touching the runtime, so the runtime can keep an earlier explicit level. Rendering the selector state while streaming would then label a turn "auto" that is in fact running at, say, "high". When a turn starts, read the runtime's thinking level from the agent state and adopt it, so the read-only label and the selector both reflect the level in effect. The lookup is skipped if the turn has already ended.
37b6553 to
6898cd6
Compare
SameSite=Strict drops the session cookie on external top-level navigations (common on mobile), forcing a re-login while in-page XHR still works. Fixes agegr#806
Patches GHSA-2xp9-vwfh-vxw4 / GHSA-p293-qw3h-jr36 (unauthenticated RCE in [email protected]) and pulls sharp 0.35.4 for the libheif advisories via npm audit fix. next/image is only used for the static logo, so the /_next/image endpoint is turned off entirely with images.unoptimized. Co-authored-by: Cursor <[email protected]>
scrollIntoView({ block: "nearest" }) parked the keyboard-selected option flush
against the scroll container, where whole-pixel scroll snapping left it a
fraction of a pixel outside the viewport and overflow clipping cut off its
focus ring. Give options a scroll-margin equal to the container padding so
navigation always lands them fully visible; this also unblocks the e2e
"Keyboard selection must scroll into view" assertion.
Co-authored-by: Cursor <[email protected]>
Route handlers have no reliable client address, so a per-IP limiter would be spoofable via x-forwarded-for and empty for direct 127.0.0.1 access. Use one shared exponential backoff (1s doubling to 60s) for POST /api/web-auth instead; a success or five idle minutes resets it. Return 429 with Retry-After while blocked and surface the wait on the login page. Co-authored-by: Cursor <[email protected]>
Co-authored-by: Cursor <[email protected]>
agegr
left a comment
There was a problem hiding this comment.
Small, focused, and answers a real question during a long turn. Approving.
I merged current main into the branch and tightened the turn-start fetch you added in 37b6553: it now captures sid and promptRunIdRef before the request and drops the response if either changed while it was in flight — the same guard reconcileAgentState uses — so a slow reply cannot set the level for a different session or a later run. Test updated to match.
Verified: tsc, eslint, ChatInput* and hooks/* tests pass.
Show the resolved runtime level instead of the auto placeholder, and keep the same disabled control while a turn runs. Auto stays an uncommitted default, matching isAutoModelSelection. Co-authored-by: Cursor <[email protected]>
* Show the reasoning level of the running turn The reasoning control is hidden while a turn streams because the level cannot be changed mid-turn. That also hides the level itself, exactly when it decides how long the turn runs and how much budget it spends. Render the active level as a read-only label in the same slot while streaming. It is not a button: nothing can change until the turn ends, so a clickable control would only invite clicks that do nothing. The label reuses the existing display label, icon, padding, height, and mobile collapse rule, so the control row keeps its spacing next to Stop. * Address review: show the level the turn actually runs with Choosing "Use pi default" sets the selector to "auto" without touching the runtime, so the runtime can keep an earlier explicit level. Rendering the selector state while streaming would then label a turn "auto" that is in fact running at, say, "high". When a turn starts, read the runtime's thinking level from the agent state and adopt it, so the read-only label and the selector both reflect the level in effect. The lookup is skipped if the turn has already ended. * Align new session branding with chat input * fix: preserve UNC roots in file API paths * fix(auth): use SameSite=Lax for pi_web_session cookie (agegr#818) SameSite=Strict drops the session cookie on external top-level navigations (common on mobile), forcing a re-login while in-page XHR still works. Fixes agegr#806 * fix: preserve newlines in extension dialog titles like pi's TUI * fix(deps): upgrade Next.js to 16.3.5 and disable image optimizer Patches GHSA-2xp9-vwfh-vxw4 / GHSA-p293-qw3h-jr36 (unauthenticated RCE in [email protected]) and pulls sharp 0.35.4 for the libheif advisories via npm audit fix. next/image is only used for the static logo, so the /_next/image endpoint is turned off entirely with images.unoptimized. Co-authored-by: Cursor <[email protected]> * fix: keep focused extension select option clear of the scroller edge scrollIntoView({ block: "nearest" }) parked the keyboard-selected option flush against the scroll container, where whole-pixel scroll snapping left it a fraction of a pixel outside the viewport and overflow clipping cut off its focus ring. Give options a scroll-margin equal to the container padding so navigation always lands them fully visible; this also unblocks the e2e "Keyboard selection must scroll into view" assertion. Co-authored-by: Cursor <[email protected]> * fix(auth): throttle web password failures with global backoff Route handlers have no reliable client address, so a per-IP limiter would be spoofable via x-forwarded-for and empty for direct 127.0.0.1 access. Use one shared exponential backoff (1s doubling to 60s) for POST /api/web-auth instead; a success or five idle minutes resets it. Return 429 with Retry-After while blocked and surface the wait on the login page. Co-authored-by: Cursor <[email protected]> * Guard the turn-start thinking-level fetch against session/run races Co-authored-by: Cursor <[email protected]> * Align thinking-level display with model selection Show the resolved runtime level instead of the auto placeholder, and keep the same disabled control while a turn runs. Auto stays an uncommitted default, matching isAutoModelSelection. Co-authored-by: Cursor <[email protected]> --------- Co-authored-by: wayne.luo <[email protected]> Co-authored-by: Alex Yang <[email protected]> Co-authored-by: richardmilles <[email protected]> Co-authored-by: Cursor <[email protected]> (cherry picked from commit 3f07a5f)
) The reasoning control was disabled for the whole run on the assumption that the level cannot change mid-turn (#777). pi-agent-core does snapshot `reasoning` into the loop config when a run starts, but AgentSession's prepareRequest / prepareNextTurnWithContext hooks re-read agent.state.thinkingLevel before every model request, and pi's TUI lets Shift+Tab change it during a run. So set_thinking_level mid-run applies from the next request; only the response already streaming keeps its level. The server never refused the command, only the composer did. Keep the control usable while streaming and stop closing its menu when a run starts. The tooltip is unchanged. An integration test drives a real AgentSession with the faux provider and changes the level while the first request streams: the requests go out at low, then high. That pins the SDK behavior the control now relies on across SDK upgrades. Co-authored-by: Claude Opus 5.5 <[email protected]>
* Show the reasoning level of the running turn The reasoning control is hidden while a turn streams because the level cannot be changed mid-turn. That also hides the level itself, exactly when it decides how long the turn runs and how much budget it spends. Render the active level as a read-only label in the same slot while streaming. It is not a button: nothing can change until the turn ends, so a clickable control would only invite clicks that do nothing. The label reuses the existing display label, icon, padding, height, and mobile collapse rule, so the control row keeps its spacing next to Stop. * Address review: show the level the turn actually runs with Choosing "Use pi default" sets the selector to "auto" without touching the runtime, so the runtime can keep an earlier explicit level. Rendering the selector state while streaming would then label a turn "auto" that is in fact running at, say, "high". When a turn starts, read the runtime's thinking level from the agent state and adopt it, so the read-only label and the selector both reflect the level in effect. The lookup is skipped if the turn has already ended. * Align new session branding with chat input * fix: preserve UNC roots in file API paths * fix(auth): use SameSite=Lax for pi_web_session cookie (agegr#818) SameSite=Strict drops the session cookie on external top-level navigations (common on mobile), forcing a re-login while in-page XHR still works. Fixes agegr#806 * fix: preserve newlines in extension dialog titles like pi's TUI * fix(deps): upgrade Next.js to 16.3.5 and disable image optimizer Patches GHSA-2xp9-vwfh-vxw4 / GHSA-p293-qw3h-jr36 (unauthenticated RCE in [email protected]) and pulls sharp 0.35.4 for the libheif advisories via npm audit fix. next/image is only used for the static logo, so the /_next/image endpoint is turned off entirely with images.unoptimized. Co-authored-by: Cursor <[email protected]> * fix: keep focused extension select option clear of the scroller edge scrollIntoView({ block: "nearest" }) parked the keyboard-selected option flush against the scroll container, where whole-pixel scroll snapping left it a fraction of a pixel outside the viewport and overflow clipping cut off its focus ring. Give options a scroll-margin equal to the container padding so navigation always lands them fully visible; this also unblocks the e2e "Keyboard selection must scroll into view" assertion. Co-authored-by: Cursor <[email protected]> * fix(auth): throttle web password failures with global backoff Route handlers have no reliable client address, so a per-IP limiter would be spoofable via x-forwarded-for and empty for direct 127.0.0.1 access. Use one shared exponential backoff (1s doubling to 60s) for POST /api/web-auth instead; a success or five idle minutes resets it. Return 429 with Retry-After while blocked and surface the wait on the login page. Co-authored-by: Cursor <[email protected]> * Guard the turn-start thinking-level fetch against session/run races Co-authored-by: Cursor <[email protected]> * Align thinking-level display with model selection Show the resolved runtime level instead of the auto placeholder, and keep the same disabled control while a turn runs. Auto stays an uncommitted default, matching isAutoModelSelection. Co-authored-by: Cursor <[email protected]> --------- Co-authored-by: wayne.luo <[email protected]> Co-authored-by: Alex Yang <[email protected]> Co-authored-by: richardmilles <[email protected]> Co-authored-by: Cursor <[email protected]>
agegr#1022) The reasoning control was disabled for the whole run on the assumption that the level cannot change mid-turn (agegr#777). pi-agent-core does snapshot `reasoning` into the loop config when a run starts, but AgentSession's prepareRequest / prepareNextTurnWithContext hooks re-read agent.state.thinkingLevel before every model request, and pi's TUI lets Shift+Tab change it during a run. So set_thinking_level mid-run applies from the next request; only the response already streaming keeps its level. The server never refused the command, only the composer did. Keep the control usable while streaming and stop closing its menu when a run starts. The tooltip is unchanged. An integration test drives a real AgentSession with the faux provider and changes the level while the first request streams: the requests go out at low, then high. That pins the SDK behavior the control now relies on across SDK upgrades. Co-authored-by: Claude Opus 5.5 <[email protected]>
* Show the reasoning level of the running turn The reasoning control is hidden while a turn streams because the level cannot be changed mid-turn. That also hides the level itself, exactly when it decides how long the turn runs and how much budget it spends. Render the active level as a read-only label in the same slot while streaming. It is not a button: nothing can change until the turn ends, so a clickable control would only invite clicks that do nothing. The label reuses the existing display label, icon, padding, height, and mobile collapse rule, so the control row keeps its spacing next to Stop. * Address review: show the level the turn actually runs with Choosing "Use pi default" sets the selector to "auto" without touching the runtime, so the runtime can keep an earlier explicit level. Rendering the selector state while streaming would then label a turn "auto" that is in fact running at, say, "high". When a turn starts, read the runtime's thinking level from the agent state and adopt it, so the read-only label and the selector both reflect the level in effect. The lookup is skipped if the turn has already ended. * Align new session branding with chat input * fix: preserve UNC roots in file API paths * fix(auth): use SameSite=Lax for pi_web_session cookie (agegr#818) SameSite=Strict drops the session cookie on external top-level navigations (common on mobile), forcing a re-login while in-page XHR still works. Fixes agegr#806 * fix: preserve newlines in extension dialog titles like pi's TUI * fix(deps): upgrade Next.js to 16.3.5 and disable image optimizer Patches GHSA-2xp9-vwfh-vxw4 / GHSA-p293-qw3h-jr36 (unauthenticated RCE in [email protected]) and pulls sharp 0.35.4 for the libheif advisories via npm audit fix. next/image is only used for the static logo, so the /_next/image endpoint is turned off entirely with images.unoptimized. Co-authored-by: Cursor <[email protected]> * fix: keep focused extension select option clear of the scroller edge scrollIntoView({ block: "nearest" }) parked the keyboard-selected option flush against the scroll container, where whole-pixel scroll snapping left it a fraction of a pixel outside the viewport and overflow clipping cut off its focus ring. Give options a scroll-margin equal to the container padding so navigation always lands them fully visible; this also unblocks the e2e "Keyboard selection must scroll into view" assertion. Co-authored-by: Cursor <[email protected]> * fix(auth): throttle web password failures with global backoff Route handlers have no reliable client address, so a per-IP limiter would be spoofable via x-forwarded-for and empty for direct 127.0.0.1 access. Use one shared exponential backoff (1s doubling to 60s) for POST /api/web-auth instead; a success or five idle minutes resets it. Return 429 with Retry-After while blocked and surface the wait on the login page. Co-authored-by: Cursor <[email protected]> * Guard the turn-start thinking-level fetch against session/run races Co-authored-by: Cursor <[email protected]> * Align thinking-level display with model selection Show the resolved runtime level instead of the auto placeholder, and keep the same disabled control while a turn runs. Auto stays an uncommitted default, matching isAutoModelSelection. Co-authored-by: Cursor <[email protected]> --------- Co-authored-by: wayne.luo <[email protected]> Co-authored-by: Alex Yang <[email protected]> Co-authored-by: richardmilles <[email protected]> Co-authored-by: Cursor <[email protected]>
agegr#1022) The reasoning control was disabled for the whole run on the assumption that the level cannot change mid-turn (agegr#777). pi-agent-core does snapshot `reasoning` into the loop config when a run starts, but AgentSession's prepareRequest / prepareNextTurnWithContext hooks re-read agent.state.thinkingLevel before every model request, and pi's TUI lets Shift+Tab change it during a run. So set_thinking_level mid-run applies from the next request; only the response already streaming keeps its level. The server never refused the command, only the composer did. Keep the control usable while streaming and stop closing its menu when a run starts. The tooltip is unchanged. An integration test drives a real AgentSession with the faux provider and changes the level while the first request streams: the requests go out at low, then high. That pins the SDK behavior the control now relies on across SDK upgrades. Co-authored-by: Claude Opus 5.5 <[email protected]>
Problem
The reasoning level control is hidden while a turn is streaming, because the level cannot be changed mid-turn. That also removes the answer to the question that matters most at exactly that moment: which budget is this turn spending. A long-running turn gives no indication of whether it is on
auto,low, orxhigh, and the level is only visible again once the turn is over.Change
While streaming, the control row shows the active level as a read-only label in the same slot the dropdown normally occupies. Nothing else about the streaming controls changes.
It is deliberately not a button: the level cannot be changed until the turn ends, so a clickable control there would invite clicks that do nothing. The label reuses
thinkingDisplayLabel, the existingThinkingIcon, and the same padding, height, and mobile collapse rule as the editable control, so the row keeps its spacing next to Stop.Tests
components/ChatInput.streaming-thinking.test.mjs— the streaming branch renders the level without any button or click handler, and shares padding, height, and the mobile collapse rule with the dropdown.npm test(952),tsc --noEmit,eslint, andnext buildpass.