thirdshift 0.33.0

Turn a GitHub issue into a ready-for-review pull request, unattended
<!doctype html>
<html lang="en" data-theme="{{ page.theme }}">
<head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>Plan usage · {{ page.hostname }} · thirdshift</title><link rel="icon" href="data:,"><link rel="stylesheet" href="/assets/console.css"><script src="/assets/console.js" type="module"></script></head>
<body>{% include "console/header.html" %}{% include "console/nav.html" %}
<main class="plan-usage"><div class="page-title"><h1>Plan usage{% if let Some(machine) = selector.chosen %} · {{ machine }}{% else %} · Fleet{% endif %}</h1><code>thirdshift {{ cli }}</code></div>
<p>How much of each subscription Harness's allowance is used: its Plan windows, utilization, reset times and cooldowns, with each User config route to it and whether that route could take a session now. {% if selector.chosen.is_none() %}A login shared by several machines shows once, with the freshest observation and every machine using it; a Harness that names no account shows on each machine. A machine that cannot be reached shows the view this Console last read from it, and one that reports outward the view it last pushed, both read-only with their age. {% endif %}Factory sessions route on each machine's own Plan usage alone. Reload to see changes.</p>
{% if selector.fleet || !selector.others.is_empty() || !selector.is(selector.local) %}<form class="metrics-filters" method="get" action="/plan-usage" aria-label="Plan usage machines">
<label>Machine <select name="machine">{% if selector.fleet || selector.chosen.is_none() %}<option value=""{% if selector.chosen.is_none() %} selected{% endif %}>Fleet</option>{% endif %}<option value="{{ selector.local }}"{% if selector.is(selector.local) %} selected{% endif %}>This machine ({{ selector.local }})</option>{% for name in selector.others %}<option value="{{ name }}"{% if selector.is(name) %} selected{% endif %}>{{ name }}</option>{% endfor %}</select></label>
<button>Show</button></form>{% endif %}
{% if !machines.is_empty() %}<section aria-labelledby="plan-usage-machines"><h2 id="plan-usage-machines">Machines</h2>
<ul class="metrics-machines">{% for machine in machines %}<li><strong>{{ machine.name }}</strong>{% if machine.local %} (this machine){% endif %}: <span class="metrics-status {{ machine.status }}">{{ machine.status }}{% if machine.status == Status::Cached %}, offline{% else if machine.status == Status::Reported %}, read-only{% endif %}</span>{% if self.saved(machine) %}{% if let Some(pushed) = machine.pushed_at %} · pushed <time datetime="{{ pushed.to_rfc3339() }}">{{ self.local_time(pushed) }}</time> ({{ self.age(pushed) }}){% else if let Some(seen) = machine.last_seen %} · last seen <time datetime="{{ seen.to_rfc3339() }}">{{ self.local_time(seen) }}</time> ({{ self.age(seen) }}){% endif %}{% endif %}{% if let Some(address) = machine.address %} · <a href="{{ address }}">Open Console</a>{% endif %}{% if let Some(error) = machine.error %} · {{ error }}{% endif %}</li>{% endfor %}</ul>
</section>{% endif %}
{% if logins.is_empty() %}<p>{{ empty }}.</p>{% endif %}
{% for login in logins %}<section class="plan-usage-login" aria-label="{{ login.harness.name() }} on {{ login.machines|join(", ") }}"><h2>{{ login.harness.name() }}{% if !machines.is_empty() %}{% if login.identity.is_some() && login.machines.len() > 1 %} · shared by {{ login.machines|join(", ") }}{% else %} · {{ login.machines|join(", ") }}{% endif %}{% endif %}{% if !login.active_on.is_empty() %} <span class="plan-usage-active">active{% if !machines.is_empty() %} on {{ login.active_on|join(", ") }}{% endif %}</span>{% endif %}</h2>
<dl>
{% if let Some(identity) = login.identity %}<dt>Login</dt><dd>{{ identity }}</dd>{% endif %}
{% if let Some(account) = login.state.account %}<dt>Account</dt><dd>{% if account.signed_in == Some(true) %}signed in{% else if account.signed_in == Some(false) %}signed out{% endif %}{% if let Some(plan) = account.plan %} · plan {{ plan }}{% endif %}{% if let Some(tier) = account.tier %} · tier {{ tier }}{% endif %}</dd>{% endif %}
{% for route in login.routes %}<dt>Route{% if !machines.is_empty() %} on {{ route.machine }}{% endif %}</dt><dd data-limited="{{ route.route.availability.limited() }}">{{ route.route }}</dd>{% endfor %}
{% for window in login.state.windows %}<dt>{{ window.name }}</dt><dd>{% match window.used_percent %}{% when Some(used) %}{% if self.reset(window) %}reset since observed{% else %}<meter min="0" max="100" value="{{ used }}" aria-hidden="true"></meter> {{ used|fmt("{:.0}") }}% used{% endif %}{% when None %}utilization not reported{% endmatch %}{% if let Some(status) = window.status %} · {{ status }}{% endif %}{% if let Some(reset) = window.resets_at %}{% if self.ahead(reset) %} · resets <time datetime="{{ reset.to_rfc3339() }}">{{ self.local_time(reset) }}</time>{% endif %}{% endif %}</dd>{% endfor %}
{% if let Some(credits) = login.state.credits %}{% if let Some(balance) = credits.balance %}<dt>Credits</dt><dd>{{ balance }}</dd>{% else if let Some(has) = credits.has_credits %}<dt>Credits</dt><dd>{% if has %}some{% else %}none{% endif %}</dd>{% endif %}{% endif %}
{% if login.state.ordinary_usage_allowed == Some(false) %}<dt>Included usage</dt><dd>not allowed</dd>{% endif %}
{% if login.state.spend_control_reached == Some(true) %}<dt>Spend control</dt><dd>reached</dd>{% endif %}
{% if let Some(cooldown) = login.state.cooldown %}<dt>Cooldown</dt><dd>{% if self.ahead(cooldown.until) %}until{% else %}revalidating since{% endif %} <time datetime="{{ cooldown.until.to_rfc3339() }}">{{ self.local_time(cooldown.until) }}</time>{% if let Some(window) = cooldown.window %} · {{ window }} window{% endif %}{% if let Some(overage) = cooldown.overage %} · overage {{ overage }}{% endif %}{% if let Some(minutes) = cooldown.backoff_minutes %} · no reset reported, backoff {{ minutes }} minutes{% endif %}</dd>{% endif %}
<dt>Observed</dt><dd>{% if let Some(at) = login.state.observed_at %}<time datetime="{{ at.to_rfc3339() }}">{{ self.local_time(at) }}</time>{% if let Some(source) = login.state.source %} by {{ source }}{% endif %}{% if !machines.is_empty() %} on {{ login.observed_on }}{% endif %}{% else if !login.installed %}CLI not on PATH{% else %}nothing observed yet{% endif %}</dd>
</dl></section>{% endfor %}
<section aria-labelledby="plan-usage-clear"><h2 id="plan-usage-clear">Clear cooldowns on this machine</h2>
<p>Forget the cooldowns and revalidation backoff recorded on {{ selector.local }}, so its next factory session tries the route again. Another machine's are cleared on its own Console. <code>thirdshift plan-usage --clear [&lt;harness&gt;] --json</code></p>
{% if page.can_act() %}<form class="metrics-filters" action="/plan-usage/clear" method="post"><input type="hidden" name="csrf" value="{{ csrf }}"><label>Harness <select name="harness"><option value="">Every subscription Harness</option>{% for name in harnesses %}<option>{{ name }}</option>{% endfor %}</select></label><button>Clear cooldowns</button></form>{% else %}<p>Clearing cooldowns needs the act scope.</p>{% endif %}
</section>
</main>{% include "console/chrome.html" %}</body></html>