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
2 changes: 2 additions & 0 deletions admin/server/projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -2133,6 +2133,7 @@ func (s *Server) projToDTO(p *database.Project, orgName string) *adminv1.Project
ArchiveAssetId: safeStr(p.ArchiveAssetID),
PrimaryDeploymentId: safeStr(p.PrimaryDeploymentID),
ProdTtlSeconds: safeInt64(p.ProdTTLSeconds),
DevTtlSeconds: p.DevTTLSeconds,
FrontendUrl: s.admin.URLs.Project(orgName, p.Name),
Annotations: p.Annotations,
CreatedOn: timestamppb.New(p.CreatedOn),
Expand Down Expand Up @@ -2286,6 +2287,7 @@ func deploymentToDTO(d *database.Deployment) *adminv1.Deployment {
StatusMessage: d.StatusMessage,
CreatedOn: timestamppb.New(d.CreatedOn),
UpdatedOn: timestamppb.New(d.UpdatedOn),
UsedOn: timestamppb.New(d.UsedOn),
}
}

Expand Down
6 changes: 6 additions & 0 deletions proto/gen/rill/admin/v1/admin.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5117,6 +5117,9 @@ definitions:
updatedOn:
type: string
format: date-time
usedOn:
type: string
format: date-time
v1DeploymentStatus:
type: string
enum:
Expand Down Expand Up @@ -6090,6 +6093,9 @@ definitions:
prodTtlSeconds:
type: string
format: int64
devTtlSeconds:
type: string
format: int64
annotations:
type: object
additionalProperties:
Expand Down
5,510 changes: 2,766 additions & 2,744 deletions proto/gen/rill/admin/v1/api.pb.go

Large diffs are not rendered by default.

31 changes: 31 additions & 0 deletions proto/gen/rill/admin/v1/api.pb.validate.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions proto/gen/rill/admin/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,9 @@ components:
updatedOn:
format: date-time
type: string
usedOn:
format: date-time
type: string
type: object
v1DeploymentStatus:
default: DEPLOYMENT_STATUS_UNSPECIFIED
Expand Down Expand Up @@ -1502,6 +1505,9 @@ components:
devSlots:
format: int64
type: string
devTtlSeconds:
format: int64
type: string
directoryName:
type: string
frontendUrl:
Expand Down
6 changes: 6 additions & 0 deletions proto/gen/rill/admin/v1/public.openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,9 @@ components:
updatedOn:
format: date-time
type: string
usedOn:
format: date-time
type: string
type: object
v1DeploymentStatus:
default: DEPLOYMENT_STATUS_UNSPECIFIED
Expand Down Expand Up @@ -1502,6 +1505,9 @@ components:
devSlots:
format: int64
type: string
devTtlSeconds:
format: int64
type: string
directoryName:
type: string
frontendUrl:
Expand Down
2 changes: 2 additions & 0 deletions proto/rill/admin/v1/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3317,6 +3317,7 @@ message Project {
int64 dev_slots = 25;
string frontend_url = 16; // Note: Does NOT incorporate the parent org's custom domain.
int64 prod_ttl_seconds = 18;
int64 dev_ttl_seconds = 27;
map<string, string> annotations = 20;
string prod_version = 21;
google.protobuf.Timestamp created_on = 14;
Expand Down Expand Up @@ -3350,6 +3351,7 @@ message Deployment {
string status_message = 8;
google.protobuf.Timestamp created_on = 9;
google.protobuf.Timestamp updated_on = 10;
google.protobuf.Timestamp used_on = 14;
}

message ProvisionerResource {
Expand Down
2 changes: 2 additions & 0 deletions web-admin/src/client/gen/index.schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ export interface V1Deployment {
statusMessage?: string;
createdOn?: string;
updatedOn?: string;
usedOn?: string;
}

export type V1DeploymentStatus =
Expand Down Expand Up @@ -1085,6 +1086,7 @@ export interface V1Project {
/** Note: Does NOT incorporate the parent org's custom domain. */
frontendUrl?: string;
prodTtlSeconds?: string;
devTtlSeconds?: string;
annotations?: V1ProjectAnnotations;
prodVersion?: string;
createdOn?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
const BANNER_ID = "edit-session-timeout";
const BANNER_PRIORITY = 0; // Highest priority; session loss is urgent

/** Session timeout duration in milliseconds (1 hour) */
export let timeoutMs = 60 * 60 * 1000;
/** When to start showing the warning (10 minutes before timeout) */
export let warningMs = 10 * 60 * 1000;
/** Session start time */
export let sessionStartedAt: string | undefined;
/** Last time the deployment was used; bumped server-side on every GetProject. */
export let usedOn: string | undefined;
/** TTL after which an idle dev deployment hibernates. Stringified int64 from the API. */
export let devTtlSeconds: string | undefined;

let showing = false;
let interval: ReturnType<typeof setInterval>;
Expand All @@ -26,11 +26,12 @@
});

function checkTimeout() {
if (!sessionStartedAt) return;
if (!usedOn || !devTtlSeconds) return;
const ttlSeconds = Number(devTtlSeconds);
if (!ttlSeconds) return;

const startTime = new Date(sessionStartedAt).getTime();
const elapsed = Date.now() - startTime;
const remaining = timeoutMs - elapsed;
const expiresAt = new Date(usedOn).getTime() + ttlSeconds * 1000;
const remaining = expiresAt - Date.now();

const minutesRemaining = Math.max(0, Math.ceil(remaining / 60_000));
const shouldShow = remaining > 0 && remaining <= warningMs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
);
$: projectPermissions = $projectQuery.data?.projectPermissions ?? {};
$: primaryBranch = $projectQuery.data?.project?.primaryBranch;
$: devTtlSeconds = $projectQuery.data?.project?.devTtlSeconds;

// Deployment data and credentials come from GetProject (no separate API needed)
$: deployment = $projectQuery.data?.deployment;
Expand Down Expand Up @@ -174,7 +175,10 @@
{organizationLogoUrl}
editContext={true}
/>
<EditSessionTimeoutBanner sessionStartedAt={deployment.createdOn} />
<EditSessionTimeoutBanner
usedOn={deployment.usedOn}
{devTtlSeconds}
/>
{/if}
<FileAndResourceWatcher
lifecycle="none"
Expand Down
12 changes: 12 additions & 0 deletions web-common/src/proto/gen/rill/admin/v1/api_pb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16042,6 +16042,11 @@ export class Project extends Message<Project> {
*/
prodTtlSeconds = protoInt64.zero;

/**
* @generated from field: int64 dev_ttl_seconds = 27;
*/
devTtlSeconds = protoInt64.zero;

/**
* @generated from field: map<string, string> annotations = 20;
*/
Expand Down Expand Up @@ -16089,6 +16094,7 @@ export class Project extends Message<Project> {
{ no: 25, name: "dev_slots", kind: "scalar", T: 3 /* ScalarType.INT64 */ },
{ no: 16, name: "frontend_url", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 18, name: "prod_ttl_seconds", kind: "scalar", T: 3 /* ScalarType.INT64 */ },
{ no: 27, name: "dev_ttl_seconds", kind: "scalar", T: 3 /* ScalarType.INT64 */ },
{ no: 20, name: "annotations", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "scalar", T: 9 /* ScalarType.STRING */} },
{ no: 21, name: "prod_version", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 14, name: "created_on", kind: "message", T: Timestamp },
Expand Down Expand Up @@ -16176,6 +16182,11 @@ export class Deployment extends Message<Deployment> {
*/
updatedOn?: Timestamp;

/**
* @generated from field: google.protobuf.Timestamp used_on = 14;
*/
usedOn?: Timestamp;

constructor(data?: PartialMessage<Deployment>) {
super();
proto3.util.initPartial(data, this);
Expand All @@ -16196,6 +16207,7 @@ export class Deployment extends Message<Deployment> {
{ no: 8, name: "status_message", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 9, name: "created_on", kind: "message", T: Timestamp },
{ no: 10, name: "updated_on", kind: "message", T: Timestamp },
{ no: 14, name: "used_on", kind: "message", T: Timestamp },
]);

static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Deployment {
Expand Down
Loading