Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 34 additions & 12 deletions apps/desktop/renderer-architecture.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"src/renderer/locales/shell-copy.ts",
"src/renderer/locales/shell-remaining-copy.ts",
"src/renderer/locales/task-readiness-copy.ts",
"src/renderer/locales/work-board-error-copy.ts",
"src/renderer/locales/workhub-copy.ts",
"src/renderer/main.tsx",
"src/renderer/mcp-brand-contrast.ts",
Expand Down Expand Up @@ -343,7 +344,7 @@
"@maka/ui": 1
},
"importSpecifiers": 13,
"nonTriviaTokens": 4076
"nonTriviaTokens": 4074
},
"src/renderer/app-shell-chrome-actions.tsx": {
"importDeclarations": 4,
Expand Down Expand Up @@ -394,7 +395,7 @@
"react": 1
},
"importSpecifiers": 9,
"nonTriviaTokens": 2307
"nonTriviaTokens": 2283
},
"src/renderer/app-shell-context-compaction.ts": {
"importDeclarations": 0,
Expand All @@ -411,19 +412,19 @@
"nonTriviaTokens": 610
},
"src/renderer/app-shell-copy.ts": {
"importDeclarations": 1,
"importDeclarations": 0,
"bridgePaths": {},
"environmentCapabilities": {},
"hookCalls": {},
"lifecycleMethods": {},
"unresolvedDependencies": 0,
"actionFactories": [],
"dependencyPaths": {
"./locales/shell-copy.js": 1,
"@maka/core/redaction": 1
"./application/contracts/operation-diagnostics.js": 1,
"./locales/shell-copy.js": 1
},
"importSpecifiers": 1,
"nonTriviaTokens": 504
"importSpecifiers": 0,
"nonTriviaTokens": 363
},
"src/renderer/app-shell-detail-panel.tsx": {
"importDeclarations": 0,
Expand Down Expand Up @@ -895,7 +896,7 @@
"react": 1
},
"importSpecifiers": 121,
"nonTriviaTokens": 14630
"nonTriviaTokens": 14626
},
"src/renderer/use-app-shell-composer-quotes.ts": {
"importDeclarations": 2,
Expand Down Expand Up @@ -1102,7 +1103,6 @@
"unresolvedDependencies": 0,
"actionFactories": [],
"dependencyPaths": {
"./locales/conversation-copy.js": 1,
"@maka/core/attachments": 1
}
},
Expand Down Expand Up @@ -1610,7 +1610,9 @@
"lifecycleMethods": {},
"unresolvedDependencies": 0,
"actionFactories": [],
"dependencyPaths": {}
"dependencyPaths": {
"@maka/core/ui-locale": 1
}
},
"src/renderer/locales/session-collaboration-copy.ts": {
"bridgePaths": {},
Expand Down Expand Up @@ -1770,7 +1772,8 @@
"unresolvedDependencies": 0,
"actionFactories": [],
"dependencyPaths": {
"@maka/core/redaction": 1
"@maka/core/redaction": 1,
"@maka/core/ui-locale": 1
}
},
"src/renderer/locales/shell-remaining-copy.ts": {
Expand All @@ -1791,6 +1794,17 @@
"actionFactories": [],
"dependencyPaths": {}
},
"src/renderer/locales/work-board-error-copy.ts": {
"bridgePaths": {},
"environmentCapabilities": {},
"hookCalls": {},
"lifecycleMethods": {},
"unresolvedDependencies": 0,
"actionFactories": [],
"dependencyPaths": {
"@maka/core/ui-locale": 1
}
},
"src/renderer/locales/workhub-copy.ts": {
"bridgePaths": {},
"environmentCapabilities": {},
Expand Down Expand Up @@ -2069,6 +2083,7 @@
"unresolvedDependencies": 0,
"actionFactories": [],
"dependencyPaths": {
"./application/contracts/operation-diagnostics.js": 1,
"./locales/plan-mode-copy.js": 1,
"@astryxdesign/core/Banner": 1,
"@astryxdesign/core/Collapsible": 1,
Expand Down Expand Up @@ -2105,6 +2120,7 @@
"unresolvedDependencies": 0,
"actionFactories": [],
"dependencyPaths": {
"./application/contracts/operation-diagnostics.js": 1,
"./locales/shell-copy.js": 1,
"@astryxdesign/core/Button": 1,
"@astryxdesign/core/Dialog": 1,
Expand Down Expand Up @@ -2170,6 +2186,7 @@
"unresolvedDependencies": 0,
"actionFactories": [],
"dependencyPaths": {
"./application/contracts/operation-diagnostics.js": 1,
"./features/session-collaboration": 1,
"./locales/session-collaboration-copy.js": 1,
"@astryxdesign/core": 1,
Expand Down Expand Up @@ -4538,6 +4555,7 @@
"unresolvedDependencies": 0,
"actionFactories": [],
"dependencyPaths": {
"./application/contracts/operation-diagnostics.js": 1,
"@maka/core/work-board": 1,
"react": 1
}
Expand All @@ -4556,7 +4574,9 @@
"unresolvedDependencies": 0,
"actionFactories": [],
"dependencyPaths": {
"./application/contracts/operation-diagnostics.js": 1,
"./locales/conversation-copy.js": 1,
"./locales/work-board-error-copy.js": 1,
"./use-work-board.js": 1,
"@astryxdesign/core": 1,
"@astryxdesign/core/Button": 1,
Expand All @@ -4574,6 +4594,7 @@
"unresolvedDependencies": 0,
"actionFactories": [],
"dependencyPaths": {
"./application/contracts/operation-diagnostics.js": 1,
"./features/workhub/index.js": 1
}
},
Expand Down Expand Up @@ -4654,8 +4675,9 @@
"unresolvedDependencies": 0,
"actionFactories": [],
"dependencyPaths": {
"./application/contracts/operation-diagnostics.js": 1,
"./features/workhub/index.js": 1,
"./locales/workhub-copy.js": 1,
"./locales/workhub-copy.js": 2,
"./workhub-coordination-port.js": 1,
"./workhub-send-lease.js": 1,
"@astryxdesign/core": 1,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

/**
* Review regression on #4457: the new-task send path runs the renderer-side
* attachment preflight BEFORE `newTasks.create`, so the main-side token
* validation never sees an over-limit request. The preflight must reject with
* the same stable `attachment_ingest:<code>` tokens main rejects with, so the
* send catch maps the real reason through the locale catalog instead of the
* generic "try again later" fallback (retrying nine attachments can never
* succeed) — and an expected rejection must not log an unexpected diagnostic.
*/

import { MAX_ATTACHMENT_COUNT } from '@maka/core/attachments';
import { strict as assert } from 'node:assert';
import { test } from 'node:test';
import type { PendingAttachment } from '../../renderer/composer-attachments.js';
import { createAppShellChatActions } from '../../renderer/app-shell-chat-actions.js';
import { getShellCopy } from '../../renderer/locales/shell-copy.js';
import {
createActionsDeps,
installWindow,
} from './app-shell-chat-actions-fixture.js';

function fileAttachment(size: number, index: number): PendingAttachment {
return {
stagingKey: `staged-file-${index}`,
displayName: 'report.txt',
kind: 'other',
size,
source: { type: 'file', file: { size } },
} as PendingAttachment;
}

test('a nine-attachment new-task send shows the count reason, creates no session, and logs no unexpected diagnostic', async (context) => {
const errorLog = context.mock.method(console, 'error', () => undefined);
const created: unknown[] = [];
const toasts: Array<{ title: string; description?: string }> = [];
const restoreWindow = installWindow({
newTasks: {
create: async () => {
created.push(true);
return { id: 'session-created-anyway' };
},
},
});

try {
for (const locale of ['zh-CN', 'en'] as const) {
toasts.length = 0;
const actions = createAppShellChatActions({
...createActionsDeps(),
uiLocale: locale,
toastApi: {
error: (title, description) => {
toasts.push({ title, description });
},
info: () => undefined,
},
});
const pending = Array.from(
{ length: MAX_ATTACHMENT_COUNT + 1 },
(_, index) => fileAttachment(10, index),
);
const accepted = await actions.send('hello', pending);
assert.equal(accepted, false, `${locale}: the send must be rejected`);
assert.equal(created.length, 0, `${locale}: preflight runs before the session exists`);
assert.equal(toasts.length, 1, `${locale}: exactly one rejection toast`);
assert.equal(
toasts[0].description,
getShellCopy(locale).sessionSettingsActions.attachmentIngestBlocked.count_limit,
`${locale}: the toast carries the count reason, not the generic fallback`,
);
}
} finally {
restoreWindow();
}
assert.equal(
errorLog.mock.callCount(),
0,
'an expected preflight rejection must not land the unexpected-error diagnostic',
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { encodeIngestItems } from '../../preload/attachment-ingest-payload.js';
describe('encodeIngestItems', () => {
test('rejects more than 8 items without reading any file bytes', async () => {
const items = Array.from({ length: 9 }, (_, i) => ({ approvalId: `a${i}`, name: `f${i}.txt` }));
await assert.rejects(encodeIngestItems(items as never), /8/);
await assert.rejects(encodeIngestItems(items as never), /attachment_ingest:count_limit/);
});

test('rejects a File over 50MB without calling arrayBuffer', async () => {
Expand All @@ -38,7 +38,7 @@ describe('encodeIngestItems', () => {
return new ArrayBuffer(0);
},
} as unknown as File;
await assert.rejects(encodeIngestItems([{ file: bigFile }]), /50/);
await assert.rejects(encodeIngestItems([{ file: bigFile }]), /attachment_ingest:item_too_large/);
assert.equal(arrayBufferCalls, 0, 'arrayBuffer must not be called for an oversized file');
});

Expand Down Expand Up @@ -67,7 +67,7 @@ describe('encodeIngestItems', () => {
test('rejects a raw base64 item that is neither a File nor an approval token', async () => {
await assert.rejects(
encodeIngestItems([{ name: 'forged', base64: 'AAAA' }] as never),
/无效/,
/attachment_ingest:items_invalid/,
);
});
});
Loading