Skip to content
Merged
5 changes: 4 additions & 1 deletion mobile/src/i18n/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,10 @@
"compaction": "Kontext komprimiert",
"contextCleared": "Kontext geleert",
"plan": "Plan",
"stoppedManually": "Manuell gestoppt"
"stoppedManually": "Manuell gestoppt",
"permissionDenied": "{{agent}} hat die Berechtigung verweigert. Details anzeigen.",
"safetyReview": "{{agent}} hat eine Warnung zur Sicherheitsprüfung gemeldet. Details anzeigen.",
"truncatedResponse": "Anbieterantwort gekürzt (ursprüngliche Größe: {{bytes}} Bytes)."
},
"orcaStop": {
"canContinue": "Die Unterhaltung kann fortgesetzt werden.",
Expand Down
5 changes: 4 additions & 1 deletion mobile/src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2669,7 +2669,10 @@
"stoppedManually": "Stopped manually",
"compaction": "Context compacted",
"contextCleared": "Context cleared",
"plan": "Plan"
"plan": "Plan",
"permissionDenied": "{{agent}} denied permission. View details.",
"safetyReview": "{{agent}} reported a safety review warning. View details.",
"truncatedResponse": "Provider response truncated (original size: {{bytes}} bytes)."
},
"nativeChatProse": {
"attachedImage": "Attached image",
Expand Down
5 changes: 4 additions & 1 deletion mobile/src/i18n/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,10 @@
"compaction": "Contexto compactado",
"contextCleared": "Contexto borrado",
"plan": "Plan",
"stoppedManually": "Detenido manualmente"
"stoppedManually": "Detenido manualmente",
"permissionDenied": "{{agent}} denegó el permiso. Ver detalles.",
"safetyReview": "{{agent}} notificó una advertencia de revisión de seguridad. Ver detalles.",
"truncatedResponse": "Respuesta del proveedor truncada (tamaño original: {{bytes}} bytes)."
},
"orcaStop": {
"canContinue": "Puedes continuar en esta conversación.",
Expand Down
5 changes: 4 additions & 1 deletion mobile/src/i18n/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,10 @@
"compaction": "Contexte compacté",
"contextCleared": "Contexte effacé",
"plan": "Plan",
"stoppedManually": "Arrêté manuellement"
"stoppedManually": "Arrêté manuellement",
"permissionDenied": "{{agent}} a refusé la permission. Voir les détails.",
"safetyReview": "{{agent}} a signalé un avertissement de sécurité. Voir les détails.",
"truncatedResponse": "Réponse du fournisseur tronquée (taille d’origine : {{bytes}} octets)."
},
"orcaStop": {
"canContinue": "Vous pouvez continuer dans cette conversation.",
Expand Down
5 changes: 4 additions & 1 deletion mobile/src/i18n/locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,10 @@
"compaction": "コンテキストを圧縮しました",
"contextCleared": "コンテキストをクリアしました",
"plan": "プラン",
"stoppedManually": "手動で停止しました"
"stoppedManually": "手動で停止しました",
"permissionDenied": "{{agent}} が権限を拒否しました。詳細を表示。",
"safetyReview": "{{agent}} が安全性レビューの警告を報告しました。詳細を表示。",
"truncatedResponse": "プロバイダーの応答は切り詰められています(元のサイズ:{{bytes}} バイト)。"
},
"orcaStop": {
"canContinue": "この会話で続行できます。",
Expand Down
5 changes: 4 additions & 1 deletion mobile/src/i18n/locales/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,10 @@
"compaction": "컨텍스트가 압축됨",
"contextCleared": "컨텍스트 지워짐",
"plan": "계획",
"stoppedManually": "수동으로 중지됨"
"stoppedManually": "수동으로 중지됨",
"permissionDenied": "{{agent}}이(가) 권한을 거부했습니다. 세부 정보 보기.",
"safetyReview": "{{agent}}이(가) 안전 검토 경고를 보고했습니다. 세부 정보 보기.",
"truncatedResponse": "공급자 응답이 잘렸습니다(원래 크기: {{bytes}}바이트)."
},
"orcaStop": {
"canContinue": "이 대화에서 계속할 수 있습니다.",
Expand Down
5 changes: 4 additions & 1 deletion mobile/src/i18n/locales/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,10 @@
"compaction": "Contexto compactado",
"contextCleared": "Contexto limpo",
"plan": "Plano",
"stoppedManually": "Interrompido manualmente"
"stoppedManually": "Interrompido manualmente",
"permissionDenied": "{{agent}} negou a permissão. Ver detalhes.",
"safetyReview": "{{agent}} relatou um aviso de revisão de segurança. Ver detalhes.",
"truncatedResponse": "Resposta do provedor truncada (tamanho original: {{bytes}} bytes)."
},
"orcaStop": {
"canContinue": "Você pode continuar nesta conversa.",
Expand Down
5 changes: 4 additions & 1 deletion mobile/src/i18n/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,10 @@
"compaction": "Контекст сокращён",
"contextCleared": "Контекст очищен",
"plan": "План",
"stoppedManually": "Остановлено вручную"
"stoppedManually": "Остановлено вручную",
"permissionDenied": "{{agent}} отказал в разрешении. Подробнее.",
"safetyReview": "{{agent}} сообщил о предупреждении проверки безопасности. Подробнее.",
"truncatedResponse": "Ответ поставщика обрезан (исходный размер: {{bytes}} байт)."
},
"orcaStop": {
"canContinue": "Вы можете продолжить этот разговор.",
Expand Down
5 changes: 4 additions & 1 deletion mobile/src/i18n/locales/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,10 @@
"compaction": "Bağlam sıkıştırıldı",
"contextCleared": "Bağlam temizlendi",
"plan": "Plan",
"stoppedManually": "Elle durduruldu"
"stoppedManually": "Elle durduruldu",
"permissionDenied": "{{agent}} izin vermedi. Ayrıntıları görüntüleyin.",
"safetyReview": "{{agent}} bir güvenlik incelemesi uyarısı bildirdi. Ayrıntıları görüntüleyin.",
"truncatedResponse": "Sağlayıcı yanıtı kısaltıldı (özgün boyut: {{bytes}} bayt)."
},
"orcaStop": {
"canContinue": "Bu konuşmada devam edebilirsiniz.",
Expand Down
5 changes: 4 additions & 1 deletion mobile/src/i18n/locales/zh-Hant.json
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,10 @@
"compaction": "已壓縮上下文",
"contextCleared": "上下文已清除",
"plan": "計畫",
"stoppedManually": "已手動停止"
"stoppedManually": "已手動停止",
"permissionDenied": "{{agent}} 拒絕了權限。查看詳細資訊。",
"safetyReview": "{{agent}} 回報了安全審查警告。查看詳細資訊。",
"truncatedResponse": "供應商回應已截斷(原始大小:{{bytes}} 位元組)。"
},
"orcaStop": {
"canContinue": "您可以在此對話中繼續。",
Expand Down
5 changes: 4 additions & 1 deletion mobile/src/i18n/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,10 @@
"compaction": "上下文压缩",
"contextCleared": "上下文已清除",
"plan": "计划",
"stoppedManually": "已手动停止"
"stoppedManually": "已手动停止",
"permissionDenied": "{{agent}} 拒绝了权限。查看详情。",
"safetyReview": "{{agent}} 报告了安全审查警告。查看详情。",
"truncatedResponse": "提供方响应已截断(原始大小:{{bytes}} 字节)。"
},
"orcaStop": {
"canContinue": "您可以在此对话中继续。",
Expand Down
84 changes: 84 additions & 0 deletions mobile/src/session/mobile-native-chat-scroll-ownership.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { MobileNativeChatScrollRootsBoundary } from './MobileNativeChatScrollRoo
import { MobileNativeChatScrollMotion } from './mobile-native-chat-scroll-motion'
import {
mobileNativeChatScrollFrame,
mobileNativeChatScrollRootKey,
mobileNativeChatReadingParts,
mobileNativeChatVisible,
MobileNativeChatScrollRoots
Expand Down Expand Up @@ -482,3 +483,86 @@ it("forgets a closed tool line's nested command and output positions, not its ne
new MobileNativeChatScrollRoots(memory, 10).forget('line:a')
expect([...memory.keys()]).toEqual(['run:o', 'run:o/line:ab:command', 'diff:src/line:a.ts'])
})

it.each([10, 100])(
'bounds expanded notice scroll work and releases collapsed/unmounted roots (%i notices)',
(count) => {
const draw = mount()
const notices = Array.from({ length: count }, (_, i) =>
msg(
`notice:${i}`,
[
{
type: 'text',
text: `Diagnostic ${i}`,
tone: i % 2 === 0 ? 'warning' : 'error',
providerFrame: {
provider: i % 2 === 0 ? 'codex' : 'claude',
kind:
i % 2 === 0 ? 'notification:guardianWarning' : 'message:system:permission_denied',
payload: { head: '{}', byteLength: 2, digest: 'synthetic', truncated: false }
}
}
],
'system'
)
)
const register = vi.spyOn(MobileNativeChatScrollRoots.prototype, 'register')
draw(notices)
expect(register).not.toHaveBeenCalled()
const observer = { observe: vi.fn(), unobserve: vi.fn(), disconnect: vi.fn() }
roots.observeWith(observer)
const toggles = Array.from(container.querySelectorAll('div')).filter(
(node) => node.childElementCount === 0 && node.textContent?.includes('View details.')
)
expect(toggles).toHaveLength(count)
act(() => toggles.forEach((toggle) => toggle.click()))
expect(register).toHaveBeenCalledTimes(count)
expect(observer.observe).toHaveBeenCalledTimes(2 * count)
const viewports = Array.from(container.querySelectorAll<HTMLElement>('[data-chat-scroll-root]'))
expect(viewports).toHaveLength(count)
const ids = viewports.map((node) => mobileNativeChatScrollRootKey(node)!)
expect(new Set(ids).size).toBe(count)
draw([...notices])
viewports.forEach((node) => reader(node, 35))
act(() => vi.advanceTimersByTime(160))

const memoryWrites = vi.spyOn(store.runScroll, 'set')
const queries = vi.spyOn(Element.prototype, 'querySelectorAll')
const geometry = vi.spyOn(Element.prototype, 'getBoundingClientRect')
const capture = vi.spyOn(roots, 'capture')
const restore = vi.spyOn(roots, 'restoreAll')
register.mockClear()
draw([...notices])
expect(capture).toHaveBeenCalledOnce()
expect(restore).toHaveBeenCalledOnce()
expect(memoryWrites).toHaveBeenCalledTimes(2 * count)
expect(queries.mock.calls.length).toBeLessThanOrEqual(12 * count)
expect(geometry.mock.calls.length).toBeLessThanOrEqual(8 * count)
expect(register.mock.calls.length).toBeLessThanOrEqual(count)
expect(observer.observe).toHaveBeenCalledTimes(2 * count)
expect(viewports.map((node) => node.scrollTop)).toEqual(Array(count).fill(35))

act(() => toggles.slice(0, count / 2).forEach((toggle) => toggle.click()))
expect(observer.unobserve).toHaveBeenCalledTimes(count)
ids.forEach((id, i) => expect(roots.frame(id)).toBe(i < count / 2 ? undefined : viewports[i]))
draw(notices, { shown: false })
expect(observer.unobserve).toHaveBeenCalledTimes(2 * count)
for (const node of viewports) {
expect(node.hasAttribute('data-chat-scroll-root')).toBe(false)
expect(mobileNativeChatScrollRootKey(node)).toBeUndefined()
expect(observer.unobserve).toHaveBeenCalledWith(node)
expect(observer.unobserve).toHaveBeenCalledWith(node.firstElementChild)
}
ids.forEach((id) => expect(roots.frame(id)).toBeUndefined())
memoryWrites.mockClear()
queries.mockClear()
geometry.mockClear()
roots.capture(new Set(), false)
roots.restoreAll()
viewports.forEach((node) => reader(node, 50))
expect(memoryWrites).not.toHaveBeenCalled()
expect(queries).not.toHaveBeenCalled()
expect(geometry).not.toHaveBeenCalled()
}
)
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { readFileSync } from 'node:fs'
import { createRequire } from 'node:module'
import { runInNewContext } from 'node:vm'
import { createElement, type ReactNode } from 'react'
import { act, create, type ReactTestInstance, type ReactTestRenderer } from 'react-test-renderer'
import { afterEach, describe, expect, it, vi } from 'vitest'
Expand Down Expand Up @@ -65,6 +68,55 @@ vi.mock('../visual/MobileNativeChatImageViewer', () => ({
import { MobileNativeChatMessage } from './MobileNativeChatMessage'
import { MobileNativeChatRowOverlaysHost } from './MobileNativeChatRowOverlaysHost'

// Run the installed RN gesture state machine; only native bridges are stand-ins.
function loadPressability() {
const requireNative = createRequire(
createRequire(import.meta.url).resolve('react-native/package.json')
)
const requirePreset = createRequire(requireNative.resolve('@react-native/babel-preset'))
const filename = requireNative.resolve('./Libraries/Pressability/Pressability.js')
const { code } = requireNative('@babel/core').transformSync(readFileSync(filename, 'utf8'), {
filename,
babelrc: false,
configFile: false,
plugins: [
requirePreset.resolve('babel-plugin-syntax-hermes-parser'),
requireNative.resolve('@babel/plugin-transform-flow-strip-types'),
requireNative.resolve('@babel/plugin-transform-modules-commonjs')
]
})
return runInNewContext(`${code}\nexports.default`, {
exports: {},
require: (name: string) => {
switch (name) {
case '../../src/private/featureflags/ReactNativeFeatureFlags':
return { shouldPressibilityUseW3CPointerEventsForHover: () => false }
case '../Components/Sound/SoundManager':
return { playTouchSound: vi.fn() }
case '../ReactNative/UIManager':
return { measure: vi.fn() }
case '../StyleSheet/Rect':
return { normalizeRect: (rect: unknown) => rect }
case '../Utilities/Platform':
return { OS: 'android' }
case './HoverState':
return { isHoverEnabled: () => false }
case './PressabilityPerformanceEventEmitter.js':
return { emitEvent: vi.fn() }
case 'invariant':
return requireNative(name)
default:
throw new Error(`Unexpected Pressability dependency: ${name}`)
}
},
setTimeout,
clearTimeout,
Date,
__DEV__: false,
process: { env: { NODE_ENV: 'test' } }
})
}

const inChat = (...rows: NativeChatMessage[]) =>
createElement(
MobileNativeChatRowOverlaysHost,
Expand All @@ -86,6 +138,7 @@ describe('MobileNativeChatMessage on Android', () => {
afterEach(() => {
act(() => renderer?.unmount())
renderer = null
vi.useRealTimers()
})

function byType(type: string): ReactTestInstance[] {
Expand Down Expand Up @@ -115,6 +168,64 @@ describe('MobileNativeChatMessage on Android', () => {
expect(byType('MessageActionsSheet')).toHaveLength(0)
})

it.each([
['codex', 'notification:guardianWarning'],
['claude', 'message:system:permission_denied']
])('keeps %s notice long press for actions and short press for disclosure', (provider, kind) => {
vi.useFakeTimers()
const Pressability = loadPressability()
const notice: NativeChatMessage = {
...message,
role: 'system',
blocks: [
{
type: 'text',
text: 'The command was denied outside the workspace.',
tone: 'error',
providerFrame: {
provider,
kind,
payload: { head: '{}', byteLength: 2, digest: 'synthetic', truncated: false }
}
}
]
}
act(() => {
renderer = create(inChat(notice))
})
const summary = () =>
byType('Pressable').find((node) => node.props.accessibilityLabel?.includes('View details.'))!
const press = (duration: number) => {
const responder = new Pressability({
onPress: summary().props.onPress,
onLongPress: summary().props.onLongPress
})
const handlers = responder.getEventHandlers()
const event = {
currentTarget: 1,
nativeEvent: { pageX: 0, pageY: 0 },
persist: () => {}
}
expect(handlers.onStartShouldSetResponder()).toBe(true)
act(() => {
handlers.onResponderGrant(event)
vi.advanceTimersByTime(duration)
handlers.onResponderRelease(event)
})
responder.reset()
}
press(50)
expect(summary().props['aria-expanded']).toBe(true)
expect(byType('MessageActionsSheet')).toHaveLength(0)
press(50)
expect(summary().props['aria-expanded']).toBe(false)
press(600)
expect(summary().props['aria-expanded']).toBe(false)
expect(byType('MessageActionsSheet')).toHaveLength(1)
expect(byType('MessageActionsSheet')[0]!.props.message).toBe(notice)
expect(summary().props.onLongPress).toBe(byType('Pressable')[0]!.props.onLongPress)
})

it('opens the actions sheet from a long press on an attached picture, not the viewer', () => {
act(() => {
renderer = create(
Expand Down
Loading
Loading