feat(mobile): share history as Markdown or original audio and harden the E2E gate

Adds history share (Markdown file / original audio) with 12-locale strings, pins Maestro to
the target device with --udid, allows cleartext only for explicit local E2E artifacts, and
fixes small-screen scroll/keyboard races in the Maestro flows.
Evidence: docs/evidence/2026-11-17-backlog-operations.md.
This commit is contained in:
Yun Chan 2026-11-20 15:16:13 +09:00
parent e0b1ceaa75
commit 8d8aaf5794
29 changed files with 627 additions and 26 deletions

View file

@ -12,7 +12,7 @@
필수 게이트는 실제 가입, OAuth, 결제, 팀 가입, 서버 데이터 생성을 수행하지 않는다.
CI는 같은 `fresh-install-signup.yaml`을 기본 프로필과 `840x1490` 작은 화면에서 각각 실행하고, 실패 여부와 관계없이 디스플레이 override를 초기화한다. Maestro 실행 전에 debug 앱과 AndroidTest APK를 임시 설치해 `CsprngInstrumentedTest`를 한 번 실행한다. 이 계측 검사는 실제 Android `RNGetRandomValuesModule`에서 16바이트 엔트로피를 두 번 받아 길이, non-zero, 비동일성, UUID v4 version/variant 소비 계약을 확인한 뒤 두 패키지를 제거한다. 이후 검증 대상 E2E APK를 fresh install한다.
CI는 같은 `fresh-install-signup.yaml`을 기본 프로필과 `840x1490` 작은 화면에서 각각 실행하고, 실패 여부와 관계없이 디스플레이 override를 초기화한다. 다중 기기 연결 시 `ANDROID_SERIAL`을 지정하면 runner가 모든 Maestro 호출에 같은 `--udid`를 전달해 다른 기기를 선택하지 않는다. 작은 화면에서는 실제 스크롤 후 컨트롤을 탭한다. Maestro 실행 전에 debug 앱과 AndroidTest APK를 임시 설치해 `CsprngInstrumentedTest`를 한 번 실행한다. 이 계측 검사는 실제 Android `RNGetRandomValuesModule`에서 16바이트 엔트로피를 두 번 받아 길이, non-zero, 비동일성, UUID v4 version/variant 소비 계약을 확인한 뒤 두 패키지를 제거한다. 이후 검증 대상 E2E APK를 fresh install한다.
## 외부 계정 게이트

View file

@ -20,6 +20,7 @@ name: Authenticated mobile parity navigation and fail-closed billing
direction: DOWN
timeout: 15000
visibilityPercentage: 50
waitToSettleTimeoutMs: 1000
- tapOn:
id: onboarding-skip
- extendedWaitUntil:
@ -29,6 +30,7 @@ name: Authenticated mobile parity navigation and fail-closed billing
- tapOn:
id: login-email
- inputText: ${MOBILE_E2E_EMAIL}
- hideKeyboard
- tapOn:
id: login-password
- inputText: ${MOBILE_E2E_PASSWORD}
@ -39,6 +41,7 @@ name: Authenticated mobile parity navigation and fail-closed billing
direction: DOWN
timeout: 15000
visibilityPercentage: 50
waitToSettleTimeoutMs: 1000
- tapOn:
id: login-submit
- extendedWaitUntil:
@ -60,8 +63,22 @@ name: Authenticated mobile parity navigation and fail-closed billing
id: record-fab-dictation
- assertVisible:
id: record-screen
- scrollUntilVisible:
element:
id: record-import-file
direction: DOWN
timeout: 15000
visibilityPercentage: 50
waitToSettleTimeoutMs: 1000
- assertVisible:
id: record-import-file
- scrollUntilVisible:
element:
id: record-start
direction: DOWN
timeout: 15000
visibilityPercentage: 50
waitToSettleTimeoutMs: 1000
- tapOn:
id: record-start
- tapOn:
@ -74,14 +91,30 @@ name: Authenticated mobile parity navigation and fail-closed billing
- setPermissions:
permissions:
microphone: allow
- scrollUntilVisible:
element:
id: record-start
direction: DOWN
timeout: 15000
visibilityPercentage: 50
waitToSettleTimeoutMs: 1000
- tapOn:
id: record-start
- extendedWaitUntil:
visible:
id: record-stop
timeout: 15000
- scrollUntilVisible:
element:
id: record-cancel
direction: DOWN
timeout: 15000
visibilityPercentage: 50
waitToSettleTimeoutMs: 1000
- tapOn:
id: record-cancel
waitToSettleTimeoutMs: 1000
retryTapIfNoChange: false
- extendedWaitUntil:
visible:
id: record-start
@ -95,6 +128,7 @@ name: Authenticated mobile parity navigation and fail-closed billing
id: open-talk
direction: DOWN
visibilityPercentage: 50
waitToSettleTimeoutMs: 1000
- tapOn:
id: open-talk
- assertVisible:
@ -109,6 +143,7 @@ name: Authenticated mobile parity navigation and fail-closed billing
id: more-open-settings
direction: DOWN
visibilityPercentage: 50
waitToSettleTimeoutMs: 1000
- tapOn:
id: more-open-settings
- assertVisible:
@ -118,8 +153,16 @@ name: Authenticated mobile parity navigation and fail-closed billing
id: open-account
direction: DOWN
visibilityPercentage: 50
waitToSettleTimeoutMs: 1000
- tapOn:
id: open-account
- scrollUntilVisible:
element:
id: account-logout
direction: DOWN
timeout: 15000
visibilityPercentage: 50
waitToSettleTimeoutMs: 1000
- assertVisible:
id: account-logout
- pressKey: BACK
@ -128,6 +171,7 @@ name: Authenticated mobile parity navigation and fail-closed billing
id: open-paywall
direction: DOWN
visibilityPercentage: 50
waitToSettleTimeoutMs: 1000
- tapOn:
id: open-paywall
- assertVisible:
@ -143,6 +187,7 @@ name: Authenticated mobile parity navigation and fail-closed billing
id: open-devices
direction: DOWN
visibilityPercentage: 50
waitToSettleTimeoutMs: 1000
- tapOn:
id: open-devices
- assertVisible:
@ -168,6 +213,7 @@ name: Authenticated mobile parity navigation and fail-closed billing
id: open-templates
direction: DOWN
visibilityPercentage: 50
waitToSettleTimeoutMs: 1000
- tapOn:
id: open-templates
- assertVisible:
@ -178,6 +224,7 @@ name: Authenticated mobile parity navigation and fail-closed billing
id: open-memos
direction: DOWN
visibilityPercentage: 50
waitToSettleTimeoutMs: 1000
- tapOn:
id: open-memos
- assertVisible:
@ -188,6 +235,7 @@ name: Authenticated mobile parity navigation and fail-closed billing
id: open-teams
direction: DOWN
visibilityPercentage: 50
waitToSettleTimeoutMs: 1000
- tapOn:
id: open-teams
- assertVisible:
@ -198,6 +246,7 @@ name: Authenticated mobile parity navigation and fail-closed billing
id: open-notifications
direction: DOWN
visibilityPercentage: 50
waitToSettleTimeoutMs: 1000
- tapOn:
id: open-notifications
- assertVisible:
@ -215,6 +264,7 @@ name: Authenticated mobile parity navigation and fail-closed billing
id: open-notifications
direction: DOWN
visibilityPercentage: 50
waitToSettleTimeoutMs: 1000
- tapOn:
id: open-notifications
- assertVisible:
@ -227,6 +277,7 @@ name: Authenticated mobile parity navigation and fail-closed billing
id: open-data-portability
direction: DOWN
visibilityPercentage: 50
waitToSettleTimeoutMs: 1000
- tapOn:
id: open-data-portability
- assertVisible:
@ -235,8 +286,9 @@ name: Authenticated mobile parity navigation and fail-closed billing
- scrollUntilVisible:
element:
id: open-dictionary
direction: DOWN
direction: UP
visibilityPercentage: 50
waitToSettleTimeoutMs: 1000
- tapOn:
id: open-dictionary
- assertVisible:
@ -245,8 +297,9 @@ name: Authenticated mobile parity navigation and fail-closed billing
- scrollUntilVisible:
element:
id: open-commands
direction: DOWN
direction: UP
visibilityPercentage: 50
waitToSettleTimeoutMs: 1000
- tapOn:
id: open-commands
- assertVisible:
@ -257,6 +310,7 @@ name: Authenticated mobile parity navigation and fail-closed billing
id: open-knowledge
direction: DOWN
visibilityPercentage: 50
waitToSettleTimeoutMs: 1000
- tapOn:
id: open-knowledge
- assertVisible:
@ -267,6 +321,7 @@ name: Authenticated mobile parity navigation and fail-closed billing
id: open-actions
direction: DOWN
visibilityPercentage: 50
waitToSettleTimeoutMs: 1000
- tapOn:
id: open-actions
- assertVisible:

View file

@ -84,8 +84,8 @@ name: Fresh install complete tutorial and new-account boundary
id: onboarding-next
- scrollUntilVisible:
element:
id: onboarding-step-5
direction: UP
id: onboarding-theme-dark
direction: DOWN
timeout: 10000
visibilityPercentage: 50
- swipe:
@ -130,10 +130,12 @@ name: Fresh install complete tutorial and new-account boundary
permissions:
microphone: allow
notifications: allow
- extendedWaitUntil:
visible:
- scrollUntilVisible:
element:
id: login-submit
direction: DOWN
timeout: 30000
visibilityPercentage: 50
- assertNotVisible:
id: onboarding-screen
- assertNotVisible:
@ -148,6 +150,12 @@ name: Fresh install complete tutorial and new-account boundary
permissions:
microphone: deny
notifications: deny
- scrollUntilVisible:
element:
id: login-submit
direction: DOWN
timeout: 30000
visibilityPercentage: 50
- assertVisible:
id: login-submit
- assertNotVisible:

View file

@ -29,6 +29,7 @@ name: Mobile shell and unified search local proof
- tapOn:
id: login-email
- inputText: ${MOBILE_E2E_EMAIL}
- hideKeyboard
- tapOn:
id: login-password
- inputText: ${MOBILE_E2E_PASSWORD}
@ -86,6 +87,8 @@ name: Mobile shell and unified search local proof
visible:
id: history-detail-favorite
timeout: 30000
- assertVisible:
id: history-detail-share-markdown
- takeScreenshot: unified-search-record-detail
- pressKey: BACK
- extendedWaitUntil:

View file

@ -69,6 +69,28 @@ jest.mock('../src/features/history/history-service', () => {
}
})
const mockPrepareTranscriptShareFile = jest.fn()
const mockPrepareAudioShareFile = jest.fn()
const mockSharePreparedPortableFile = jest.fn()
const mockDisposePreparedFile = jest.fn(async () => undefined)
const PREPARED_FILE = {
path: '/cache/portable_exports/transcript.md',
uri: 'file:///cache/portable_exports/transcript.md',
fileName: 'transcript.md',
mimeType: 'text/markdown',
format: 'md',
textContent: 'transcript',
dispose: mockDisposePreparedFile,
}
jest.mock('../src/features/history/history-share', () => ({
prepareTranscriptShareFile: (...args: unknown[]) => mockPrepareTranscriptShareFile(...args),
prepareAudioShareFile: (...args: unknown[]) => mockPrepareAudioShareFile(...args),
}))
jest.mock('../src/features/data-portability/portable-file', () => ({
sharePreparedPortableFile: (...args: unknown[]) => mockSharePreparedPortableFile(...args),
}))
import HistoryDetailScreen from '../src/screens/HistoryDetailScreen'
const SAMPLE_DETAIL: HistoryDetail = {
@ -129,7 +151,11 @@ describe('HistoryDetailScreen unmount audio & async cleanup', () => {
mockPausePlayer.mockClear()
mockResumePlayer.mockClear()
mockGetHistoryDetail.mockReset().mockResolvedValue(SAMPLE_DETAIL)
mockCreateAudioPlaybackUrl.mockReset()
mockCreateAudioPlaybackUrl.mockReset().mockResolvedValue('https://storage.example/signed.wav')
mockPrepareTranscriptShareFile.mockReset().mockResolvedValue(PREPARED_FILE)
mockPrepareAudioShareFile.mockReset().mockResolvedValue(PREPARED_FILE)
mockSharePreparedPortableFile.mockReset().mockResolvedValue(undefined)
mockDisposePreparedFile.mockClear()
mockGoBack.mockClear()
})
@ -181,4 +207,85 @@ describe('HistoryDetailScreen unmount audio & async cleanup', () => {
})
expect(mockStartPlayer).not.toHaveBeenCalled()
})
test('HistoryDetailScreen_Markdown버튼_파일생성및공유호출', async () => {
let renderer!: ReactTestRenderer
await act(async () => {
renderer = create(
<HistoryDetailScreen
route={{ key: 'HistoryDetail-2', name: 'HistoryDetail', params: { historyId: HISTORY_ID } }}
navigation={{ goBack: mockGoBack } as never}
/>,
)
})
await act(async () => {
renderer.root.findByProps({ testID: 'history-detail-share-markdown' }).props.onPress()
await Promise.resolve()
})
expect(mockPrepareTranscriptShareFile).toHaveBeenCalledWith(
SAMPLE_DETAIL.entry,
'md',
'mobile.hist.summaryLabel',
)
expect(mockSharePreparedPortableFile).toHaveBeenCalledWith(PREPARED_FILE, 'mobile.hist.shareMarkdown')
act(() => renderer.unmount())
})
test('HistoryDetailScreen_원본오디오버튼_서명URL다운로드후공유', async () => {
let renderer!: ReactTestRenderer
await act(async () => {
renderer = create(
<HistoryDetailScreen
route={{ key: 'HistoryDetail-3', name: 'HistoryDetail', params: { historyId: HISTORY_ID } }}
navigation={{ goBack: mockGoBack } as never}
/>,
)
})
await act(async () => {
renderer.root.findByProps({ testID: `history-audio-share-${AUDIO_ID}` }).props.onPress()
await Promise.resolve()
})
expect(mockCreateAudioPlaybackUrl).toHaveBeenCalledWith(USER_ID, SAMPLE_DETAIL.audioFiles[0])
expect(mockPrepareAudioShareFile).toHaveBeenCalledWith(
SAMPLE_DETAIL.audioFiles[0],
'https://storage.example/signed.wav',
)
expect(mockSharePreparedPortableFile).toHaveBeenCalledWith(PREPARED_FILE, 'mobile.hist.shareAudio')
act(() => renderer.unmount())
})
test('HistoryDetailScreen_공유준비중언마운트_늦은공유시트를열지않고파일정리', async () => {
let resolvePreparation: (file: typeof PREPARED_FILE) => void = () => undefined
mockPrepareAudioShareFile.mockImplementation(
() => new Promise<typeof PREPARED_FILE>((resolve) => {
resolvePreparation = resolve
}),
)
let renderer!: ReactTestRenderer
await act(async () => {
renderer = create(
<HistoryDetailScreen
route={{ key: 'HistoryDetail-4', name: 'HistoryDetail', params: { historyId: HISTORY_ID } }}
navigation={{ goBack: mockGoBack } as never}
/>,
)
})
await act(async () => {
renderer.root.findByProps({ testID: `history-audio-share-${AUDIO_ID}` }).props.onPress()
await Promise.resolve()
})
act(() => renderer.unmount())
await act(async () => {
resolvePreparation(PREPARED_FILE)
await Promise.resolve()
})
expect(mockSharePreparedPortableFile).not.toHaveBeenCalled()
expect(mockDisposePreparedFile).toHaveBeenCalledTimes(1)
})
})

View file

@ -0,0 +1,92 @@
import { FileSystem } from 'react-native-file-access';
import {
MAX_SHARED_AUDIO_BYTES,
prepareAudioShareFile,
prepareTranscriptShareFile,
} from '../src/features/history/history-share';
jest.mock('react-native-file-access', () => ({
Dirs: { CacheDir: '/cache' },
FileSystem: {
exists: jest.fn(async () => true),
mkdir: jest.fn(async () => undefined),
writeFile: jest.fn(async () => undefined),
stat: jest.fn(async () => ({ size: 1 })),
unlink: jest.fn(async () => undefined),
},
}));
const ENTRY = {
title: '주간 회의',
original_text: '원문',
polished_text: '다듬은 전사',
summary_text: '요약 내용',
};
describe('기록 파일 공유', () => {
beforeEach(() => {
jest.clearAllMocks();
});
it('다듬은 전사와 요약을 Markdown 파일로 저장한다', async () => {
const file = await prepareTranscriptShareFile(ENTRY, 'md', '요약');
const write = jest.mocked(FileSystem.writeFile);
expect(file.format).toBe('md');
expect(file.mimeType).toBe('text/markdown');
expect(file.fileName.endsWith('.md')).toBe(true);
expect(write.mock.calls[0]?.[1]).toBe('# 주간 회의\n\n다듬은 전사\n\n## 요약\n\n요약 내용');
});
it('다듬은 값이 비어 있으면 원문으로 텍스트 파일을 만든다', async () => {
await prepareTranscriptShareFile({ ...ENTRY, polished_text: ' ' }, 'txt', '요약');
expect(jest.mocked(FileSystem.writeFile).mock.calls[0]?.[1]).toBe('주간 회의\n\n원문\n\n요약\n\n요약 내용');
});
it('사용자가 선택한 원본 오디오를 제한 안에서 파일로 준비한다', async () => {
const bytes = new Uint8Array([82, 73, 70, 70]);
const fetchAudio: typeof fetch = async () => new Response(bytes, {
status: 200,
headers: { 'content-length': String(bytes.byteLength) },
});
const file = await prepareAudioShareFile({
mime_type: 'audio/wav',
original_name: '회의.wav',
size_bytes: bytes.byteLength,
}, 'https://example.com/signed-audio', fetchAudio);
expect(file).toMatchObject({
format: 'binary',
mimeType: 'audio/wav',
textContent: null,
});
expect(jest.mocked(FileSystem.writeFile).mock.calls[0]?.[2]).toBe('base64');
});
it('Content-Length가 50 MiB를 넘으면 본문을 파일에 쓰지 않는다', async () => {
const fetchAudio: typeof fetch = async () => new Response(new Uint8Array([1]), {
status: 200,
headers: { 'content-length': String(MAX_SHARED_AUDIO_BYTES + 1) },
});
await expect(prepareAudioShareFile({
mime_type: 'audio/wav',
original_name: 'large.wav',
size_bytes: 1,
}, 'https://example.com/signed-audio', fetchAudio)).rejects.toThrow('50 MiB');
expect(FileSystem.writeFile).not.toHaveBeenCalled();
});
it('다운로드 실패를 공유 성공으로 처리하지 않는다', async () => {
const fetchAudio: typeof fetch = async () => new Response(null, { status: 403 });
await expect(prepareAudioShareFile({
mime_type: 'audio/wav',
original_name: 'private.wav',
size_bytes: 4,
}, 'https://example.com/expired-audio', fetchAudio)).rejects.toThrow('HTTP 403');
expect(FileSystem.writeFile).not.toHaveBeenCalled();
});
});

View file

@ -31,7 +31,6 @@
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>d3ro</string>
<string>d3ro-voice</string>
</array>
</dict>

View file

@ -56,7 +56,7 @@
"typescript": "^5.8.3"
},
"engines": {
"node": "^22.21.0 || ^24.3.0 || >=25.0.0"
"node": "24.x"
}
},
"../..": {

View file

@ -61,6 +61,6 @@
"typescript": "^5.8.3"
},
"engines": {
"node": "^22.21.0 || ^24.3.0 || >=25.0.0"
"node": "24.x"
}
}

View file

@ -224,7 +224,7 @@ export interface PreparedPortableFile {
uri: string;
fileName: string;
mimeType: string;
format: PortableTextFormat | MeetingDocumentFormat;
format: PortableTextFormat | MeetingDocumentFormat | 'binary';
textContent: string | null;
dispose: () => Promise<void>;
}

View file

@ -74,7 +74,7 @@ async function disposeExport(path: string): Promise<void> {
if (await FileSystem.exists(path)) await FileSystem.unlink(path);
}
async function persistExport(options: {
export async function persistExport(options: {
baseName: string;
extension: string;
mimeType: string;

View file

@ -0,0 +1,94 @@
import type { AudioFile, HistoryEntry } from '@d3ro/api-client';
import { persistExport } from '../data-portability/portable-file';
import type { PreparedPortableFile } from '../data-portability/portability-types';
export const MAX_SHARED_AUDIO_BYTES = 50 * 1024 * 1024;
export type TranscriptShareFormat = 'txt' | 'md';
type TranscriptShareEntry = Pick<
HistoryEntry,
'title' | 'original_text' | 'polished_text' | 'summary_text'
>;
export function buildTranscriptShareText(
entry: TranscriptShareEntry,
format: TranscriptShareFormat,
summaryLabel: string,
): string {
const title = entry.title?.replace(/\s*\r?\n\s*/g, ' ').trim() ?? '';
const transcript = entry.polished_text?.trim() || entry.original_text.trim();
const summary = entry.summary_text?.trim() ?? '';
const sections = [
format === 'md' && title !== '' ? `# ${title}` : title,
transcript,
];
if (summary !== '') {
sections.push(`${format === 'md' ? '## ' : ''}${summaryLabel}`, summary);
}
return sections.filter(section => section !== '').join('\n\n');
}
export function prepareTranscriptShareFile(
entry: TranscriptShareEntry,
format: TranscriptShareFormat,
summaryLabel: string,
): Promise<PreparedPortableFile> {
return persistExport({
baseName: entry.title?.trim() || 'd3ro-transcript',
extension: format,
mimeType: format === 'md' ? 'text/markdown' : 'text/plain',
format,
text: buildTranscriptShareText(entry, format, summaryLabel),
bytes: null,
});
}
const AUDIO_EXTENSIONS: Readonly<Record<string, string>> = {
'audio/aac': 'aac',
'audio/flac': 'flac',
'audio/mp4': 'm4a',
'audio/mpeg': 'mp3',
'audio/ogg': 'ogg',
'audio/wav': 'wav',
'audio/wave': 'wav',
'audio/webm': 'webm',
'audio/x-m4a': 'm4a',
'audio/x-wav': 'wav',
'video/mp4': 'mp4',
};
export async function prepareAudioShareFile(
audioFile: Pick<AudioFile, 'mime_type' | 'original_name' | 'size_bytes'>,
signedUrl: string,
fetchAudio: typeof fetch = fetch,
): Promise<PreparedPortableFile> {
const mimeType = audioFile.mime_type.toLowerCase().split(';')[0].trim();
const extension = AUDIO_EXTENSIONS[mimeType];
if (extension === undefined) throw new Error('Unsupported audio share format');
if (audioFile.size_bytes > MAX_SHARED_AUDIO_BYTES) throw new Error('Audio share exceeds 50 MiB');
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), 30_000);
try {
const response = await fetchAudio(signedUrl, { signal: controller.signal });
if (!response.ok) throw new Error(`Audio download failed with HTTP ${response.status}`);
const declaredLength = Number(response.headers.get('content-length'));
if (Number.isFinite(declaredLength) && declaredLength > MAX_SHARED_AUDIO_BYTES) {
throw new Error('Audio share exceeds 50 MiB');
}
const bytes = new Uint8Array(await response.arrayBuffer());
if (bytes.byteLength === 0) throw new Error('Audio share is empty');
if (bytes.byteLength > MAX_SHARED_AUDIO_BYTES) throw new Error('Audio share exceeds 50 MiB');
return await persistExport({
baseName: audioFile.original_name?.replace(/\.[^.]+$/, '') || 'd3ro-audio',
extension,
mimeType,
format: 'binary',
text: null,
bytes,
});
} finally {
clearTimeout(timeout);
}
}

View file

@ -30,6 +30,14 @@ import {
type HistoryDetail,
} from '../features/history/history-service'
import { loadHistoryCache } from '../features/history/history-cache'
import {
prepareAudioShareFile,
prepareTranscriptShareFile,
} from '../features/history/history-share'
import {
sharePreparedPortableFile,
} from '../features/data-portability/portable-file'
import type { PreparedPortableFile } from '../features/data-portability/portability-types'
import { useMobilePreferences } from '../lib/preferences-context'
const HISTORY_MODE_KEYS: Record<HistoryEntry['mode'], TranslationKey> = {
@ -104,6 +112,8 @@ export default function HistoryDetailScreen({
const [activeAudioId, setActiveAudioId] = useState<string | null>(null)
const [paused, setPaused] = useState(false)
const [audioBusy, setAudioBusy] = useState(false)
const [sharingFile, setSharingFile] = useState(false)
const [sharingAudioId, setSharingAudioId] = useState<string | null>(null)
useEffect(() => {
mountedRef.current = true
@ -306,6 +316,48 @@ export default function HistoryDetailScreen({
}
}
const shareTranscriptFile = async (): Promise<void> => {
if (detail === null || sharingFile) return
setSharingFile(true)
setError(null)
let file: PreparedPortableFile | null = null
try {
file = await prepareTranscriptShareFile(detail.entry, 'md', t('mobile.hist.summaryLabel'))
if (!mountedRef.current) {
await file.dispose().catch(() => undefined)
return
}
await sharePreparedPortableFile(file, t('mobile.hist.shareMarkdown'))
} catch {
if (file !== null) await file.dispose().catch(() => undefined)
if (mountedRef.current) setError(t('mobile.hist.shareFailed'))
} finally {
if (mountedRef.current) setSharingFile(false)
}
}
const shareAudio = async (audioFile: AudioFile): Promise<void> => {
if (user === null || sharingAudioId !== null || offline || audioFile.upload_status !== 'uploaded') return
setSharingAudioId(audioFile.id)
setError(null)
let file: PreparedPortableFile | null = null
try {
const signedUrl = await createAudioPlaybackUrl(user.id, audioFile)
if (!mountedRef.current) return
file = await prepareAudioShareFile(audioFile, signedUrl)
if (!mountedRef.current) {
await file.dispose().catch(() => undefined)
return
}
await sharePreparedPortableFile(file, t('mobile.hist.shareAudio'))
} catch {
if (file !== null) await file.dispose().catch(() => undefined)
if (mountedRef.current) setError(t('mobile.hist.audioError'))
} finally {
if (mountedRef.current) setSharingAudioId(null)
}
}
const controlAudio = async (audioFile: AudioFile): Promise<void> => {
if (user === null || audioBusy) return
const playbackGeneration = ++playbackGenerationRef.current
@ -478,6 +530,16 @@ export default function HistoryDetailScreen({
>
<PhosphorText variant="small" color="primary">{t('mobile.hist.share')}</PhosphorText>
</Pressable>
<Pressable
accessibilityRole="button"
accessibilityLabel={t('mobile.hist.shareMarkdown')}
disabled={sharingFile || saving || editing}
onPress={() => { void shareTranscriptFile() }}
style={styles.compactButton}
testID="history-detail-share-markdown"
>
<PhosphorText variant="small" color="primary">{t('mobile.hist.shareMarkdown')}</PhosphorText>
</Pressable>
</View>
<FieldLabel label={t('mobile.hist.titleLabel')} />
@ -611,6 +673,16 @@ export default function HistoryDetailScreen({
: t('mobile.hist.audioPlay')}
</PhosphorText>
</Pressable>
<Pressable
accessibilityRole="button"
accessibilityLabel={t('mobile.hist.shareAudio')}
disabled={audioBusy || sharingAudioId !== null || audioFile.upload_status !== 'uploaded' || offline}
onPress={() => { void shareAudio(audioFile) }}
style={styles.compactButton}
testID={`history-audio-share-${audioFile.id}`}
>
<PhosphorText variant="small" color="primary">{t('mobile.hist.share')}</PhosphorText>
</Pressable>
</View>
))}
{activeAudioId !== null && (
@ -729,7 +801,7 @@ function createStyles(palette: Palette) {
},
inlineButton: { minHeight: 48, justifyContent: 'center' },
primaryCard: { gap: 8 },
actionRow: { flexDirection: 'row', justifyContent: 'flex-end', gap: 8, marginBottom: 4 },
actionRow: { flexDirection: 'row', flexWrap: 'wrap', justifyContent: 'flex-end', gap: 8, marginBottom: 4 },
compactButton: {
minWidth: 48,
minHeight: 48,