Skip to content

Commit 6b350d0

Browse files
committed
chore(file-viewer): final comment cleanup before merge
1 parent 791f76a commit 6b350d0

3 files changed

Lines changed: 1 addition & 23 deletions

File tree

apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/text-editor-state.test.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -339,21 +339,12 @@ describe('syncTextEditorContentState — streaming finalize shortcuts', () => {
339339
})
340340

341341
describe('syncTextEditorContentState — inter-session content shrink (replace mode)', () => {
342-
// These tests cover the path that causes scroll jumps in the file viewer.
343-
// During "session linger" (session 1 complete, session 2 not yet started),
344-
// the state machine stays in 'streaming' phase with session 1's full content.
345-
// When session 2's first chunk arrives it is often SHORTER than session 1's
346-
// final content. The state machine must correctly replace the content rather
347-
// than treating it as already-final or dropping it.
348-
349342
it('replaces long linger content with a short first chunk from a new session', () => {
350-
// State during linger: streaming with session 1's full long content
351343
const lingerState = streaming(
352344
'a very long document with many paragraphs',
353345
'a very long document with many paragraphs',
354346
''
355347
)
356-
// Session 2 first chunk arrives — much shorter than session 1's content
357348
const next = syncTextEditorContentState(lingerState, {
358349
canReconcileToFetchedContent: false,
359350
fetchedContent: undefined,
@@ -382,8 +373,6 @@ describe('syncTextEditorContentState — inter-session content shrink (replace m
382373
})
383374

384375
it('does not finalize early when the new short chunk happens to equal savedContent', () => {
385-
// savedContent '' and streamingContent '' — but we are in streaming phase,
386-
// not ready, so content should remain in streaming phase
387376
const lingerState = streaming('long content', 'long content', 'old saved')
388377
const next = syncTextEditorContentState(lingerState, {
389378
canReconcileToFetchedContent: false,
@@ -427,8 +416,6 @@ describe('syncTextEditorContentState — inter-session content shrink (replace m
427416
})
428417

429418
it('synthetic file (canReconcile=false) finalizes with current content when streaming ends', () => {
430-
// After the new session finishes streaming, since there is no fetchedContent
431-
// to reconcile with (synthetic file has no db key), it must finalize immediately.
432419
const finalChunk = streaming(
433420
'# Complete Document\n\nAll done.',
434421
'# Complete Document\n\nAll done.',

apps/sim/app/workspace/[workspaceId]/home/hooks/use-file-preview-sessions.test.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,6 @@ describe('reduceFilePreviewSessions', () => {
397397
previewText: 'final',
398398
}),
399399
})
400-
// activeSessionId is lingering on preview-1 after complete
401400

402401
const reset = reduceFilePreviewSessions(state, { type: 'reset' })
403402

@@ -417,7 +416,6 @@ describe('reduceFilePreviewSessions', () => {
417416
})
418417

419418
it('hydrate merges incoming sessions into existing state without replacing non-stale sessions', () => {
420-
// Existing state has preview-1 at version 3
421419
const existing = reduceFilePreviewSessions(INITIAL_FILE_PREVIEW_SESSIONS_STATE, {
422420
type: 'upsert',
423421
session: createSession({
@@ -429,7 +427,6 @@ describe('reduceFilePreviewSessions', () => {
429427
}),
430428
})
431429

432-
// Hydrate with preview-1 at older version 2 + a new preview-2
433430
const hydrated = reduceFilePreviewSessions(existing, {
434431
type: 'hydrate',
435432
sessions: [
@@ -450,10 +447,8 @@ describe('reduceFilePreviewSessions', () => {
450447
],
451448
})
452449

453-
// preview-1 kept at version 3 (not replaced by stale version 2)
454450
expect(hydrated.sessions['preview-1']?.previewVersion).toBe(3)
455451
expect(hydrated.sessions['preview-1']?.previewText).toBe('current')
456-
// preview-2 added
457452
expect(hydrated.sessions['preview-2']?.previewText).toBe('new')
458453
})
459454

@@ -553,8 +548,6 @@ describe('reduceFilePreviewSessions', () => {
553548
previewText: 'background',
554549
}),
555550
})
556-
// active is now preview-2 (later upsert); preview-1 is no longer active
557-
// Complete preview-1 (the non-active session)
558551
const completed = reduceFilePreviewSessions(state, {
559552
type: 'complete',
560553
session: createSession({

apps/sim/hooks/use-auto-scroll.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ export function useAutoScroll(
4949
const el = containerRef.current
5050
if (!el) return
5151

52-
// Only pin to bottom if the user is already near the bottom (or the
53-
// container has no scrollable content yet). If they've scrolled up to
54-
// read, keep their position — they can scroll down to re-engage.
52+
// Don't jump if the user scrolled up — keep their position.
5553
const distanceFromBottom = el.scrollHeight - el.scrollTop - el.clientHeight
5654
const isNearBottom = distanceFromBottom <= STICK_THRESHOLD
5755
stickyRef.current = isNearBottom

0 commit comments

Comments
 (0)