Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix: 标注审查收尾——空闲崩溃不计入重挂上限、AVIF 保留透明、画笔不可用原因点按时重取
Dasheab44ea86a7f
diff --git a/apps/desktop/src/main/__tests__/agentInputQueue.test.ts b/apps/desktop/src/main/__tests__/agentInputQueue.test.tsindex 987e2ed233..7d86408cbc 100644--- a/apps/desktop/src/main/__tests__/agentInputQueue.test.ts+++ b/apps/desktop/src/main/__tests__/agentInputQueue.test.ts@@ -163,7 +163,7 @@ describe('agentInputQueue', () => {);// 编号只在本条消息内有效,说明里必须讲清楚。expect(ANNOTATED_IMAGE_REGIONS_PREFIX).toBe(- 'Marked regions (normalized coordinates, origin top-left; ' ++ 'Marked regions (normalized image coordinates, origin top-left; ' +'images numbered in their order within this message): ',);});diff --git a/apps/desktop/src/shared/agentInputQueue.ts b/apps/desktop/src/shared/agentInputQueue.tsindex 8b11304609..74f01f5b74 100644--- a/apps/desktop/src/shared/agentInputQueue.ts+++ b/apps/desktop/src/shared/agentInputQueue.ts@@ -780,7 +780,7 @@ export const ANNOTATED_IMAGE_NOTE =* 顺序从 1 编号,帮助模型在多张图 / 多处标注时对上用户所指。*/export const ANNOTATED_IMAGE_REGIONS_PREFIX =- 'Marked regions (normalized coordinates, origin top-left; ' ++ 'Marked regions (normalized image coordinates, origin top-left; ' +'images numbered in their order within this message): ';/** 一张标注图的区域描述,如 `image 2: x 0.31–0.46, y 0.12–0.20; x 0.70–0.90, y 0.55–0.61`。 */diff --git a/apps/mobile/src/__tests__/annotationBurnInQueue.test.ts b/apps/mobile/src/__tests__/annotationBurnInQueue.test.tsindex cd8c95e88a..6b108e645b 100644--- a/apps/mobile/src/__tests__/annotationBurnInQueue.test.ts+++ b/apps/mobile/src/__tests__/annotationBurnInQueue.test.ts@@ -265,4 +265,23 @@ describe('annotation burn-in queue', () => {expect(host.mounts).toHaveLength(MAX_CONSECUTIVE_CRASH_REMOUNTS + 1);expect(host.mounted).toBeNull();});++ it('does not count idle (prewarm-only) crashes toward the remount cap', async () => {+ const { queue, host } = setup();+ // 切后台被系统回收之类的空闲崩溃,多次也不累计。+ for (let i = 0; i <= MAX_CONSECUTIVE_CRASH_REMOUNTS + 1; i++) {+ const release = queue.acquireWarm();+ queue.handleProcessGone(host.mounted!, 'render process gone');+ release();+ }+ const first = queue.burnIn(input);+ const second = queue.burnIn(input);+ // 一次打断任务的崩溃:队首失败,但仍换新 WebView 继续处理后续任务。+ queue.handleProcessGone(host.mounted!, 'render process gone');+ expect((await settled(first)).error?.message).toContain('terminated');+ const key = host.mounted!;+ ready(queue, key);+ reply(queue, key, 'burn-2');+ expect((await settled(second)).value).toBeDefined();+ });});diff --git a/apps/mobile/src/__tests__/imageAnnotationModel.test.ts b/apps/mobile/src/__tests__/imageAnnotationModel.test.tsindex b5056b0150..b6c643b080 100644--- a/apps/mobile/src/__tests__/imageAnnotationModel.test.ts+++ b/apps/mobile/src/__tests__/imageAnnotationModel.test.ts@@ -189,11 +189,11 @@ describe('planAnnotationBurnSource(烧录前预处理)', () => {.toMatchObject({ resize: { width: 2048 }, format: 'png' });});- it('Android 上 HEIC / AVIF 即使是小图 / 尺寸未知也先转码为高质量 JPEG;iOS 小图维持原路径', () => {+ it('Android 上 HEIC 即使是小图 / 尺寸未知也先转码为高质量 JPEG,AVIF 转无损 PNG 保留透明;iOS 小图维持原路径', () => {expect(planAnnotationBurnSource({ mimeType: 'image/heic', platformOS: 'android', naturalWidth: 800, naturalHeight: 600 })).toEqual({ resize: null, format: 'jpeg', compress: 0.92, strokeSpace: null });expect(planAnnotationBurnSource({ mimeType: 'image/avif', platformOS: 'android' }))- .toMatchObject({ resize: null, format: 'jpeg', compress: 0.92 });+ .toEqual({ resize: null, format: 'png', compress: 1, strokeSpace: null });// 转码 + 预缩同时发生时仍是 JPEG。expect(planAnnotationBurnSource({ mimeType: 'image/heif', platformOS: 'android', naturalWidth: 4032, naturalHeight: 3024 })).toMatchObject({ resize: { width: 2048 }, format: 'jpeg', compress: 0.92, strokeSpace: { width: 4032, height: 3024 } });diff --git a/apps/mobile/src/i18n/locales/en/composer.json b/apps/mobile/src/i18n/locales/en/composer.jsonindex d1d0ba2bbc..b0ab6bea03 100644--- a/apps/mobile/src/i18n/locales/en/composer.json+++ b/apps/mobile/src/i18n/locales/en/composer.json@@ -19,7 +19,7 @@"imageNotAnnotatable": "This image can't be annotated or forwarded.","downloadOriginalFailed": "Could not download the original image (HTTP {{status}}).","annotationSaveFailed": "Could not save annotation",- "replacementPending": "Your last change to this image hasn’t finished uploading. Wait for it to finish, or retry or remove it above the input, then edit again.",+ "replacementPending": "Your last change to this image hasn't finished uploading. Wait for it to finish, or retry or remove it above the input, then edit again.","tryAgain": "Try again.","sendToChat": "Send to Chat","save": "Save",diff --git a/apps/mobile/src/session/ImageLightbox.tsx b/apps/mobile/src/session/ImageLightbox.tsxindex aac6e6bd8e..c124ea51de 100644--- a/apps/mobile/src/session/ImageLightbox.tsx+++ b/apps/mobile/src/session/ImageLightbox.tsx@@ -570,12 +570,14 @@ export const ImageLightbox = memo(function ImageLightbox({const annotateEnabled = annotateReady && !annotateBlockedReason;const enterAnnotationMode = useCallback(() => {if (!annotateReady || submittingRef.current || sharingRef.current) return;- if (annotateBlockedReason) {- Alert.alert(t('message.lightbox.annotateUnavailableTitle'), annotateBlockedReason);+ // 点按时重新询问宿主:替换上传可能在上次渲染后已落定,避免弹出过期原因。+ const blockedReason = activeImage ? annotation?.annotationBlockedReason?.(activeImage) : undefined;+ if (blockedReason) {+ Alert.alert(t('message.lightbox.annotateUnavailableTitle'), blockedReason);return;}setIsAnnotating(true);- }, [annotateReady, annotateBlockedReason, t]);+ }, [annotateReady, activeImage, annotation, t]);// 独立直发(发送到对话):不要求可标注——gif 等不可画的图同样能转发。const directSubmitVisible = !!annotation?.allowDirectSubmit && !!activeImage && !!activeUri;diff --git a/apps/mobile/src/session/annotationBurnInQueue.ts b/apps/mobile/src/session/annotationBurnInQueue.tsindex bbbd8a02f9..837f875232 100644--- a/apps/mobile/src/session/annotationBurnInQueue.ts+++ b/apps/mobile/src/session/annotationBurnInQueue.ts@@ -221,8 +221,10 @@ export function createAnnotationBurnInQueue(const head = queue[0];if (head && takeHead(head)) {head.reject(new Error(`annotation burn-in webview terminated: ${reason}`));+ // 只有真正打断了任务的崩溃才计数:仅预热持有时(如切后台被系统回收)的崩溃+ // 不累计,避免之后一次正常崩溃就让排队任务全部失败。+ consecutiveCrashes += 1;}- consecutiveCrashes += 1;if (consecutiveCrashes > MAX_CONSECUTIVE_CRASH_REMOUNTS) {// 反复崩溃:不再重建,剩余任务一并失败(走调用方既有失败提示),卸载。failAllQueued(new Error(`annotation burn-in webview terminated: ${reason}`));diff --git a/apps/mobile/src/session/imageAnnotationModel.ts b/apps/mobile/src/session/imageAnnotationModel.tsindex 6cb623366c..929ffbf8ca 100644--- a/apps/mobile/src/session/imageAnnotationModel.ts+++ b/apps/mobile/src/session/imageAnnotationModel.ts@@ -465,8 +465,8 @@ export interface AnnotationBurnSourcePlan {* 决定烧录前要不要先把源图交给原生 manipulator 处理。返回 null = 原样交给* WebView(与既有路径完全一致)。*- * - Android 系统 WebView 解不了 HEIC / HEIF / AVIF:先转成高质量 JPEG,否则用户- * 画完才得到解码失败。+ * - Android 系统 WebView 解不了 HEIC / HEIF / AVIF:先转码(HEIC / HEIF 转高质量+ * JPEG 控制体积,AVIF 可能带透明、转无损 PNG),否则用户画完才得到解码失败。* - 已知尺寸长边超过上传上限(2048)的大图:先按上传同口径缩到上限,WebView* 只需解码 / 注入 / 烧录一张小图(内存与注入体积按像素数下降)。* 尺寸未知时不预缩(不为探测尺寸额外解码),维持原路径。@@ -484,12 +484,15 @@ export function planAnnotationBurnSource(input: {const transcode = input.platformOS === 'android' && ANDROID_WEBVIEW_UNDECODABLE_MIMES.has(mime);const prescale = width > 0 && height > 0 && Math.max(width, height) > MOBILE_IMAGE_UPLOAD_MAX_LONG_EDGE;if (!transcode && !prescale) return null;+ // HEIC/HEIF(相机照片,无透明通道)转 JPEG 控制体积;AVIF 可能带透明(贴纸等),+ // 保持 PNG 以免透明区变黑(体积由调用方的源文件上限兜底)。+ const transcodeToJpeg = transcode && mime !== 'image/avif';return {resize: prescale? (width >= height ? { width: MOBILE_IMAGE_UPLOAD_MAX_LONG_EDGE } : { height: MOBILE_IMAGE_UPLOAD_MAX_LONG_EDGE }): null,- format: mime === 'image/jpeg' || transcode ? 'jpeg' : 'png',- compress: transcode ? ANDROID_TRANSCODE_JPEG_QUALITY : 1,+ format: mime === 'image/jpeg' || transcodeToJpeg ? 'jpeg' : 'png',+ compress: transcodeToJpeg ? ANDROID_TRANSCODE_JPEG_QUALITY : 1,strokeSpace: prescale ? annotationBurnCanvasSize(width, height) : null,};}