Repository navigation
feat(agent): ask before the agent changes a file with unsaved changes, and stop the tool clock while the user answers - #2883
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review: 2
Please check the settings in the CodeRabbit UI or the
|
🤖 Internal: Discord sync markerAuto-managed by the Discord notification workflow. Stores the linked Discord message ID and forum thread ID. Do not edit or delete. |
42a01c8 to
9b53ef6
Compare
be03858 to
c81691a
Compare
dylan-savage
left a comment
There was a problem hiding this comment.
Requesting changes on one thing.
Below 1024 px the question never shows. The shell's compact sidebar is always in the page with role="dialog" aria-modal="true", drawer open or closed (Sidebar.tsx:759-760), so otherDialogOpen() (choice.tsx:104) matches it and every question resolves unasked. The agent is then told to "try again after they close it" for a dialog the user can't see. Count only visible dialogs, for example by skipping any where checkVisibility({ visibilityProperty: true }) is false.
3bd9822 to
c6a99f0
Compare
…, and stop the tool clock while the user answers When the agent wanted to change a file the user had unsaved changes in, the call was refused and the model told the user to save first. Now the user is asked: Save mine first, Discard mine or Keep mine, one dialog at a time. The open editors do what the user chose. A call's time limit stands still while the question is open, in its prepare and in its run. A call its tool refused before changing anything is unstarted, so the finish rule asks for no check. One in which the user's save landed or sent a write still counts as a change, even when that save or another editor's save then failed, since the file may have changed. A save that joins a Ctrl+S already on its way counts once it lands. Open questions close as Keep mine when the run ends or the user stops it.
…imit, also after a later read With versioned writes, a read that takes a teammate's copy in counts it for the editor too. When that read waited for a write that then failed, the failure's count lands before the read and the editor misses only that one, while the file moves past the failure's version. The text tab exploration broke its not-stored rule in 3 such orders, where the tab shows the stored file. They now count under the known limit for a failed write, as the same order without the teammate's change already does.
…e closed drawer is a hidden dialog
Below 1024 px the shell's sidebar is a drawer. It stays in the page as a
modal dialog, with `visibility: hidden` while it is closed. otherDialogOpen()
counted it, so every question resolved unasked, and the agent was told to try
again after the user closed a dialog they could not see.
otherDialogOpen() now counts only dialogs that
checkVisibility({ visibilityProperty: true }) reports visible. The call also
passes the option's old name, checkVisibilityCSS, which Chrome 105 to 120
know instead. An open drawer still blocks the question. A browser without
checkVisibility counts every dialog, as before, so a question never opens
over another dialog.
c81691a to
95b719b
Compare
|
Fixed in the top commit. I reproduced the bug at 900 px on the old head: no question showed, and the model was told the user had another dialog open. With the fix, the unsaved-edits journey passes at 900 px and at 1440 px. With the drawer actually open at 900 px, the question still waits. The tests cover a hidden dialog, a visible one, and a hidden drawer that answers only to The branch now sits directly on |
…mmit all meets a teammate's change (#2884) * fix(agent): check a staged file against the copy the page read, so Commit all meets a teammate's change In manual mode a staged file's conflict anchor was a fresh server read taken when it was first staged. A teammate's change from before then became the anchor, so Commit all wrote over it. The anchor is now the copy the page read, so the commit meets a conflict. The view's prime records the path only: the dev preview primed what its batch read returned, unsaved typing included, and the cache then served it as the server's copy. The preview and teammate exploration covers both. Going back to a team drops the page's cached copies, so a delete the agent decided on before a switch away and back anchored on the server's copy after it, and Commit all deleted a teammate's change. The view's delete now takes an anchor, the hash of the stored copy the delete is based on. delete_file passes the copy the agent last read or wrote. Under unsaved typing that is the stored copy below the typing, which Discard mine brings back. The view checks the anchor in the delete's turn, against the same capture its tombstone records, so no copy read later can become the delete's anchor. In write-through mode it checks the server's copy. * feat(agent): end each turn with a result card, let the agent ask the user, and stop only its own runs in Auto (#2869) * refactor(agent): move FileTracker changes() here from the save-race PR The turn's result card lists what the run changed, so FileTracker records each file's change (added, modified, deleted or renamed, and where a renamed file came from) and changes() lists them. A file the run created and then deleted is no change. A deleted file keeps its version, so a file the run only deleted is not read back as seen. The stored copy a delete is checked against stays with each read, write and rename. * feat(agent): end each turn with a result card, let the agent ask the user, and stop only its own runs in Auto - runAgent, agent() and AgentSession.execute return a TurnResult: the outcome (done, needs_input, stopped, failed, incomplete), the files and checks, the usage and any needs-you request. Every turn ends once through execute, including a refused message, an error, Stop and an unmount. - The session file is version 2. It keeps the turns, linked to the rows that close them, and the runs the conversation started. A version 1 file loads with neither. Every saved field passes through redactText. - The shell's ChatMessage gains an optional `card`, and ChatView gains `onCardAction`. The Agent tab puts each turn's card under its row: links to the changed files, Open Variables, a button per choice, and Continue. - ask_user ends the turn as needs_input, as a question or a missing Variable. Only the user's next message answers the request. - terminate and restart ask first in Ask mode. In Auto they run only on a run this conversation started with use, after a fresh getTaskStatus matches the record and the scope. Any other run is refused, and the model is told to ask the user. - A turn running when the Agent tab unmounts is saved with its rows and a closing row (known bug 5). - A use refused because the pipeline is already running says how to run the edited version (known bug 14). * fix(agent): answer a needs-you request only after it showed, document the row card, and check the run on the Ask card A turn the user stopped in the wave that called ask_user kept its request. Its card said only "Stopped", yet the next message answered the question and disabled its buttons. Only a needs_input turn keeps its request now. A message the user sent during the wave that called ask_user stayed queued, then ran as its own turn and answered the question the user had not seen. The loop now takes such a message before it ends the turn. It drops the question, and the model reads the message and may ask again. ChatMessage.card and the onCardAction prop of ChatView and MessageList are documented in ROCKETRIDE_UI_COMPONENTS.md and the ChatView gallery entry. The Ask card for terminate and restart said "This conversation started it." from the run record alone. The engine gives a later run on the same project and source the same token, so the card could claim the user's run. It now reads the run's status first, as the Auto run step does. * feat(agent): pause a turn at its step or cost limit, show its estimated cost, and undo its file changes (#2873) * feat(agent): pause a turn at its step or cost limit, show its estimated cost, and undo its file changes - A turn takes at most 60 steps (waves) by default. At the limit the loop plans no more, answers with the best-effort summary, and the turn ends as needs_input with a continue request: the card says "Paused after 60 steps" and Continue starts a new turn with a fresh budget. Messages sent during the turn do not reset the count. Agent Step Limit in Settings changes it, and 0 turns it off. - A UsageMeter estimates each model request from characters, 4 to a token, priced from a dated table with one row for the stand-in's model (claude-sonnet-5, Anthropic's price page, read 2026-10-27). The prompt start is priced at the cache-write rate on a turn's first request, at the cache-read rate after, and as a write again after a gap over five minutes, only for a provider that caches it and a question that asks. - Before every model request, the retry after a pipeline restart and the best-effort summary included, the meter reserves the input estimate and an output allowance. A request that could pass the turn's cost limit is not sent, and the turn pauses with Continue. A failed request keeps its reservation. The limit is $2 per turn by default (Agent Cost Limit, 0 turns it off); a model with no price shows tokens and has no limit. - The bot row's meta line shows the estimate ("~$0.42 est."), and TurnResult.usage carries the tokens and the cost, marked estimated. - The latest turn's card has Undo for that turn's file changes. The file toolkit records, in memory only, each path's content at its first touch and the version and hash each agent change left. Undo checks every path first: no editor holds unsaved changes, the version is the agent's, no one else changed it between agent changes, and the stored content matches what the agent left (the server's copy afresh, or the staged content for a path still staged). Then every inverse starts in one block, through the versioned write. In manual mode a file the agent created and never committed has its staged entry dropped, so nothing stays pending. A note row says what Undo did, and the model reads it in the next turn. * fix(agent): say that the cost estimate and the cost limit leave out thinking The stand-in model request sends no thinking param, so Sonnet 5 thinks by default and bills it as output the browser never sees. The estimate counts only the reply text, so "~$X est." and the cost limit are lower bounds. The row's meta line now reads "~$X est., not counting thinking", and the cost limit setting says a turn can cost more than the limit. --------- Co-authored-by: Krish Garg <kg@g14-node1.tailb99b1b.ts.net> --------- Co-authored-by: Krish Garg <kg@g14-node1.tailb99b1b.ts.net> --------- Co-authored-by: Krish Garg <kg@g14-node1.tailb99b1b.ts.net>
Part of #2718. Stacks on
feat/rocket-agent-browser, which now holds the save-race PR (#2840) and the editor documents PR (#2882). It is the third of the four PRs split from #2840.The problem
When the agent wanted to change a file the user had unsaved changes in, the call was refused and the model asked the user to save first. The user had to stop, save or discard by hand, and ask again. A question that did show had to beat the tool's time limit, so a call could time out while the user was deciding.
What changes
EditorControl,AgentHost.editor). One dialog shows at a time, in order; a question whose turn comes while another app dialog is on screen is not shown, and the model is told so. A dialog that is in the page but hidden does not count.write_fileafter Save mine first still counts as a change, so the app check runs. So does a Save mine first that landed or sent a write and then failed, since the file may have changed: its reply can fail before or after the write lands, or one editor saves and the next fails (a text tab and a canvas on one pipeline, or two files of a folder being moved). The view counts a write when it is called, so the toolkit compares the dirty paths' versions before and after the save. A save that joins a Ctrl+S already on its way moves no version, so each editor also reports when its save lands (EditorControl.save(stored)). A save the user dropped before it wrote anything is still a refusal that changed nothing.UserTime). A call its tool refused before changing anything (RefusedError) is unstarted, so the finish rule asks for no check.Tests
The manual explorations get the dialog: an answer is a step. With the runAgent variant (the clock stands still while a question is open, and a step moves it past the limit) and the editor documents, every order breaks 0 rules: manual 8,876 orders, restored start 12,014, slow first read 7,368, as runAgent runs it 13,843, text tab 54,510 and 16,223, canvas 141,527 and 47,665. With the question switched off, the manual runs never reach an answer.
Unit tests cover what the explorations don't: the queue and its end-of-run and Stop handling, a question blocked by another dialog, our own closing dialog, the clock in the prepare and in the run, runAgent's wiring of the clock (a question still open past the 300 s limit, then answered), a dirty file with no editor, the delete's card before its question, the delete and rename after Save mine first, a save that joins a Ctrl+S on its way and lands before the next editor or file fails, a save whose reply fails before or after its write lands, a save dropped before it wrote, and the finish rule after Keep mine and after Save mine first. The clock tests fake
setTimeoutandperformance.nowtogether, so only the test moves time and a late timer on a busy machine changes nothing.After the restack
On the final versioned writes, the text tab exploration broke its not-stored rule in 3 of 54,510 orders, for example
edit > answer discard > release 0 > type > reload > fail 0 > teammate. The agent's write fails while a Reload's read waits for it, so the view counts a version for the failure, then the read takes the teammate's copy in and counts that too. The tab shows the stored file, one version behind: the read was called before the failure, so it counted the teammate's copy but not the failure. That is the known limit for a write that failed (versioned writes PR, Known limits), which the exploration already counts apart when nothing moves the version after the failure. A second commit counts these orders under it too. The text tab exploration now breaks 0 rules, with 2,221 orders under that limit where it had 2,218, and nothing else moved. With the rule widened, the exploration still catches a clean canvas that stops following its file (11,904 orders) and unsaved text behind a moved file that never turns stale (1,750).Since Dylan's review
Below 1024 px the question never showed. There the shell's sidebar is a drawer, and it stays in the page as a modal dialog (
role="dialog",aria-modal="true") withvisibility: hiddenwhile it is closed.otherDialogOpen()counted it, so every question resolved unasked, and the agent asked the user to close a dialog they could not see. A new commit counts only the dialogs thatcheckVisibility({ visibilityProperty: true, checkVisibilityCSS: true })reports visible.checkVisibility()with true andcheckVisibility({ visibilityProperty: true })with false, so the option is needed.checkVisibilitycounts every dialog, as before, so a question never opens over another dialog. Chrome has the method from 105 andvisibilityPropertyfrom 121. Chrome 105 to 120 know the option only by its old name,checkVisibilityCSS, so the call passes both.visibilityPropertyis dropped. "The closed drawer does not block the question in Chrome 105 to 120, which know the option only as checkVisibilityCSS" fails whencheckVisibilityCSSis dropped. Both fail when the visibility check is removed. "A visible dialog still blocks the question, as does one in a browser without checkVisibility" fails when a missing method counts as hidden. Each revert of one option, or of the fallback, fails only its own test. The visible-dialog test passes on the previous head, which counted every dialog.The stack
Eleven PRs, each on the one below it. #2835, #2836, #2839, #2840 and #2882 are merged, and this PR now sits directly on
feat/rocket-agent-browser. The rest merge top-down: each PR squashes into the branch below it, starting with #2885.