gitpod/components/gitpod-protocol/src/headless-workspace-log.ts
Gero Posmyk-Leinemann fbc0d76554
Prebuild issues roundup (#20000)
* redirect in the offline case

* [public-api] generate noise

* [server] Refactor Prebuild resolution to happen in a single place

* [dashboard, api] Show Prebuild details

* fixup! [server] Refactor Prebuild resolution to happen in a single place

* [bridge] Revive Prebuild QUEUED state: it's everything before running

* [server] Fix dead-end for streaming logs when starting too early

* [dashboard] Adds SHA + duration, fix re-rendering when prebuildId changes, and uses the new/old streaming logic

WIP because still has the "duplicate (sometimes triple!) logs" react re-rendering issue

* Prevent unnecessary re-renders of task output

* remove double-comment

* Duration display improvements

* Properly dismiss toasts and render durations

* Remove SHA from prebuild list

* Clean up and implement the `reset` event for workspace logs

* fix comment

* Tiny cleanup

---------

Co-authored-by: Filip Troníček <filip@gitpod.io>
2024-07-10 04:50:55 -04:00

43 lines
1.3 KiB
TypeScript

/**
* Copyright (c) 2020 Gitpod GmbH. All rights reserved.
* Licensed under the GNU Affero General Public License (AGPL).
* See License.AGPL.txt in the project root for license information.
*/
export enum HeadlessWorkspaceEventType {
LogOutput = "log-output",
FinishedSuccessfully = "finish-success",
FinishedButFailed = "finish-fail",
AbortedTimedOut = "aborted-timeout",
Aborted = "aborted",
Failed = "failed",
Started = "started",
}
export namespace HeadlessWorkspaceEventType {
export function isRunning(t: HeadlessWorkspaceEventType) {
return t === HeadlessWorkspaceEventType.LogOutput;
}
export function didFinish(t: HeadlessWorkspaceEventType) {
return (
t === HeadlessWorkspaceEventType.FinishedButFailed || t === HeadlessWorkspaceEventType.FinishedSuccessfully
);
}
}
export interface HeadlessWorkspaceEvent {
workspaceID: string;
type: HeadlessWorkspaceEventType;
}
export interface HeadlessLogUrls {
// A map of id to URL
streams: { [streamID: string]: string };
// Whether the workspace is online
online?: boolean;
}
/** cmp. @const HEADLESS_LOG_STREAM_STATUS_CODE_REGEX */
export const HEADLESS_LOG_STREAM_STATUS_CODE = "X-LogStream-StatusCode";
export const HEADLESS_LOG_STREAM_STATUS_CODE_REGEX = /X-LogStream-StatusCode: ([0-9]{3})/;