Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
test(desktop-app): the Grok composer total names 16 MiB, not its base64 size
Alfredo Lopez9a6a3ac4eb02
diff --git a/desktop-app/ui/src/components/agents/__tests__/ComposerPanel.test.tsx b/desktop-app/ui/src/components/agents/__tests__/ComposerPanel.test.tsxindex 1909dd7ee..637eef036 100644--- a/desktop-app/ui/src/components/agents/__tests__/ComposerPanel.test.tsx+++ b/desktop-app/ui/src/components/agents/__tests__/ComposerPanel.test.tsx@@ -758,6 +758,56 @@ describe('ComposerPanel Codex image budgets', () => {})})+describe('ComposerPanel Grok image budget', () => {+ beforeEach(() => {+ composerModelState.data = {+ provider: 'grok-subscription',+ hostDefault: 'grok-4.6',+ sessionModel: 'grok-4.6',+ degraded: false,+ models: [{ name: 'grok-4.6', displayName: 'Grok 4.6' }],+ }+ composerModelState.effectiveModel = 'grok-4.6'+ })++ // The picker counts base64 bytes (22369624 = 4 * ceil(16 MiB / 3)), but the+ // limit it enforces is the ingress's 16 MiB decoded total, so the copy says+ // 16 MiB, not the rounded base64 figure (21 MiB).+ it('names the 16 MiB decoded total when an annotation save exceeds it', () => {+ const grokTotalBase64Bytes = 4 * Math.ceil((16 * 1024 * 1024) / 3)+ const already: ComposerImageAttachment = {+ id: 'already-attached',+ name: 'already.png',+ mimeType: 'image/png',+ dataBase64: 'A'.repeat(grokTotalBase64Bytes - 32),+ sizeBytes: 1,+ previewDataUrl: 'data:image/png;base64,AAAA',+ }+ const editing: ComposerImageAttachment = {+ id: 'editing',+ name: 'edit.png',+ mimeType: 'image/png',+ dataBase64: 'B'.repeat(16),+ sizeBytes: 1,+ previewDataUrl: 'data:image/png;base64,BBBB',+ }+ composerState.composerImageAttachments = [already, editing]+ render(<ComposerPanel inline />)+ fireEvent.click(screen.getByText('edit.png'))+ expect(annotationCanvasMock.onSave).toEqual(expect.any(Function))++ expect(() =>+ annotationCanvasMock.onSave?.({+ ...editing,+ dataBase64: 'B'.repeat(64),+ })+ ).toThrow(+ 'edit.png was kept unchanged. The images in one message are limited to 16 MiB in total.'+ )+ expect(actionsMock.handleUpdateComposerImageAttachment).not.toHaveBeenCalled()+ })+})+describe('ComposerPanel with a pending image after a model switch', () => {const pendingImage: ComposerImageAttachment = {id: 'pending-image-1',diff --git a/desktop-app/ui/src/constants/__tests__/attachments.test.ts b/desktop-app/ui/src/constants/__tests__/attachments.test.tsindex 6f1165a5d..736efb6ec 100644--- a/desktop-app/ui/src/constants/__tests__/attachments.test.ts+++ b/desktop-app/ui/src/constants/__tests__/attachments.test.ts@@ -15,6 +15,7 @@ describe('composerImageBudget', () => {expect(budget).toEqual({maxImageBytes: 16777216,maxTotalBase64Bytes: 22369624,+ totalLimitLabelBytes: 16777216,maxDimension: null,sizeUnit: 'MiB',})@@ -22,6 +23,9 @@ describe('composerImageBudget', () => {// accept for one message, not the 20 MiB xAI allows per image.expect(budget.maxImageBytes).toBe(16 * MIB)expect(budget.maxTotalBase64Bytes).toBe(4 * Math.ceil((16 * MIB) / 3))+ // The copy names the decoded total (16 MiB), not the base64 bytes the+ // picker counts (which would round to "21 MiB").+ expect(budget.totalLimitLabelBytes).toBe(16 * MIB)expect(15 * MIB).toBeLessThanOrEqual(budget.maxImageBytes)expect(17 * MIB).toBeGreaterThan(budget.maxImageBytes)})@@ -30,6 +34,7 @@ describe('composerImageBudget', () => {expect(composerImageBudget('codex-subscription')).toEqual({maxImageBytes: CODEX_COMPOSER_MAX_IMAGE_BYTES,maxTotalBase64Bytes: null,+ totalLimitLabelBytes: null,maxDimension: CODEX_COMPOSER_MAX_IMAGE_DIMENSION,sizeUnit: 'MiB',})@@ -43,6 +48,7 @@ describe('composerImageBudget', () => {expect(composerImageBudget(provider)).toEqual({maxImageBytes: COMPOSER_MAX_IMAGE_BYTES,maxTotalBase64Bytes: COMPOSER_MAX_TOTAL_IMAGE_BASE64_BYTES,+ totalLimitLabelBytes: COMPOSER_MAX_TOTAL_IMAGE_BASE64_BYTES,maxDimension: null,sizeUnit: 'MB',})