Skip to content

Commit ce56f25

Browse files
authored
fix(screenMarker): action text screen marker not show for vlm (#80)
1 parent 99319b4 commit ce56f25

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

src/main/store/create.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
showWindow,
1616
} from '@main/window/index';
1717

18-
import { closeScreenMarker } from './ScreenMarker';
18+
import { closeScreenMarker } from '@main/window/ScreenMarker';
1919
import { runAgent } from './runAgent';
2020
import { SettingStore } from './setting';
2121
import { AppState } from './types';

src/main/store/runAgent.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
showPauseButton,
2020
showPredictionMarker,
2121
showScreenWaterFlow,
22-
} from './ScreenMarker';
22+
} from '@main/window/ScreenMarker';
2323
import { SettingStore } from './setting';
2424
import { AppState } from './types';
2525

src/main/store/ScreenMarker.ts renamed to src/main/window/ScreenMarker.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import * as env from '@main/env';
1515
import { logger } from '@main/logger';
1616
import { parseBoxToScreenCoords } from '@main/utils/coords';
1717

18-
import { store } from './create';
18+
import { store } from '@main/store/create';
1919

2020
class ScreenMarker {
2121
private static instance: ScreenMarker;
@@ -319,7 +319,7 @@ class ScreenMarker {
319319
}
320320

321321
this.currentOverlay.blur();
322-
this.currentOverlay.setContentProtection(false); // show for vlm model
322+
this.currentOverlay.setContentProtection(true); // not show for vlm model
323323
this.currentOverlay.setIgnoreMouseEvents(true);
324324

325325
// 在 Windows 上设置窗口为工具窗口

src/renderer/src/hooks/useScreenRecord.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ export const useScreenRecord = (
88
watermarkText = ${new Date().getFullYear()} UI-TARS Desktop`,
99
) => {
1010
const [isRecording, setIsRecording] = useState(false);
11-
const [recordedChunks, setRecordedChunks] = useState<BlobPart[]>([]);
11+
const recordedChunksRef = useRef<BlobPart[]>([]);
1212
const mediaRecorderRef = useRef<MediaRecorder | null>(null);
1313
const streamRef = useRef<MediaStream | null>(null);
1414
const canvasRef = useRef<HTMLCanvasElement>(null);
1515
const videoRef = useRef<HTMLVideoElement>(null);
1616

1717
const startRecording = async () => {
1818
try {
19-
setRecordedChunks([]);
19+
recordedChunksRef.current = [];
2020

2121
const { screenWidth, screenHeight } =
2222
await window.electron.ipcRenderer.invoke('get-screen-size');
@@ -91,7 +91,7 @@ export const useScreenRecord = (
9191

9292
recorder.onstop = () => {
9393
clearInterval(drawInterval);
94-
setRecordedChunks(chunks);
94+
recordedChunksRef.current = chunks;
9595
};
9696

9797
mediaRecorderRef.current = recorder;
@@ -105,7 +105,7 @@ export const useScreenRecord = (
105105

106106
useEffect(() => {
107107
return () => {
108-
setRecordedChunks([]);
108+
recordedChunksRef.current = [];
109109
if (mediaRecorderRef.current) {
110110
mediaRecorderRef.current.stop();
111111
}
@@ -127,9 +127,9 @@ export const useScreenRecord = (
127127
};
128128

129129
const saveRecording = () => {
130-
if (recordedChunks.length === 0) return;
130+
if (recordedChunksRef.current.length === 0) return;
131131

132-
const blob = new Blob(recordedChunks, { type: 'video/mp4' });
132+
const blob = new Blob(recordedChunksRef.current, { type: 'video/mp4' });
133133
const url = URL.createObjectURL(blob);
134134
const a = document.createElement('a');
135135
a.href = url;
@@ -139,7 +139,7 @@ export const useScreenRecord = (
139139
URL.revokeObjectURL(url);
140140
};
141141

142-
const canSaveRecording = !isRecording && recordedChunks.length > 0;
142+
const canSaveRecording = !isRecording && recordedChunksRef.current.length > 0;
143143

144144
return {
145145
isRecording,

0 commit comments

Comments
 (0)