markupr 2.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/commands/review-feedback.md +47 -0
- package/.eslintrc.json +35 -0
- package/.github/CODEOWNERS +16 -0
- package/.github/FUNDING.yml +1 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +56 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +54 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +89 -0
- package/.github/dependabot.yml +70 -0
- package/.github/workflows/ci.yml +184 -0
- package/.github/workflows/deploy-landing.yml +134 -0
- package/.github/workflows/nightly.yml +288 -0
- package/.github/workflows/release.yml +318 -0
- package/CHANGELOG.md +127 -0
- package/CLAUDE.md +137 -0
- package/CODE_OF_CONDUCT.md +9 -0
- package/CONTRIBUTING.md +390 -0
- package/LICENSE +21 -0
- package/PRODUCT_VISION.md +277 -0
- package/README.md +517 -0
- package/SECURITY.md +51 -0
- package/SIGNING_INSTRUCTIONS.md +284 -0
- package/assets/DMG_BACKGROUND_INSTRUCTIONS.md +130 -0
- package/assets/svg-source/dmg-background.svg +70 -0
- package/assets/svg-source/icon.svg +20 -0
- package/assets/svg-source/tray-icon-processing.svg +7 -0
- package/assets/svg-source/tray-icon-recording.svg +7 -0
- package/assets/svg-source/tray-icon.svg +6 -0
- package/assets/tray-complete.png +0 -0
- package/assets/tray-complete@2x.png +0 -0
- package/assets/tray-completeTemplate.png +0 -0
- package/assets/tray-completeTemplate@2x.png +0 -0
- package/assets/tray-error.png +0 -0
- package/assets/tray-error@2x.png +0 -0
- package/assets/tray-errorTemplate.png +0 -0
- package/assets/tray-errorTemplate@2x.png +0 -0
- package/assets/tray-icon-processing.png +0 -0
- package/assets/tray-icon-processing@2x.png +0 -0
- package/assets/tray-icon-processingTemplate.png +0 -0
- package/assets/tray-icon-processingTemplate@2x.png +0 -0
- package/assets/tray-icon-recording.png +0 -0
- package/assets/tray-icon-recording@2x.png +0 -0
- package/assets/tray-icon-recordingTemplate.png +0 -0
- package/assets/tray-icon-recordingTemplate@2x.png +0 -0
- package/assets/tray-icon.png +0 -0
- package/assets/tray-icon@2x.png +0 -0
- package/assets/tray-iconTemplate.png +0 -0
- package/assets/tray-iconTemplate@2x.png +0 -0
- package/assets/tray-idle.png +0 -0
- package/assets/tray-idle@2x.png +0 -0
- package/assets/tray-idleTemplate.png +0 -0
- package/assets/tray-idleTemplate@2x.png +0 -0
- package/assets/tray-processing-0.png +0 -0
- package/assets/tray-processing-0@2x.png +0 -0
- package/assets/tray-processing-0Template.png +0 -0
- package/assets/tray-processing-0Template@2x.png +0 -0
- package/assets/tray-processing-1.png +0 -0
- package/assets/tray-processing-1@2x.png +0 -0
- package/assets/tray-processing-1Template.png +0 -0
- package/assets/tray-processing-1Template@2x.png +0 -0
- package/assets/tray-processing-2.png +0 -0
- package/assets/tray-processing-2@2x.png +0 -0
- package/assets/tray-processing-2Template.png +0 -0
- package/assets/tray-processing-2Template@2x.png +0 -0
- package/assets/tray-processing-3.png +0 -0
- package/assets/tray-processing-3@2x.png +0 -0
- package/assets/tray-processing-3Template.png +0 -0
- package/assets/tray-processing-3Template@2x.png +0 -0
- package/assets/tray-processing.png +0 -0
- package/assets/tray-processing@2x.png +0 -0
- package/assets/tray-processingTemplate.png +0 -0
- package/assets/tray-processingTemplate@2x.png +0 -0
- package/assets/tray-recording.png +0 -0
- package/assets/tray-recording@2x.png +0 -0
- package/assets/tray-recordingTemplate.png +0 -0
- package/assets/tray-recordingTemplate@2x.png +0 -0
- package/build/DMG_BACKGROUND_SPEC.md +50 -0
- package/build/dmg-background.png +0 -0
- package/build/dmg-background@2x.png +0 -0
- package/build/entitlements.mac.inherit.plist +27 -0
- package/build/entitlements.mac.plist +41 -0
- package/build/favicon-16.png +0 -0
- package/build/favicon-180.png +0 -0
- package/build/favicon-192.png +0 -0
- package/build/favicon-32.png +0 -0
- package/build/favicon-48.png +0 -0
- package/build/favicon-512.png +0 -0
- package/build/favicon-64.png +0 -0
- package/build/icon-128.png +0 -0
- package/build/icon-16.png +0 -0
- package/build/icon-24.png +0 -0
- package/build/icon-256.png +0 -0
- package/build/icon-32.png +0 -0
- package/build/icon-48.png +0 -0
- package/build/icon-64.png +0 -0
- package/build/icon.icns +0 -0
- package/build/icon.ico +0 -0
- package/build/icon.iconset/icon_128x128.png +0 -0
- package/build/icon.iconset/icon_128x128@2x.png +0 -0
- package/build/icon.iconset/icon_16x16.png +0 -0
- package/build/icon.iconset/icon_16x16@2x.png +0 -0
- package/build/icon.iconset/icon_256x256.png +0 -0
- package/build/icon.iconset/icon_256x256@2x.png +0 -0
- package/build/icon.iconset/icon_32x32.png +0 -0
- package/build/icon.iconset/icon_32x32@2x.png +0 -0
- package/build/icon.iconset/icon_512x512.png +0 -0
- package/build/icon.iconset/icon_512x512@2x.png +0 -0
- package/build/icon.png +0 -0
- package/build/installer-header.bmp +0 -0
- package/build/installer-header.png +0 -0
- package/build/installer-sidebar.bmp +0 -0
- package/build/installer-sidebar.png +0 -0
- package/build/installer.nsh +45 -0
- package/build/overlay-processing.png +0 -0
- package/build/overlay-recording.png +0 -0
- package/build/toolbar-record.png +0 -0
- package/build/toolbar-screenshot.png +0 -0
- package/build/toolbar-settings.png +0 -0
- package/build/toolbar-stop.png +0 -0
- package/dist/main/index.mjs +12612 -0
- package/dist/preload/index.mjs +907 -0
- package/dist/renderer/assets/index-CCmUjl9K.js +19495 -0
- package/dist/renderer/assets/index-CUqz_Gs6.css +2270 -0
- package/dist/renderer/index.html +27 -0
- package/docs/AI_AGENT_QUICKSTART.md +42 -0
- package/docs/AI_PIPELINE_DESIGN.md +595 -0
- package/docs/API.md +514 -0
- package/docs/ARCHITECTURE.md +460 -0
- package/docs/CONFIGURATION.md +336 -0
- package/docs/DEVELOPMENT.md +508 -0
- package/docs/EXPORT_FORMATS.md +451 -0
- package/docs/GETTING_STARTED.md +236 -0
- package/docs/KEYBOARD_SHORTCUTS.md +334 -0
- package/docs/TROUBLESHOOTING.md +418 -0
- package/docs/landing/index.html +672 -0
- package/docs/landing/script.js +342 -0
- package/docs/landing/styles.css +1543 -0
- package/electron-builder.yml +140 -0
- package/electron.vite.config.ts +63 -0
- package/package.json +108 -0
- package/railway.json +12 -0
- package/scripts/build.mjs +51 -0
- package/scripts/generate-icons.mjs +314 -0
- package/scripts/generate-installer-images.cjs +253 -0
- package/scripts/generate-tray-icons.mjs +258 -0
- package/scripts/notarize.cjs +180 -0
- package/scripts/one-click-clean-test.sh +147 -0
- package/scripts/postinstall.mjs +36 -0
- package/scripts/setup-markupr.sh +55 -0
- package/setup +17 -0
- package/site/index.html +1835 -0
- package/site/package.json +11 -0
- package/site/railway.json +12 -0
- package/site/server.js +31 -0
- package/src/main/AutoUpdater.ts +392 -0
- package/src/main/CrashRecovery.ts +655 -0
- package/src/main/ErrorHandler.ts +703 -0
- package/src/main/HotkeyManager.ts +399 -0
- package/src/main/MenuManager.ts +529 -0
- package/src/main/PermissionManager.ts +420 -0
- package/src/main/SessionController.ts +1465 -0
- package/src/main/TrayManager.ts +540 -0
- package/src/main/ai/AIPipelineManager.ts +199 -0
- package/src/main/ai/ClaudeAnalyzer.ts +339 -0
- package/src/main/ai/ImageOptimizer.ts +176 -0
- package/src/main/ai/StructuredMarkdownBuilder.ts +379 -0
- package/src/main/ai/index.ts +16 -0
- package/src/main/ai/types.ts +258 -0
- package/src/main/analysis/ClarificationGenerator.ts +385 -0
- package/src/main/analysis/FeedbackAnalyzer.ts +531 -0
- package/src/main/analysis/index.ts +19 -0
- package/src/main/audio/AudioCapture.ts +978 -0
- package/src/main/audio/audioUtils.ts +100 -0
- package/src/main/audio/index.ts +20 -0
- package/src/main/capture/index.ts +1 -0
- package/src/main/index.ts +1693 -0
- package/src/main/ipc/captureHandlers.ts +272 -0
- package/src/main/ipc/index.ts +45 -0
- package/src/main/ipc/outputHandlers.ts +302 -0
- package/src/main/ipc/sessionHandlers.ts +56 -0
- package/src/main/ipc/settingsHandlers.ts +471 -0
- package/src/main/ipc/types.ts +56 -0
- package/src/main/ipc/windowHandlers.ts +277 -0
- package/src/main/output/ClipboardService.ts +369 -0
- package/src/main/output/ExportService.ts +539 -0
- package/src/main/output/FileManager.ts +416 -0
- package/src/main/output/MarkdownGenerator.ts +791 -0
- package/src/main/output/MarkdownPatcher.ts +299 -0
- package/src/main/output/index.ts +186 -0
- package/src/main/output/sessionAdapter.ts +207 -0
- package/src/main/output/templates/html-template.ts +553 -0
- package/src/main/pipeline/FrameExtractor.ts +330 -0
- package/src/main/pipeline/PostProcessor.ts +399 -0
- package/src/main/pipeline/TranscriptAnalyzer.ts +226 -0
- package/src/main/pipeline/index.ts +36 -0
- package/src/main/platform/WindowsTaskbar.ts +600 -0
- package/src/main/platform/index.ts +16 -0
- package/src/main/settings/SettingsManager.ts +730 -0
- package/src/main/settings/index.ts +19 -0
- package/src/main/transcription/ModelDownloadManager.ts +494 -0
- package/src/main/transcription/TierManager.ts +219 -0
- package/src/main/transcription/TranscriptionRecoveryService.ts +340 -0
- package/src/main/transcription/WhisperService.ts +748 -0
- package/src/main/transcription/index.ts +56 -0
- package/src/main/transcription/types.ts +135 -0
- package/src/main/windows/PopoverManager.ts +284 -0
- package/src/main/windows/TaskbarIntegration.ts +452 -0
- package/src/main/windows/index.ts +23 -0
- package/src/preload/index.ts +1047 -0
- package/src/renderer/App.tsx +515 -0
- package/src/renderer/AppWrapper.tsx +28 -0
- package/src/renderer/assets/logo-dark.svg +7 -0
- package/src/renderer/assets/logo.svg +7 -0
- package/src/renderer/audio/AudioCaptureRenderer.ts +454 -0
- package/src/renderer/capture/ScreenRecordingRenderer.ts +492 -0
- package/src/renderer/components/AnnotationOverlay.tsx +836 -0
- package/src/renderer/components/AudioWaveform.tsx +811 -0
- package/src/renderer/components/ClarificationQuestions.tsx +656 -0
- package/src/renderer/components/CountdownTimer.tsx +495 -0
- package/src/renderer/components/CrashRecoveryDialog.tsx +632 -0
- package/src/renderer/components/DonateButton.tsx +127 -0
- package/src/renderer/components/ErrorBoundary.tsx +308 -0
- package/src/renderer/components/ExportDialog.tsx +872 -0
- package/src/renderer/components/HotkeyHint.tsx +261 -0
- package/src/renderer/components/KeyboardShortcuts.tsx +787 -0
- package/src/renderer/components/ModelDownloadDialog.tsx +844 -0
- package/src/renderer/components/Onboarding.tsx +1830 -0
- package/src/renderer/components/ProcessingOverlay.tsx +157 -0
- package/src/renderer/components/RecordingOverlay.tsx +423 -0
- package/src/renderer/components/SessionHistory.tsx +1746 -0
- package/src/renderer/components/SessionReview.tsx +1321 -0
- package/src/renderer/components/SettingsPanel.tsx +217 -0
- package/src/renderer/components/Skeleton.tsx +347 -0
- package/src/renderer/components/StatusIndicator.tsx +86 -0
- package/src/renderer/components/ThemeProvider.tsx +429 -0
- package/src/renderer/components/Tooltip.tsx +370 -0
- package/src/renderer/components/TranscriptionPreview.tsx +183 -0
- package/src/renderer/components/TranscriptionTierSelector.tsx +640 -0
- package/src/renderer/components/UpdateNotification.tsx +377 -0
- package/src/renderer/components/WindowSelector.tsx +947 -0
- package/src/renderer/components/index.ts +99 -0
- package/src/renderer/components/primitives/ApiKeyInput.tsx +98 -0
- package/src/renderer/components/primitives/ColorPicker.tsx +65 -0
- package/src/renderer/components/primitives/DangerButton.tsx +45 -0
- package/src/renderer/components/primitives/DirectoryPicker.tsx +41 -0
- package/src/renderer/components/primitives/Dropdown.tsx +34 -0
- package/src/renderer/components/primitives/KeyRecorder.tsx +117 -0
- package/src/renderer/components/primitives/SettingsSection.tsx +32 -0
- package/src/renderer/components/primitives/Slider.tsx +43 -0
- package/src/renderer/components/primitives/Toggle.tsx +36 -0
- package/src/renderer/components/primitives/index.ts +10 -0
- package/src/renderer/components/settings/AdvancedTab.tsx +174 -0
- package/src/renderer/components/settings/AppearanceTab.tsx +77 -0
- package/src/renderer/components/settings/GeneralTab.tsx +40 -0
- package/src/renderer/components/settings/HotkeysTab.tsx +79 -0
- package/src/renderer/components/settings/RecordingTab.tsx +84 -0
- package/src/renderer/components/settings/index.ts +9 -0
- package/src/renderer/components/settings/settingsStyles.ts +673 -0
- package/src/renderer/components/settings/tabConfig.tsx +85 -0
- package/src/renderer/components/settings/useSettingsPanel.ts +447 -0
- package/src/renderer/contexts/ProcessingContext.tsx +227 -0
- package/src/renderer/contexts/RecordingContext.tsx +683 -0
- package/src/renderer/contexts/UIContext.tsx +326 -0
- package/src/renderer/contexts/index.ts +24 -0
- package/src/renderer/donateMessages.ts +69 -0
- package/src/renderer/hooks/index.ts +75 -0
- package/src/renderer/hooks/useAnimation.tsx +544 -0
- package/src/renderer/hooks/useTheme.ts +313 -0
- package/src/renderer/index.html +26 -0
- package/src/renderer/main.tsx +52 -0
- package/src/renderer/styles/animations.css +1093 -0
- package/src/renderer/styles/app-shell.css +662 -0
- package/src/renderer/styles/globals.css +515 -0
- package/src/renderer/styles/theme.ts +578 -0
- package/src/renderer/types/electron.d.ts +385 -0
- package/src/shared/hotkeys.ts +283 -0
- package/src/shared/types.ts +809 -0
- package/tests/clipboard.test.ts +228 -0
- package/tests/e2e/criticalPaths.test.ts +594 -0
- package/tests/feedbackAnalyzer.test.ts +303 -0
- package/tests/integration/sessionFlow.test.ts +583 -0
- package/tests/markdownGenerator.test.ts +418 -0
- package/tests/output.test.ts +96 -0
- package/tests/setup.ts +486 -0
- package/tests/unit/appIntegration.test.ts +676 -0
- package/tests/unit/appViewState.test.ts +281 -0
- package/tests/unit/audioIpcChannels.test.ts +17 -0
- package/tests/unit/exportService.test.ts +492 -0
- package/tests/unit/hotkeys.test.ts +92 -0
- package/tests/unit/navigationPreload.test.ts +94 -0
- package/tests/unit/onboardingFlow.test.ts +345 -0
- package/tests/unit/permissionManager.test.ts +175 -0
- package/tests/unit/permissionManagerExpanded.test.ts +296 -0
- package/tests/unit/screenRecordingRenderer.test.ts +368 -0
- package/tests/unit/sessionController.test.ts +515 -0
- package/tests/unit/tierManager.test.ts +61 -0
- package/tests/unit/tierManagerExpanded.test.ts +142 -0
- package/tests/unit/transcriptAnalyzer.test.ts +64 -0
- package/tsconfig.json +25 -0
- package/vitest.config.ts +46 -0
|
@@ -0,0 +1,683 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RecordingContext
|
|
3
|
+
*
|
|
4
|
+
* Manages the core recording session lifecycle: state machine, IPC listeners,
|
|
5
|
+
* screen recording sync, audio levels, output paths, and session actions.
|
|
6
|
+
* This is the foundational context that other contexts depend on.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import React, { createContext, useCallback, useContext, useEffect, useRef, useState } from 'react';
|
|
10
|
+
import type { SessionPayload, SessionState, ReviewSession } from '../../shared/types';
|
|
11
|
+
import { getScreenRecordingRenderer } from '../capture/ScreenRecordingRenderer';
|
|
12
|
+
import { useCrashRecovery } from '../components';
|
|
13
|
+
|
|
14
|
+
// ============================================================================
|
|
15
|
+
// Types
|
|
16
|
+
// ============================================================================
|
|
17
|
+
|
|
18
|
+
export interface ProcessingProgress {
|
|
19
|
+
percent: number;
|
|
20
|
+
step: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface RecentSession {
|
|
24
|
+
id: string;
|
|
25
|
+
startTime: number;
|
|
26
|
+
endTime: number;
|
|
27
|
+
itemCount: number;
|
|
28
|
+
screenshotCount: number;
|
|
29
|
+
sourceName: string;
|
|
30
|
+
firstThumbnail?: string;
|
|
31
|
+
folder: string;
|
|
32
|
+
transcriptionPreview?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface LastCapture {
|
|
36
|
+
trigger?: 'pause' | 'manual' | 'voice-command';
|
|
37
|
+
timestamp: number;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface RecordingContextValue {
|
|
41
|
+
// Session state
|
|
42
|
+
state: SessionState;
|
|
43
|
+
duration: number;
|
|
44
|
+
screenshotCount: number;
|
|
45
|
+
isPaused: boolean;
|
|
46
|
+
isMutating: boolean;
|
|
47
|
+
|
|
48
|
+
// Audio
|
|
49
|
+
audioLevel: number;
|
|
50
|
+
isVoiceActive: boolean;
|
|
51
|
+
lastCapture: LastCapture | null;
|
|
52
|
+
|
|
53
|
+
// Output
|
|
54
|
+
reportPath: string | null;
|
|
55
|
+
recordingPath: string | null;
|
|
56
|
+
audioPath: string | null;
|
|
57
|
+
sessionDir: string | null;
|
|
58
|
+
reviewSession: ReviewSession | null;
|
|
59
|
+
errorMessage: string | null;
|
|
60
|
+
|
|
61
|
+
// Capability
|
|
62
|
+
hasTranscriptionCapability: boolean | null;
|
|
63
|
+
|
|
64
|
+
// Recent sessions
|
|
65
|
+
recentSessions: RecentSession[];
|
|
66
|
+
loadRecentSessions: () => Promise<void>;
|
|
67
|
+
|
|
68
|
+
// Processing raw state (consumed by ProcessingContext)
|
|
69
|
+
rawProcessingProgress: ProcessingProgress | null;
|
|
70
|
+
processingStartedAt: number | null;
|
|
71
|
+
|
|
72
|
+
// Review editor
|
|
73
|
+
showReviewEditor: boolean;
|
|
74
|
+
setShowReviewEditor: (show: boolean) => void;
|
|
75
|
+
|
|
76
|
+
// Crash recovery
|
|
77
|
+
incompleteSession: ReturnType<typeof useCrashRecovery>['incompleteSession'];
|
|
78
|
+
isCheckingRecovery: boolean;
|
|
79
|
+
|
|
80
|
+
// Actions
|
|
81
|
+
startSession: () => Promise<void>;
|
|
82
|
+
stopSession: () => Promise<void>;
|
|
83
|
+
togglePause: () => Promise<void>;
|
|
84
|
+
manualCapture: () => Promise<void>;
|
|
85
|
+
copyReportPath: () => Promise<void>;
|
|
86
|
+
openReportFolder: () => Promise<void>;
|
|
87
|
+
copyRecordingPath: () => Promise<void>;
|
|
88
|
+
copyAudioPath: () => Promise<void>;
|
|
89
|
+
openRecent: (session: { folder: string }) => Promise<void>;
|
|
90
|
+
copyRecentPath: (session: { folder: string }) => Promise<void>;
|
|
91
|
+
recoverSession: () => void;
|
|
92
|
+
discardSession: () => void;
|
|
93
|
+
reviewSave: (session: ReviewSession) => Promise<void>;
|
|
94
|
+
reviewClose: () => void;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const RecordingContext = createContext<RecordingContextValue | null>(null);
|
|
98
|
+
|
|
99
|
+
export function useRecording(): RecordingContextValue {
|
|
100
|
+
const context = useContext(RecordingContext);
|
|
101
|
+
if (!context) {
|
|
102
|
+
throw new Error('useRecording must be used within RecordingProvider');
|
|
103
|
+
}
|
|
104
|
+
return context;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// ============================================================================
|
|
108
|
+
// Provider
|
|
109
|
+
// ============================================================================
|
|
110
|
+
|
|
111
|
+
export const RecordingProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
|
|
112
|
+
// ---------------------------------------------------------------------------
|
|
113
|
+
// Session state
|
|
114
|
+
// ---------------------------------------------------------------------------
|
|
115
|
+
const [state, setState] = useState<SessionState>('idle');
|
|
116
|
+
const [duration, setDuration] = useState(0);
|
|
117
|
+
const [screenshotCount, setScreenshotCount] = useState(0);
|
|
118
|
+
const [isPaused, setIsPaused] = useState(false);
|
|
119
|
+
const [isMutating, setIsMutating] = useState(false);
|
|
120
|
+
const [audioLevel, setAudioLevel] = useState(0);
|
|
121
|
+
const [isVoiceActive, setIsVoiceActive] = useState(false);
|
|
122
|
+
const [lastCapture, setLastCapture] = useState<LastCapture | null>(null);
|
|
123
|
+
const [reportPath, setReportPath] = useState<string | null>(null);
|
|
124
|
+
const [recordingPath, setRecordingPath] = useState<string | null>(null);
|
|
125
|
+
const [audioPath, setAudioPath] = useState<string | null>(null);
|
|
126
|
+
const [sessionDir, setSessionDir] = useState<string | null>(null);
|
|
127
|
+
const [reviewSession, setReviewSession] = useState<ReviewSession | null>(null);
|
|
128
|
+
const [errorMessage, setErrorMessage] = useState<string | null>(null);
|
|
129
|
+
const [hasTranscriptionCapability, setHasTranscriptionCapability] = useState<boolean | null>(null);
|
|
130
|
+
const [recentSessions, setRecentSessions] = useState<RecentSession[]>([]);
|
|
131
|
+
const [rawProcessingProgress, setRawProcessingProgress] = useState<ProcessingProgress | null>(null);
|
|
132
|
+
const [showReviewEditor, setShowReviewEditor] = useState(false);
|
|
133
|
+
|
|
134
|
+
// Refs
|
|
135
|
+
const outputReadyRef = useRef(false);
|
|
136
|
+
const processingStartedAtRef = useRef<number | null>(null);
|
|
137
|
+
const stopRequestedRef = useRef(false);
|
|
138
|
+
const screenRecorderRef = useRef(getScreenRecordingRenderer());
|
|
139
|
+
const screenSyncQueueRef = useRef<Promise<void>>(Promise.resolve());
|
|
140
|
+
|
|
141
|
+
// ---------------------------------------------------------------------------
|
|
142
|
+
// Crash recovery
|
|
143
|
+
// ---------------------------------------------------------------------------
|
|
144
|
+
const {
|
|
145
|
+
incompleteSession,
|
|
146
|
+
isCheckingRecovery,
|
|
147
|
+
recoverSession: rawRecoverSession,
|
|
148
|
+
discardSession: rawDiscardSession,
|
|
149
|
+
} = useCrashRecovery();
|
|
150
|
+
|
|
151
|
+
// ---------------------------------------------------------------------------
|
|
152
|
+
// Recent sessions
|
|
153
|
+
// ---------------------------------------------------------------------------
|
|
154
|
+
const loadRecentSessions = useCallback(async () => {
|
|
155
|
+
try {
|
|
156
|
+
if (!window.markupr?.output?.listSessions) {
|
|
157
|
+
setRecentSessions([]);
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
const sessions = await window.markupr.output.listSessions();
|
|
161
|
+
setRecentSessions(sessions.slice(0, 5));
|
|
162
|
+
} catch (error) {
|
|
163
|
+
console.error('[RecordingContext] Failed to load recent sessions:', error);
|
|
164
|
+
setRecentSessions([]);
|
|
165
|
+
}
|
|
166
|
+
}, []);
|
|
167
|
+
|
|
168
|
+
useEffect(() => {
|
|
169
|
+
loadRecentSessions();
|
|
170
|
+
}, [loadRecentSessions]);
|
|
171
|
+
|
|
172
|
+
// ---------------------------------------------------------------------------
|
|
173
|
+
// Transcription capability check
|
|
174
|
+
// ---------------------------------------------------------------------------
|
|
175
|
+
useEffect(() => {
|
|
176
|
+
window.markupr.whisper
|
|
177
|
+
.hasTranscriptionCapability()
|
|
178
|
+
.then((ready) => setHasTranscriptionCapability(ready))
|
|
179
|
+
.catch(() => setHasTranscriptionCapability(false));
|
|
180
|
+
}, []);
|
|
181
|
+
|
|
182
|
+
// ---------------------------------------------------------------------------
|
|
183
|
+
// Screen recording sync
|
|
184
|
+
// ---------------------------------------------------------------------------
|
|
185
|
+
const syncScreenRecording = useCallback(
|
|
186
|
+
async (nextState: SessionState, session: SessionPayload | null, paused: boolean) => {
|
|
187
|
+
const recorder = screenRecorderRef.current;
|
|
188
|
+
|
|
189
|
+
if (nextState === 'recording') {
|
|
190
|
+
if (stopRequestedRef.current) {
|
|
191
|
+
recorder.releaseCaptureTracks();
|
|
192
|
+
if (recorder.isRecording() || recorder.getSessionId()) {
|
|
193
|
+
await recorder.stop().catch((error) => {
|
|
194
|
+
console.warn('[RecordingContext] Forced recorder stop during stop-request guard failed:', error);
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const latestStatus = await window.markupr.session.getStatus().catch(() => null);
|
|
201
|
+
if (latestStatus && latestStatus.state !== 'recording') {
|
|
202
|
+
if (recorder.isRecording() || recorder.getSessionId()) {
|
|
203
|
+
await recorder.stop().catch((error) => {
|
|
204
|
+
console.warn('[RecordingContext] Forced recorder stop during stale recording status guard failed:', error);
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (!recorder.isRecording()) {
|
|
211
|
+
let activeSession = session;
|
|
212
|
+
if (!activeSession) {
|
|
213
|
+
for (let attempt = 0; attempt < 4; attempt += 1) {
|
|
214
|
+
activeSession = await window.markupr.session.getCurrent();
|
|
215
|
+
if (activeSession) break;
|
|
216
|
+
if (attempt < 3) {
|
|
217
|
+
await new Promise((resolve) => setTimeout(resolve, 180));
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
if (!activeSession) {
|
|
223
|
+
setErrorMessage((prev) => prev || 'Session started, but screen recorder could not find an active capture target.');
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
try {
|
|
228
|
+
await recorder.start({
|
|
229
|
+
sessionId: activeSession.id,
|
|
230
|
+
sourceId: activeSession.sourceId,
|
|
231
|
+
});
|
|
232
|
+
} catch (error) {
|
|
233
|
+
console.warn('[RecordingContext] Continuous screen recording failed to start with primary source:', error);
|
|
234
|
+
|
|
235
|
+
try {
|
|
236
|
+
const sources = await window.markupr.capture.getSources();
|
|
237
|
+
const fallbackSource = sources.find((source) => source.type === 'screen');
|
|
238
|
+
|
|
239
|
+
if (!fallbackSource || fallbackSource.id === activeSession.sourceId) {
|
|
240
|
+
throw error;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
await recorder.start({
|
|
244
|
+
sessionId: activeSession.id,
|
|
245
|
+
sourceId: fallbackSource.id,
|
|
246
|
+
});
|
|
247
|
+
} catch (fallbackError) {
|
|
248
|
+
const message =
|
|
249
|
+
fallbackError instanceof Error
|
|
250
|
+
? fallbackError.message
|
|
251
|
+
: 'Unknown screen recording error.';
|
|
252
|
+
console.warn('[RecordingContext] Continuous screen recording fallback also failed:', message);
|
|
253
|
+
setErrorMessage((prev) => prev || `Screen recording unavailable: ${message}`);
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (paused) {
|
|
260
|
+
await recorder.pause();
|
|
261
|
+
} else {
|
|
262
|
+
await recorder.resume();
|
|
263
|
+
}
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
recorder.releaseCaptureTracks();
|
|
268
|
+
if (recorder.isRecording() || recorder.getSessionId()) {
|
|
269
|
+
await recorder.stop().catch((error) => {
|
|
270
|
+
console.warn('[RecordingContext] Failed to stop continuous screen recording:', error);
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
recorder.forceReleaseOrphanedCapture();
|
|
274
|
+
},
|
|
275
|
+
[]
|
|
276
|
+
);
|
|
277
|
+
|
|
278
|
+
const queueScreenRecordingSync = useCallback(
|
|
279
|
+
(nextState: SessionState, session: SessionPayload | null, paused: boolean) => {
|
|
280
|
+
screenSyncQueueRef.current = screenSyncQueueRef.current
|
|
281
|
+
.catch(() => {})
|
|
282
|
+
.then(() => syncScreenRecording(nextState, session, paused));
|
|
283
|
+
return screenSyncQueueRef.current;
|
|
284
|
+
},
|
|
285
|
+
[syncScreenRecording]
|
|
286
|
+
);
|
|
287
|
+
|
|
288
|
+
// ---------------------------------------------------------------------------
|
|
289
|
+
// Session IPC listeners
|
|
290
|
+
// ---------------------------------------------------------------------------
|
|
291
|
+
useEffect(() => {
|
|
292
|
+
let mounted = true;
|
|
293
|
+
const recorder = screenRecorderRef.current;
|
|
294
|
+
|
|
295
|
+
window.markupr.session
|
|
296
|
+
.getStatus()
|
|
297
|
+
.then((status) => {
|
|
298
|
+
if (!mounted) return;
|
|
299
|
+
setState(status.state);
|
|
300
|
+
setDuration(status.duration);
|
|
301
|
+
setScreenshotCount(status.screenshotCount);
|
|
302
|
+
setIsPaused(status.isPaused);
|
|
303
|
+
void queueScreenRecordingSync(status.state, null, status.isPaused);
|
|
304
|
+
})
|
|
305
|
+
.catch((error) => {
|
|
306
|
+
console.error('[RecordingContext] Failed to load initial status:', error);
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
const toUiState = (nextState: SessionState): SessionState =>
|
|
310
|
+
nextState === 'complete' && !outputReadyRef.current ? 'processing' : nextState;
|
|
311
|
+
|
|
312
|
+
const unsubState = window.markupr.session.onStateChange(({ state: nextState, session }) => {
|
|
313
|
+
const effectiveState =
|
|
314
|
+
stopRequestedRef.current && nextState === 'recording' ? 'stopping' : nextState;
|
|
315
|
+
setState(toUiState(effectiveState));
|
|
316
|
+
void queueScreenRecordingSync(effectiveState, session, false);
|
|
317
|
+
if (nextState === 'recording') {
|
|
318
|
+
stopRequestedRef.current = false;
|
|
319
|
+
outputReadyRef.current = false;
|
|
320
|
+
setErrorMessage(null);
|
|
321
|
+
setReportPath(null);
|
|
322
|
+
setRecordingPath(null);
|
|
323
|
+
setAudioPath(null);
|
|
324
|
+
setSessionDir(null);
|
|
325
|
+
setReviewSession(null);
|
|
326
|
+
setShowReviewEditor(false);
|
|
327
|
+
setRawProcessingProgress(null);
|
|
328
|
+
processingStartedAtRef.current = null;
|
|
329
|
+
setIsPaused(false);
|
|
330
|
+
}
|
|
331
|
+
if (nextState === 'stopping' || nextState === 'processing') {
|
|
332
|
+
stopRequestedRef.current = true;
|
|
333
|
+
if (!processingStartedAtRef.current) {
|
|
334
|
+
processingStartedAtRef.current = Date.now();
|
|
335
|
+
}
|
|
336
|
+
setRawProcessingProgress((previous) => previous ?? { percent: 0, step: 'preparing' });
|
|
337
|
+
}
|
|
338
|
+
if (nextState === 'idle') {
|
|
339
|
+
stopRequestedRef.current = false;
|
|
340
|
+
outputReadyRef.current = false;
|
|
341
|
+
setDuration(0);
|
|
342
|
+
setRawProcessingProgress(null);
|
|
343
|
+
processingStartedAtRef.current = null;
|
|
344
|
+
setIsPaused(false);
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
const unsubStatus = window.markupr.session.onStatusUpdate((status) => {
|
|
349
|
+
if (status.state === 'stopping' || status.state === 'processing') {
|
|
350
|
+
stopRequestedRef.current = true;
|
|
351
|
+
}
|
|
352
|
+
const effectiveState =
|
|
353
|
+
stopRequestedRef.current && status.state === 'recording' ? 'stopping' : status.state;
|
|
354
|
+
setDuration(status.duration);
|
|
355
|
+
setScreenshotCount(status.screenshotCount);
|
|
356
|
+
setState(toUiState(effectiveState));
|
|
357
|
+
setIsPaused(status.isPaused);
|
|
358
|
+
void queueScreenRecordingSync(effectiveState, null, status.isPaused);
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
const unsubScreenshot = window.markupr.capture.onScreenshot((payload) => {
|
|
362
|
+
setScreenshotCount(payload.count);
|
|
363
|
+
setLastCapture({
|
|
364
|
+
trigger: payload.trigger,
|
|
365
|
+
timestamp: payload.timestamp,
|
|
366
|
+
});
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
const unsubReady = window.markupr.output.onReady((payload) => {
|
|
370
|
+
recorder.releaseCaptureTracks();
|
|
371
|
+
recorder.forceReleaseOrphanedCapture();
|
|
372
|
+
void queueScreenRecordingSync('idle', null, false).catch((error) => {
|
|
373
|
+
console.warn('[RecordingContext] Failed to force-release screen recorder on output ready:', error);
|
|
374
|
+
});
|
|
375
|
+
window.setTimeout(() => {
|
|
376
|
+
recorder.forceReleaseOrphanedCapture();
|
|
377
|
+
void queueScreenRecordingSync('idle', null, false).catch(() => {});
|
|
378
|
+
}, 450);
|
|
379
|
+
stopRequestedRef.current = false;
|
|
380
|
+
outputReadyRef.current = true;
|
|
381
|
+
setRawProcessingProgress({ percent: 100, step: 'complete' });
|
|
382
|
+
setState('complete');
|
|
383
|
+
setErrorMessage(null);
|
|
384
|
+
setReportPath(payload.path || payload.reportPath || null);
|
|
385
|
+
setRecordingPath(payload.recordingPath || null);
|
|
386
|
+
setAudioPath(payload.audioPath || null);
|
|
387
|
+
setSessionDir(payload.sessionDir || null);
|
|
388
|
+
setReviewSession(payload.reviewSession || null);
|
|
389
|
+
setShowReviewEditor(false);
|
|
390
|
+
setDuration(0);
|
|
391
|
+
loadRecentSessions();
|
|
392
|
+
processingStartedAtRef.current = null;
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
const unsubSessionError = window.markupr.session.onError((payload) => {
|
|
396
|
+
stopRequestedRef.current = false;
|
|
397
|
+
outputReadyRef.current = false;
|
|
398
|
+
setState('error');
|
|
399
|
+
setErrorMessage(payload.message);
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
const unsubOutputError = window.markupr.output.onError((payload) => {
|
|
403
|
+
stopRequestedRef.current = false;
|
|
404
|
+
outputReadyRef.current = false;
|
|
405
|
+
setState('error');
|
|
406
|
+
setErrorMessage(payload.message);
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
return () => {
|
|
410
|
+
mounted = false;
|
|
411
|
+
unsubState();
|
|
412
|
+
unsubStatus();
|
|
413
|
+
unsubScreenshot();
|
|
414
|
+
unsubReady();
|
|
415
|
+
unsubSessionError();
|
|
416
|
+
unsubOutputError();
|
|
417
|
+
|
|
418
|
+
if (recorder.isRecording()) {
|
|
419
|
+
void recorder.stop();
|
|
420
|
+
}
|
|
421
|
+
};
|
|
422
|
+
}, [loadRecentSessions, queueScreenRecordingSync]);
|
|
423
|
+
|
|
424
|
+
// ---------------------------------------------------------------------------
|
|
425
|
+
// Audio level + voice activity listeners
|
|
426
|
+
// ---------------------------------------------------------------------------
|
|
427
|
+
useEffect(() => {
|
|
428
|
+
const unsubLevel = window.markupr.audio.onLevel((level) => {
|
|
429
|
+
setAudioLevel(level);
|
|
430
|
+
});
|
|
431
|
+
const unsubVoice = window.markupr.audio.onVoiceActivity((active) => {
|
|
432
|
+
setIsVoiceActive(active);
|
|
433
|
+
});
|
|
434
|
+
const unsubSessionVoice = window.markupr.session.onVoiceActivity(({ active }) => {
|
|
435
|
+
setIsVoiceActive(active);
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
return () => {
|
|
439
|
+
unsubLevel();
|
|
440
|
+
unsubVoice();
|
|
441
|
+
unsubSessionVoice();
|
|
442
|
+
};
|
|
443
|
+
}, []);
|
|
444
|
+
|
|
445
|
+
// ---------------------------------------------------------------------------
|
|
446
|
+
// Post-processing progress listeners
|
|
447
|
+
// ---------------------------------------------------------------------------
|
|
448
|
+
useEffect(() => {
|
|
449
|
+
const markuprApi = window.markupr as Record<string, unknown>;
|
|
450
|
+
let unsubProgress: (() => void) | null = null;
|
|
451
|
+
let unsubComplete: (() => void) | null = null;
|
|
452
|
+
|
|
453
|
+
if (markuprApi.processing && typeof (markuprApi.processing as Record<string, unknown>).onProgress === 'function') {
|
|
454
|
+
const processingApi = markuprApi.processing as {
|
|
455
|
+
onProgress: (cb: (data: ProcessingProgress) => void) => () => void;
|
|
456
|
+
onComplete: (cb: (data: unknown) => void) => () => void;
|
|
457
|
+
};
|
|
458
|
+
unsubProgress = processingApi.onProgress((data) => {
|
|
459
|
+
setRawProcessingProgress({
|
|
460
|
+
percent: Math.max(0, Math.min(100, Math.round(data.percent))),
|
|
461
|
+
step: data.step,
|
|
462
|
+
});
|
|
463
|
+
});
|
|
464
|
+
unsubComplete = processingApi.onComplete(() => {
|
|
465
|
+
setRawProcessingProgress({ percent: 100, step: 'complete' });
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
return () => {
|
|
470
|
+
unsubProgress?.();
|
|
471
|
+
unsubComplete?.();
|
|
472
|
+
};
|
|
473
|
+
}, []);
|
|
474
|
+
|
|
475
|
+
// ---------------------------------------------------------------------------
|
|
476
|
+
// Actions
|
|
477
|
+
// ---------------------------------------------------------------------------
|
|
478
|
+
const startSession = useCallback(async () => {
|
|
479
|
+
setIsMutating(true);
|
|
480
|
+
try {
|
|
481
|
+
setScreenshotCount(0);
|
|
482
|
+
setLastCapture(null);
|
|
483
|
+
setRecordingPath(null);
|
|
484
|
+
setAudioPath(null);
|
|
485
|
+
setErrorMessage(null);
|
|
486
|
+
stopRequestedRef.current = false;
|
|
487
|
+
outputReadyRef.current = false;
|
|
488
|
+
|
|
489
|
+
const result = await window.markupr.session.start();
|
|
490
|
+
if (!result.success) {
|
|
491
|
+
setState('error');
|
|
492
|
+
setErrorMessage(result.error || 'Unable to start session.');
|
|
493
|
+
window.markupr.whisper
|
|
494
|
+
.hasTranscriptionCapability()
|
|
495
|
+
.then((ready) => setHasTranscriptionCapability(ready))
|
|
496
|
+
.catch(() => {});
|
|
497
|
+
} else {
|
|
498
|
+
const activeSession = await window.markupr.session.getCurrent();
|
|
499
|
+
if (activeSession) {
|
|
500
|
+
await queueScreenRecordingSync('recording', activeSession, false);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
} catch (error) {
|
|
504
|
+
setState('error');
|
|
505
|
+
setErrorMessage(error instanceof Error ? error.message : 'Unknown session error.');
|
|
506
|
+
} finally {
|
|
507
|
+
setIsMutating(false);
|
|
508
|
+
}
|
|
509
|
+
}, [queueScreenRecordingSync]);
|
|
510
|
+
|
|
511
|
+
const stopSession = useCallback(async () => {
|
|
512
|
+
setIsMutating(true);
|
|
513
|
+
try {
|
|
514
|
+
stopRequestedRef.current = true;
|
|
515
|
+
|
|
516
|
+
const recorder = screenRecorderRef.current;
|
|
517
|
+
recorder.releaseCaptureTracks();
|
|
518
|
+
|
|
519
|
+
try {
|
|
520
|
+
await queueScreenRecordingSync('idle', null, false);
|
|
521
|
+
} catch (error) {
|
|
522
|
+
console.warn('[RecordingContext] Failed to flush screen recording before stop:', error);
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
const result = await window.markupr.session.stop();
|
|
526
|
+
if (!result.success) {
|
|
527
|
+
setState('error');
|
|
528
|
+
setErrorMessage(result.error || 'Unable to stop session.');
|
|
529
|
+
}
|
|
530
|
+
} catch (error) {
|
|
531
|
+
setState('error');
|
|
532
|
+
setErrorMessage(error instanceof Error ? error.message : 'Unknown session error.');
|
|
533
|
+
} finally {
|
|
534
|
+
setIsMutating(false);
|
|
535
|
+
}
|
|
536
|
+
}, [queueScreenRecordingSync]);
|
|
537
|
+
|
|
538
|
+
const togglePause = useCallback(async () => {
|
|
539
|
+
if (state !== 'recording') return;
|
|
540
|
+
|
|
541
|
+
setIsMutating(true);
|
|
542
|
+
try {
|
|
543
|
+
if (isPaused) {
|
|
544
|
+
const result = await window.markupr.session.resume();
|
|
545
|
+
if (!result.success) {
|
|
546
|
+
setErrorMessage(result.error || 'Unable to resume session.');
|
|
547
|
+
return;
|
|
548
|
+
}
|
|
549
|
+
setIsPaused(false);
|
|
550
|
+
await queueScreenRecordingSync('recording', null, false);
|
|
551
|
+
return;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
const result = await window.markupr.session.pause();
|
|
555
|
+
if (!result.success) {
|
|
556
|
+
setErrorMessage(result.error || 'Unable to pause session.');
|
|
557
|
+
return;
|
|
558
|
+
}
|
|
559
|
+
setIsPaused(true);
|
|
560
|
+
setIsVoiceActive(false);
|
|
561
|
+
await queueScreenRecordingSync('recording', null, true);
|
|
562
|
+
} catch (error) {
|
|
563
|
+
setErrorMessage(error instanceof Error ? error.message : 'Pause/resume failed.');
|
|
564
|
+
} finally {
|
|
565
|
+
setIsMutating(false);
|
|
566
|
+
}
|
|
567
|
+
}, [isPaused, state, queueScreenRecordingSync]);
|
|
568
|
+
|
|
569
|
+
const manualCapture = useCallback(async () => {
|
|
570
|
+
if (state !== 'recording' || isPaused || isMutating) return;
|
|
571
|
+
const result = await window.markupr.capture.manualScreenshot();
|
|
572
|
+
if (!result.success) {
|
|
573
|
+
setErrorMessage(result.error || 'Manual capture failed.');
|
|
574
|
+
}
|
|
575
|
+
}, [state, isPaused, isMutating]);
|
|
576
|
+
|
|
577
|
+
const copyReportPath = useCallback(async () => {
|
|
578
|
+
if (!reportPath) return;
|
|
579
|
+
await window.markupr.copyToClipboard(reportPath);
|
|
580
|
+
}, [reportPath]);
|
|
581
|
+
|
|
582
|
+
const openReportFolder = useCallback(async () => {
|
|
583
|
+
if (sessionDir) {
|
|
584
|
+
await window.markupr.output.openFolder(sessionDir);
|
|
585
|
+
return;
|
|
586
|
+
}
|
|
587
|
+
if (reportPath) {
|
|
588
|
+
await window.markupr.output.openFolder(reportPath);
|
|
589
|
+
}
|
|
590
|
+
}, [sessionDir, reportPath]);
|
|
591
|
+
|
|
592
|
+
const copyRecordingPath = useCallback(async () => {
|
|
593
|
+
if (!recordingPath) return;
|
|
594
|
+
await window.markupr.copyToClipboard(recordingPath);
|
|
595
|
+
}, [recordingPath]);
|
|
596
|
+
|
|
597
|
+
const copyAudioPath = useCallback(async () => {
|
|
598
|
+
if (!audioPath) return;
|
|
599
|
+
await window.markupr.copyToClipboard(audioPath);
|
|
600
|
+
}, [audioPath]);
|
|
601
|
+
|
|
602
|
+
const openRecent = useCallback(async (session: { folder: string }) => {
|
|
603
|
+
await window.markupr.output.openFolder(session.folder);
|
|
604
|
+
}, []);
|
|
605
|
+
|
|
606
|
+
const copyRecentPath = useCallback(async (session: { folder: string }) => {
|
|
607
|
+
await window.markupr.copyToClipboard(`${session.folder}/feedback-report.md`);
|
|
608
|
+
}, []);
|
|
609
|
+
|
|
610
|
+
const recoverSession = useCallback(() => {
|
|
611
|
+
rawRecoverSession();
|
|
612
|
+
outputReadyRef.current = true;
|
|
613
|
+
setState('complete');
|
|
614
|
+
loadRecentSessions();
|
|
615
|
+
}, [rawRecoverSession, loadRecentSessions]);
|
|
616
|
+
|
|
617
|
+
const discardSession = useCallback(() => {
|
|
618
|
+
rawDiscardSession();
|
|
619
|
+
}, [rawDiscardSession]);
|
|
620
|
+
|
|
621
|
+
const reviewSave = useCallback(async (_session: ReviewSession) => {
|
|
622
|
+
try {
|
|
623
|
+
await window.markupr.output.save();
|
|
624
|
+
} catch {
|
|
625
|
+
// Save failure is non-fatal in review mode
|
|
626
|
+
}
|
|
627
|
+
}, []);
|
|
628
|
+
|
|
629
|
+
const reviewClose = useCallback(() => {
|
|
630
|
+
setShowReviewEditor(false);
|
|
631
|
+
}, []);
|
|
632
|
+
|
|
633
|
+
// ---------------------------------------------------------------------------
|
|
634
|
+
// Context value
|
|
635
|
+
// ---------------------------------------------------------------------------
|
|
636
|
+
const value: RecordingContextValue = {
|
|
637
|
+
state,
|
|
638
|
+
duration,
|
|
639
|
+
screenshotCount,
|
|
640
|
+
isPaused,
|
|
641
|
+
isMutating,
|
|
642
|
+
audioLevel,
|
|
643
|
+
isVoiceActive,
|
|
644
|
+
lastCapture,
|
|
645
|
+
reportPath,
|
|
646
|
+
recordingPath,
|
|
647
|
+
audioPath,
|
|
648
|
+
sessionDir,
|
|
649
|
+
reviewSession,
|
|
650
|
+
errorMessage,
|
|
651
|
+
hasTranscriptionCapability,
|
|
652
|
+
recentSessions,
|
|
653
|
+
loadRecentSessions,
|
|
654
|
+
rawProcessingProgress,
|
|
655
|
+
processingStartedAt: processingStartedAtRef.current,
|
|
656
|
+
showReviewEditor,
|
|
657
|
+
setShowReviewEditor,
|
|
658
|
+
incompleteSession,
|
|
659
|
+
isCheckingRecovery,
|
|
660
|
+
startSession,
|
|
661
|
+
stopSession,
|
|
662
|
+
togglePause,
|
|
663
|
+
manualCapture,
|
|
664
|
+
copyReportPath,
|
|
665
|
+
openReportFolder,
|
|
666
|
+
copyRecordingPath,
|
|
667
|
+
copyAudioPath,
|
|
668
|
+
openRecent,
|
|
669
|
+
copyRecentPath,
|
|
670
|
+
recoverSession,
|
|
671
|
+
discardSession,
|
|
672
|
+
reviewSave,
|
|
673
|
+
reviewClose,
|
|
674
|
+
};
|
|
675
|
+
|
|
676
|
+
return (
|
|
677
|
+
<RecordingContext.Provider value={value}>
|
|
678
|
+
{children}
|
|
679
|
+
</RecordingContext.Provider>
|
|
680
|
+
);
|
|
681
|
+
};
|
|
682
|
+
|
|
683
|
+
export default RecordingContext;
|