Skip to content

Commit d221490

Browse files
committed
fix(webapp): normalize taskKind in API + drop unsafe casts in playground action
ApiRunListPresenter was returning `run.taskKind` raw from ClickHouse where the column defaults to `""` for pre-migration rows, while the dashboard's NextRunListPresenter normalizes to `"STANDARD"`. API consumers and the dashboard now agree. Playground action's two `as unknown as AuthenticatedEnvironment` casts were redundant — `findEnvironmentBySlug` already returns `Promise<AuthenticatedEnvironment | null>`. Drop the casts (and the now-unused import) so a future change to the function's return shape actually surfaces as a type error instead of crashing at runtime.
1 parent 02dca08 commit d221490

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

apps/webapp/app/presenters/v3/ApiRunListPresenter.server.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,10 @@ export class ApiRunListPresenter extends BasePresenter {
304304
durationMs: run.usageDurationMs,
305305
depth: run.depth,
306306
metadata,
307-
taskKind: run.taskKind,
307+
// ClickHouse defaults `task_kind` to "" for pre-migration rows.
308+
// Match `NextRunListPresenter`'s "STANDARD" fallback so API
309+
// consumers and the dashboard see the same value.
310+
taskKind: run.taskKind || "STANDARD",
308311
...ApiRetrieveRunPresenter.apiBooleanHelpersFromRunStatus(
309312
ApiRetrieveRunPresenter.apiStatusFromRunStatus(run.status, apiVersion)
310313
),

apps/webapp/app/routes/resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.playground.action.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { requireUserId } from "~/services/session.server";
1010
import { EnvironmentParamSchema } from "~/utils/pathBuilder";
1111
import { mintSessionToken } from "~/services/realtime/mintSessionToken.server";
1212
import { ensureRunForSession } from "~/services/realtime/sessionRunManager.server";
13-
import type { AuthenticatedEnvironment } from "~/services/apiAuth.server";
1413

1514
const PlaygroundAction = z.object({
1615
intent: z.enum(["create", "start", "save", "delete"]),
@@ -180,7 +179,7 @@ export const action = async ({ request, params }: ActionFunctionArgs) => {
180179

181180
const ensureResult = await ensureRunForSession({
182181
session,
183-
environment: environment as unknown as AuthenticatedEnvironment,
182+
environment,
184183
reason: "initial",
185184
});
186185

@@ -225,10 +224,7 @@ export const action = async ({ request, params }: ActionFunctionArgs) => {
225224
},
226225
});
227226

228-
const publicAccessToken = await mintSessionToken(
229-
environment as unknown as AuthenticatedEnvironment,
230-
chatId
231-
);
227+
const publicAccessToken = await mintSessionToken(environment, chatId);
232228

233229
return json({
234230
runId: run.friendlyId,

0 commit comments

Comments
 (0)