Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
`run_once` results to the calling session.
- Keep `Send now` attached to the first visible queued prompt when synthetic
runtime notifications are present.
- Preserve transcript follow mode when a viewport resize or tall Shell output
reflow moves an already-bottom scroll position.
- Add native PTY coverage for queued notifications, transcript paging and
double-`Esc` cancellation.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -554,8 +554,8 @@ async function startTui(
{
cwd: PACKAGE_ROOT,
env: ptyEnvironment(sandbox.env),
cols: 120,
rows: 40,
cols: Math.max(40, Number.parseInt(process.env.MENDCODE_SMOKE_COLS ?? "120", 10) || 120),
rows: Math.max(16, Number.parseInt(process.env.MENDCODE_SMOKE_ROWS ?? "40", 10) || 40),
name: "xterm-256color",
},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ export function sessionUserMovedViewport(input: {
viewportHeight: number
lastViewportHeight: number
followOutput?: boolean
atBottom?: boolean
}) {
const scrollDelta = input.scrollTop - input.lastScrollTop
const scrollMoved = Math.abs(scrollDelta) > 1
Expand All @@ -510,9 +511,11 @@ export function sessionUserMovedViewport(input: {
// A sticky/following scrollbox can move its scrollTop while layout is
// settling after a streamed part changes height. A downward movement can
// be that layout adjustment, but a negative delta is an unmistakable manual
// scroll-up gesture and must detach follow immediately.
// scroll-up gesture and must detach follow immediately. When sticky follow
// has already settled at the new bottom, however, a negative delta can be
// caused entirely by a larger viewport or a shorter reflowed child.
if (layoutChanged) {
if (input.followOutput) return scrollDelta < -1
if (input.followOutput) return scrollDelta < -1 && input.atBottom !== true
return false
}
return true
Expand Down Expand Up @@ -2584,6 +2587,7 @@ export function Session() {
viewportHeight,
lastViewportHeight: lastObservedViewportHeight,
followOutput: followSessionOutput(),
atBottom,
})
const contentHeightChanged = Math.abs(scrollHeight - lastObservedScrollHeight) > 1
const viewportHeightChanged = Math.abs(viewportHeight - lastObservedViewportHeight) > 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1966,10 +1966,40 @@ describe("resolveWorkingStartedAt", () => {
viewportHeight: 48,
lastViewportHeight: 48,
followOutput: true,
atBottom: false,
}),
).toBe(true)
})

test("does not detach follow when a layout reflow moves an already-bottom viewport", () => {
for (const input of [
{
scrollTop: 180,
lastScrollTop: 200,
scrollHeight: 300,
lastScrollHeight: 300,
viewportHeight: 120,
lastViewportHeight: 100,
},
{
scrollTop: 180,
lastScrollTop: 200,
scrollHeight: 280,
lastScrollHeight: 300,
viewportHeight: 100,
lastViewportHeight: 100,
},
]) {
expect(
sessionUserMovedViewport({
...input,
followOutput: true,
atBottom: true,
}),
).toBe(false)
}
})

test("detaches follow when a manual scroll-up overlaps a content reflow", () => {
expect(
sessionUserMovedViewport({
Expand Down
Loading