Skip to content
Draft
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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 20 additions & 3 deletions apps/web/src/app/(sandbox)/task/[taskId]/hooks/use-terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export function useTerminal(
let opened = false;
let intentionalClose = false;
let initialInputSent = false;
let resizeFrame: number | null = null;

// Helper to fit the terminal and notify the server of the new size.
function fitAndResize() {
Expand Down Expand Up @@ -212,7 +213,6 @@ export function useTerminal(

opened = true;
terminal.open(container);
fitAddon.fit();
connect();
}

Expand All @@ -231,8 +231,22 @@ export function useTerminal(

// Resize handling — also triggers deferred open when container becomes visible.
const resizeObserver = new ResizeObserver(() => {
openIfReady();
fitAndResize();
if (resizeFrame !== null) {
return;
}

// Fitting xterm mutates layout. Defer it outside the ResizeObserver
// callback and coalesce notifications to avoid observer feedback loops.
resizeFrame = requestAnimationFrame(() => {
resizeFrame = null;

if (!opened) {
openIfReady();
return;
}

fitAndResize();
});
});
resizeObserver.observe(container);

Expand All @@ -241,6 +255,9 @@ export function useTerminal(
intentionalClose = true;
connectRef.current = null;
cancelAnimationFrame(initialOpenFrame);
if (resizeFrame !== null) {
cancelAnimationFrame(resizeFrame);
}

resizeObserver.disconnect();
inputDisposable.dispose();
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions apps/web/src/components/layout/CloudAnalyticsProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const DEFAULT_POSTHOG_HOST = 'https://us.i.posthog.com';
type PostHogOptions = {
api_host: string;
defaults: '2026-05-30';
capture_exceptions: boolean;
disable_session_recording: boolean;
session_recording: {
maskAllInputs: boolean;
Expand Down Expand Up @@ -81,6 +82,7 @@ export function CloudAnalyticsProvider({
{
api_host: resolvedPosthogHost,
defaults: '2026-05-30',
capture_exceptions: true,
disable_session_recording: false,
session_recording: { maskAllInputs: true },
},
Expand Down
Loading