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:
parent
e0b1ceaa75
commit
8d8aaf5794
29 changed files with 627 additions and 26 deletions
|
|
@ -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>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
94
apps/mobile-rn/src/features/history/history-share.ts
Normal file
94
apps/mobile-rn/src/features/history/history-share.ts
Normal 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);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue