chore(lint): no-shadow in app composer/message-input/e2e helpers

This commit is contained in:
Mohamed Boudra
2026-04-24 05:21:20 +07:00
parent f03ccc3241
commit 15528c8a14
5 changed files with 44 additions and 41 deletions

View File

@@ -27,14 +27,14 @@ async function ensureE2EStorageSeeded(page: Page): Promise<void> {
}
const needsReset = await page.evaluate(
({ expectedEndpoint, expectedServerId }) => {
({ expectedEndpoint: endpoint, expectedServerId: serverId }) => {
const raw = localStorage.getItem("@paseo:daemon-registry");
if (!raw) return true;
try {
const parsed = JSON.parse(raw);
if (!Array.isArray(parsed) || parsed.length !== 1) return true;
const entry = parsed[0] as any;
if (entry?.serverId !== expectedServerId) return true;
if (entry?.serverId !== serverId) return true;
const connections = entry?.connections;
if (!Array.isArray(connections)) return true;
if (
@@ -46,9 +46,7 @@ async function ensureE2EStorageSeeded(page: Page): Promise<void> {
)
)
return true;
return !connections.some(
(c: any) => c?.type === "directTcp" && c?.endpoint === expectedEndpoint,
);
return !connections.some((c: any) => c?.type === "directTcp" && c?.endpoint === endpoint);
} catch {
return true;
}
@@ -68,10 +66,10 @@ async function ensureE2EStorageSeeded(page: Page): Promise<void> {
});
const preferences = buildCreateAgentPreferences(expectedServerId);
await page.evaluate(
({ daemon, preferences }) => {
({ daemon: seededDaemon, preferences: seededPreferences }) => {
localStorage.setItem("@paseo:e2e", "1");
localStorage.setItem("@paseo:daemon-registry", JSON.stringify([daemon]));
localStorage.setItem("@paseo:create-agent-preferences", JSON.stringify(preferences));
localStorage.setItem("@paseo:daemon-registry", JSON.stringify([seededDaemon]));
localStorage.setItem("@paseo:create-agent-preferences", JSON.stringify(seededPreferences));
localStorage.removeItem("@paseo:settings");
},
{ daemon, preferences },

View File

@@ -148,21 +148,21 @@ export async function primeAdditionalPage(page: Page): Promise<void> {
await ws.close({ code: 1008, reason: "Blocked connection to localhost:6767 during e2e." });
});
await page.addInitScript(
({ daemon, preferences, seedNonce }) => {
({ daemon: seededDaemon, preferences: seededPreferences, seedNonce: nonce }) => {
const disableOnceKey = "@paseo:e2e-disable-default-seed-once";
const disableValue = localStorage.getItem(disableOnceKey);
if (disableValue) {
localStorage.removeItem(disableOnceKey);
if (disableValue === seedNonce) {
if (disableValue === nonce) {
return;
}
}
localStorage.setItem("@paseo:e2e", "1");
localStorage.setItem("@paseo:e2e-seed-nonce", seedNonce);
localStorage.setItem("@paseo:daemon-registry", JSON.stringify([daemon]));
localStorage.setItem("@paseo:e2e-seed-nonce", nonce);
localStorage.setItem("@paseo:daemon-registry", JSON.stringify([seededDaemon]));
localStorage.removeItem("@paseo:settings");
localStorage.setItem("@paseo:create-agent-preferences", JSON.stringify(preferences));
localStorage.setItem("@paseo:create-agent-preferences", JSON.stringify(seededPreferences));
},
{ daemon, preferences, seedNonce },
);
@@ -173,11 +173,11 @@ export async function resetSeededPageState(page: Page): Promise<void> {
const { daemon, preferences } = buildSeededStoragePayload();
await page.goto("/");
await page.evaluate(
({ daemon, preferences }) => {
({ daemon: seededDaemon, preferences: seededPreferences }) => {
localStorage.clear();
localStorage.setItem("@paseo:e2e", "1");
localStorage.setItem("@paseo:daemon-registry", JSON.stringify([daemon]));
localStorage.setItem("@paseo:create-agent-preferences", JSON.stringify(preferences));
localStorage.setItem("@paseo:daemon-registry", JSON.stringify([seededDaemon]));
localStorage.setItem("@paseo:create-agent-preferences", JSON.stringify(seededPreferences));
localStorage.removeItem("@paseo:settings");
},
{ daemon, preferences },

View File

@@ -83,12 +83,17 @@ export function useComposerHeightMirror({
}
ms.width = `${source.clientWidth}px`;
const { value, minHeight, maxHeight, onHeight } = paramsRef.current;
const {
value: currentValue,
minHeight: currentMinHeight,
maxHeight: currentMaxHeight,
onHeight: currentOnHeight,
} = paramsRef.current;
// Trailing newline is collapsed by textarea measurement — pad with a space.
mirror.value = value.endsWith("\n") ? `${value} ` : value;
mirror.value = currentValue.endsWith("\n") ? `${currentValue} ` : currentValue;
const next = Math.max(minHeight, Math.min(maxHeight, mirror.scrollHeight));
onHeight(next);
const next = Math.max(currentMinHeight, Math.min(currentMaxHeight, mirror.scrollHeight));
currentOnHeight(next);
}, [textareaRef]);
useLayoutEffect(() => {

View File

@@ -650,13 +650,13 @@ export const MessageInput = forwardRef<MessageInputRef, MessageInputProps>(funct
}
const getWebTextArea = useCallback((): TextAreaHandle | null => {
const ref = textInputRef.current;
if (!ref) return null;
if (typeof (ref as any).getNativeRef === "function") {
const native = (ref as any).getNativeRef();
const current = textInputRef.current;
if (!current) return null;
if (typeof (current as any).getNativeRef === "function") {
const native = (current as any).getNativeRef();
if (isTextAreaLike(native)) return native;
}
if (isTextAreaLike(ref)) return ref;
if (isTextAreaLike(current)) return current;
return null;
}, []);
@@ -673,12 +673,12 @@ export const MessageInput = forwardRef<MessageInputRef, MessageInputProps>(funct
});
const getWebElement = useCallback((target: "root" | "wrapper"): HTMLElement | null => {
const ref = target === "root" ? rootRef.current : inputWrapperRef.current;
if (!ref) return null;
return ref instanceof HTMLElement
? ref
: (ref as unknown as { getBoundingClientRect?: () => DOMRect }).getBoundingClientRect
? (ref as unknown as HTMLElement)
const current = target === "root" ? rootRef.current : inputWrapperRef.current;
if (!current) return null;
return current instanceof HTMLElement
? current
: (current as unknown as { getBoundingClientRect?: () => DOMRect }).getBoundingClientRect
? (current as unknown as HTMLElement)
: null;
}, []);
@@ -710,11 +710,11 @@ export const MessageInput = forwardRef<MessageInputRef, MessageInputProps>(funct
event.preventDefault();
void filesToImageAttachments(imageFiles)
.then((attachments) => {
if (disposed || attachments.length === 0) {
.then((pastedAttachments) => {
if (disposed || pastedAttachments.length === 0) {
return;
}
onAddImages(attachments);
onAddImages(pastedAttachments);
return;
})
.catch((error) => {

View File

@@ -24,26 +24,26 @@ type CheckoutPrStatusPayload = CheckoutPrStatusResponse["payload"];
type PullRequestTimelinePayload = PullRequestTimelineResponse["payload"];
const { mockRuntime, mockClient, checkoutStatusUpdateHandlers } = vi.hoisted(() => {
const checkoutStatusUpdateHandlers = new Set<(message: unknown) => void>();
const mockClient = {
const hoistedHandlers = new Set<(message: unknown) => void>();
const hoistedClient = {
checkoutPrStatus: vi.fn(),
pullRequestTimeline: vi.fn(),
on: vi.fn((type: string, handler: (message: unknown) => void) => {
if (type !== "checkout_status_update") {
return () => {};
}
checkoutStatusUpdateHandlers.add(handler);
hoistedHandlers.add(handler);
return () => {
checkoutStatusUpdateHandlers.delete(handler);
hoistedHandlers.delete(handler);
};
}),
};
return {
mockClient,
checkoutStatusUpdateHandlers,
mockClient: hoistedClient,
checkoutStatusUpdateHandlers: hoistedHandlers,
mockRuntime: {
client: mockClient,
client: hoistedClient,
isConnected: true,
},
};