Skip to content

vp migrate beta test#2

Draft
fengmk2 wants to merge 1 commit into
mainfrom
vp-migrate-test
Draft

vp migrate beta test#2
fengmk2 wants to merge 1 commit into
mainfrom
vp-migrate-test

Conversation

@fengmk2

@fengmk2 fengmk2 commented Jun 26, 2026

Copy link
Copy Markdown
Owner

No description provided.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request primarily applies formatting and style cleanups across various frontend files, alongside updating several dependencies such as Vite and Oxlint. The review feedback highlights several critical robustness issues where API response fields (such as insights, projects, agents, machines, pins, and buckets) can be null according to the OpenAPI specification, potentially causing runtime TypeError crashes. Additionally, a missing null check was identified in the isBlob utility function in request.ts which could lead to a crash when checking nullable values.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines 26 to 36
export const isBlob = (value: any): value is Blob => {
return (
typeof value === 'object' &&
typeof value.type === 'string' &&
typeof value.stream === 'function' &&
typeof value.arrayBuffer === 'function' &&
typeof value.constructor === 'function' &&
typeof value.constructor.name === 'string' &&
typeof value === "object" &&
typeof value.type === "string" &&
typeof value.stream === "function" &&
typeof value.arrayBuffer === "function" &&
typeof value.constructor === "function" &&
typeof value.constructor.name === "string" &&
/^(Blob|File)$/.test(value.constructor.name) &&
/^(Blob|File)$/.test(value[Symbol.toStringTag])
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

In JavaScript/TypeScript, typeof null evaluates to "object". If value is null, accessing value.type will throw a TypeError: Cannot read properties of null (reading 'type'). Adding a null check prevents potential runtime crashes when checking nullable values.

export const isBlob = (value: any): value is Blob => {
  return (
    value !== null &&
    typeof value === "object" &&
    typeof value.type === "string" &&
    typeof value.stream === "function" &&
    typeof value.arrayBuffer === "function" &&
    typeof value.constructor === "function" &&
    typeof value.constructor.name === "string" &&
    /^(Blob|File)$/.test(value.constructor.name) &&
    /^(Blob|File)$/.test(value[Symbol.toStringTag])
  );

await InsightsService.getApiV1Insights({}) as unknown as InsightsResponse;
const res = (await InsightsService.getApiV1Insights({})) as unknown as InsightsResponse;
if (this.#version === v) {
this.items = res.insights;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

According to the OpenAPI specification, res.insights can be null. If it is null, assigning it directly to this.items will cause a TypeError on the subsequent line when calling this.items.some(...). Defaulting to an empty array prevents this crash.

Suggested change
this.items = res.insights;
this.items = res.insights ?? [];

const res = (await MetadataService.getApiV1Projects(opts)) as unknown as {
projects: ProjectInfo[];
};
if (ver === this.#filterOptionsVersion) this.projects = res.projects;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

According to the OpenAPI specification, res.projects can be null. Assigning null to this.projects can cause runtime errors in Svelte templates when attempting to iterate over the projects list. Using a nullish coalescing operator to default to an empty array prevents this.

Suggested change
if (ver === this.#filterOptionsVersion) this.projects = res.projects;
if (ver === this.#filterOptionsVersion) this.projects = res.projects ?? [];

const res = (await MetadataService.getApiV1Agents(opts)) as unknown as {
agents: AgentInfo[];
};
if (ver === this.#filterOptionsVersion) this.agents = res.agents;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

According to the OpenAPI specification, res.agents can be null. Assigning null to this.agents can cause runtime errors in Svelte templates when attempting to iterate over the agents list. Using a nullish coalescing operator to default to an empty array prevents this.

Suggested change
if (ver === this.#filterOptionsVersion) this.agents = res.agents;
if (ver === this.#filterOptionsVersion) this.agents = res.agents ?? [];

const res = (await MetadataService.getApiV1Machines(opts)) as unknown as {
machines: string[];
};
if (ver === this.#filterOptionsVersion) this.machines = res.machines;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

According to the OpenAPI specification, res.machines can be null. Assigning null to this.machines can cause runtime errors in Svelte templates when attempting to iterate over the machines list. Using a nullish coalescing operator to default to an empty array prevents this.

Suggested change
if (ver === this.#filterOptionsVersion) this.machines = res.machines;
if (ver === this.#filterOptionsVersion) this.machines = res.machines ?? [];

this.sessionPinIds = new Set(
res.pins.map((p) => p.message_id),
);
this.sessionPinIds = new Set(res.pins.map((p) => p.message_id));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

According to the OpenAPI specification, res.pins can be null. If it is null, calling res.pins.map(...) will throw a TypeError. Defaulting to an empty array prevents this crash.

Suggested change
this.sessionPinIds = new Set(res.pins.map((p) => p.message_id));
this.sessionPinIds = new Set((res.pins ?? []).map((p) => p.message_id));

id: sessionId,
})) as unknown as SessionActivityResponse;
// Ignore stale responses from previous sessions.
if (version !== this.loadVersion) return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

According to the OpenAPI specification, resp.buckets can be null. If it is null, assigning it directly to this.buckets will cause a TypeError when calling findActiveBucketIndex(this.buckets, ...) on line 40. Defaulting to an empty array prevents this crash.

Suggested change
if (version !== this.loadVersion) return;
this.buckets = resp.buckets ?? [];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant