Switch to double quotes and reformat codebase with Biome
This commit is contained in:
@@ -4,9 +4,7 @@ import {
|
||||
retainWorkspaceTerminalSession,
|
||||
} from "@/terminal/runtime/workspace-terminal-session";
|
||||
|
||||
export function useWorkspaceTerminalSessionRetention(input: {
|
||||
scopeKey: string | null;
|
||||
}): void {
|
||||
export function useWorkspaceTerminalSessionRetention(input: { scopeKey: string | null }): void {
|
||||
useEffect(() => {
|
||||
if (!input.scopeKey) {
|
||||
return;
|
||||
|
||||
@@ -312,7 +312,7 @@ export class TerminalEmulatorRuntime {
|
||||
const fitTimeouts = FIT_TIMEOUT_DELAYS_MS.map((delayMs) =>
|
||||
window.setTimeout(() => {
|
||||
fitAndEmitResize(true);
|
||||
}, delayMs)
|
||||
}, delayMs),
|
||||
);
|
||||
|
||||
const fontSet = document.fonts;
|
||||
@@ -555,8 +555,9 @@ export class TerminalEmulatorRuntime {
|
||||
const previousDocumentElementHeight = documentElement.style.height;
|
||||
const previousDocumentElementTextSizeAdjust =
|
||||
documentElement.style.getPropertyValue("text-size-adjust");
|
||||
const previousDocumentElementWebkitTextSizeAdjust =
|
||||
documentElement.style.getPropertyValue("-webkit-text-size-adjust");
|
||||
const previousDocumentElementWebkitTextSizeAdjust = documentElement.style.getPropertyValue(
|
||||
"-webkit-text-size-adjust",
|
||||
);
|
||||
|
||||
const previousBodyOverflow = body.style.overflow;
|
||||
const previousBodyWidth = body.style.width;
|
||||
@@ -564,8 +565,9 @@ export class TerminalEmulatorRuntime {
|
||||
const previousBodyMargin = body.style.margin;
|
||||
const previousBodyPadding = body.style.padding;
|
||||
const previousBodyTextSizeAdjust = body.style.getPropertyValue("text-size-adjust");
|
||||
const previousBodyWebkitTextSizeAdjust =
|
||||
body.style.getPropertyValue("-webkit-text-size-adjust");
|
||||
const previousBodyWebkitTextSizeAdjust = body.style.getPropertyValue(
|
||||
"-webkit-text-size-adjust",
|
||||
);
|
||||
|
||||
const previousRootOverflow = rootContainer?.style.overflow ?? "";
|
||||
const previousRootWidth = rootContainer?.style.width ?? "";
|
||||
@@ -598,7 +600,7 @@ export class TerminalEmulatorRuntime {
|
||||
documentElement.style.setProperty("text-size-adjust", previousDocumentElementTextSizeAdjust);
|
||||
documentElement.style.setProperty(
|
||||
"-webkit-text-size-adjust",
|
||||
previousDocumentElementWebkitTextSizeAdjust
|
||||
previousDocumentElementWebkitTextSizeAdjust,
|
||||
);
|
||||
|
||||
body.style.overflow = previousBodyOverflow;
|
||||
@@ -651,7 +653,7 @@ export class TerminalEmulatorRuntime {
|
||||
viewportElement.style.pointerEvents = previousViewportPointerEvents;
|
||||
viewportElement.style.setProperty(
|
||||
"-webkit-overflow-scrolling",
|
||||
previousViewportWebkitOverflowScrolling
|
||||
previousViewportWebkitOverflowScrolling,
|
||||
);
|
||||
}
|
||||
if (screenElement) {
|
||||
@@ -667,12 +669,10 @@ export class TerminalEmulatorRuntime {
|
||||
}): () => void {
|
||||
let touchScrollRemainderPx = 0;
|
||||
const measuredLineHeight =
|
||||
input.host.querySelector<HTMLElement>(".xterm-rows > div")?.getBoundingClientRect()
|
||||
.height ?? 0;
|
||||
input.host.querySelector<HTMLElement>(".xterm-rows > div")?.getBoundingClientRect().height ??
|
||||
0;
|
||||
const touchScrollLineHeightPx =
|
||||
measuredLineHeight > 0
|
||||
? measuredLineHeight
|
||||
: DEFAULT_TOUCH_SCROLL_LINE_HEIGHT_PX;
|
||||
measuredLineHeight > 0 ? measuredLineHeight : DEFAULT_TOUCH_SCROLL_LINE_HEIGHT_PX;
|
||||
|
||||
const activeTouch = {
|
||||
identifier: -1,
|
||||
@@ -714,7 +714,7 @@ export class TerminalEmulatorRuntime {
|
||||
}
|
||||
|
||||
const touch = Array.from(event.touches).find(
|
||||
(candidate) => candidate.identifier === activeTouch.identifier
|
||||
(candidate) => candidate.identifier === activeTouch.identifier,
|
||||
);
|
||||
if (!touch) {
|
||||
return;
|
||||
@@ -750,7 +750,7 @@ export class TerminalEmulatorRuntime {
|
||||
|
||||
const touchEndHandler = (event: TouchEvent) => {
|
||||
const activeTouchEnded = Array.from(event.changedTouches).some(
|
||||
(touch) => touch.identifier === activeTouch.identifier
|
||||
(touch) => touch.identifier === activeTouch.identifier,
|
||||
);
|
||||
if (activeTouchEnded || event.touches.length === 0) {
|
||||
touchScrollRemainderPx = 0;
|
||||
|
||||
@@ -19,8 +19,7 @@ export class TerminalOutputDeliveryQueue {
|
||||
private readonly deliveryTimeoutMs: number;
|
||||
|
||||
constructor(private readonly options: TerminalOutputDeliveryQueueOptions) {
|
||||
this.deliveryTimeoutMs =
|
||||
options.deliveryTimeoutMs ?? DEFAULT_DELIVERY_TIMEOUT_MS;
|
||||
this.deliveryTimeoutMs = options.deliveryTimeoutMs ?? DEFAULT_DELIVERY_TIMEOUT_MS;
|
||||
}
|
||||
|
||||
enqueue(chunk: TerminalOutputDeliveryChunk): void {
|
||||
|
||||
@@ -22,9 +22,7 @@ describe("terminal-output-pump", () => {
|
||||
|
||||
vi.runOnlyPendingTimers();
|
||||
|
||||
expect(chunks).toEqual([
|
||||
{ sequence: 1, text: "abc", replay: false },
|
||||
]);
|
||||
expect(chunks).toEqual([{ sequence: 1, text: "abc", replay: false }]);
|
||||
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
import {
|
||||
TerminalOutputPump,
|
||||
type TerminalOutputChunk,
|
||||
} from "./terminal-output-pump";
|
||||
import { TerminalOutputPump, type TerminalOutputChunk } from "./terminal-output-pump";
|
||||
import {
|
||||
TerminalOutputDeliveryQueue,
|
||||
type TerminalOutputDeliveryChunk,
|
||||
|
||||
@@ -31,7 +31,7 @@ class FakeTerminalStreamClient implements TerminalStreamControllerClient {
|
||||
resumeOffset?: number;
|
||||
rows?: number;
|
||||
cols?: number;
|
||||
}
|
||||
},
|
||||
): Promise<TerminalStreamControllerAttachPayload> {
|
||||
this.attachCalls.push({ terminalId, options });
|
||||
const response = this.nextAttachResponses.shift();
|
||||
@@ -47,7 +47,7 @@ class FakeTerminalStreamClient implements TerminalStreamControllerClient {
|
||||
|
||||
onTerminalStreamData(
|
||||
streamId: number,
|
||||
handler: (chunk: TerminalStreamControllerChunk) => void
|
||||
handler: (chunk: TerminalStreamControllerChunk) => void,
|
||||
): () => void {
|
||||
const pendingChunks = this.pendingChunksByStreamId.get(streamId);
|
||||
if (pendingChunks && pendingChunks.length > 0) {
|
||||
@@ -343,9 +343,7 @@ describe("terminal-stream-controller", () => {
|
||||
harness.controller.setTerminal({ terminalId: "term-buffered" });
|
||||
await flushAsyncWork();
|
||||
|
||||
expect(harness.chunks).toEqual([
|
||||
{ terminalId: "term-buffered", text: "buffered-replay" },
|
||||
]);
|
||||
expect(harness.chunks).toEqual([{ terminalId: "term-buffered", text: "buffered-replay" }]);
|
||||
});
|
||||
|
||||
it("clears stale selected output when bootstrap replay starts before current offset", async () => {
|
||||
|
||||
@@ -30,12 +30,12 @@ export type TerminalStreamControllerClient = {
|
||||
resumeOffset?: number;
|
||||
rows?: number;
|
||||
cols?: number;
|
||||
}
|
||||
},
|
||||
) => Promise<TerminalStreamControllerAttachPayload>;
|
||||
detachTerminalStream: (streamId: number) => Promise<unknown>;
|
||||
onTerminalStreamData: (
|
||||
streamId: number,
|
||||
handler: (chunk: TerminalStreamControllerChunk) => void
|
||||
handler: (chunk: TerminalStreamControllerChunk) => void,
|
||||
) => () => void;
|
||||
};
|
||||
|
||||
@@ -175,8 +175,7 @@ export class TerminalStreamController {
|
||||
terminalId: input.terminalId,
|
||||
streamId: null,
|
||||
isAttaching: true,
|
||||
error:
|
||||
this.options.reconnectErrorMessage ?? DEFAULT_RECONNECT_ERROR_MESSAGE,
|
||||
error: this.options.reconnectErrorMessage ?? DEFAULT_RECONNECT_ERROR_MESSAGE,
|
||||
});
|
||||
void this.attachTerminal({
|
||||
terminalId: input.terminalId,
|
||||
@@ -220,10 +219,7 @@ export class TerminalStreamController {
|
||||
});
|
||||
}
|
||||
|
||||
private async attachTerminal(input: {
|
||||
terminalId: string;
|
||||
generation: number;
|
||||
}): Promise<void> {
|
||||
private async attachTerminal(input: { terminalId: string; generation: number }): Promise<void> {
|
||||
const {
|
||||
maxAttachAttempts = DEFAULT_ATTACH_MAX_ATTEMPTS,
|
||||
attachTimeoutMs = DEFAULT_ATTACH_TIMEOUT_MS,
|
||||
@@ -236,7 +232,12 @@ export class TerminalStreamController {
|
||||
let lastErrorMessage = "Unable to attach terminal stream";
|
||||
|
||||
for (let attempt = 0; attempt < maxAttachAttempts; attempt += 1) {
|
||||
if (!this.isAttachGenerationCurrent({ generation: input.generation, terminalId: input.terminalId })) {
|
||||
if (
|
||||
!this.isAttachGenerationCurrent({
|
||||
generation: input.generation,
|
||||
terminalId: input.terminalId,
|
||||
})
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -249,9 +250,7 @@ export class TerminalStreamController {
|
||||
const attachPayload = await withTimeout({
|
||||
promise: this.options.client.attachTerminalStream(input.terminalId, {
|
||||
...(resumeOffset !== undefined ? { resumeOffset } : {}),
|
||||
...(preferredSize
|
||||
? { rows: preferredSize.rows, cols: preferredSize.cols }
|
||||
: {}),
|
||||
...(preferredSize ? { rows: preferredSize.rows, cols: preferredSize.cols } : {}),
|
||||
}),
|
||||
timeoutMs: attachTimeoutMs,
|
||||
timeoutMessage: "Timed out attaching terminal stream",
|
||||
@@ -263,7 +262,12 @@ export class TerminalStreamController {
|
||||
resumeOffsetStore: this.getResumeOffsetStore(),
|
||||
});
|
||||
|
||||
if (!this.isAttachGenerationCurrent({ generation: input.generation, terminalId: input.terminalId })) {
|
||||
if (
|
||||
!this.isAttachGenerationCurrent({
|
||||
generation: input.generation,
|
||||
terminalId: input.terminalId,
|
||||
})
|
||||
) {
|
||||
if (typeof attachPayload.streamId === "number") {
|
||||
void this.options.client.detachTerminalStream(attachPayload.streamId).catch(() => {});
|
||||
}
|
||||
@@ -309,10 +313,7 @@ export class TerminalStreamController {
|
||||
typeof attachPayload.replayedFrom === "number"
|
||||
? Math.max(0, Math.floor(attachPayload.replayedFrom))
|
||||
: null;
|
||||
const currentOffset = Math.max(
|
||||
0,
|
||||
Math.floor(attachPayload.currentOffset)
|
||||
);
|
||||
const currentOffset = Math.max(0, Math.floor(attachPayload.currentOffset));
|
||||
const shouldResetForReplayBootstrap =
|
||||
typeof resumeOffset !== "number" &&
|
||||
typeof replayedFromOffset === "number" &&
|
||||
@@ -490,8 +491,7 @@ export class TerminalStreamController {
|
||||
terminalId: input.terminalId,
|
||||
streamId: null,
|
||||
isAttaching: true,
|
||||
error:
|
||||
this.options.reconnectErrorMessage ?? DEFAULT_RECONNECT_ERROR_MESSAGE,
|
||||
error: this.options.reconnectErrorMessage ?? DEFAULT_RECONNECT_ERROR_MESSAGE,
|
||||
});
|
||||
void this.attachTerminal({
|
||||
terminalId: input.terminalId,
|
||||
@@ -536,16 +536,12 @@ export class TerminalStreamController {
|
||||
}
|
||||
}
|
||||
|
||||
private isAttachGenerationCurrent(input: {
|
||||
generation: number;
|
||||
terminalId: string;
|
||||
}): boolean {
|
||||
private isAttachGenerationCurrent(input: { generation: number; terminalId: string }): boolean {
|
||||
if (this.isDisposed) {
|
||||
return false;
|
||||
}
|
||||
return (
|
||||
this.attachGeneration === input.generation &&
|
||||
this.selectedTerminalId === input.terminalId
|
||||
this.attachGeneration === input.generation && this.selectedTerminalId === input.terminalId
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user