fix(ui): hide Change the output limit when the limit is at its maximum (C8)

Signed-off-by: Bernhard Jackiewicz <bj@techport.io>
This commit is contained in:
Bernhard Jackiewicz
2026-10-04 13:15:21 +02:00
parent 1d4c4ad125
commit a93edb223d
2 changed files with 15 additions and 1 deletions
@@ -1089,6 +1089,19 @@ describe('graph answers and answer limits', () => {
expect(document.activeElement?.id).toBe('cbm-chat-output-tokens');
});
it('does not offer to change an output limit that is already at its maximum, and still lists the larger models (C8)', async () => {
const { props, runtime } = fixture();
runtime.chat.mockImplementationOnce(async (_messages, _onToken, options) => {
options?.onComplete?.({ stopReason: 'length' }); return 'A long answer that';
});
await render({ ...props, attachment: selection }); await click('Download & load');
await type('Explain this part'); await click('Send ↑');
const note = container.querySelector<HTMLDetailsElement>('.cbm-chat-turn details.cbm-chat-limit-note');
expect(note?.textContent).toContain('The output limit is at the maximum of 512 tokens for this model.');
expect([...note?.querySelectorAll('button') ?? []].map(item => item.textContent)).not.toContain('Change the output limit');
expect(note?.textContent).toContain('Qwen3 0.6B · 579 MB download');
});
it('says why an automatic explanation stops early and that a question may answer longer (K1)', async () => {
vi.useFakeTimers();
try {
+2 -1
View File
@@ -95,7 +95,8 @@ function TokenLimitNote({ limit, automatic, chat, model, onChangeOutput }: Limit
<summary>{browserChatText.shortened}</summary>
<p>{automatic ? browserChatText.limitAutomatic(limit.inputTokens, limit.outputTokens, chat.inputTokens, chat.outputTokens) : browserChatText.limitReached(limit.inputTokens, limit.outputTokens)}</p>
<p>{browserChatText.outputRoom(chat.outputTokens, model.maxOutputTokens)}</p>
<button type="button" onClick={onChangeOutput}>{browserChatText.changeOutputLimit}</button>
{/* At its maximum the limit cannot be raised, so there is nothing to change (C8). */}
{chat.outputTokens < model.maxOutputTokens && <button type="button" onClick={onChangeOutput}>{browserChatText.changeOutputLimit}</button>}
{larger.length > 0 && <><p>{browserChatText.largerModels}</p>
<ul>{larger.map(candidate => <li key={candidate.id}>{browserChatText.modelDownload(candidate.displayName, sizeLabel(candidate.bytes))}</li>)}</ul></>}
</details>;