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
8 changes: 8 additions & 0 deletions console/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,14 @@ and Ready tag colours, Landing keeps Working's live-activity marker, and a live
row given a Stop shows Stopping with a drifting stripe until it ends. Pause
motion and reduced motion hold the stripe still.

Ended rows show their recorded finish date and time in UTC, followed by an
explicit relative age, such as “Ended Oct 23, 2026 at 23:03:17 UTC · 52 min ago”.
That age is time since finish, not run duration. Each nested Ticket run uses its
own finish time, including in History. Refreshing recomputes the relative age
and keeps the recorded instant. The information is rendered by the server and
remains visible without JavaScript. Missing or invalid finish times say “End
time unknown”; file modification times are not presented as recorded finishes.

When no Commands are live on this machine, the Inbox explains that above its
sections. It points to ended problems in Needs you and pull requests in Ready
for review, and shows the last recorded skipped Pass reasons from Activity logs.
Expand Down
42 changes: 42 additions & 0 deletions console/tests/inbox.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,48 @@ test("Inbox folds, loads only its own resources and fits a 390 px phone", async
assert.equal(await page.evaluate(() => document.fonts.check('14px "IBM Plex Sans"') && document.fonts.check('12px "IBM Plex Mono"')), true);
});

test("finish information is visible without JavaScript on a narrow phone", async t => {
const page = await pageFor(t, { javaScriptEnabled: false, viewport: { width: 320, height: 844 } });
await page.goto(origin);
const age = page.locator('[data-group="needs you"] .command > .row-head > .age').first();
assert.equal(await age.isVisible(), true);
assert.match(await age.innerText(), /^Ended \w+ \d+, \d{4} at \d\d:\d\d:\d\d UTC · \d+ (sec|min|hr \d+ min) ago$/);
assert.ok(Number.isFinite(Date.parse(await age.locator('time').getAttribute('datetime'))));
const box = await age.boundingBox();
assert.ok(box.x >= 0 && box.x + box.width <= 320, JSON.stringify(box));
assert.equal(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth), true);
assert.equal(await page.locator('.command .peek-link').first().isVisible(), true);
});

test("existing refresh advances finish age while keeping its recorded instant", async t => {
const path = join(home, '.thirdshift/logs/acme/widgets/commands/issue/71-fixture.command.json');
const end = new Date(Date.now() - 55000).toISOString();
const fixture = JSON.parse(await readFile(join(home, '.thirdshift/logs/acme/widgets/commands/issue/1-fixture.command.json'), 'utf8'));
fixture.issue = { number: 71, url: 'https://github.com/acme/widgets/issues/71', title: 'Finish refresh fixture' };
fixture.started_at = new Date(Date.parse(end) - 140 * 60000).toISOString();
fixture.ended_at = end;
fixture.cause = 'finish refresh fixture';
await writeFile(path, JSON.stringify(fixture));
t.after(() => rm(path, { force: true }));
const page = await pageFor(t);
await page.goto(origin);
const row = page.locator('.command').filter({ has: page.locator('a[href="https://github.com/acme/widgets/issues/71"]') });
const time = row.locator('time');
assert.equal(await time.getAttribute('datetime'), end);
assert.match(await row.locator('.age').textContent(), /\d+ sec ago$/);
const absolute = await time.textContent();
// Cross the server's minute boundary, then wake the ordinary filesystem refresh.
await page.waitForTimeout(Math.max(0, Date.parse(end) + 61000 - Date.now()));
await appendFile(join(home, '.thirdshift/logs/acme/widgets/commands/issue/1-fixture.log'), 'Refresh finish age\n');
await page.waitForFunction(() => [...document.querySelectorAll('.command')].some(row =>
row.querySelector('a[href="https://github.com/acme/widgets/issues/71"]') && row.querySelector('.age')?.textContent.includes('1 min ago')));
assert.equal(await time.getAttribute('datetime'), end);
assert.equal(await time.textContent(), absolute);
await page.reload();
assert.match(await row.locator('.age').textContent(), /1 min ago$/);
assert.equal(await time.getAttribute('datetime'), end);
});

test("all section headings fit above the fold on a 14 inch laptop with a busy Needs you", async t => {
const page = await pageFor(t, { viewport: { width: 1440, height: 900 } });
await page.goto(origin);
Expand Down
2 changes: 1 addition & 1 deletion docs/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ To open this machine's Inbox locally, run:
thirdshift console --no-sign-in
```

Open the localhost address it prints. The Console shows the same Inbox as `thirdshift status`, with live stages, logs and Session traces. It never starts work; start Commands from the CLI or the operating system's scheduler.
Open the localhost address it prints. The Console shows the same Inbox as `thirdshift status`, with live stages, logs and Session traces. Ended rows show their recorded finish date and time in UTC and an explicit relative age, for example **Ended Oct 23, 2026 at 23:03:17 UTC · 52 min ago**. This is time since finish, not run duration. Nested Ticket runs and History use each Command's own finish time; missing or invalid finish times say **End time unknown**. The finish information also works without JavaScript. The Console never starts work; start Commands from the CLI or the operating system's scheduler.

#### Console on a server

Expand Down
2 changes: 1 addition & 1 deletion site/docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@
<p>To open this machine&#39;s Inbox locally, run:</p>
<pre><code class="language-sh">thirdshift console --no-sign-in
</code></pre>
<p>Open the localhost address it prints. The Console shows the same Inbox as <code>thirdshift status</code>, with live stages, logs and Session traces. It never starts work; start Commands from the CLI or the operating system&#39;s scheduler.</p>
<p>Open the localhost address it prints. The Console shows the same Inbox as <code>thirdshift status</code>, with live stages, logs and Session traces. Ended rows show their recorded finish date and time in UTC and an explicit relative age, for example <strong>Ended Oct 23, 2026 at 23:03:17 UTC · 52 min ago</strong>. This is time since finish, not run duration. Nested Ticket runs and History use each Command&#39;s own finish time; missing or invalid finish times say <strong>End time unknown</strong>. The finish information also works without JavaScript. The Console never starts work; start Commands from the CLI or the operating system&#39;s scheduler.</p>
<details class="fold"><summary><h4>Console on a server</h4></summary>
<div class="manual-content" id="console-on-a-server">
<p>Set the machine&#39;s address, fixed localhost port and sign-in allowlist in <code>~/.thirdshift/config.toml</code>:</p>
Expand Down
1 change: 1 addition & 0 deletions site/how-it-works/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ <h1>How thirdshift works</h1>
thirdshift logs https://github.com/acme/widgets/issues/7 --follow</code></pre>
<p>The <strong>Console</strong> shows this machine's Commands, opening on its <strong>Inbox</strong>. Beside the CLI, you can watch their stages and logs there. For this machine on localhost, start it with:</p>
<p>When no Commands are running, the Inbox shows the last recorded skipped Pass reasons, points to work waiting for you, and links to Cron jobs to help diagnose launch failures. If no reason was recorded, it says so.</p>
<p>Ended rows show the recorded finish date and time in UTC and an explicit age, such as <strong>Ended Oct 23, 2026 at 23:03:17 UTC · 52 min ago</strong>. The age means time since finish, not run duration. Nested Ticket runs and History show each Command's own finish; an unavailable finish says <strong>End time unknown</strong>.</p>
<pre class="guide-command"><code>thirdshift console --no-sign-in</code></pre>
<p>For a server, <code>thirdshift console install</code> prints an installation script to read and run with <code>sudo</code>, putting its Console behind a sign-in. <a href="/docs/#console-installation">Console installation</a> and <a href="/docs/#machine-status">machine status</a>.</p>
<p>The Console's <a href="/docs/#host-resources">Resources page</a> and <code>thirdshift resources</code> show available memory and one-minute CPU load. Optional <code>[resources]</code> limits in the User config make each new session wait while the host is busy; sessions already running continue.</p>
Expand Down
2 changes: 1 addition & 1 deletion src/console/assets/console.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ summary .count { margin-left: 12px; color: var(--dim); font-size: 13px; }
.row-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.state { color: var(--text); }
.heartbeat { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--working); opacity: .4; }
.age { margin-left: auto; white-space: nowrap; }
.age { margin-left: auto; }
.issue-title { flex: 1 1 160px; }
.command p { margin: 4px 0 0; }
.now { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
Expand Down
2 changes: 1 addition & 1 deletion src/console/row.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<li class="command" id="{{ row.id }}" tabindex="0" data-live="{{ row.live }}" data-state="{{ row.state }}" data-started-ms="{{ row.started_ms }}" data-occurred-ms="{{ row.occurred_ms }}" data-logging="{{ row.logging }}" data-log-growth="{{ row.log_growth }}" data-command="{{ row.selector }}" data-peek="{{ row.peek_url() }}" data-log="{{ row.log_url() }}">
<div class="row-head">{% if row.live %}<span class="heartbeat" aria-label="Log activity"></span>{% endif %}<span class="state">{{ row.state }}</span> <span class="subject">{% match row.subject_url %}{% when Some with (url) %}<a href="{{ url }}">{{ row.subject }}</a>{% when None %}{{ row.subject }}{% endmatch %}</span> <span class="issue-title">{{ row.title }}</span><span class="new" hidden>New since you last looked</span><span class="age">{{ row.age }}</span></div>
<div class="row-head">{% if row.live %}<span class="heartbeat" aria-label="Log activity"></span>{% endif %}<span class="state">{{ row.state }}</span> <span class="subject">{% match row.subject_url %}{% when Some with (url) %}<a href="{{ url }}">{{ row.subject }}</a>{% when None %}{{ row.subject }}{% endmatch %}</span> <span class="issue-title">{{ row.title }}</span><span class="new" hidden>New since you last looked</span><span class="age">{% match row.timing.finish %}{% when Some with (finish) %}<time datetime="{{ finish.datetime }}">Ended {{ finish.label }}</time> · {% when None %}{% endmatch %}{{ row.timing.age }}</span></div>
<p class="now">{{ row.now_line|linkify }}</p>
<a href="{{ row.logs_url }}">Command logs and Session traces</a>
{% if !row.harness.is_empty() %}<p class="harness">{{ row.harness }}</p>{% endif %}
Expand Down
4 changes: 4 additions & 0 deletions src/logs/command_record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ pub(super) struct CommandRecord {
pub started_at: String,
#[serde(default)]
pub ended_at: Option<String>,
/// Reader-only provenance: legacy retention estimates are not recorded finishes.
#[serde(skip)]
pub end_time_estimated: bool,
pub stages: Vec<Stage>,
pub session_log: Option<PathBuf>,
pub outcome: Option<String>,
Expand Down Expand Up @@ -287,6 +290,7 @@ impl CommandRecord {
effort: harness.effort.clone(),
started_at: now.to_rfc3339(),
ended_at: None,
end_time_estimated: false,
stages: Vec::new(),
session_log: None,
outcome: None,
Expand Down
1 change: 1 addition & 0 deletions src/logs/reading.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ fn read_records(folder: &Path) -> Result<BTreeMap<PathBuf, CommandTree>> {
// Records written before completion times existed were last
// replaced when their outcome was recorded.
if record.outcome.is_some() && record.ended_at.is_none() {
record.end_time_estimated = true;
record.ended_at = entry
.metadata()?
.modified()
Expand Down
54 changes: 47 additions & 7 deletions src/logs/status/inbox.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Owned Inbox presentation for the Console, from the same observations as status.
use anyhow::Result;
use chrono::{DateTime, Local};
use chrono::{DateTime, Local, Utc};
use std::path::Path;

use super::{age, stage_text, ticket_text};
Expand Down Expand Up @@ -37,7 +37,7 @@ pub(crate) struct Row {
pub title: String,
pub state: String,
pub now_line: String,
pub age: String,
pub timing: Timing,
pub count: usize,
pub cause: String,
pub harness: String,
Expand All @@ -48,6 +48,41 @@ pub(crate) struct Row {
pub sessions: Vec<std::path::PathBuf>,
}

pub(crate) struct Timing {
pub finish: Option<Finish>,
pub age: String,
}

pub(crate) struct Finish {
pub datetime: String,
pub label: String,
}

impl Timing {
fn new(live: bool, start: &str, end: Option<&str>, now: DateTime<Local>) -> Self {
if live {
return Self {
finish: None,
age: elapsed(start, now),
};
}
let finish = end.and_then(|end| {
DateTime::parse_from_rfc3339(end).ok().map(|time| Finish {
datetime: end.into(),
label: time
.with_timezone(&Utc)
.format("%b %-d, %Y at %H:%M:%S UTC")
.to_string(),
})
});
let age = finish.as_ref().map_or_else(
|| "End time unknown".into(),
|finish| format!("{} ago", elapsed(&finish.datetime, now)),
);
Self { finish, age }
}
}

impl Row {
pub fn peek_url(&self) -> String {
super::inspect::url("/peek", &self.selector, None)
Expand Down Expand Up @@ -179,10 +214,7 @@ fn entry_row(entry: Observation<'_>, now: DateTime<Local>, root: &std::path::Pat
.outcome
.clone()
.unwrap_or_else(|| "unknown outcome".into()),
age: elapsed(
command.ended_at.as_deref().unwrap_or(&command.started_at),
now,
),
timing: Timing::new(false, &command.started_at, command.ended_at.as_deref(), now),
count: 1,
cause: String::new(),
harness: String::new(),
Expand Down Expand Up @@ -334,7 +366,15 @@ fn row(
title,
state: command.state.into(),
now_line: stage_text(command),
age: elapsed(facts.ended_at.as_deref().unwrap_or(&facts.started_at), now),
timing: Timing::new(
live,
&facts.started_at,
facts
.ended_at
.as_deref()
.filter(|_| !facts.end_time_estimated),
now,
),
count: 1,
cause: facts.cause.clone().unwrap_or_default(),
harness: format!(
Expand Down
Loading
Loading