-
Notifications
You must be signed in to change notification settings - Fork 847
Show the reasoning level of the running turn #777
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
uvforce
wants to merge
2
commits into
agegr:main
Choose a base branch
from
uvforce:pr/streaming-thinking-level
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+70
−0
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import assert from "node:assert/strict"; | ||
| import { readFile } from "node:fs/promises"; | ||
| import test from "node:test"; | ||
|
|
||
| const source = await readFile(new URL("./ChatInput.tsx", import.meta.url), "utf8"); | ||
| const controls = source.slice(source.indexOf("{isStreaming && onThinkingLevelChange &&")); | ||
|
|
||
| test("shows the reasoning level of the running turn without offering a control", () => { | ||
| const readOnly = controls.slice(0, controls.indexOf("{!isStreaming && onThinkingLevelChange &&")); | ||
| assert.match(readOnly, /<span\s+title=\{t\("chat\.currentReasoning", \{ level: thinkingDisplayLabel \}\)\}/); | ||
| assert.match(readOnly, /\{thinkingDisplayLabel\}<\/span>/); | ||
| assert.doesNotMatch(readOnly, /<button|onClick=/); | ||
| }); | ||
|
|
||
| test("keeps the read-only level aligned with the neighbouring controls", () => { | ||
| const readOnly = controls.slice(0, controls.indexOf("{!isStreaming && onThinkingLevelChange &&")); | ||
| const dropdown = controls.slice(controls.indexOf("{!isStreaming && onThinkingLevelChange &&")); | ||
| const padding = /padding: isMobile \? "0 6px" : "8px 12px"/; | ||
| const height = /height: 32/; | ||
| for (const [label, markup] of [["read-only", readOnly], ["dropdown", dropdown]]) { | ||
| assert.match(markup, padding, `${label} horizontal padding`); | ||
| assert.match(markup, height, `${label} height`); | ||
| } | ||
| // The label collapses to the icon on mobile exactly like the editable control. | ||
| assert.match(readOnly, /\(!isMobile \|\| controlsMenuOpen\) &&/); | ||
| }); | ||
|
|
||
| test("shows the level the runtime actually applies, not the selector placeholder", async () => { | ||
| const session = await readFile(new URL("../hooks/useAgentSession.ts", import.meta.url), "utf8"); | ||
| const start = session.slice(session.indexOf('case "agent_start":'), session.indexOf('case "agent_end":')); | ||
| // Choosing "auto" leaves pi's setting untouched, so the selector alone cannot be trusted. | ||
| assert.match(session, /if \(level === "auto"\) return;/); | ||
| assert.match(start, /fetch\(`\/api\/agent\/\$\{encodeURIComponent\(sessionIdRef\.current\)\}`\)/); | ||
| assert.match(start, /if \(!agentRunningRef\.current \|\| !d\.state\?\.thinkingLevel\) return;\s*setThinkingLevel\(d\.state\.thinkingLevel as ThinkingLevelOption\);/); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
autoWhen an existing session previously used an explicit level and the user selects “Use pi default,”
handleThinkingLevelChangesets the client state toautobut returns without updating the runtime, so the agent retains the previous level. On the next prompt this new badge therefore reportsautoas the current turn's level even though, for example,highis 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 👍 / 👎.