Repository navigation
feat: add plan mode with restricted tool boundary - #24236
Conversation
c4bb5c6 to
485e020
Compare
6b8948f to
b069f01
Compare
f2311be to
2a723e2
Compare
8918ef3 to
008233e
Compare
Documentation CheckUpdates Needed
New Documentation Needed
Automated review via Coder Tasks |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 008233e2e3
ℹ️ 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".
d6c0bf1 to
8203c24
Compare
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8203c24dcd
ℹ️ 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".
8203c24 to
f8d521d
Compare
Adds a chat-level plan mode that restricts the LLM to read-only investigation and a single writable plan artifact. The mode is stored on the chats table and persists across page reloads and turns. Backend: - Database migration 000469 adds chat_plan_mode enum and plan_mode column - Plan mode gates tools via allowedPlanToolNames() and stopAfterPlanTools() - PlanningOverlayPrompt with dynamic plan file path via ResolvePlanPath - Tool restrictions: write_file/edit_files limited to plan path - ask_user_question tool for structured clarification during planning - Chat PATCH API supports plan_mode field for toggling - Moved propose_plan references out of default prompt into plan-mode overlay - Plan turns stop after both propose_plan and ask_user_question Frontend: - Plan mode toggle in AgentChatPage from chat.plan_mode query state - updateChatPlanMode mutation with optimistic cache updates - AskUserQuestionTool wizard UI with radio options and keyboard support - ConversationTimeline reconstructs answered-question views - PlanModeInstructionsSettings for admin deployment-wide instructions
@codex review |
|
@codex review |
left a comment
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: de2c024435
ℹ️ 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".
commented
Apr 16, 2026
|
@codex review
|
commented
Apr 16, 2026
|
commented
Apr 16, 2026
|
@codex review |
left a comment
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c0ab8353d7
ℹ️ 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".
commented
Apr 16, 2026
|
commented
Apr 16, 2026
|
@codex review |
commented
Apr 16, 2026
|
Codex Review: Didn't find any major issues. Chef's kiss. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
commented
Apr 16, 2026
@codex review Latest push relaxes plan mode so root chats and subagents can use |
commented
Apr 16, 2026
|
@codex review
Please review the latest push. |
commented
Apr 16, 2026
Requesting a fresh exact Codex trigger because the previous comments included extra text and may not have matched the repository's expected trigger format. |
commented
Apr 16, 2026
|
@codex review |
left a comment
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e736ab6a24
ℹ️ 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".
| }; | ||
|
|
||
| const DEFAULT_CHAT_PAGE_LIMIT = 50; | ||
| const nilUUID = "00000000-0000-0000-0000-000000000000"; |
There was a problem hiding this comment.
i think this is probably a bad use of nilUUID const re-defining
| planMode?: ChatPlanModeOrClear; | ||
| }; | ||
|
|
||
| const clearPlanMode = "" satisfies ChatPlanModeOrClear; |
There was a problem hiding this comment.
this feels wrong, why is clear plan mode an empty string?
| let latestAskUserQuestionToolId: string | undefined; | ||
| let hasUserResponseAfterAskQuestion = false; | ||
| const askUserQuestionResponseTextByToolId = new Map<string, string>(); | ||
| let pendingAskUserQuestionToolId: string | undefined; | ||
| for (const { message, parsed } of parsedMessages) { | ||
| let askUserQuestionToolIdInMessage: string | undefined; | ||
| for (const tool of parsed.tools) { | ||
| if (tool.name === "ask_user_question") { | ||
| askUserQuestionToolIdInMessage = tool.id; | ||
| latestAskUserQuestionToolId = tool.id; | ||
| hasUserResponseAfterAskQuestion = false; | ||
| } | ||
| } | ||
|
|
||
| if (askUserQuestionToolIdInMessage) { | ||
| pendingAskUserQuestionToolId = askUserQuestionToolIdInMessage; | ||
| } | ||
|
|
||
| if (pendingAskUserQuestionToolId && message.role === "user") { | ||
| hasUserResponseAfterAskQuestion = | ||
| pendingAskUserQuestionToolId === latestAskUserQuestionToolId; | ||
| const responseText = getChatMessageTextContent(message.content); | ||
| if (responseText !== undefined) { | ||
| askUserQuestionResponseTextByToolId.set( | ||
| pendingAskUserQuestionToolId, | ||
| responseText, | ||
| ); | ||
| } | ||
| pendingAskUserQuestionToolId = undefined; | ||
| } | ||
| } | ||
| const historicalAskUserQuestionResponseTextByToolId = | ||
| askUserQuestionResponseTextByToolId.size > 0 | ||
| ? askUserQuestionResponseTextByToolId | ||
| : undefined; | ||
|
|
There was a problem hiding this comment.
We're massively bloating the complexity of this component. This can cause React Compiler to bail out. Please move some/most of this out into a helper.
| const cloneAnswer = ( | ||
| answer: QuestionAnswer | undefined, | ||
| ): QuestionAnswer | undefined => { | ||
| if (!answer) { | ||
| return undefined; | ||
| } | ||
|
|
||
| if (answer.kind === "other") { | ||
| return { kind: "other", text: answer.text }; | ||
| } | ||
|
|
||
| return { | ||
| kind: "option", | ||
| label: answer.label, | ||
| optionIndex: answer.optionIndex, | ||
| }; | ||
| }; |
There was a problem hiding this comment.
is this just a hand-rolled structuredClone? https://developer.mozilla.org/en-US/docs/Web/API/Window/structuredClone
| .join("\n"); | ||
| }; | ||
|
|
||
| export const AskUserQuestionTool: FC<AskUserQuestionToolProps> = ({ |
There was a problem hiding this comment.
this entire component is a bit of a mess.
- We should be using
formik - We're manually adding
setIsSubmitting. Again, formik and mutation helpers help here - We have a
mapcall where the content should absolutely be pulled out into a separate component. - There are more issues but I'd be here all day so pls get your agent to do this properly
| const handleImplementPlanClick = async () => { | ||
| if (!onImplementPlan || isSubmitting) { | ||
| return; | ||
| } | ||
| setIsSubmitting(true); | ||
| try { | ||
| await onImplementPlan(); | ||
| setIsSubmitting(false); | ||
| } catch { | ||
| setIsSubmitting(false); | ||
| } | ||
| }; |
There was a problem hiding this comment.
setIsSubmitting no. Proper useMutation work should avoid this.
Your agent should look at how we handle this elsewhere, because I think this is probably wrong.
| const toolBadgeClassName = | ||
| "inline-flex shrink-0 items-center gap-1 rounded-full bg-surface-secondary px-2 py-0.5 text-xs font-medium text-content-secondary"; |
There was a problem hiding this comment.
We should never be promoting class variable names up like this. Inline this where it is used.
| const planModeInvisibleCharCount = countInvisibleCharacters( | ||
| form.values.plan_mode_instructions, | ||
| ); | ||
| const planModeInvisibleCharWarning = `This text contains ${planModeInvisibleCharCount} invisible Unicode ${planModeInvisibleCharCount !== 1 ? "characters" : "character"} that could hide content. These will be stripped on save.`; |
There was a problem hiding this comment.
why is this a variable? just inline it
Summary
ask_user_questionandpropose_planwrite_fileandedit_filesconstrained to the chat-specific plan file during plan turnsexecuteandprocess_output