Repository navigation
feat(chat): question headers, multi-select, question tool replay, edit preview and run info - #1241
Merged
Merged
Conversation
…t preview and run info The question card labels each question tab with its header (falling back to Q1, Q2, ...) and supports multiple: true. Until K-brain has a selected_labels field, a multi-select answer is sent as the joined labels with custom: true. History replay renders K-brain's question tool as the question card. The original arguments are kept so the transcript is sent back to K-brain with the original name. The Gateway direct link normalizes question calls, results, history and multi-select answers the same way, and it forwards the permission preview. Edit approvals render permission.requested.preview diff rows. They note new files and too-large previews, and keep the tool-arguments preview as the fallback. Shell tool results show exit code, timeout and duration. Closes #1240
K-brain's native bash tool has no shell display, so its result fell through to the raw details view and showed the kbrainRun object as JSON. Show the exit code and duration as one line there, and leave the run info out of the JSON dump of any other details. Refs #1240
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Linked issue
Closes #1240
Follows up on the question and permission data from Stack-Cairn/K-brain#162 and Stack-Cairn/K-brain#135 (both in K-brain v0.107.22).
Summary
header. When there is no header, the tab falls back toQ1,Q2, …multiple: trueuses checkboxes and a "Select all that apply" hint. The custom answer can be combined with the listed options. K-brain has no field for several labels yet, so when more than one option is picked, the answer is sent as the labels joined with,pluscustom: true. A single picked option is sent as a normal answer. When the card is shown again from history, the joined text is split back into the listed options.questiontool. In history, K-brain's ownquestioncalls now render as the question card with the recorded answers, including custom text. A dismissed question shows as cancelled, and one with no answer shows as timed out. Both the single and thequestions: [...]forms are handled. The original arguments are kept in a hidden__kbrainQuestionArgumentsfield, so a transcript sent back to K-brain still uses thequestionname and its original arguments.crates/agent-gatewayalready passed multi-questionquestion.requestedevents through. It now also handles the rest:questioncalls, both live and in history.questionresults into card answers.selectedLabelsfrom the WebUI and sends them as joined text, withcustom: truewhen there is more than one label.permission.requested.previewto the approval card.permission.requested.previewhas adiff, the approval card renders K-brain's diff rows (<line> <mark> <text>), including the… +N more linesoverflow note.new_fileadds a "This creates a new file." line.truncatedwith an empty diff says the change is too large to preview. Without a preview, the card falls back to the old preview built from the tool arguments.exit_code,timed_outandduration_msfrom shell tools (Bash,bash,ManagedProcess,ProcessWait,ProcessStop) are read fromtool.resultevents and from historytool_calls[]. They show in the Shell header, for exampleexit 1 · 2.3sortimed out · 30.0s. K-brain's nativebashhas no Shell display, so its result shows the same thing as one line.K-brain protocol need
A
selected_labels: []stringanswer field, validated against the options whenmultipleis set. Today a multi-select answer with more than one option has to be sent as joined labels withcustom: true. That has two problems:AskUserQuestionresult text presents the answer as something the user typed.,can't be split back reliably. LiveAgent splits on the longest listed label, which is a best effort.Observation on K-brain's preview rows (no change needed here)
editDiffRowsprints the trailing context row as the last line of the old text,o[len(o)-1]. It does not print the first line after the change. For a whole-file preview, that row is the file's last line. In the edit screenshot below the trailing row is7 }, while the line right after the change is line 5. LiveAgent renders the rows exactly as K-brain sends them.Change scope
crates/agent-ui/src/components/chat/AskUserQuestionCard.tsx: header tabs and multi-selectcrates/agent-ui/src/lib/chat/askUserQuestion.ts:questionargument normalization, result parsing, multi-select answerscrates/agent-ui/src/lib/chat/toolApprovalArgs.ts:approvalPreviewFromKBrain()crates/agent-ui/src/lib/chat/diffRows.ts(new),crates/agent-ui/src/components/chat/EditDiffView.tsx,crates/agent-ui/src/components/chat/ToolApprovalBar.tsx: preview rows, new file and too-large messagescrates/agent-ui/src/lib/chat/toolRunInfo.ts(new),crates/agent-ui/src/components/chat/assistant-bubble/ToolResultDisplay.tsx: run infocrates/agent-gui/src/lib/kbrain/{history,questions,turn,types}.ts,crates/agent-gui/src/pages/chat/turns/runKBrainConversationTurn.tscrates/agent-gateway/internal/kbrain/question_tool.go(new),events.go,history.go,interactive.go,client.goScreenshots / preview
All screenshots come from the real desktop debug app (macOS arm64). It was a
cargo buildof this branch with the Vite dev server from this worktree, and it ran the real K-brain v0.107.22 release binary throughLIVEAGENT_KBRAIN_BINARY.HOMEandLIVEAGENT_DEV_HOMEpointed at temporary directories. The model was a local scripted OpenAI-compatible fixture. It picks the tool from the request's tool list and returns:questioncall with three questions (Format,Checkswithmultiple: true,Rollout)editon an existing filewriteof a new filebashcommand that exits with status 3K-brain produced everything else itself: the
question.requestedevents, the permission requests withpreview(in Always ask mode), the history, and the run info. The screenshots are only cropped (sidebar removed) and not otherwise edited.Multi-question card with headers (live
question.requestedfrom thequestiontool):Multi-select question (two options checked):
Edit approval rendered from
permission.requested.preview:Write approval for a new file (
new_file: true):History replay (after a reload): the
questiontool call from K-brain history shows as the settled card, and the joined multi-select answer is split back into its options:Run info on K-brain's native
bash, read from historytool_calls[](exit_code: 3,duration_ms: 16):The Gateway direct link was not run live in this pass. It is covered by the Go tests and the WebUI tests listed below.
Verification
pnpm typecheck:ui,pnpm typecheck:gui,pnpm typecheck:webui: passpnpm lint(biome): no errorspnpm test:gui: 4122 pass, 12 skipped, 0 fail. The backend tests ran withLIVEAGENT_KBRAIN_BINARYset to the v0.107.22 release binary.pnpm test:webui: 887 passcd crates/agent-gateway && go test ./...: pass (afterpnpm --filter @liveagent/gateway-webui build)test/providers/kbrain-question-tool.test.mjs: normalization, result parsing, multi-select answers, history replay and the round trip back to K-brain, run info, and a live turn with thequestiontool and aBashexit codeinternal/kbrain/question_tool_test.go: the Gateway side of the same cases, plus the preview reaching the approval cardweb/test/kbrain-question-preview.test.mjsbashresult showed the run info as raw JSON. It is fixed in the second commit and covered by a test.