Skip to content

Commit 77623d8

Browse files
committed
refactor(webapp,database): drop isTest backfill, hide legacy tag in UI
The Session.isTest backfill (and the array_remove of the "playground" tag) is removed from the migration, which now only adds the column. Existing sessions keep isTest=false; only sessions created from the Test playground going forward set it. The legacy "playground" tag is hidden from the Tags display in both the sessions list and detail presenters (via LEGACY_PLAYGROUND_TAG) so it does not surface on pre-isTest rows, without mutating historical data.
1 parent f71507d commit 77623d8

5 files changed

Lines changed: 22 additions & 13 deletions

File tree

.server-changes/sessions-test-column.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ area: webapp
33
type: feature
44
---
55

6-
Agent sessions started from the Test playground are now flagged with a real `Session.isTest` boolean instead of a `"playground"` tag, surfaced as a dedicated "Test" column (check icon) in the Sessions table on both the Sessions and Agent pages, plus a matching property on the session detail page. Existing sessions are backfilled and the now-redundant tag is removed.
6+
Agent sessions started from the Test playground are now flagged with a real `Session.isTest` boolean instead of a `"playground"` tag, surfaced as a dedicated "Test" column (check icon) in the Sessions table on both the Sessions and Agent pages, plus a matching property on the session detail page. The legacy `"playground"` tag is hidden from the Tags display on pre-existing sessions.

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { findDisplayableEnvironment } from "~/models/runtimeEnvironment.server";
77
import {
88
type SessionStatus,
99
SessionsRepository,
10+
LEGACY_PLAYGROUND_TAG,
1011
} from "~/services/sessionsRepository/sessionsRepository.server";
1112
import { ServiceValidationError } from "~/v3/services/baseService.server";
1213
import { findCurrentWorkerFromEnvironment } from "~/v3/models/workerDeployment.server";
@@ -226,7 +227,12 @@ export class SessionListPresenter {
226227
type: session.type,
227228
taskIdentifier: session.taskIdentifier,
228229
isTest: session.isTest,
229-
tags: session.tags ? [...session.tags].sort((a, b) => a.localeCompare(b)) : [],
230+
// Hide the legacy "playground" tag (pre-isTest sessions) from display.
231+
tags: session.tags
232+
? [...session.tags]
233+
.filter((t) => t !== LEGACY_PLAYGROUND_TAG)
234+
.sort((a, b) => a.localeCompare(b))
235+
: [],
230236
status,
231237
closedAt: session.closedAt ? session.closedAt.toISOString() : undefined,
232238
closedReason: session.closedReason ?? undefined,

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { env } from "~/env.server";
44
import { findDisplayableEnvironment } from "~/models/runtimeEnvironment.server";
55
import { chatSnapshotStorageKey } from "~/services/realtime/chatSnapshot.server";
66
import { resolveSessionByIdOrExternalId } from "~/services/realtime/sessions.server";
7+
import { LEGACY_PLAYGROUND_TAG } from "~/services/sessionsRepository/sessionsRepository.server";
78
import { logger } from "~/services/logger.server";
89
import { generatePresignedUrl } from "~/v3/objectStore.server";
910
import { runStore } from "~/v3/runStore.server";
@@ -178,7 +179,12 @@ export class SessionPresenter {
178179
type: session.type,
179180
taskIdentifier: session.taskIdentifier,
180181
isTest: session.isTest,
181-
tags: session.tags ? [...session.tags].sort((a, b) => a.localeCompare(b)) : [],
182+
// Hide the legacy "playground" tag (pre-isTest sessions) from display.
183+
tags: session.tags
184+
? [...session.tags]
185+
.filter((t) => t !== LEGACY_PLAYGROUND_TAG)
186+
.sort((a, b) => a.localeCompare(b))
187+
: [],
182188
metadata: session.metadata,
183189
triggerConfig: session.triggerConfig,
184190
streamBasinName: session.streamBasinName,

apps/webapp/app/services/sessionsRepository/sessionsRepository.server.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ export type SessionsRepositoryOptions = {
2424
export const SessionStatus = z.enum(["ACTIVE", "CLOSED", "EXPIRED"]);
2525
export type SessionStatus = z.infer<typeof SessionStatus>;
2626

27+
/**
28+
* Legacy marker tag for sessions created from the Test/playground before the
29+
* `Session.isTest` boolean existed. New sessions set `isTest` instead; this tag
30+
* is hidden from the Tags display so it doesn't surface on pre-isTest rows.
31+
*/
32+
export const LEGACY_PLAYGROUND_TAG = "playground";
33+
2734
const SessionListInputOptionsSchema = z.object({
2835
organizationId: z.string(),
2936
projectId: z.string(),
Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,2 @@
11
-- AlterTable
22
ALTER TABLE "Session" ADD COLUMN "isTest" BOOLEAN NOT NULL DEFAULT false;
3-
4-
-- Backfill: legacy Test sessions were marked with a "playground" tag. Flag them
5-
-- as test and strip the now-redundant tag (the Test column replaces it), so the
6-
-- list and detail views render consistently without read-time tag filtering.
7-
-- Bounded one-shot over the playground subset; matches existing in-migration
8-
-- backfill precedent. (Prisma wraps each migration in a single transaction, so
9-
-- batching with intermediate commits isn't possible here.)
10-
UPDATE "Session"
11-
SET "isTest" = true, "tags" = array_remove("tags", 'playground')
12-
WHERE 'playground' = ANY("tags");

0 commit comments

Comments
 (0)