Repository navigation
fix(minimax-bot): fold the background job queue behind one line, separate the reply bubbles #51
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
Merged
MyPrototypeWhat
merged 6 commits into
MiniMax-AI:main
from
July-X:fix/minimax-bot-task-queue-fold-and-bubble-gap
Oct 21, 2026
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
011c418
fix(minimax-bot): fold a long queue of background jobs behind one line
Z-starts c85ddf8
fix(minimax-bot): keep three job rows in the open in the task strip
Z-starts f93265f
chore(minimax-bot): bump the version to 0.7.6
Z-starts 045eade
fix(minimax-bot): drop the folded working messages, separate the bubbles
Z-starts f296610
fix(minimax-bot): keep the working jobs in the open, hold the fold bu…
Z-starts e030957
docs(minimax-bot): describe the folded job queue
Z-starts 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
Some comments aren't visible on the classic Files Changed page.
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -447,6 +447,7 @@ async function mountChat(chatId) { | |
| const revision = ++mountRevision; | ||
| closeReactionPicker(); | ||
| mounted = chatId; | ||
| helpersExpanded = false; | ||
| const target = targetOf(chatId); | ||
| ui.pillBar = h('div', { class: 'pill-bar' }); | ||
| ui.feedInner = h('div', { class: 'feed-inner' }); | ||
|
|
@@ -938,90 +939,21 @@ function legacyParts(m) { | |
| return parts; | ||
| } | ||
|
|
||
| /** | ||
| * The Host opens a text part for every assistant turn between two tool calls, so a reply that | ||
| * worked for a while arrives with dozens of them, and one bubble per part filled the screen. | ||
| * The newest bubbles stay in the open, exactly where the flat layout put them; the earlier ones | ||
| * fold away behind a one line summary. | ||
| */ | ||
| const FOLD_AFTER_PARTS = 3; | ||
|
|
||
| /** The bubble's own text, short enough to be a hover hint. */ | ||
| function hintOf(text) { | ||
| const flat = String(text ?? '').replace(/\s+/g, ' ').trim(); | ||
| return flat.length > 160 ? `${flat.slice(0, 160)}…` : flat; | ||
| } | ||
|
|
||
| /** | ||
| * The earlier bubbles of a long reply: folded behind a one line summary, and the area that | ||
| * opens has a fixed height with its own scrollbar, so the feed keeps its length. | ||
| */ | ||
| function foldView(m, parts, presentation) { | ||
| const inner = () => | ||
| parts.map((part, index) => ({ | ||
| key: `text:${index}`, | ||
| signature: JSON.stringify([part.text, presentation]), | ||
| create: () => h('div', { class: 'bubble', title: hintOf(part.text) }, markdownNode(part.text, m.chatId)), | ||
| update: (bubble) => { | ||
| markdownNode(part.text, m.chatId, bubble.firstElementChild); | ||
| bubble.title = hintOf(part.text); | ||
| return bubble; | ||
| }, | ||
| })); | ||
| const body = h('div', { class: 'bubble-fold-body' }); | ||
| reconcileChildren(body, inner()); | ||
| return { | ||
| key: 'fold', | ||
| signature: JSON.stringify([parts.map((part) => part.text), presentation, locale()]), | ||
| create: () => | ||
| h( | ||
| 'details', | ||
| { class: 'bubble-fold' }, | ||
| h( | ||
| 'summary', | ||
| { class: 'bubble-fold-summary', title: t('fold.hint', { n: parts.length }) }, | ||
| icon('down', 12), | ||
| h('span', { class: 'bubble-fold-closed' }, t('fold.show', { n: parts.length })), | ||
| h('span', { class: 'bubble-fold-open' }, t('fold.hide')), | ||
| ), | ||
| body, | ||
| ), | ||
| update: (node) => { | ||
| reconcileChildren(node.querySelector('.bubble-fold-body'), inner()); | ||
| const summary = node.querySelector('.bubble-fold-summary'); | ||
| if (summary) summary.title = t('fold.hint', { n: parts.length }); | ||
| const closed = node.querySelector('.bubble-fold-closed'); | ||
| if (closed) closed.textContent = t('fold.show', { n: parts.length }); | ||
| return node; | ||
| }, | ||
| }; | ||
| } | ||
|
|
||
| /** Keep part order exactly as recorded; matching prefixes are not evidence of duplication. */ | ||
| function partViews(m, inGroup) { | ||
| const parts = m.key ? [{ type: 'text', text: displayText(m) }] : m.parts ?? legacyParts(m); | ||
| const lastText = parts.findLastIndex((part) => part.type === 'text' && part.text?.trim()); | ||
| const views = []; | ||
| const presentation = presentationKey(); | ||
| const textParts = []; | ||
| parts.forEach((part, index) => { | ||
| if (part.type === 'text' && part.text?.trim()) textParts.push(index); | ||
| }); | ||
| // The newest bubbles stay in the open, where the flat layout had them; the earlier ones fold. | ||
| const folded = textParts.length > FOLD_AFTER_PARTS ? textParts.slice(0, -FOLD_AFTER_PARTS) : []; | ||
| const foldedSet = new Set(folded); | ||
| if (folded.length) views.push(foldView(m, folded.map((index) => parts[index]), presentation)); | ||
| parts.forEach((part, index) => { | ||
| const key = `part:${index}`; | ||
| if (part.type === 'text' && part.text?.trim()) { | ||
| if (foldedSet.has(index)) return; | ||
| views.push({ | ||
| key, | ||
| signature: JSON.stringify([part.text, presentation, index === lastText ? [m.status, m.userReactions, m.reactionsRevision, displayText(m), m.sessionId, botById(m.botId)?.name] : null]), | ||
| create: () => updateBubbleControls(h('div', { class: 'bubble', title: folded.length ? hintOf(part.text) : undefined }, markdownNode(part.text, m.chatId)), m, index === lastText), | ||
| create: () => updateBubbleControls(h('div', { class: 'bubble' }, markdownNode(part.text, m.chatId)), m, index === lastText), | ||
| update: (bubble) => { | ||
| markdownNode(part.text, m.chatId, bubble.firstElementChild); | ||
| if (folded.length) bubble.title = hintOf(part.text); | ||
| return updateBubbleControls(bubble, m, index === lastText); | ||
| }, | ||
| }); | ||
|
|
@@ -1298,12 +1230,49 @@ function helperElapsed(helper) { | |
| return minutes < 1 ? t('helper.justStarted') : t('helper.minutes', { n: minutes }); | ||
| } | ||
|
|
||
| /** How many job rows stay in the open before the rest folds into one line. */ | ||
| const HELPER_ROWS_PREVIEW = 3; | ||
| let helpersExpanded = false; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [小问题] 展开状态会被带到后面
|
||
|
|
||
| /** A job that is already working comes first; one that still waits can wait a little longer. */ | ||
| const HELPER_STATUS_ORDER = { running: 0, waiting_for_tasks: 1, queued: 2 }; | ||
|
|
||
| /** | ||
| * The rows that stay in the open. Which rows those are is our choice, the order they appear in | ||
| * is not: a job that is already working comes first, so the row the reader cares about is never | ||
| * the one that folds away, and the rows keep the order the official build gives them. | ||
| */ | ||
| function visibleHelperRows(items) { | ||
| const ranked = [...items].sort((a, b) => HELPER_STATUS_ORDER[a.status] - HELPER_STATUS_ORDER[b.status]); | ||
| const keep = new Set(ranked.slice(0, HELPER_ROWS_PREVIEW)); | ||
| return items.filter((item) => keep.has(item)); | ||
| } | ||
|
|
||
| /** Background helpers working for this chat: one line each, with a stop button. */ | ||
| function renderHelpers() { | ||
| if (!ui.helpers) return; | ||
| const items = [...state.helpers, ...state.tasks].filter((x) => [x.chatId, x.originChatId, x.resultChatId].includes(mounted) && ['queued', 'running', 'waiting_for_tasks'].includes(x.status)); | ||
| ui.helpers.replaceChildren( | ||
| ...items.map((helper) => { | ||
| if (!items.length) { | ||
| ui.helpers.replaceChildren(); | ||
| ui.helpers.classList.remove('has-fold'); | ||
| helpersExpanded = false; | ||
| return; | ||
| } | ||
| // A queue that fits in the open rows has nothing to fold, so an open queue ends with it and | ||
| // the next busy chat starts folded again. | ||
| if (items.length <= HELPER_ROWS_PREVIEW) helpersExpanded = false; | ||
| const preview = helpersExpanded ? items : visibleHelperRows(items); | ||
| const hidden = items.length - preview.length; | ||
| const foldable = items.length > HELPER_ROWS_PREVIEW; | ||
| // The rows keep the scroll area they had, and the fold button sits below it, so the button | ||
| // stays reachable however long the queue is. | ||
| let rows = ui.helpers.querySelector('.helper-rows'); | ||
| if (!rows) { | ||
| rows = h('div', { class: 'helper-rows' }); | ||
| ui.helpers.replaceChildren(rows); | ||
| } | ||
| rows.replaceChildren( | ||
| ...preview.map((helper) => { | ||
| const bot = botById(helper.botId); | ||
| return h( | ||
| 'div', | ||
|
|
@@ -1329,6 +1298,31 @@ function renderHelpers() { | |
| ); | ||
| }), | ||
| ); | ||
| ui.helpers.classList.toggle('has-fold', foldable); | ||
| // The fold button is the same node from one render to the next, so the keyboard focus stays | ||
| // on it when a new job arrives, when the clock ticks or when the button itself is pressed. | ||
| let more = ui.helpers.querySelector('.helper-more'); | ||
| if (!foldable) { | ||
| more?.remove(); | ||
| return; | ||
| } | ||
| if (!more) { | ||
| more = h( | ||
| 'button', | ||
| { | ||
| type: 'button', | ||
| class: 'btn sm helper-more', | ||
| 'aria-expanded': String(helpersExpanded), | ||
| onclick: () => { | ||
| helpersExpanded = !helpersExpanded; | ||
| renderHelpers(); | ||
| }, | ||
| }, | ||
| ); | ||
| ui.helpers.append(more); | ||
| } | ||
| more.textContent = hidden > 0 ? t('helper.more', { n: hidden }) : t('helper.collapse'); | ||
| more.setAttribute('aria-expanded', String(helpersExpanded)); | ||
| } | ||
| setInterval(() => { | ||
| if (mounted && state.helpers.some((x) => x.chatId === mounted && x.status === 'running')) renderHelpers(); | ||
|
|
||
Oops, something went wrong.
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.
[小问题] README 没写任务条折叠
这次只改了这条 "Working messages",新的任务条折叠行为没写进 Background work 段落(第 17 行 "Running jobs are shown above the chat input…")。建议在那里补一句"超过 3 个任务时折叠,可展开"。