workspaces 0.1.18 → 0.1.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/DESIGN.md +31 -30
- data/README.md +42 -2
- data/lib/workspaces/config.rb +4 -0
- data/lib/workspaces/coordinator.rb +8 -0
- data/lib/workspaces/dashboard/app.js +19 -20
- data/lib/workspaces/dashboard/card.html.erb +42 -0
- data/lib/workspaces/dashboard/styles.css +160 -135
- data/lib/workspaces/dashboard/template.html.erb +13 -13
- data/lib/workspaces/dashboard_view.rb +115 -17
- data/lib/workspaces/front_door.rb +102 -7
- data/lib/workspaces/presentation.rb +18 -28
- data/lib/workspaces/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b62d0530751f975a4e8604a691dce7bc133c3d7bd57a966e08e9b9e24c7088d9
|
|
4
|
+
data.tar.gz: 3fb3b5acff924444694d1390b9edd0f4dc2eaf5885da24b938552180b52a0b0e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e860375ef8492aba63ef9340ff2ad29e22fc504353546d343b3e2c3dc31833b9df5bc77de4a8b367eeeb8e3423aef5918e0f61a51d4de26dd8ea9d916af7bec3
|
|
7
|
+
data.tar.gz: d8521f83fd632951c5ac551f52f1c4a72db8d22afd33dca483bad10e1f82456f01d8fcf4fa0d50fc00e93cb98da32eab34ae6c16454a8cb931e5654c9349ee19
|
data/DESIGN.md
CHANGED
|
@@ -8,26 +8,22 @@ GET is read-only. All creation and lifecycle controls submit same-origin POST fo
|
|
|
8
8
|
|
|
9
9
|
## Visual direction
|
|
10
10
|
|
|
11
|
-
Restrained tooling UI:
|
|
11
|
+
Restrained tooling UI: a near-black page, one slightly lighter card surface with a hairline border and no shadow, a compact spacing rhythm, clear status affordances, and no decorative animation. Every text pairing is at least 4.5:1 against its surface.
|
|
12
12
|
|
|
13
13
|
## Tokens used
|
|
14
14
|
|
|
15
15
|
### Color
|
|
16
16
|
|
|
17
|
-
- `--bg`:
|
|
18
|
-
- `--
|
|
19
|
-
- `--
|
|
20
|
-
- `--text
|
|
21
|
-
- `--
|
|
22
|
-
- `--accent`: active status and primary action
|
|
23
|
-
- `--success`: completed/ready states
|
|
24
|
-
- `--danger`: failed/error states
|
|
25
|
-
- `--warning`: retry/connection warning text
|
|
17
|
+
- `--bg` `#0b0f17`: page. `--bg-elevated` `#141a26`: card surface. `--border` `#2a3447`: card edge. `--divider` `#252e41`: row dividers. `--border-strong` `#3f4b63`: the table header rule.
|
|
18
|
+
- `--control-border`: the edge of inputs, outline buttons and tabs. Currently `#3f4b63`, about 2:1 against the card. WCAG 1.4.11 asks 3:1 for a control's boundary, so this is a known shortfall, kept to match the design handoff; `#5b6b8a` or lighter reaches 3:1. It is one token, so changing it is a one-line edit.
|
|
19
|
+
- Text: `--text-strong` `#f8fafc` (headings, workspace names, input values), `--text` `#e2e8f0` (body), `--text-cell` `#cbd5e1` (table cells, logs), `--muted` `#a8b3c7` (secondary), `--placeholder` `#8a97ad`.
|
|
20
|
+
- `--accent` `#6fa8ff` with `--on-accent` `#06101f` text on buttons; `--accent-hover` `#8dbbff` for link and button hover. `--success`, `--danger` and `--warning` are unchanged.
|
|
21
|
+
- **Status pills** take three custom properties, `--pill-bg`, `--pill-text` and `--pill-dot`, set per `data-status`. Sleeping indigo, idle amber and stopped red come from the handoff. Ready green, preparing cyan, error deeper red and interrupted orange were chosen to the same contrast (text 8:1 or better, dot 3:1 or better). Any other status gets the neutral slate pair.
|
|
26
22
|
|
|
27
23
|
### Radius and depth
|
|
28
24
|
|
|
29
|
-
- `--radius`: 12px panel corners
|
|
30
|
-
- `--shadow`:
|
|
25
|
+
- `--radius`: 12px panel corners. `--radius-control`: 8px for inputs, buttons and tabs. `--control-height`: 44px.
|
|
26
|
+
- `--shadow`: none. Panels are separated by their border alone.
|
|
31
27
|
|
|
32
28
|
### Spacing scale
|
|
33
29
|
|
|
@@ -35,31 +31,36 @@ Restrained tooling UI: dark elevated panels, compact spacing rhythm, clear statu
|
|
|
35
31
|
|
|
36
32
|
### Typography
|
|
37
33
|
|
|
38
|
-
-
|
|
39
|
-
-
|
|
34
|
+
- Interface: Inter (`--font-sans`) at 15px body, 14px labels at 600, h1 32px at 700, panel h2 20px at 600, table column headers 12px at 600 uppercase with 0.06em tracking.
|
|
35
|
+
- Workspace names, input values and logs: JetBrains Mono (`--font-mono`), 14px. Both stacks fall back to system fonts, because nothing is loaded from the network.
|
|
36
|
+
- Timestamps use `font-variant-numeric: tabular-nums`.
|
|
40
37
|
|
|
41
38
|
## Component primitives
|
|
42
39
|
|
|
43
|
-
- **Creation form**: labelled
|
|
44
|
-
- **Workspace inventory**:
|
|
45
|
-
- **Status pill**:
|
|
40
|
+
- **Creation form**: four labelled fields in one wrapping row (`flex: 1 1 220px`, 16px gap), each with a real `<label for>`, then a `type="submit"` button on its own line.
|
|
41
|
+
- **Workspace inventory**: a centered column up to 1180px. Rows are ordered by last startup, newest first; workspaces that never started (or whose start time cannot be read) come last, and ties fall back to the id so the list never shuffles between loads. Moments are compared as moments, not text. The page header carries "N managed worktrees · none running" (or "· K running"), counted from the data. The table sits in an `overflow-x: auto` wrapper with `min-width: 820px`, so a phone scrolls it sideways instead of cramming or hiding columns. Rows have 16px padding; workspace names are monospaced links with no underline until hover. Times read "Oct 27, 10:48", are UTC (the headers say so) and keep the full ISO value in a `title`. A missing start reads "Never" and a missing creation time "Unavailable", in the muted colour.
|
|
42
|
+
- **Status pill**: a dot and one word (13px, 600, fully rounded), never colour alone. A busy workspace adds "(busy)" and pulses its dot, which stops under reduced motion.
|
|
46
43
|
- **Setup progress**: names and ordered states come from repository run steps; failures are highlighted. Restart shows the background launch and later readiness commands.
|
|
47
44
|
- **Actions by state**: idle/stopped offers Start; active operations show progress without lifecycle buttons; failure offers Retry; ready offers Open workspace plus rebuild/restart/stop.
|
|
48
45
|
- **PR source update**: a secondary Update from PR form only for PR-sourced workspaces; it fetches the latest PR head, fast-forwards the checkout, and preserves local edits without rebuilding or restarting. A persistent result message explains when rebuild is needed or when a retained stash needs manual recovery.
|
|
49
46
|
- **Failure panel**: prominently above the log, with escaped error details and a matching retry action.
|
|
50
47
|
- **PR page**: existing workspaces are primary; creating another is a collapsed secondary disclosure. Creation is primary only when none exist.
|
|
51
|
-
- **
|
|
48
|
+
- **Workspace card**: the default page for a workspace (`/workspaces/ID`, and the same card at the visitor's own address on a preview host while the workspace is not serving). One centered card, about 26rem wide: the workspace id with a gear (an icon link to `/workspaces/ID/settings`, labelled "Settings and details"), the headline and a muted sentence, the *Preset: name* badge when the saved settings match a preset, the progress bar with its step line, elapsed time and estimate, then at most one large full-width action. Idle shows a single start form with a preset select; ready shows **Open workspace**; asleep or stopped shows **Wake workspace** or **Start workspace**; failure shows the shortened error with a link to the full log. The card never opens the preview by itself.
|
|
49
|
+
- **Shared with the settings page**: the card reuses the page's element ids and `app.js`, so polling needs no second script. `app.js` tolerates the elements the card lacks (actions, steps, logs, environment).
|
|
50
|
+
- **On a preview host** (`data-base="/__workspaces"`, `data-reload-when-ready="true"`): the card is served from the workspace's own origin, so it is the smallest surface that can work. It polls `/__workspaces/status`, posts only to `/__workspaces/start|prepare|restart|resume`, shows a fixed failure line instead of error text, and reloads the current page once when the workspace is ready. Everything else (settings, environment, secrets, logs, removal) stays on the shared dashboard origin behind its same-origin check.
|
|
51
|
+
- **Settings page**: the full page described below, with a *Back to workspace* link. It is where Update from PR, keep-awake, rebuild, restart, stop, environment editing and deletion live.
|
|
52
|
+
- **Three layers** (the settings page; the card shows only the lead): the workspace page leads with the friendly, the deliberate, then the technical. Which layers are shown depends on lifecycle state, driven by `Presentation::STATES`. They are plain sections, never folded: the card at `/workspaces/ID` is what keeps the details out of the way, so the settings page has nothing to hide.
|
|
52
53
|
1. **Lead** (always visible): a plain-language headline, one sentence, and at most one primary action (a large button). The setup steps never appear here.
|
|
53
|
-
2. **Settings** (a
|
|
54
|
-
3. **Technical details** (
|
|
54
|
+
2. **Settings** (a section headed *Change settings*, with a *Preset: name* badge beside the heading whenever the saved settings exactly match a preset, or *Choose what to preview* on a brand new workspace): presets first, as buttons, then the environment variables. The one submit button names what it does (Start workspace, Save & restart, Save & start, Save & retry).
|
|
55
|
+
3. **Technical details** (a section): setup step logs with timings, the web server log, workspace controls (rebuild, restart, stop, update from PR), preview URL, branch and path, and the Danger Zone. It is shown whenever the state has something to show (while setup runs, after a failure, and once ready), so a cause is never hidden.
|
|
55
56
|
- **Lead by state**:
|
|
56
|
-
- `idle`: "Let's get your workspace running", with the settings
|
|
57
|
-
- `busy`: "Setting things up…", with the current step as a quiet line and the elapsed time. Technical details
|
|
58
|
-
- `ready`: "Your workspace is ready" with a large **Open workspace** button.
|
|
57
|
+
- `idle`: "Let's get your workspace running", with the settings shown and *Start workspace* in the form.
|
|
58
|
+
- `busy`: "Setting things up…", with the current step as a quiet line and the elapsed time. Technical details are shown so progress and the log can be watched.
|
|
59
|
+
- `ready`: "Your workspace is ready" with a large **Open workspace** button. Settings and technical details sit below it.
|
|
59
60
|
- `stopped`: "Your workspace is paused" with a large **Start workspace** button.
|
|
60
|
-
- `error`/`interrupted`: a plain "Something didn't go to plan" with a large **Retry failed step** button (**Continue setup** after an interruption) that names the step in the summary, a subtle **Re-run all steps** beside it, the error shown, and technical details
|
|
61
|
-
- `unknown`: a minimal view with technical details
|
|
62
|
-
- **
|
|
61
|
+
- `error`/`interrupted`: a plain "Something didn't go to plan" with a large **Retry failed step** button (**Continue setup** after an interruption) that names the step in the summary, a subtle **Re-run all steps** beside it, the error shown, and technical details shown. When the recorded steps cannot be resumed, the single **Retry** of the earlier design is shown instead.
|
|
62
|
+
- `unknown`: a minimal view with technical details shown.
|
|
63
|
+
- **Section visibility**: the server renders which sections the state shows, and the polling script reveals or hides them as the state changes. Sections that are not meaningful in a state are hidden, never shown disabled. Nothing on the page folds except the per-step log rows below, so polling never opens or closes anything the reader is looking at.
|
|
63
64
|
- **Per-step re-run controls**: inside each step's accordion, small subtle **Re-run this step** and **Re-run from here** forms aimed at `/workspaces/ID/resume?only=KEY` and `?from=KEY`. The server decides which appear (`presentation.resume.step_modes`), so the page never offers something that would be refused; they are hidden while a run is in progress and are disabled with the other controls while busy.
|
|
64
65
|
- **Sleeping**: a workspace asleep is its own state (`sleeping`), distinct from stopped and failed. The lead reads "Your workspace is asleep", says files and data are kept and that opening the preview wakes it, and offers one **Wake workspace** button. A ready workspace shows one muted line, "Sleeps after N min without preview traffic", or "Kept awake" when exempt. **Keep awake** / **Allow sleep** are subtle workspace controls. A waking workspace is simply busy.
|
|
65
66
|
- **Environment rows**: the settings form is a list of rows, each a name input, a value input and a **Secret** checkbox, with **Add variable** and a per-row **Remove** (both revealed by script; without it the server-rendered rows still save). Rows post as `env[N][name|value|secret]`. A secret row's value is a password field that is never pre-filled; a stored secret shows its name, the placeholder "Stored. Enter a new value to replace it", and a locked checked checkbox (a hidden field carries it), so it can only be replaced or removed, not exposed. Ticking Secret on a new row switches its value to a password field. Presets replace only the visible rows and are matched against visible rows alone. A note under the rows shows why secrets are unavailable when the vault is not usable, and a line explains that secrets are write-only.
|
|
@@ -69,7 +70,7 @@ Restrained tooling UI: dark elevated panels, compact spacing rhythm, clear statu
|
|
|
69
70
|
- **Step logs (GitHub Actions style)**: setup output is split by recipe step. Each step is a `<details>` row with a status icon (ring, pulsing ring, check or cross), its name, how long it took and a chevron; opening it shows only that step's output. A step that is running or has failed starts open and a completed or waiting one starts closed. The script updates rows in place by step id, and applies the open preference only when a step's state changes, so a row the reader toggled is never reopened or reclosed and what they are reading is never rebuilt.
|
|
70
71
|
- **Capture**: `StepLog` wraps the combined log. Every line still goes to the combined `<id>.setup.log`; while a step is current the same scrubbed text also goes to `logs/<id>.steps/<step-id>.log`. A step's file is truncated when it begins, the files are cleared when a run starts, and a failing step records its error message in its own file.
|
|
71
72
|
- **Read**: the snapshot carries `step_logs` (the tail of each step that has output, with a `truncated` flag) for the setup view only, and `backend_log_available`.
|
|
72
|
-
- **Tabs**: *Setup steps* (the
|
|
73
|
+
- **Tabs**: *Setup steps* (the step rows) and *Web server log*. The server tab appears only once the backend log has content. Switching tabs reloads the page, and the links end in `#log-title` so the reader lands back on the log rather than the top of the page. The combined log stays reachable as a final, collapsed *Full setup log* row, which also covers workspaces set up before step files existed.
|
|
73
74
|
- **Build progress**: while a build is being prepared the lead is the headline, a progress bar (`role="progressbar"` with a text value), and one line saying *Step n of m · name*, the percentage, the elapsed time and an estimate. The server computes the numbers from the step states and per-step averages frozen when the run began (`Progress`), and the script only draws them; the elapsed clock ticks locally between polls. A step well past its usual time turns the bar amber and the estimate reads "Taking longer than usual". Without history there is no time estimate. The bar is hidden when no build is running.
|
|
74
75
|
- **Build history**: every finished run is appended to `build-history.jsonl` (`BuildHistory`). Estimates are the mean of a step's last 10 successful completions; failed runs are recorded but never counted. Recording is best-effort and cannot fail a build.
|
|
75
76
|
- **Bounded log panel**: monospace text, fixed max height, manual-scroll-safe updates
|
|
@@ -89,6 +90,6 @@ Restrained tooling UI: dark elevated panels, compact spacing rhythm, clear statu
|
|
|
89
90
|
|
|
90
91
|
## Responsive behavior
|
|
91
92
|
|
|
92
|
-
- Single-column layout with intrinsic grid sections
|
|
93
|
-
-
|
|
94
|
-
-
|
|
93
|
+
- Single-column layout with intrinsic grid sections; panel padding is 28px and compresses to 20px at <=640px
|
|
94
|
+
- The workspace table is the one deliberate exception to "no horizontal scrolling": it keeps its columns and scrolls inside its own wrapper, rather than stacking rows and hiding the dates
|
|
95
|
+
- Everything else fits a 375px viewport
|
data/README.md
CHANGED
|
@@ -120,7 +120,9 @@ A ready workspace that sees no preview traffic for a while is put to sleep: its
|
|
|
120
120
|
managed process group, and nothing shared such as PostgreSQL or Redis) is stopped, and the
|
|
121
121
|
front door keeps answering on the same preview URL. The worktree, database, dependencies, built
|
|
122
122
|
assets, environment settings and build history are untouched. The first request to a sleeping
|
|
123
|
-
preview wakes it
|
|
123
|
+
preview wakes it. A browser opening a page is shown the waiting card (below) at that address, and
|
|
124
|
+
the card reloads the page once the workspace is ready. Any other request (an API call, an asset, a
|
|
125
|
+
form post) waits for readiness and is then forwarded.
|
|
124
126
|
|
|
125
127
|
```sh
|
|
126
128
|
WORKSPACES_SLEEP_AFTER_MINUTES=30 # default; 15 also works; 0 switches sleeping off
|
|
@@ -154,7 +156,8 @@ What counts as activity:
|
|
|
154
156
|
How waking behaves:
|
|
155
157
|
|
|
156
158
|
- Only an intentionally sleeping workspace wakes. A workspace stopped by hand, failed, or still
|
|
157
|
-
preparing is never started by traffic
|
|
159
|
+
preparing is never started by traffic. A browser opening a page is shown the waiting card; any
|
|
160
|
+
other GET is redirected to the card on the dashboard host, and other methods get `503`.
|
|
158
161
|
- Simultaneous first requests share one wake and start one server. A request is sent upstream
|
|
159
162
|
once, never replayed, and keeps its method and body.
|
|
160
163
|
- A wake runs only the server and readiness steps. If a step before the server changed in
|
|
@@ -194,6 +197,43 @@ provides `WORKSPACE_RUN_ID`). The runner also supplies `WORKSPACE_URL` and
|
|
|
194
197
|
`WORKSPACE_HOST` for applications that need browser-facing URLs and host settings.
|
|
195
198
|
`serve` does **not** start workspace backends; use `start` or `restart` for those.
|
|
196
199
|
|
|
200
|
+
### The workspace card and the settings page
|
|
201
|
+
|
|
202
|
+
`/workspaces/<id>` is one small card in the middle of the screen: a headline, the progress bar
|
|
203
|
+
while something is running, the preset in use, and the single next action. That action is **Open
|
|
204
|
+
workspace** when ready, **Wake workspace** or **Start workspace** when asleep or stopped, and
|
|
205
|
+
**Retry failed step** or **Continue setup** after a failure. A gear links to
|
|
206
|
+
`/workspaces/<id>/settings`, which is the full page: environment variables and secrets, setup
|
|
207
|
+
steps and logs, workspace details, lifecycle controls and removal. A new workspace starts from the
|
|
208
|
+
card by choosing one preset (or the defaults); use the settings page to edit variables first.
|
|
209
|
+
Update from PR lives on the settings page and returns there. Nothing opens the preview for you;
|
|
210
|
+
the card only offers the button.
|
|
211
|
+
|
|
212
|
+
The `/workspaces` list and the PR page are unchanged.
|
|
213
|
+
|
|
214
|
+
#### The waiting card on a preview host
|
|
215
|
+
|
|
216
|
+
When a browser opens a page of a workspace that is not serving (stopped, preparing, failed or
|
|
217
|
+
asleep), the preview host answers `200` with the same card instead of redirecting to the
|
|
218
|
+
dashboard, so the address in the bar is the one the visitor asked for. A sleeping workspace is
|
|
219
|
+
woken at once. The card polls its status and, when the workspace is ready, reloads the page, so the
|
|
220
|
+
visitor lands where they meant to go, query string included.
|
|
221
|
+
|
|
222
|
+
- Only browser navigations see it: a `GET` that accepts `text/html`, is not an `XMLHttpRequest`
|
|
223
|
+
and, when the browser says, has `Sec-Fetch-Mode: navigate`. API calls, assets and other methods
|
|
224
|
+
behave as before.
|
|
225
|
+
- The preview origin also serves the workspace's own app, so the card is deliberately small. Its
|
|
226
|
+
endpoints are `GET /__workspaces/status` and `POST /__workspaces/start|prepare|restart|resume`.
|
|
227
|
+
The prefix is reserved: any other path under it answers `404`, and it is never forwarded to the
|
|
228
|
+
app. Settings, environment, secrets, logs and removal are not reachable from it.
|
|
229
|
+
- The posts accept only the workspace's own preview origin (the `Origin`, or `Referer`, must match
|
|
230
|
+
`ws-<id>…`); the shared dashboard origin and other workspaces are refused. After a post the
|
|
231
|
+
visitor returns to the page they were on.
|
|
232
|
+
- The status payload carries no logs, steps, environment values or error text. A failure reads
|
|
233
|
+
"Setup failed. Open settings for the full log.", with the gear and link going to the shared
|
|
234
|
+
settings page.
|
|
235
|
+
- Polling the card is not preview traffic, so it never keeps a workspace awake.
|
|
236
|
+
|
|
197
237
|
### Re-running part of a run
|
|
198
238
|
|
|
199
239
|
When a run fails, or is interrupted, you do not have to start over. `resume` continues from the
|
data/lib/workspaces/config.rb
CHANGED
|
@@ -130,6 +130,10 @@ module Workspaces
|
|
|
130
130
|
"#{public_origin}/workspaces/#{validate_id!(id)}"
|
|
131
131
|
end
|
|
132
132
|
|
|
133
|
+
def self.settings_url(id)
|
|
134
|
+
"#{dashboard_url(id)}/settings"
|
|
135
|
+
end
|
|
136
|
+
|
|
133
137
|
def self.validate_preview_subdomain_prefix!(prefix)
|
|
134
138
|
parts = prefix.to_s.split('.', -1)
|
|
135
139
|
raise ArgumentError, 'WORKSPACES_SUBDOMAIN_PREFIX must not be empty' if parts.empty? || parts.any?(&:empty?)
|
|
@@ -74,6 +74,14 @@ module Workspaces
|
|
|
74
74
|
})
|
|
75
75
|
end
|
|
76
76
|
|
|
77
|
+
# Applies one named preset (see EnvironmentOverrides#apply_preset) and starts the workspace,
|
|
78
|
+
# restarting it if it is already up.
|
|
79
|
+
def apply_environment_preset(id, name:)
|
|
80
|
+
restart = Backend.new(id).running? || sleeping?(id)
|
|
81
|
+
launch(id, restart: restart, force: true,
|
|
82
|
+
prelaunch: ->(_workspace) { EnvironmentOverrides.new(id).apply_preset(name) })
|
|
83
|
+
end
|
|
84
|
+
|
|
77
85
|
def replace_editable_environment(id, text:)
|
|
78
86
|
restart = Backend.new(id).running? || sleeping?(id)
|
|
79
87
|
launch(id, restart: restart, force: true,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const root = document.getElementById('workspace');
|
|
4
4
|
if (!root) return;
|
|
5
5
|
const node = (id) => document.getElementById(id);
|
|
6
|
-
const base = '/workspaces/' + root.dataset.id;
|
|
6
|
+
const base = root.dataset.base || '/workspaces/' + root.dataset.id;
|
|
7
7
|
const selectedLog = new URLSearchParams(window.location.search).get('log') === 'backend'
|
|
8
8
|
? 'backend'
|
|
9
9
|
: 'setup';
|
|
@@ -30,7 +30,9 @@
|
|
|
30
30
|
const signature = JSON.stringify(actions);
|
|
31
31
|
if (signature === actionsSignature) return;
|
|
32
32
|
actionsSignature = signature;
|
|
33
|
-
node('actions')
|
|
33
|
+
const holder = node('actions');
|
|
34
|
+
if (!holder) return;
|
|
35
|
+
holder.replaceChildren();
|
|
34
36
|
actions.forEach((action) => {
|
|
35
37
|
if (!allowedActions.includes(action.key)) return;
|
|
36
38
|
const form = document.createElement('form');
|
|
@@ -41,7 +43,7 @@
|
|
|
41
43
|
'button ' + (action.primary ? 'button--primary' : 'button--subtle');
|
|
42
44
|
button.textContent = action.label;
|
|
43
45
|
form.append(button);
|
|
44
|
-
|
|
46
|
+
holder.append(form);
|
|
45
47
|
});
|
|
46
48
|
toggleBusyState(busy);
|
|
47
49
|
}
|
|
@@ -213,7 +215,8 @@
|
|
|
213
215
|
const full = node('full-log');
|
|
214
216
|
if (full) writeLog(full.querySelector('pre'), data.log_tail);
|
|
215
217
|
}
|
|
216
|
-
node('updated')
|
|
218
|
+
const updated = node('updated');
|
|
219
|
+
if (updated) updated.textContent = data.updated_at || '';
|
|
217
220
|
}
|
|
218
221
|
|
|
219
222
|
function update(data) {
|
|
@@ -226,7 +229,8 @@
|
|
|
226
229
|
renderStatus(view);
|
|
227
230
|
renderSections(view);
|
|
228
231
|
if (node('message')) node('message').textContent = data.message || '';
|
|
229
|
-
node('source-update-message')
|
|
232
|
+
const sourceMessage = node('source-update-message');
|
|
233
|
+
if (sourceMessage) sourceMessage.textContent = data.source_update_message || '';
|
|
230
234
|
renderSteps(view, data.step_logs);
|
|
231
235
|
renderActions(view.actions);
|
|
232
236
|
if (window.WorkspaceEnvironment)
|
|
@@ -240,7 +244,6 @@
|
|
|
240
244
|
element.hidden = !sections[element.dataset.section];
|
|
241
245
|
});
|
|
242
246
|
renderLead(view);
|
|
243
|
-
applyDisclosureState(view);
|
|
244
247
|
if (window.WorkspaceEnvironment)
|
|
245
248
|
window.WorkspaceEnvironment.setSubmitLabel(view.environment_submit);
|
|
246
249
|
}
|
|
@@ -271,6 +274,9 @@
|
|
|
271
274
|
badge.textContent = view.current_preset ? 'Preset: ' + view.current_preset : '';
|
|
272
275
|
}
|
|
273
276
|
renderLeadAction(view.lead_action);
|
|
277
|
+
root.querySelectorAll('[data-only-state]').forEach((element) => {
|
|
278
|
+
element.hidden = element.dataset.onlyState !== view.state;
|
|
279
|
+
});
|
|
274
280
|
}
|
|
275
281
|
|
|
276
282
|
// The lead action is a lifecycle post (start/retry) or, when ready, the preview link
|
|
@@ -318,24 +324,17 @@
|
|
|
318
324
|
toggleBusyState(busy);
|
|
319
325
|
}
|
|
320
326
|
|
|
321
|
-
// A
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
lastDisclosureState = view.state;
|
|
328
|
-
const open = view.open || {};
|
|
329
|
-
[['environment-disclosure', open.environment], ['technical-disclosure', open.technical]].forEach(
|
|
330
|
-
([id, shouldOpen]) => {
|
|
331
|
-
const element = node(id);
|
|
332
|
-
if (element) element.open = !!shouldOpen;
|
|
333
|
-
}
|
|
334
|
-
);
|
|
327
|
+
// A card on a preview host stands in for the page the visitor asked for; reloading brings them to it.
|
|
328
|
+
let reloading = false;
|
|
329
|
+
function reloadWhenReady(view) {
|
|
330
|
+
if (!view.ready || reloading || root.dataset.reloadWhenReady !== 'true') return;
|
|
331
|
+
reloading = true;
|
|
332
|
+
window.location.reload();
|
|
335
333
|
}
|
|
336
334
|
|
|
337
335
|
function renderStatus(view) {
|
|
338
336
|
node('preview').hidden = !view.ready;
|
|
337
|
+
reloadWhenReady(view);
|
|
339
338
|
node('error').textContent = view.error || '';
|
|
340
339
|
node('error-panel').hidden = !view.error;
|
|
341
340
|
if (window.WorkspaceEnvironment)
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<main class="card-page" id="workspace" data-id="<%= @id %>" data-base="<%= action_base %>" data-reload-when-ready="<%= @preview ? 'true' : 'false' %>" data-status="<%= field('status') %>" data-started="<%= field('prepare_started_at') %>" data-completed="<%= field('completed_at') %>" data-busy="<%= @presentation['busy'] %>">
|
|
2
|
+
<section class="card" aria-labelledby="status">
|
|
3
|
+
<header class="card__header">
|
|
4
|
+
<p class="card__name"><span class="eyebrow">Workspace</span><span class="card__id"><%= @id %></span></p>
|
|
5
|
+
<a class="icon-link" href="<%= escape(settings_href) %>" aria-label="Settings and details" title="Settings and details"><svg viewBox="0 0 24 24" width="20" height="20" aria-hidden="true" focusable="false"><path fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" d="M10.52 5.57L10.69 2.69L13.31 2.69L13.48 5.57A6.6 6.6 0 0 1 15.50 6.40L17.66 4.49L19.51 6.34L17.60 8.50A6.6 6.6 0 0 1 18.43 10.52L21.31 10.69L21.31 13.31L18.43 13.48A6.6 6.6 0 0 1 17.60 15.50L19.51 17.66L17.66 19.51L15.50 17.60A6.6 6.6 0 0 1 13.48 18.43L13.31 21.31L10.69 21.31L10.52 18.43A6.6 6.6 0 0 1 8.50 17.60L6.34 19.51L4.49 17.66L6.40 15.50A6.6 6.6 0 0 1 5.57 13.48L2.69 13.31L2.69 10.69L5.57 10.52A6.6 6.6 0 0 1 6.40 8.50L4.49 6.34L6.34 4.49L8.50 6.40A6.6 6.6 0 0 1 10.52 5.57ZM9.20 12.00a2.8 2.8 0 1 0 5.6 0a2.8 2.8 0 1 0 -5.6 0Z"/></svg></a>
|
|
6
|
+
</header>
|
|
7
|
+
<div class="card__text">
|
|
8
|
+
<h1 id="status" role="status"><%= escape(@presentation['headline']) %></h1>
|
|
9
|
+
<p id="summary" class="card__summary"><%= escape(@presentation['summary']) %></p>
|
|
10
|
+
<p><span class="badge" id="environment-preset-badge" <%= 'hidden' unless @presentation['current_preset'] %>><%= escape(preset_badge_text) %></span></p>
|
|
11
|
+
</div>
|
|
12
|
+
<div class="build-progress" id="build-progress" <%= 'hidden' unless @presentation['progress'] %>>
|
|
13
|
+
<div class="progress-bar" id="progress-bar" role="progressbar" aria-label="Setup progress" aria-valuemin="0" aria-valuemax="100" aria-valuenow="<%= progress_percent %>" aria-valuetext="<%= escape(progress_valuetext) %>" data-slow="<%= @presentation.dig('progress', 'slow') ? 'true' : 'false' %>"><span class="progress-bar__fill" id="progress-fill" style="inline-size: <%= progress_percent %>%"></span></div>
|
|
14
|
+
<div class="progress-meta">
|
|
15
|
+
<p class="progress-meta__step"><span class="activity-dot" aria-hidden="true"></span><span id="progress-step"><%= escape(progress_step_text) %></span></p>
|
|
16
|
+
<p class="progress-meta__time muted"><span id="progress-percent"><%= progress_percent %>%</span><span aria-hidden="true"> · </span><span id="elapsed"><%= escape(progress_elapsed_text) %></span><span id="progress-eta"><%= escape(progress_eta_suffix) %></span></p>
|
|
17
|
+
</div>
|
|
18
|
+
</div>
|
|
19
|
+
<form method="post" action="<%= start_form_action %>" class="card__start stack stack--snug lead__action" data-only-state="idle" <%= 'hidden' unless @presentation['state'] == 'idle' %>>
|
|
20
|
+
<% unless environment_presets.empty? %>
|
|
21
|
+
<label class="field" for="card-preset">Preset
|
|
22
|
+
<select id="card-preset" name="preset">
|
|
23
|
+
<% environment_presets.each_key do |name| %><option value="<%= escape(name) %>"><%= escape(name) %></option><% end %>
|
|
24
|
+
<option value="">Defaults</option>
|
|
25
|
+
</select>
|
|
26
|
+
</label>
|
|
27
|
+
<% end %>
|
|
28
|
+
<button class="button button--primary button--large"><%= escape(@presentation['environment_submit']) %></button>
|
|
29
|
+
</form>
|
|
30
|
+
<div class="card__actions">
|
|
31
|
+
<a id="preview" class="button button--primary button--large" href="<%= escape(Config.preview_url(@id)) %>" <%= 'hidden' unless @presentation['ready'] %> target="_blank" rel="noopener noreferrer">Open workspace</a>
|
|
32
|
+
<div id="lead-action" class="lead__action"><%= lead_action_form(@presentation['lead_action']) %></div>
|
|
33
|
+
</div>
|
|
34
|
+
<p id="sleep-note" class="muted" <%= 'hidden' if sleep_note.empty? %>><%= escape(sleep_note) %></p>
|
|
35
|
+
<section class="error-panel setup-error" id="error-panel" role="alert" <%= 'hidden' unless @presentation['error'] %>>
|
|
36
|
+
<h2>What went wrong</h2><pre id="error"><%= escape(@presentation['error']) %></pre>
|
|
37
|
+
<a href="<%= escape(settings_href) %>">Open the full log</a>
|
|
38
|
+
</section>
|
|
39
|
+
<p id="connection" role="status"></p>
|
|
40
|
+
</section>
|
|
41
|
+
<noscript><a href="<%= @preview ? '' : "/workspaces/#{@id}" %>">Refresh status</a></noscript>
|
|
42
|
+
</main>
|