Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,10 @@ public struct VMCloudSession: Sendable {
public let title: String?
public let kind: String
public let status: String
/// Lifetime attaches for this session, not the number of clients attached
/// now. The control plane only ever adds to it, so it never returns to
/// zero. Socket clients receive it as `attachment_count`; do not present it
/// as a live viewer count.
public let attachmentCount: Int
public let effectiveCols: Int?
public let effectiveRows: Int?
Expand Down
1 change: 1 addition & 0 deletions web/app/api/vm/[id]/sessions/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ function sessionPayload(session: CloudVmSessionRow) {
title: session.title,
kind: session.kind,
status: session.status,
// Cumulative attaches over the session's life, never a live client count.
attachmentCount: session.attachmentCount,
effectiveCols: session.effectiveCols,
effectiveRows: session.effectiveRows,
Expand Down
5 changes: 5 additions & 0 deletions web/db/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,11 @@ export const cloudVmSessions = pgTable(
title: text("title"),
kind: text("kind").notNull().default("terminal"),
status: cloudVmSessionStatus("status").notNull().default("running"),
// Lifetime number of attaches, not the number of clients attached now.
// upsertVmSession is the only writer and there is no detach writer at all,
// so the count only grows and never returns to zero. Pair it with
// lastAttachedAt to reason about recency; do not present it as a live
// viewer or participant count.
attachmentCount: integer("attachment_count").notNull().default(0),
effectiveCols: integer("effective_cols"),
effectiveRows: integer("effective_rows"),
Expand Down
5 changes: 5 additions & 0 deletions web/services/vms/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,11 @@ export type VmRepositoryShape = {
readonly providerSessionId: string;
readonly title?: string | null;
readonly status?: CloudVmSessionStatus;
/**
* Attaches contributed by this call, defaulting to 1; pass a positive count.
* The insert branch stores it as the session's first count and the conflict
* branch adds it to the existing total, so this is never a replacement value.
*/
readonly attachmentCount?: number;
readonly effectiveCols?: number | null;
readonly effectiveRows?: number | null;
Expand Down
Loading