Skip to content

Commit e5d5230

Browse files
committed
docs: clarify editor and recorder internals
1 parent f22a764 commit e5d5230

3 files changed

Lines changed: 11 additions & 0 deletions

File tree

src/app/components/editor/Editor.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ export const CustomEditor = forwardRef<HTMLDivElement, CustomEditorProps>(
169169
const isRenderedSingleLine = !layoutIsMultiline;
170170

171171
if (isRenderedSingleLine && scroll) {
172+
// Scroll.clientWidth is the width the editable actually gets after padding and
173+
// scrollbar math. Cache that delta while we are rendered single-line so later
174+
// hidden measurements can compare against the same usable width.
172175
const renderedSingleLineWidth = scroll.clientWidth;
173176
if (renderedSingleLineWidth > 0) {
174177
singleLineWidthOffsetRef.current = Math.max(
@@ -231,6 +234,9 @@ export const CustomEditor = forwardRef<HTMLDivElement, CustomEditorProps>(
231234
textMeasurer.style.textTransform = computedStyle.textTransform;
232235
textMeasurer.style.textIndent = computedStyle.textIndent;
233236
textMeasurer.style.tabSize = computedStyle.tabSize;
237+
// Measure against a hidden clone instead of the live editable so we can ask
238+
// "would this wrap at single-line width?" without the current layout feeding
239+
// back into the answer.
234240
const measureHeight = (content: string, width: string): number => {
235241
textMeasurer.style.width = width;
236242
textMeasurer.textContent = normalizeMeasurementText(content);

src/app/features/room/AudioMessageRecorder.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ export const AudioMessageRecorder = forwardRef<
6565
onAudioLengthUpdateRef.current = onAudioLengthUpdate;
6666

6767
const stableOnStop = useCallback((payload: VoiceRecorderStopPayload) => {
68+
// useVoiceRecorder also stops during cancel/teardown paths, so only surface a completed
69+
// recording after an explicit user stop.
6870
if (!userRequestedStopRef.current) return;
6971
if (isDismissedRef.current) return;
7072
onRecordingCompleteRef.current({

src/app/plugins/voice-recorder-kit/useVoiceRecorder.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,14 @@ export function useVoiceRecorder(options: UseVoiceRecorderOptions = {}): UseVoic
146146

147147
if (!audioContext) return;
148148
if (recordingStream) {
149+
// Recording contexts are disposable. Closing them fully releases the capture graph so
150+
// mobile browsers do not keep the mic route or low-quality audio mode alive.
149151
if (audioContext.state !== 'closed') {
150152
audioContext.close().catch(() => {});
151153
}
152154
return;
153155
}
156+
// Playback reuses a shared context, so suspend it instead of tearing it down.
154157
if (audioContext.state !== 'closed') {
155158
audioContext.suspend().catch(() => {});
156159
}

0 commit comments

Comments
 (0)