Skip to content

Commit 6648924

Browse files
committed
Revert "Merge pull request #76 from moazbuilds/fix/log-scroll-and-dublication"
This reverts commit b56d157, reversing changes made to 1e1f816.
1 parent 6bc5c50 commit 6648924

2 files changed

Lines changed: 6 additions & 17 deletions

File tree

src/cli/tui/routes/workflow/components/output/output-window.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,10 @@ export function OutputWindow(props: OutputWindowProps) {
111111
// Trigger load when near the top (within 3 lines) - skip if already loading
112112
if (scrollTop <= 3 && props.hasMoreAbove && props.onLoadMore && !props.isLoadingEarlier) {
113113
debug('[OutputWindow] Loading earlier lines...')
114-
const scrollHeightBefore = ref.scrollHeight
115114
const linesLoaded = props.onLoadMore()
116115
debug('[OutputWindow] Lines loaded: %d', linesLoaded)
117116
if (linesLoaded > 0) {
118-
// SolidJS updates DOM synchronously, so we can measure and adjust immediately
119-
const scrollHeightAfter = ref.scrollHeight
120-
const heightAdded = scrollHeightAfter - scrollHeightBefore
121-
// Maintain view position with small slack to prevent immediate re-trigger
122-
const slack = 5
123-
ref.scrollTop = scrollTop + heightAdded + slack
124-
debug('[OutputWindow] Scroll adjusted: heightAdded=%d, slack=%d, newScrollTop=%d', heightAdded, slack, ref.scrollTop)
117+
ref.scrollTop = linesLoaded // Maintain view position
125118
}
126119
}
127120
}

src/cli/tui/routes/workflow/hooks/useLogStream.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@ function readLogFileIncremental(
109109
if (currentSize < state.lastFileSize) {
110110
logDebug('File truncated, doing full read. Old size: %d, new size: %d', state.lastFileSize, currentSize)
111111
const content = readFileSync(path, "utf-8")
112-
// Filter empty lines to match incremental read behavior
113-
const lines = content.split("\n").filter(line => line !== '')
112+
const lines = content.split("\n")
114113
state.lastFileSize = currentSize
115114
state.lastLineCount = lines.length
116115
return {
@@ -124,9 +123,8 @@ function readLogFileIncremental(
124123
// For small files, just do a full read (simpler and fast enough)
125124
if (currentSize < INCREMENTAL_THRESHOLD_BYTES) {
126125
const content = readFileSync(path, "utf-8")
127-
// Filter empty lines to match incremental read behavior
128-
const lines = content.split("\n").filter(line => line !== '')
129-
const newLinesCount = Math.max(0, lines.length - state.lastLineCount)
126+
const lines = content.split("\n")
127+
const newLinesCount = lines.length - state.lastLineCount
130128
state.lastFileSize = currentSize
131129
state.lastLineCount = lines.length
132130
return {
@@ -182,15 +180,14 @@ function readLogFileIncremental(
182180

183181
/**
184182
* Read entire log file (used for initial load or after truncation)
185-
* Filters empty lines to match incremental read behavior
186183
*/
187184
function readLogFileFull(path: string): string[] {
188185
try {
189186
if (!existsSync(path)) {
190187
return []
191188
}
192189
const content = readFileSync(path, "utf-8")
193-
return content.split("\n").filter(line => line !== '')
190+
return content.split("\n")
194191
} catch {
195192
return []
196193
}
@@ -502,9 +499,8 @@ export function useLogStream(
502499
const currentFileSize = getFileSize(logPath)
503500

504501
// Update incremental state
505-
// IMPORTANT: Track RAW line count, not filtered, to match readLogFileIncremental
506502
incrementalState.lastFileSize = currentFileSize
507-
incrementalState.lastLineCount = fileLines.length
503+
incrementalState.lastLineCount = filteredLines.length
508504

509505
// Update windowed state
510506
const trimCount = Math.max(0, filteredLines.length - maxWindow)

0 commit comments

Comments
 (0)