Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8cb76092b6 | ||
|
|
49d7619ba3
|
||
|
|
ae53e83ff3 | ||
|
|
ef84e18f46
|
||
|
|
cf1be16763
|
||
|
|
cc8428643a
|
||
|
|
70251ff3ce | ||
|
|
76dc34a17c
|
||
|
|
a6a0c7c11e
|
||
|
|
f759387eb7
|
||
|
|
21b3591da1
|
||
|
|
e9937ded6b
|
||
|
|
bd1acdd0cc
|
||
|
|
a2c6341544
|
||
|
|
cb3372ac76
|
||
|
|
48e605a545
|
||
|
|
9a4e59f0e0
|
||
|
|
820beda72f
|
||
|
|
c6f70de82d
|
||
|
|
f37f6e2453
|
||
|
|
f7a999e317
|
||
|
|
45494d5b43
|
||
|
|
9ca9545847
|
||
|
|
fa14e7da80
|
||
|
|
12eea5eee3
|
||
|
|
ef623f6c68
|
||
|
|
ee2d19d011
|
||
|
|
53c6b3e413
|
||
|
|
d58125c0bc
|
||
|
|
029198ff61
|
||
|
|
0b08fc5242
|
||
|
|
93609c7ab3
|
||
|
|
461d3dc1f7
|
||
|
|
94f79177a2
|
||
|
|
9169e9db09
|
||
|
|
0d0cd09124
|
||
|
|
0dc5bf9a9b
|
||
|
|
ca107f6977
|
||
|
|
4dad1415e6
|
||
|
|
5bf0a696c6
|
||
|
|
7a8d948fcb
|
||
|
|
d90f7d48d0
|
||
|
|
c5a43f21aa
|
||
|
|
d3fbb0842f
|
||
|
|
dafd426316
|
||
|
|
bec374aa92
|
||
|
|
85b21578d8
|
||
|
|
03c25e7214
|
||
|
|
c30624a59e
|
||
|
|
3cf025fb4a
|
||
|
|
81b784876b
|
No files matched your search
@@ -20,12 +20,11 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Verify extension namespace support
|
# ripgrep and the unprivileged-userns sysctl are provisioned on the host.
|
||||||
run: |
|
# A self-hosted runner should not need sudo, and installing a package on
|
||||||
if [ -e /proc/sys/kernel/apparmor_restrict_unprivileged_userns ]; then
|
# every run is not the gate's job.
|
||||||
sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
|
- name: Verify unprivileged user namespaces
|
||||||
fi
|
run: unshare --user --map-root-user --net true
|
||||||
unshare --user --map-root-user --net true
|
|
||||||
|
|
||||||
- uses: actions/setup-go@v5
|
- uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
@@ -46,9 +45,6 @@ jobs:
|
|||||||
go install mvdan.cc/gofumpt@v0.11.0
|
go install mvdan.cc/gofumpt@v0.11.0
|
||||||
bash tools/proto.sh install
|
bash tools/proto.sh install
|
||||||
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y --no-install-recommends ripgrep
|
|
||||||
|
|
||||||
- name: Ensure contract baseline ref
|
- name: Ensure contract baseline ref
|
||||||
run: |
|
run: |
|
||||||
if ! git show-ref --verify --quiet refs/heads/main; then
|
if ! git show-ref --verify --quiet refs/heads/main; then
|
||||||
|
|||||||
@@ -21,6 +21,17 @@ jobs:
|
|||||||
cut:
|
cut:
|
||||||
runs-on: self-hosted
|
runs-on: self-hosted
|
||||||
steps:
|
steps:
|
||||||
|
# A mirror carries its own Actions secrets. An empty token checks out
|
||||||
|
# fine and fails at the push instead, which reads as a broken release.
|
||||||
|
- name: Check DEPLOY_TOKEN is configured
|
||||||
|
env:
|
||||||
|
DEPLOY_TOKEN: ${{ secrets.DEPLOY_TOKEN }}
|
||||||
|
run: |
|
||||||
|
if [ -z "$DEPLOY_TOKEN" ]; then
|
||||||
|
echo "::error::DEPLOY_TOKEN is not set for this repository, so the release cannot push its commit and tag. Set the secret here, or dispatch the release from the Gitea primary."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# DEPLOY_TOKEN rather than the job token: a push made with the job token
|
# DEPLOY_TOKEN rather than the job token: a push made with the job token
|
||||||
# doesn't start workflows, and the tag push must start deploy.yml.
|
# doesn't start workflows, and the tag push must start deploy.yml.
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
|
|||||||
@@ -47,3 +47,4 @@ __pycache__/
|
|||||||
|
|
||||||
# Local symlink to the archipelago marketplace repo
|
# Local symlink to the archipelago marketplace repo
|
||||||
/archipelago
|
/archipelago
|
||||||
|
.agents-run/
|
||||||
@@ -5,6 +5,42 @@ release's per-component sections are labelled beneath its heading.
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [1.61.2] - 2026-11-07
|
||||||
|
|
||||||
|
### archied
|
||||||
|
|
||||||
|
- archied no longer gets killed by the systemd watchdog when a restart or update leaves many tasks to resume. Each resumed task used to cost a full queue poll before the next was picked up, so a dozen of them outlasted the 30-second watchdog; an update that hit this was rolled back.
|
||||||
|
|
||||||
|
## [1.61.1] - 2026-11-07
|
||||||
|
|
||||||
|
### archie-gateway
|
||||||
|
|
||||||
|
- An image or voice attachment that arrives as a link is now checked against what the link serves, the same as an uploaded one. A link whose content is not the declared type, or that cannot be read, is refused.
|
||||||
|
|
||||||
|
### archie-ui
|
||||||
|
|
||||||
|
- A workflow created on the canvas now saves the agent it runs as, so it runs instead of parking with "declares no identity to run as".
|
||||||
|
|
||||||
|
### archie-state-store
|
||||||
|
|
||||||
|
- A workflow that no longer validates after an upgrade (for example it names a step type that was removed) is repaired at startup instead of breaking every workflow. A shipped workflow is restored from this release's copy; a workflow you created is removed and logged, and its earlier revision stays in the resource history. Valid workflows you created or edited are kept.
|
||||||
|
|
||||||
|
## [1.61.0] - 2026-11-07
|
||||||
|
|
||||||
|
### archied
|
||||||
|
|
||||||
|
- A `workflow.handoff` now finishes its run and starts a separate, linked run of the next workflow on the same issue, instead of continuing as another attempt. The task page links each run to the one before and after it; attempts count only retries of one run.
|
||||||
|
|
||||||
|
- A task no longer fails to prepare its worktree with "some refs were not updated" after a tag or branch moves on the forge.
|
||||||
|
|
||||||
|
### archie-ui
|
||||||
|
|
||||||
|
- The task page no longer flashes its loading state on every live update while a task runs.
|
||||||
|
|
||||||
|
### archie-state-store
|
||||||
|
|
||||||
|
- The extension catalogue lists and installs again. Its default signing key has changed; an instance that set its own catalogue signing key in Extension settings keeps using that key.
|
||||||
|
|
||||||
## [1.60.0] - 2026-11-02
|
## [1.60.0] - 2026-11-02
|
||||||
|
|
||||||
### archied
|
### archied
|
||||||
|
|||||||
@@ -47,6 +47,21 @@ then pushes `main` and the tag atomically with `DEPLOY_TOKEN`. A push made with
|
|||||||
the job token wouldn't start other workflows, so the user token is what lets
|
the job token wouldn't start other workflows, so the user token is what lets
|
||||||
the tag start the deploy.
|
the tag start the deploy.
|
||||||
|
|
||||||
|
Every workflow that reaches the registry or the canary reads its credentials
|
||||||
|
from Actions secrets, so a mirror of this repository carries its own set:
|
||||||
|
|
||||||
|
| Name | Kind | Used by |
|
||||||
|
|---|---|---|
|
||||||
|
| `DEPLOY_TOKEN` | secret | release, deploy, canary, promote — the registry push, the tag push, and the package links |
|
||||||
|
| `RELEASE_SIGNING_KEY` | secret | deploy — signs the release statement |
|
||||||
|
| `CANARY_TOKEN` | secret | deploy, canary, promote — the canary's dashboard API |
|
||||||
|
| `CANARY_URL` | variable | deploy, canary, promote — where that dashboard is |
|
||||||
|
| `CANARY_WINDOW` | variable | canary — the judged window; empty means the default |
|
||||||
|
|
||||||
|
A mirror missing them fails at its first login or push; `release.yml` names the
|
||||||
|
missing `DEPLOY_TOKEN` before it checks out, so the run doesn't read as a broken
|
||||||
|
release.
|
||||||
|
|
||||||
After a release, pull `main` before committing on it again: CI has added the
|
After a release, pull `main` before committing on it again: CI has added the
|
||||||
release commit.
|
release commit.
|
||||||
|
|
||||||
|
|||||||
@@ -156,6 +156,15 @@ _needs a repository._
|
|||||||
| `push` | bool | Push the branch after committing. |
|
| `push` | bool | Push the branch after committing. |
|
||||||
| `reference` | `Fixes` \| `Implements` \| `Refs` | How the commit links to the task issue. |
|
| `reference` | `Fixes` \| `Implements` \| `Refs` | How the commit links to the task issue. |
|
||||||
|
|
||||||
|
Hooks never run. The commit is created by go-git, which ignores `.git/hooks`
|
||||||
|
and `core.hooksPath`, and the agent never runs git, so `pre-commit`,
|
||||||
|
`commit-msg` and `prepare-commit-msg` in the checkout are inert files. A
|
||||||
|
repository whose rules live only in a hook — a formatter, a secret scanner,
|
||||||
|
commitlint, a DCO trailer — gets a commit that does not satisfy them: the run
|
||||||
|
reports success and the pull request fails the check afterwards. Put the same
|
||||||
|
commands in `command.run` or the repository gate, which both run in the task
|
||||||
|
container before this step.
|
||||||
|
|
||||||
### `repo.open-pr`
|
### `repo.open-pr`
|
||||||
|
|
||||||
_needs a repository._
|
_needs a repository._
|
||||||
|
|||||||
@@ -91,6 +91,9 @@
|
|||||||
"/news/archie/1.59.0/": "/news/1.59.0/",
|
"/news/archie/1.59.0/": "/news/1.59.0/",
|
||||||
"/news/archie/1.6.0/": "/news/1.6.0/",
|
"/news/archie/1.6.0/": "/news/1.6.0/",
|
||||||
"/news/archie/1.60.0/": "/news/1.60.0/",
|
"/news/archie/1.60.0/": "/news/1.60.0/",
|
||||||
|
"/news/archie/1.61.0/": "/news/1.61.0/",
|
||||||
|
"/news/archie/1.61.1/": "/news/1.61.1/",
|
||||||
|
"/news/archie/1.61.2/": "/news/1.61.2/",
|
||||||
"/news/archie/1.7.0/": "/news/1.7.0/",
|
"/news/archie/1.7.0/": "/news/1.7.0/",
|
||||||
"/news/archie/1.8.0/": "/news/1.8.0/",
|
"/news/archie/1.8.0/": "/news/1.8.0/",
|
||||||
"/news/archie/1.9.0/": "/news/1.9.0/",
|
"/news/archie/1.9.0/": "/news/1.9.0/",
|
||||||
@@ -197,6 +200,9 @@
|
|||||||
"/news/archied/1.59.0/": "/news/1.59.0/",
|
"/news/archied/1.59.0/": "/news/1.59.0/",
|
||||||
"/news/archied/1.6.0/": "/news/1.6.0/",
|
"/news/archied/1.6.0/": "/news/1.6.0/",
|
||||||
"/news/archied/1.60.0/": "/news/1.60.0/",
|
"/news/archied/1.60.0/": "/news/1.60.0/",
|
||||||
|
"/news/archied/1.61.0/": "/news/1.61.0/",
|
||||||
|
"/news/archied/1.61.1/": "/news/1.61.1/",
|
||||||
|
"/news/archied/1.61.2/": "/news/1.61.2/",
|
||||||
"/news/archied/1.7.0/": "/news/1.7.0/",
|
"/news/archied/1.7.0/": "/news/1.7.0/",
|
||||||
"/news/archied/1.8.0/": "/news/1.8.0/",
|
"/news/archied/1.8.0/": "/news/1.8.0/",
|
||||||
"/news/archied/1.9.0/": "/news/1.9.0/",
|
"/news/archied/1.9.0/": "/news/1.9.0/",
|
||||||
|
|||||||
@@ -1,4 +1,19 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"version": "1.61.2",
|
||||||
|
"date": "2026-11-07",
|
||||||
|
"body": "### archied\n\n- archied no longer gets killed by the systemd watchdog when a restart or update leaves many tasks to resume. Each resumed task used to cost a full queue poll before the next was picked up, so a dozen of them outlasted the 30-second watchdog; an update that hit this was rolled back."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "1.61.1",
|
||||||
|
"date": "2026-11-07",
|
||||||
|
"body": "### archie-gateway\n\n- An image or voice attachment that arrives as a link is now checked against what the link serves, the same as an uploaded one. A link whose content is not the declared type, or that cannot be read, is refused.\n\n### archie-ui\n\n- A workflow created on the canvas now saves the agent it runs as, so it runs instead of parking with \"declares no identity to run as\".\n\n### archie-state-store\n\n- A workflow that no longer validates after an upgrade (for example it names a step type that was removed) is repaired at startup instead of breaking every workflow. A shipped workflow is restored from this release's copy; a workflow you created is removed and logged, and its earlier revision stays in the resource history. Valid workflows you created or edited are kept."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "1.61.0",
|
||||||
|
"date": "2026-11-07",
|
||||||
|
"body": "### archied\n\n- A `workflow.handoff` now finishes its run and starts a separate, linked run of the next workflow on the same issue, instead of continuing as another attempt. The task page links each run to the one before and after it; attempts count only retries of one run.\n\n- A task no longer fails to prepare its worktree with \"some refs were not updated\" after a tag or branch moves on the forge.\n\n### archie-ui\n\n- The task page no longer flashes its loading state on every live update while a task runs.\n\n### archie-state-store\n\n- The extension catalogue lists and installs again. Its default signing key has changed; an instance that set its own catalogue signing key in Extension settings keeps using that key."
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"version": "1.60.0",
|
"version": "1.60.0",
|
||||||
"date": "2026-11-02",
|
"date": "2026-11-02",
|
||||||
|
|||||||
@@ -1,9 +1,14 @@
|
|||||||
// Keyboard and phone access: the task dialog fits and tabs in order, pages
|
// Keyboard and phone access: the task dialog fits and tabs in order, pages
|
||||||
// title correctly, the skip link and palette focus main content, and
|
// title correctly, the skip link and palette focus main content, and
|
||||||
// query-only tab switches keep focus where it is.
|
// query-only tab switches keep focus where it is. Then the audit's two
|
||||||
|
// static sweeps (#1767): no unnamed controls on any route, and every keyboard
|
||||||
|
// focus stop's indicator clears 3:1 against the background behind it.
|
||||||
const assert = require('node:assert/strict');
|
const assert = require('node:assert/strict');
|
||||||
|
const { staticRoutes } = require('./helpers/routes.cjs');
|
||||||
|
|
||||||
module.exports = async ({ page, go, shot, settled }) => {
|
module.exports = async ({ page, go, shot, fail, settled, tolerate }) => {
|
||||||
|
// The extension catalogue 502 is a stack-environment issue, not this check.
|
||||||
|
tolerate(/extensions\/catalogue/);
|
||||||
await page.setViewportSize({ width: 390, height: 844 });
|
await page.setViewportSize({ width: 390, height: 844 });
|
||||||
await go('/tasks');
|
await go('/tasks');
|
||||||
await page.getByRole('button', { name: 'Jump to', exact: true }).click();
|
await page.getByRole('button', { name: 'Jump to', exact: true }).click();
|
||||||
@@ -36,7 +41,7 @@ module.exports = async ({ page, go, shot, settled }) => {
|
|||||||
await page.keyboard.press('Enter');
|
await page.keyboard.press('Enter');
|
||||||
assert.equal(await page.evaluate(() => document.activeElement?.id), 'main-content');
|
assert.equal(await page.evaluate(() => document.activeElement?.id), 'main-content');
|
||||||
await page.getByRole('button', { name: 'Toggle Sidebar', exact: true }).click();
|
await page.getByRole('button', { name: 'Toggle Sidebar', exact: true }).click();
|
||||||
await page.getByRole('list', { name: 'Sections', exact: true }).getByRole('link', { name: 'Tasks', exact: true }).click();
|
await page.getByRole('navigation', { name: 'Sections', exact: true }).getByRole('link', { name: 'Tasks', exact: true }).click();
|
||||||
await page.waitForFunction(() => document.activeElement?.id === 'main-content', null, { timeout: 5000 }).catch(() => {});
|
await page.waitForFunction(() => document.activeElement?.id === 'main-content', null, { timeout: 5000 }).catch(() => {});
|
||||||
assert.equal(await page.evaluate(() => document.activeElement?.id), 'main-content', 'route navigation did not focus main');
|
assert.equal(await page.evaluate(() => document.activeElement?.id), 'main-content', 'route navigation did not focus main');
|
||||||
await page.getByRole('button', { name: 'Jump to', exact: true }).click();
|
await page.getByRole('button', { name: 'Jump to', exact: true }).click();
|
||||||
@@ -50,4 +55,122 @@ module.exports = async ({ page, go, shot, settled }) => {
|
|||||||
const tab = page.getByRole('tab', { name: /^Map/ });
|
const tab = page.getByRole('tab', { name: /^Map/ });
|
||||||
await tab.click();
|
await tab.click();
|
||||||
assert.ok(await tab.evaluate(el => el === document.activeElement), 'query-only navigation stole focus');
|
assert.ok(await tab.evaluate(el => el === document.activeElement), 'query-only navigation stole focus');
|
||||||
|
|
||||||
|
await page.setViewportSize({ width: 1440, height: 900 });
|
||||||
|
|
||||||
|
// Unnamed controls: every visible input, textarea, select, button or
|
||||||
|
// widget role on each static route needs an accessible name (accname
|
||||||
|
// order: labelledby, label, content, value, placeholder, title).
|
||||||
|
for (const r of staticRoutes()) {
|
||||||
|
await go(r);
|
||||||
|
const unnamed = await page.evaluate(() => {
|
||||||
|
const name = (el) => {
|
||||||
|
const by = el.getAttribute('aria-labelledby');
|
||||||
|
if (by) {
|
||||||
|
const t = by.split(/\s+/).map((id) => (document.getElementById(id)?.textContent || '')).join(' ').trim();
|
||||||
|
if (t) return t;
|
||||||
|
}
|
||||||
|
const al = el.getAttribute('aria-label');
|
||||||
|
if (al && al.trim()) return al.trim();
|
||||||
|
if (el.id) {
|
||||||
|
const l = document.querySelector(`label[for="${CSS.escape(el.id)}"]`);
|
||||||
|
if (l && l.textContent.trim()) return l.textContent.trim();
|
||||||
|
}
|
||||||
|
const wrap = el.closest('label');
|
||||||
|
if (wrap && wrap.textContent.trim()) return wrap.textContent.trim();
|
||||||
|
if (el.tagName === 'BUTTON' || el.getAttribute('role') === 'button' || el.getAttribute('role') === 'tab' || el.getAttribute('role') === 'switch') return el.textContent.trim();
|
||||||
|
if (el.tagName === 'INPUT') {
|
||||||
|
const t = (el.getAttribute('type') || 'text').toLowerCase();
|
||||||
|
if (t === 'submit' || t === 'button' || t === 'reset') return el.value.trim();
|
||||||
|
if (t === 'image') return (el.getAttribute('alt') || '').trim();
|
||||||
|
}
|
||||||
|
return (el.getAttribute('placeholder') || el.getAttribute('title') || '').trim();
|
||||||
|
};
|
||||||
|
return [...document.querySelectorAll('button, input, textarea, select, [role="button"], [role="tab"], [role="switch"], [role="checkbox"]')]
|
||||||
|
.filter((el) => el.type !== 'hidden' && el.getClientRects().length)
|
||||||
|
.filter((el) => !name(el))
|
||||||
|
.map((el) => `${el.tagName.toLowerCase()}${el.id ? '#' + el.id : ''}: ${el.outerHTML.slice(0, 120)}`);
|
||||||
|
});
|
||||||
|
for (const u of unnamed) fail(`unnamed control on ${r}: ${u}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Focus contrast: Tab through each static route; the focused element's
|
||||||
|
// outline or ring must clear 3:1 against the effective background behind it.
|
||||||
|
const focusProbe = () => page.evaluate(() => {
|
||||||
|
const el = document.activeElement;
|
||||||
|
if (!el || el === document.body || el === document.documentElement) return null;
|
||||||
|
const cs = getComputedStyle(el);
|
||||||
|
const parse = (c) => {
|
||||||
|
c = String(c).trim();
|
||||||
|
let m = c.match(/rgba?\(([^)]+)\)/);
|
||||||
|
if (m) {
|
||||||
|
const p = m[1].split(',').map(Number);
|
||||||
|
return { r: p[0], g: p[1], b: p[2], a: p.length > 3 ? p[3] : 1 };
|
||||||
|
}
|
||||||
|
m = c.match(/^#([0-9a-f]{3,8})$/i);
|
||||||
|
if (m) {
|
||||||
|
let h = m[1];
|
||||||
|
if (h.length === 3 || h.length === 4) h = [...h].map((x) => x + x).join('');
|
||||||
|
const n = parseInt(h.slice(0, 6), 16);
|
||||||
|
return { r: (n >> 16) & 255, g: (n >> 8) & 255, b: n & 255, a: h.length === 8 ? parseInt(h.slice(6, 8), 16) / 255 : 1 };
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
const bgBehind = (start) => {
|
||||||
|
for (let n = start; n; n = n.parentElement) {
|
||||||
|
const c = parse(getComputedStyle(n).backgroundColor);
|
||||||
|
if (c && c.a > 0) return c;
|
||||||
|
}
|
||||||
|
return { r: 255, g: 255, b: 255, a: 1 };
|
||||||
|
};
|
||||||
|
// An outer ring or outline is painted over the parent's background; an
|
||||||
|
// inset one over the element's own. Score against whichever is higher.
|
||||||
|
const bgSelf = bgBehind(el);
|
||||||
|
const bgParent = bgBehind(el.parentElement);
|
||||||
|
const over = (fg, bg) => {
|
||||||
|
const a = fg.a + bg.a * (1 - fg.a);
|
||||||
|
if (a === 0) return { r: 0, g: 0, b: 0 };
|
||||||
|
return { r: (fg.r * fg.a + bg.r * bg.a * (1 - fg.a)) / a, g: (fg.g * fg.a + bg.g * bg.a * (1 - fg.a)) / a, b: (fg.b * fg.a + bg.b * bg.a * (1 - fg.a)) / a };
|
||||||
|
};
|
||||||
|
const lum = (c) => {
|
||||||
|
const f = (v) => { v /= 255; return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4); };
|
||||||
|
return 0.2126 * f(c.r) + 0.7152 * f(c.g) + 0.0722 * f(c.b);
|
||||||
|
};
|
||||||
|
const ratio = (c1, c2) => {
|
||||||
|
const l1 = lum(c1), l2 = lum(c2);
|
||||||
|
return (Math.max(l1, l2) + 0.05) / (Math.min(l1, l2) + 0.05);
|
||||||
|
};
|
||||||
|
let fg = null;
|
||||||
|
// The ring lives in --tw-ring-shadow on :focus-visible; read the var
|
||||||
|
// directly, then fall back to outline, any shadow layer, focus border.
|
||||||
|
if (el.matches(':focus-visible')) {
|
||||||
|
const m = cs.getPropertyValue('--tw-ring-shadow').match(/rgba?\([^)]+\)|#[0-9a-f]{3,8}\b/i);
|
||||||
|
if (m) { const c = parse(m[0]); if (c && c.a > 0) fg = c; }
|
||||||
|
}
|
||||||
|
if (!fg && cs.outlineStyle !== 'none' && parseFloat(cs.outlineWidth) > 0) fg = parse(cs.outlineColor === 'currentcolor' ? cs.color : cs.outlineColor);
|
||||||
|
if (!fg && cs.boxShadow && cs.boxShadow !== 'none') {
|
||||||
|
for (const m of cs.boxShadow.matchAll(/rgba?\([^)]+\)|#[0-9a-f]{3,8}\b/gi)) {
|
||||||
|
const c = parse(m[0]);
|
||||||
|
if (c && c.a > 0) { fg = c; break; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!fg && el.matches(':focus-visible') && parseFloat(cs.borderTopWidth) > 0) {
|
||||||
|
const c = parse(cs.borderTopColor);
|
||||||
|
if (c && c.a > 0) fg = c;
|
||||||
|
}
|
||||||
|
const sig = `${el.tagName}#${el.id}:${(el.textContent || '').trim().slice(0, 30)}`;
|
||||||
|
if (!fg) return { sig, ratio: 0 };
|
||||||
|
return { sig, ratio: Math.max(ratio(over(fg, bgSelf), bgSelf), ratio(over(fg, bgParent), bgParent)) };
|
||||||
|
});
|
||||||
|
for (const r of staticRoutes()) {
|
||||||
|
await go(r);
|
||||||
|
let prev = '';
|
||||||
|
for (let i = 0; i < 40; i++) {
|
||||||
|
await page.keyboard.press('Tab');
|
||||||
|
const info = await focusProbe();
|
||||||
|
if (!info || info.sig === prev) break;
|
||||||
|
prev = info.sig;
|
||||||
|
if (info.ratio < 3) fail(`focus indicator under 3:1 on ${r} at ${info.sig} (ratio ${info.ratio.toFixed(2)})`);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
// The dashboard's static routes, read from the router source so a new page is
|
||||||
|
// swept automatically. Parameterised and redirect routes are skipped.
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
function staticRoutes() {
|
||||||
|
const src = fs.readFileSync(path.join(__dirname, '../../../ui/src/router/index.ts'), 'utf8');
|
||||||
|
const out = [];
|
||||||
|
for (const line of src.split('\n')) {
|
||||||
|
if (/redirect:/.test(line)) continue;
|
||||||
|
const m = line.match(/path: "([^"]*)"/);
|
||||||
|
if (!m || m[1].includes(':')) continue;
|
||||||
|
if (m[1].startsWith('/')) out.push(m[1]);
|
||||||
|
else if (m[1]) out.push('/org/' + m[1]);
|
||||||
|
}
|
||||||
|
return [...new Set(out)];
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { staticRoutes };
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
const assert=require('node:assert/strict');
|
const assert=require('node:assert/strict');
|
||||||
module.exports=async({page,go,shot})=>{
|
module.exports=async({page,go,shot,tolerate})=>{
|
||||||
|
// The extension catalogue 502 is a stack-environment issue, not this check.
|
||||||
|
tolerate(/extensions\/catalogue/);
|
||||||
await page.route('**/api/access/policies',async route=>{await new Promise(r=>setTimeout(r,2200));await route.continue()});
|
await page.route('**/api/access/policies',async route=>{await new Promise(r=>setTimeout(r,2200));await route.continue()});
|
||||||
await go('/access/policies');
|
await go('/access/policies');
|
||||||
assert.equal(await page.getByText('No policies yet.',{exact:true}).count(),0);
|
assert.equal(await page.getByText('No policies yet.',{exact:true}).count(),0);
|
||||||
@@ -16,4 +18,19 @@ module.exports=async({page,go,shot})=>{
|
|||||||
await page.getByRole('button',{name:'Retry runs',exact:true}).click();
|
await page.getByRole('button',{name:'Retry runs',exact:true}).click();
|
||||||
await page.getByRole('alert').filter({hasText:'Could not load recent runs'}).waitFor({state:'hidden'});
|
await page.getByRole('alert').filter({hasText:'Could not load recent runs'}).waitFor({state:'hidden'});
|
||||||
await shot('recovered');
|
await shot('recovered');
|
||||||
|
// A failed list read is an error, never the empty state (#1767): force each
|
||||||
|
// page's list API to 500 and check its empty-state copy stays hidden.
|
||||||
|
const failList = async (pattern,path,emptyTexts,errorSel='[role=alert]')=>{
|
||||||
|
await page.route(pattern,route=>route.fulfill({status:200,contentType:'application/json',body:'unreadable response'}));
|
||||||
|
await go(path);
|
||||||
|
await page.locator(errorSel).first().waitFor();
|
||||||
|
for(const text of emptyTexts) assert.equal(await page.getByText(text,{exact:true}).count(),0,`${path} shows its empty state ("${text}") while the list read fails`);
|
||||||
|
await page.unroute(pattern);
|
||||||
|
};
|
||||||
|
await failList('**/api/tasks*','/tasks',['No tasks yet'],'text=Archie is not responding');
|
||||||
|
await failList('**/api/captures*','/events',['No captures yet']);
|
||||||
|
await failList('**/api/event-types*','/events',['No event types yet']);
|
||||||
|
await failList('**/api/tokens*','/account',['No tokens yet']);
|
||||||
|
await failList('**/api/access/policies*','/org/policies',['No policies yet']);
|
||||||
|
await shot('failed-reads-show-errors');
|
||||||
};
|
};
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
// Phone-width sweep of the views the November audit flagged (#1757): at
|
||||||
|
// 390x844 each must fit without horizontal scroll or clipped controls. The
|
||||||
|
// topbar (with its instance badge) is on every page; /account holds the
|
||||||
|
// token form, /org/agents the agent rows and the grants card, /events the
|
||||||
|
// sources table, the event-type rule editor and the mapping editor dialog.
|
||||||
|
const assert = require('node:assert/strict');
|
||||||
|
const { staticRoutes } = require('./helpers/routes.cjs');
|
||||||
|
|
||||||
|
module.exports = async ({ page, go, shot, fail, settled, tolerate }) => {
|
||||||
|
// The extension catalogue 502 is a stack-environment issue, not this check.
|
||||||
|
tolerate(/extensions\/catalogue/);
|
||||||
|
await page.setViewportSize({ width: 390, height: 844 });
|
||||||
|
|
||||||
|
const assertNoOverflow = async (label) => {
|
||||||
|
const { scrollWidth, innerWidth } = await page.evaluate(() => ({
|
||||||
|
scrollWidth: document.documentElement.scrollWidth,
|
||||||
|
innerWidth: window.innerWidth,
|
||||||
|
}));
|
||||||
|
if (scrollWidth > innerWidth) {
|
||||||
|
fail(`${label} overflows 390px: scrollWidth=${scrollWidth} > innerWidth=${innerWidth}`);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const visit = async (path, label, waitFor) => {
|
||||||
|
await go(path);
|
||||||
|
if (waitFor) await settled(waitFor);
|
||||||
|
await assertNoOverflow(label);
|
||||||
|
await shot(label);
|
||||||
|
};
|
||||||
|
|
||||||
|
await visit('/account', 'account-tokens', 'text=API tokens');
|
||||||
|
await visit('/org/agents', 'org-agents', 'text=Credential grants');
|
||||||
|
|
||||||
|
await go('/events');
|
||||||
|
await settled('[role=tab]');
|
||||||
|
await assertNoOverflow('events');
|
||||||
|
await shot('events');
|
||||||
|
|
||||||
|
// The seeded event type's rule editor (RuleEditor's condition row) opens
|
||||||
|
// from the Edit button on its row.
|
||||||
|
const editType = page.locator('button[aria-label^="Edit "]').first();
|
||||||
|
if (await editType.count()) {
|
||||||
|
await editType.click();
|
||||||
|
await page.getByRole('dialog').first().waitFor();
|
||||||
|
await settled();
|
||||||
|
await assertNoOverflow('event-type rule editor');
|
||||||
|
await shot('rule-editor');
|
||||||
|
await page.keyboard.press('Escape');
|
||||||
|
await settled();
|
||||||
|
}
|
||||||
|
|
||||||
|
// The mappings tab's editor dialog carries the payload tree.
|
||||||
|
await page.getByRole('tab', { name: 'Map' }).click();
|
||||||
|
await settled('text=New mapping');
|
||||||
|
await assertNoOverflow('mappings list');
|
||||||
|
const editMapping = page.locator('button', { hasText: 'Edit' }).first();
|
||||||
|
if (await editMapping.count()) {
|
||||||
|
await editMapping.click();
|
||||||
|
await page.getByRole('dialog').first().waitFor();
|
||||||
|
await settled();
|
||||||
|
await assertNoOverflow('mapping editor dialog');
|
||||||
|
await shot('mapping-editor');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Every static route fits 390px (#1767): horizontal scroll fails.
|
||||||
|
for (const r of staticRoutes()) {
|
||||||
|
await visit(r, `route ${r}`, null);
|
||||||
|
}
|
||||||
|
};
|
||||||
+2
-16
@@ -1,24 +1,10 @@
|
|||||||
// Every static route loads without errors, renders, and shows no text with
|
// Every static route loads without errors, renders, and shows no text with
|
||||||
// stray leading, trailing or doubled spaces.
|
// stray leading, trailing or doubled spaces.
|
||||||
const fs = require('fs');
|
const { staticRoutes } = require('./helpers/routes.cjs');
|
||||||
const path = require('path');
|
|
||||||
|
|
||||||
function routes() {
|
|
||||||
const src = fs.readFileSync(path.join(__dirname, '../../ui/src/router/index.ts'), 'utf8');
|
|
||||||
const out = [];
|
|
||||||
for (const line of src.split('\n')) {
|
|
||||||
if (/redirect:/.test(line)) continue;
|
|
||||||
const m = line.match(/path: "([^"]*)"/);
|
|
||||||
if (!m || m[1].includes(':')) continue;
|
|
||||||
if (m[1].startsWith('/')) out.push(m[1]);
|
|
||||||
else if (m[1]) out.push('/org/' + m[1]);
|
|
||||||
}
|
|
||||||
return [...new Set(out)];
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = async ({ page, go, shot, fail }) => {
|
module.exports = async ({ page, go, shot, fail }) => {
|
||||||
const stray = new Map();
|
const stray = new Map();
|
||||||
for (const r of routes()) {
|
for (const r of staticRoutes()) {
|
||||||
await go(r);
|
await go(r);
|
||||||
await shot(r);
|
await shot(r);
|
||||||
// Log lines are data, not copy.
|
// Log lines are data, not copy.
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package archied
|
package archied
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"flag"
|
"flag"
|
||||||
@@ -8,6 +9,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"oras.land/oras-go/v2/errdef"
|
"oras.land/oras-go/v2/errdef"
|
||||||
@@ -506,7 +508,11 @@ func rollBackCanary(ctx context.Context, dashboard releaseupdate.CanaryDashboard
|
|||||||
if err := releaseupdate.Installable(ctx, source, stable); err != nil {
|
if err := releaseupdate.Installable(ctx, source, stable); err != nil {
|
||||||
return fmt.Errorf("stable %s is not installable, the canary stays on next: %w", stable.Statement.Version, err)
|
return fmt.Errorf("stable %s is not installable, the canary stays on next: %w", stable.Statement.Version, err)
|
||||||
}
|
}
|
||||||
if migrated(ctx, checkout, stable.Statement.Version, failed) {
|
changed, err := migrated(ctx, checkout, stable.Statement.Version, failed)
|
||||||
|
if err != nil {
|
||||||
|
return holdCanary(ctx, dashboard, failed, err.Error(), out)
|
||||||
|
}
|
||||||
|
if changed {
|
||||||
return holdCanary(ctx, dashboard, failed, failed+" changed the database schema", out)
|
return holdCanary(ctx, dashboard, failed, failed+" changed the database schema", out)
|
||||||
}
|
}
|
||||||
if err := dashboard.Follow(ctx, "exact-pin", stable.Statement.Version); err != nil {
|
if err := dashboard.Follow(ctx, "exact-pin", stable.Statement.Version); err != nil {
|
||||||
@@ -527,12 +533,40 @@ func holdCanary(ctx context.Context, dashboard releaseupdate.CanaryDashboard, ve
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// runGitDiff runs git diff --quiet between two release tags and reports its
|
||||||
|
// exit code and stderr. It is a variable so tests can drive the three
|
||||||
|
// outcomes without a repository.
|
||||||
|
var runGitDiff = func(ctx context.Context, checkout, from, to string) (int, string, error) {
|
||||||
|
cmd := exec.CommandContext(ctx, "git", "-C", checkout, "diff", "--quiet", "v"+from, "v"+to, "--", migrationsDir)
|
||||||
|
var buf bytes.Buffer
|
||||||
|
cmd.Stderr = &buf
|
||||||
|
err := cmd.Run()
|
||||||
|
if err == nil {
|
||||||
|
return 0, "", nil
|
||||||
|
}
|
||||||
|
if exitErr, ok := errors.AsType[*exec.ExitError](err); ok {
|
||||||
|
return exitErr.ExitCode(), buf.String(), err
|
||||||
|
}
|
||||||
|
return -1, buf.String(), err
|
||||||
|
}
|
||||||
|
|
||||||
// migrated reports whether the migrations differ between two release tags.
|
// migrated reports whether the migrations differ between two release tags.
|
||||||
// If it can't tell, it says they differ, so the canary is held rather than
|
// It returns true, nil when they differ, false, nil when they are identical,
|
||||||
// rolled back.
|
// and true, err when git could not answer, with the reason in err. Every
|
||||||
func migrated(ctx context.Context, checkout, from, to string) bool {
|
// non-identical outcome holds the canary rather than rolls it back.
|
||||||
err := exec.CommandContext(ctx, "git", "-C", checkout, "diff", "--quiet", "v"+from, "v"+to, "--", migrationsDir).Run()
|
func migrated(ctx context.Context, checkout, from, to string) (bool, error) {
|
||||||
return err != nil
|
code, stderr, runErr := runGitDiff(ctx, checkout, from, to)
|
||||||
|
switch code {
|
||||||
|
case 0:
|
||||||
|
return false, nil
|
||||||
|
case 1:
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
reason := strings.TrimSpace(stderr)
|
||||||
|
if reason == "" && runErr != nil {
|
||||||
|
reason = runErr.Error()
|
||||||
|
}
|
||||||
|
return true, fmt.Errorf("could not tell whether %s changed the database schema: %s", to, reason)
|
||||||
}
|
}
|
||||||
|
|
||||||
func runCanaryPromote(args []string, out, stderr io.Writer) int {
|
func runCanaryPromote(args []string, out, stderr io.Writer) int {
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
package archied
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestMigrated(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
code int
|
||||||
|
stderr string
|
||||||
|
wantChanged bool
|
||||||
|
wantErr bool
|
||||||
|
wantSubstr string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "identical migrations",
|
||||||
|
code: 0,
|
||||||
|
wantChanged: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "migrations differ",
|
||||||
|
code: 1,
|
||||||
|
wantChanged: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "git cannot answer",
|
||||||
|
code: 128,
|
||||||
|
stderr: "fatal: bad revision 'v1.0.0'\n",
|
||||||
|
wantChanged: true,
|
||||||
|
wantErr: true,
|
||||||
|
wantSubstr: "fatal: bad revision 'v1.0.0'",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
old := runGitDiff
|
||||||
|
runGitDiff = func(context.Context, string, string, string) (int, string, error) {
|
||||||
|
return tt.code, tt.stderr, nil
|
||||||
|
}
|
||||||
|
t.Cleanup(func() { runGitDiff = old })
|
||||||
|
|
||||||
|
changed, err := migrated(context.Background(), ".", "1.0.0", "1.1.0")
|
||||||
|
if changed != tt.wantChanged {
|
||||||
|
t.Fatalf("changed = %v, want %v", changed, tt.wantChanged)
|
||||||
|
}
|
||||||
|
if (err != nil) != tt.wantErr {
|
||||||
|
t.Fatalf("err = %v, want err %v", err, tt.wantErr)
|
||||||
|
}
|
||||||
|
if tt.wantErr && !strings.Contains(err.Error(), tt.wantSubstr) {
|
||||||
|
t.Fatalf("err = %q, want substring %q", err, tt.wantSubstr)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -77,6 +77,13 @@ func (b *boot) removeTaskWorktree(task *taskactions.Task) error {
|
|||||||
if b.d == nil {
|
if b.d == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
// A run that handed off shares the work item's worktree with its
|
||||||
|
// successor; archiving the old run must not remove it.
|
||||||
|
if current, err := b.stateStore.TaskByIssue(context.Background(), task.Owner, task.Repo, task.IssueNumber); err != nil {
|
||||||
|
return err
|
||||||
|
} else if current != nil && current.ID != task.ID {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
return b.d.RemoveWorktree(&workflow.Task{Owner: task.Owner, Repo: task.Repo, Identity: task.Identity, IssueNumber: task.IssueNumber, Org: task.Org})
|
return b.d.RemoveWorktree(&workflow.Task{Owner: task.Owner, Repo: task.Repo, Identity: task.Identity, IssueNumber: task.IssueNumber, Org: task.Org})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -202,6 +202,11 @@ func (b *server) seedAndValidatePolicies(ctx context.Context) error {
|
|||||||
// not to the sequence that triggers it.
|
// not to the sequence that triggers it.
|
||||||
func (b *server) reportUnseededResources(skipped []controlplanestore.SeedSkip) {
|
func (b *server) reportUnseededResources(skipped []controlplanestore.SeedSkip) {
|
||||||
for _, skip := range skipped {
|
for _, skip := range skipped {
|
||||||
|
if len(skip.Removed) > 0 {
|
||||||
|
b.log.Warn("removed stored entries that no longer validate; their earlier revision is in the resource history",
|
||||||
|
"kind", skip.Kind, "removed", skip.Removed)
|
||||||
|
continue
|
||||||
|
}
|
||||||
b.log.Error("control-plane resource not seeded; the kind stays absent and the file's value is the one in effect",
|
b.log.Error("control-plane resource not seeded; the kind stays absent and the file's value is the one in effect",
|
||||||
"kind", skip.Kind, "err", skip.Err)
|
"kind", skip.Kind, "err", skip.Err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2163,6 +2163,110 @@ func (x *EnqueueCallTaskRequest) GetCallKey() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type HandoffTaskRequest struct {
|
||||||
|
state protoimpl.MessageState `protogen:"open.v1"`
|
||||||
|
TaskId int64 `protobuf:"varint,1,opt,name=task_id,json=taskId,proto3" json:"task_id,omitempty"`
|
||||||
|
Workflow string `protobuf:"bytes,2,opt,name=workflow,proto3" json:"workflow,omitempty"`
|
||||||
|
Detail string `protobuf:"bytes,3,opt,name=detail,proto3" json:"detail,omitempty"`
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *HandoffTaskRequest) Reset() {
|
||||||
|
*x = HandoffTaskRequest{}
|
||||||
|
mi := &file_state_v1_task_proto_msgTypes[41]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *HandoffTaskRequest) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*HandoffTaskRequest) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *HandoffTaskRequest) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_state_v1_task_proto_msgTypes[41]
|
||||||
|
if x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use HandoffTaskRequest.ProtoReflect.Descriptor instead.
|
||||||
|
func (*HandoffTaskRequest) Descriptor() ([]byte, []int) {
|
||||||
|
return file_state_v1_task_proto_rawDescGZIP(), []int{41}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *HandoffTaskRequest) GetTaskId() int64 {
|
||||||
|
if x != nil {
|
||||||
|
return x.TaskId
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *HandoffTaskRequest) GetWorkflow() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.Workflow
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *HandoffTaskRequest) GetDetail() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.Detail
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
type HandoffTaskResponse struct {
|
||||||
|
state protoimpl.MessageState `protogen:"open.v1"`
|
||||||
|
Task *Task `protobuf:"bytes,1,opt,name=task,proto3" json:"task,omitempty"`
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *HandoffTaskResponse) Reset() {
|
||||||
|
*x = HandoffTaskResponse{}
|
||||||
|
mi := &file_state_v1_task_proto_msgTypes[42]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *HandoffTaskResponse) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*HandoffTaskResponse) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *HandoffTaskResponse) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_state_v1_task_proto_msgTypes[42]
|
||||||
|
if x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use HandoffTaskResponse.ProtoReflect.Descriptor instead.
|
||||||
|
func (*HandoffTaskResponse) Descriptor() ([]byte, []int) {
|
||||||
|
return file_state_v1_task_proto_rawDescGZIP(), []int{42}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *HandoffTaskResponse) GetTask() *Task {
|
||||||
|
if x != nil {
|
||||||
|
return x.Task
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
type EnqueueCallTaskResponse struct {
|
type EnqueueCallTaskResponse struct {
|
||||||
state protoimpl.MessageState `protogen:"open.v1"`
|
state protoimpl.MessageState `protogen:"open.v1"`
|
||||||
Task *Task `protobuf:"bytes,1,opt,name=task,proto3" json:"task,omitempty"`
|
Task *Task `protobuf:"bytes,1,opt,name=task,proto3" json:"task,omitempty"`
|
||||||
@@ -2173,7 +2277,7 @@ type EnqueueCallTaskResponse struct {
|
|||||||
|
|
||||||
func (x *EnqueueCallTaskResponse) Reset() {
|
func (x *EnqueueCallTaskResponse) Reset() {
|
||||||
*x = EnqueueCallTaskResponse{}
|
*x = EnqueueCallTaskResponse{}
|
||||||
mi := &file_state_v1_task_proto_msgTypes[41]
|
mi := &file_state_v1_task_proto_msgTypes[43]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@@ -2185,7 +2289,7 @@ func (x *EnqueueCallTaskResponse) String() string {
|
|||||||
func (*EnqueueCallTaskResponse) ProtoMessage() {}
|
func (*EnqueueCallTaskResponse) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *EnqueueCallTaskResponse) ProtoReflect() protoreflect.Message {
|
func (x *EnqueueCallTaskResponse) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_state_v1_task_proto_msgTypes[41]
|
mi := &file_state_v1_task_proto_msgTypes[43]
|
||||||
if x != nil {
|
if x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@@ -2198,7 +2302,7 @@ func (x *EnqueueCallTaskResponse) ProtoReflect() protoreflect.Message {
|
|||||||
|
|
||||||
// Deprecated: Use EnqueueCallTaskResponse.ProtoReflect.Descriptor instead.
|
// Deprecated: Use EnqueueCallTaskResponse.ProtoReflect.Descriptor instead.
|
||||||
func (*EnqueueCallTaskResponse) Descriptor() ([]byte, []int) {
|
func (*EnqueueCallTaskResponse) Descriptor() ([]byte, []int) {
|
||||||
return file_state_v1_task_proto_rawDescGZIP(), []int{41}
|
return file_state_v1_task_proto_rawDescGZIP(), []int{43}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *EnqueueCallTaskResponse) GetTask() *Task {
|
func (x *EnqueueCallTaskResponse) GetTask() *Task {
|
||||||
@@ -2225,7 +2329,7 @@ type WorkflowCallStatusRequest struct {
|
|||||||
|
|
||||||
func (x *WorkflowCallStatusRequest) Reset() {
|
func (x *WorkflowCallStatusRequest) Reset() {
|
||||||
*x = WorkflowCallStatusRequest{}
|
*x = WorkflowCallStatusRequest{}
|
||||||
mi := &file_state_v1_task_proto_msgTypes[42]
|
mi := &file_state_v1_task_proto_msgTypes[44]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@@ -2237,7 +2341,7 @@ func (x *WorkflowCallStatusRequest) String() string {
|
|||||||
func (*WorkflowCallStatusRequest) ProtoMessage() {}
|
func (*WorkflowCallStatusRequest) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *WorkflowCallStatusRequest) ProtoReflect() protoreflect.Message {
|
func (x *WorkflowCallStatusRequest) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_state_v1_task_proto_msgTypes[42]
|
mi := &file_state_v1_task_proto_msgTypes[44]
|
||||||
if x != nil {
|
if x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@@ -2250,7 +2354,7 @@ func (x *WorkflowCallStatusRequest) ProtoReflect() protoreflect.Message {
|
|||||||
|
|
||||||
// Deprecated: Use WorkflowCallStatusRequest.ProtoReflect.Descriptor instead.
|
// Deprecated: Use WorkflowCallStatusRequest.ProtoReflect.Descriptor instead.
|
||||||
func (*WorkflowCallStatusRequest) Descriptor() ([]byte, []int) {
|
func (*WorkflowCallStatusRequest) Descriptor() ([]byte, []int) {
|
||||||
return file_state_v1_task_proto_rawDescGZIP(), []int{42}
|
return file_state_v1_task_proto_rawDescGZIP(), []int{44}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *WorkflowCallStatusRequest) GetCallerTaskId() int64 {
|
func (x *WorkflowCallStatusRequest) GetCallerTaskId() int64 {
|
||||||
@@ -2283,7 +2387,7 @@ type WorkflowCallStatusResponse struct {
|
|||||||
|
|
||||||
func (x *WorkflowCallStatusResponse) Reset() {
|
func (x *WorkflowCallStatusResponse) Reset() {
|
||||||
*x = WorkflowCallStatusResponse{}
|
*x = WorkflowCallStatusResponse{}
|
||||||
mi := &file_state_v1_task_proto_msgTypes[43]
|
mi := &file_state_v1_task_proto_msgTypes[45]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@@ -2295,7 +2399,7 @@ func (x *WorkflowCallStatusResponse) String() string {
|
|||||||
func (*WorkflowCallStatusResponse) ProtoMessage() {}
|
func (*WorkflowCallStatusResponse) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *WorkflowCallStatusResponse) ProtoReflect() protoreflect.Message {
|
func (x *WorkflowCallStatusResponse) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_state_v1_task_proto_msgTypes[43]
|
mi := &file_state_v1_task_proto_msgTypes[45]
|
||||||
if x != nil {
|
if x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@@ -2308,7 +2412,7 @@ func (x *WorkflowCallStatusResponse) ProtoReflect() protoreflect.Message {
|
|||||||
|
|
||||||
// Deprecated: Use WorkflowCallStatusResponse.ProtoReflect.Descriptor instead.
|
// Deprecated: Use WorkflowCallStatusResponse.ProtoReflect.Descriptor instead.
|
||||||
func (*WorkflowCallStatusResponse) Descriptor() ([]byte, []int) {
|
func (*WorkflowCallStatusResponse) Descriptor() ([]byte, []int) {
|
||||||
return file_state_v1_task_proto_rawDescGZIP(), []int{43}
|
return file_state_v1_task_proto_rawDescGZIP(), []int{45}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *WorkflowCallStatusResponse) GetStatus() string {
|
func (x *WorkflowCallStatusResponse) GetStatus() string {
|
||||||
@@ -2341,7 +2445,7 @@ type TaskModelsRequest struct {
|
|||||||
|
|
||||||
func (x *TaskModelsRequest) Reset() {
|
func (x *TaskModelsRequest) Reset() {
|
||||||
*x = TaskModelsRequest{}
|
*x = TaskModelsRequest{}
|
||||||
mi := &file_state_v1_task_proto_msgTypes[44]
|
mi := &file_state_v1_task_proto_msgTypes[46]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@@ -2353,7 +2457,7 @@ func (x *TaskModelsRequest) String() string {
|
|||||||
func (*TaskModelsRequest) ProtoMessage() {}
|
func (*TaskModelsRequest) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *TaskModelsRequest) ProtoReflect() protoreflect.Message {
|
func (x *TaskModelsRequest) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_state_v1_task_proto_msgTypes[44]
|
mi := &file_state_v1_task_proto_msgTypes[46]
|
||||||
if x != nil {
|
if x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@@ -2366,7 +2470,7 @@ func (x *TaskModelsRequest) ProtoReflect() protoreflect.Message {
|
|||||||
|
|
||||||
// Deprecated: Use TaskModelsRequest.ProtoReflect.Descriptor instead.
|
// Deprecated: Use TaskModelsRequest.ProtoReflect.Descriptor instead.
|
||||||
func (*TaskModelsRequest) Descriptor() ([]byte, []int) {
|
func (*TaskModelsRequest) Descriptor() ([]byte, []int) {
|
||||||
return file_state_v1_task_proto_rawDescGZIP(), []int{44}
|
return file_state_v1_task_proto_rawDescGZIP(), []int{46}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *TaskModelsRequest) GetTaskId() int64 {
|
func (x *TaskModelsRequest) GetTaskId() int64 {
|
||||||
@@ -2385,7 +2489,7 @@ type TaskInstructionsRequest struct {
|
|||||||
|
|
||||||
func (x *TaskInstructionsRequest) Reset() {
|
func (x *TaskInstructionsRequest) Reset() {
|
||||||
*x = TaskInstructionsRequest{}
|
*x = TaskInstructionsRequest{}
|
||||||
mi := &file_state_v1_task_proto_msgTypes[45]
|
mi := &file_state_v1_task_proto_msgTypes[47]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@@ -2397,7 +2501,7 @@ func (x *TaskInstructionsRequest) String() string {
|
|||||||
func (*TaskInstructionsRequest) ProtoMessage() {}
|
func (*TaskInstructionsRequest) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *TaskInstructionsRequest) ProtoReflect() protoreflect.Message {
|
func (x *TaskInstructionsRequest) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_state_v1_task_proto_msgTypes[45]
|
mi := &file_state_v1_task_proto_msgTypes[47]
|
||||||
if x != nil {
|
if x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@@ -2410,7 +2514,7 @@ func (x *TaskInstructionsRequest) ProtoReflect() protoreflect.Message {
|
|||||||
|
|
||||||
// Deprecated: Use TaskInstructionsRequest.ProtoReflect.Descriptor instead.
|
// Deprecated: Use TaskInstructionsRequest.ProtoReflect.Descriptor instead.
|
||||||
func (*TaskInstructionsRequest) Descriptor() ([]byte, []int) {
|
func (*TaskInstructionsRequest) Descriptor() ([]byte, []int) {
|
||||||
return file_state_v1_task_proto_rawDescGZIP(), []int{45}
|
return file_state_v1_task_proto_rawDescGZIP(), []int{47}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *TaskInstructionsRequest) GetTaskId() int64 {
|
func (x *TaskInstructionsRequest) GetTaskId() int64 {
|
||||||
@@ -2430,7 +2534,7 @@ type TaskInstructionsResponse struct {
|
|||||||
|
|
||||||
func (x *TaskInstructionsResponse) Reset() {
|
func (x *TaskInstructionsResponse) Reset() {
|
||||||
*x = TaskInstructionsResponse{}
|
*x = TaskInstructionsResponse{}
|
||||||
mi := &file_state_v1_task_proto_msgTypes[46]
|
mi := &file_state_v1_task_proto_msgTypes[48]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@@ -2442,7 +2546,7 @@ func (x *TaskInstructionsResponse) String() string {
|
|||||||
func (*TaskInstructionsResponse) ProtoMessage() {}
|
func (*TaskInstructionsResponse) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *TaskInstructionsResponse) ProtoReflect() protoreflect.Message {
|
func (x *TaskInstructionsResponse) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_state_v1_task_proto_msgTypes[46]
|
mi := &file_state_v1_task_proto_msgTypes[48]
|
||||||
if x != nil {
|
if x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@@ -2455,7 +2559,7 @@ func (x *TaskInstructionsResponse) ProtoReflect() protoreflect.Message {
|
|||||||
|
|
||||||
// Deprecated: Use TaskInstructionsResponse.ProtoReflect.Descriptor instead.
|
// Deprecated: Use TaskInstructionsResponse.ProtoReflect.Descriptor instead.
|
||||||
func (*TaskInstructionsResponse) Descriptor() ([]byte, []int) {
|
func (*TaskInstructionsResponse) Descriptor() ([]byte, []int) {
|
||||||
return file_state_v1_task_proto_rawDescGZIP(), []int{46}
|
return file_state_v1_task_proto_rawDescGZIP(), []int{48}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *TaskInstructionsResponse) GetInstance() string {
|
func (x *TaskInstructionsResponse) GetInstance() string {
|
||||||
@@ -2483,7 +2587,7 @@ type TaskModelsResponse struct {
|
|||||||
|
|
||||||
func (x *TaskModelsResponse) Reset() {
|
func (x *TaskModelsResponse) Reset() {
|
||||||
*x = TaskModelsResponse{}
|
*x = TaskModelsResponse{}
|
||||||
mi := &file_state_v1_task_proto_msgTypes[47]
|
mi := &file_state_v1_task_proto_msgTypes[49]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@@ -2495,7 +2599,7 @@ func (x *TaskModelsResponse) String() string {
|
|||||||
func (*TaskModelsResponse) ProtoMessage() {}
|
func (*TaskModelsResponse) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *TaskModelsResponse) ProtoReflect() protoreflect.Message {
|
func (x *TaskModelsResponse) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_state_v1_task_proto_msgTypes[47]
|
mi := &file_state_v1_task_proto_msgTypes[49]
|
||||||
if x != nil {
|
if x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@@ -2508,7 +2612,7 @@ func (x *TaskModelsResponse) ProtoReflect() protoreflect.Message {
|
|||||||
|
|
||||||
// Deprecated: Use TaskModelsResponse.ProtoReflect.Descriptor instead.
|
// Deprecated: Use TaskModelsResponse.ProtoReflect.Descriptor instead.
|
||||||
func (*TaskModelsResponse) Descriptor() ([]byte, []int) {
|
func (*TaskModelsResponse) Descriptor() ([]byte, []int) {
|
||||||
return file_state_v1_task_proto_rawDescGZIP(), []int{47}
|
return file_state_v1_task_proto_rawDescGZIP(), []int{49}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *TaskModelsResponse) GetOrgId() string {
|
func (x *TaskModelsResponse) GetOrgId() string {
|
||||||
@@ -2550,7 +2654,7 @@ type ModelProvider struct {
|
|||||||
|
|
||||||
func (x *ModelProvider) Reset() {
|
func (x *ModelProvider) Reset() {
|
||||||
*x = ModelProvider{}
|
*x = ModelProvider{}
|
||||||
mi := &file_state_v1_task_proto_msgTypes[48]
|
mi := &file_state_v1_task_proto_msgTypes[50]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@@ -2562,7 +2666,7 @@ func (x *ModelProvider) String() string {
|
|||||||
func (*ModelProvider) ProtoMessage() {}
|
func (*ModelProvider) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *ModelProvider) ProtoReflect() protoreflect.Message {
|
func (x *ModelProvider) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_state_v1_task_proto_msgTypes[48]
|
mi := &file_state_v1_task_proto_msgTypes[50]
|
||||||
if x != nil {
|
if x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@@ -2575,7 +2679,7 @@ func (x *ModelProvider) ProtoReflect() protoreflect.Message {
|
|||||||
|
|
||||||
// Deprecated: Use ModelProvider.ProtoReflect.Descriptor instead.
|
// Deprecated: Use ModelProvider.ProtoReflect.Descriptor instead.
|
||||||
func (*ModelProvider) Descriptor() ([]byte, []int) {
|
func (*ModelProvider) Descriptor() ([]byte, []int) {
|
||||||
return file_state_v1_task_proto_rawDescGZIP(), []int{48}
|
return file_state_v1_task_proto_rawDescGZIP(), []int{50}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *ModelProvider) GetClass() string {
|
func (x *ModelProvider) GetClass() string {
|
||||||
@@ -2746,7 +2850,13 @@ const file_state_v1_task_proto_rawDesc = "" +
|
|||||||
"\bworkflow\x18\x02 \x01(\tR\bworkflow\x12\x1f\n" +
|
"\bworkflow\x18\x02 \x01(\tR\bworkflow\x12\x1f\n" +
|
||||||
"\vinputs_json\x18\x03 \x01(\tR\n" +
|
"\vinputs_json\x18\x03 \x01(\tR\n" +
|
||||||
"inputsJson\x12\x19\n" +
|
"inputsJson\x12\x19\n" +
|
||||||
"\bcall_key\x18\x04 \x01(\tR\acallKey\"Y\n" +
|
"\bcall_key\x18\x04 \x01(\tR\acallKey\"a\n" +
|
||||||
|
"\x12HandoffTaskRequest\x12\x17\n" +
|
||||||
|
"\atask_id\x18\x01 \x01(\x03R\x06taskId\x12\x1a\n" +
|
||||||
|
"\bworkflow\x18\x02 \x01(\tR\bworkflow\x12\x16\n" +
|
||||||
|
"\x06detail\x18\x03 \x01(\tR\x06detail\"9\n" +
|
||||||
|
"\x13HandoffTaskResponse\x12\"\n" +
|
||||||
|
"\x04task\x18\x01 \x01(\v2\x0e.state.v1.TaskR\x04task\"Y\n" +
|
||||||
"\x17EnqueueCallTaskResponse\x12\"\n" +
|
"\x17EnqueueCallTaskResponse\x12\"\n" +
|
||||||
"\x04task\x18\x01 \x01(\v2\x0e.state.v1.TaskR\x04task\x12\x1a\n" +
|
"\x04task\x18\x01 \x01(\v2\x0e.state.v1.TaskR\x04task\x12\x1a\n" +
|
||||||
"\baccepted\x18\x02 \x01(\bR\baccepted\"c\n" +
|
"\baccepted\x18\x02 \x01(\bR\baccepted\"c\n" +
|
||||||
@@ -2780,7 +2890,7 @@ const file_state_v1_task_proto_rawDesc = "" +
|
|||||||
"\bbase_url\x18\x02 \x01(\tR\abaseUrl\x12\x1e\n" +
|
"\bbase_url\x18\x02 \x01(\tR\abaseUrl\x12\x1e\n" +
|
||||||
"\vapi_key_env\x18\x03 \x01(\tR\tapiKeyEnv\x12$\n" +
|
"\vapi_key_env\x18\x03 \x01(\tR\tapiKeyEnv\x12$\n" +
|
||||||
"\x0eapi_key_engine\x18\x04 \x01(\tR\fapiKeyEngine\x12\x1e\n" +
|
"\x0eapi_key_engine\x18\x04 \x01(\tR\fapiKeyEngine\x12\x1e\n" +
|
||||||
"\vapi_key_key\x18\x05 \x01(\tR\tapiKeyKey2\xe6\x0e\n" +
|
"\vapi_key_key\x18\x05 \x01(\tR\tapiKeyKey2\xb2\x0f\n" +
|
||||||
"\vTaskService\x12M\n" +
|
"\vTaskService\x12M\n" +
|
||||||
"\fEnqueueIssue\x12\x1d.state.v1.EnqueueIssueRequest\x1a\x1e.state.v1.EnqueueIssueResponse\x12V\n" +
|
"\fEnqueueIssue\x12\x1d.state.v1.EnqueueIssueRequest\x1a\x1e.state.v1.EnqueueIssueResponse\x12V\n" +
|
||||||
"\x0fEnqueueChatTask\x12 .state.v1.EnqueueChatTaskRequest\x1a!.state.v1.EnqueueChatTaskResponse\x12b\n" +
|
"\x0fEnqueueChatTask\x12 .state.v1.EnqueueChatTaskRequest\x1a!.state.v1.EnqueueChatTaskResponse\x12b\n" +
|
||||||
@@ -2806,7 +2916,8 @@ const file_state_v1_task_proto_rawDesc = "" +
|
|||||||
"\aOpenPRs\x12\x18.state.v1.OpenPRsRequest\x1a\x19.state.v1.OpenPRsResponse\x12_\n" +
|
"\aOpenPRs\x12\x18.state.v1.OpenPRsRequest\x1a\x19.state.v1.OpenPRsResponse\x12_\n" +
|
||||||
"\x12ClearTerminalTasks\x12#.state.v1.ClearTerminalTasksRequest\x1a$.state.v1.ClearTerminalTasksResponse\x128\n" +
|
"\x12ClearTerminalTasks\x12#.state.v1.ClearTerminalTasksRequest\x1a$.state.v1.ClearTerminalTasksResponse\x128\n" +
|
||||||
"\x05Tasks\x12\x16.state.v1.TasksRequest\x1a\x17.state.v1.TasksResponse\x12V\n" +
|
"\x05Tasks\x12\x16.state.v1.TasksRequest\x1a\x17.state.v1.TasksResponse\x12V\n" +
|
||||||
"\x0fEnqueueCallTask\x12 .state.v1.EnqueueCallTaskRequest\x1a!.state.v1.EnqueueCallTaskResponse\x12_\n" +
|
"\x0fEnqueueCallTask\x12 .state.v1.EnqueueCallTaskRequest\x1a!.state.v1.EnqueueCallTaskResponse\x12J\n" +
|
||||||
|
"\vHandoffTask\x12\x1c.state.v1.HandoffTaskRequest\x1a\x1d.state.v1.HandoffTaskResponse\x12_\n" +
|
||||||
"\x12WorkflowCallStatus\x12#.state.v1.WorkflowCallStatusRequest\x1a$.state.v1.WorkflowCallStatusResponseB\xa3\x01\n" +
|
"\x12WorkflowCallStatus\x12#.state.v1.WorkflowCallStatusRequest\x1a$.state.v1.WorkflowCallStatusResponseB\xa3\x01\n" +
|
||||||
"\fcom.state.v1B\tTaskProtoP\x01ZGgithub.com/samcharles93/archie-core/internal/contracts/state/v1;statev1\xa2\x02\x03SXX\xaa\x02\bState.V1\xca\x02\bState\\V1\xe2\x02\x14State\\V1\\GPBMetadata\xea\x02\tState::V1b\x06proto3"
|
"\fcom.state.v1B\tTaskProtoP\x01ZGgithub.com/samcharles93/archie-core/internal/contracts/state/v1;statev1\xa2\x02\x03SXX\xaa\x02\bState.V1\xca\x02\bState\\V1\xe2\x02\x14State\\V1\\GPBMetadata\xea\x02\tState::V1b\x06proto3"
|
||||||
|
|
||||||
@@ -2822,7 +2933,7 @@ func file_state_v1_task_proto_rawDescGZIP() []byte {
|
|||||||
return file_state_v1_task_proto_rawDescData
|
return file_state_v1_task_proto_rawDescData
|
||||||
}
|
}
|
||||||
|
|
||||||
var file_state_v1_task_proto_msgTypes = make([]protoimpl.MessageInfo, 51)
|
var file_state_v1_task_proto_msgTypes = make([]protoimpl.MessageInfo, 53)
|
||||||
var file_state_v1_task_proto_goTypes = []any{
|
var file_state_v1_task_proto_goTypes = []any{
|
||||||
(*EnqueueIssueRequest)(nil), // 0: state.v1.EnqueueIssueRequest
|
(*EnqueueIssueRequest)(nil), // 0: state.v1.EnqueueIssueRequest
|
||||||
(*EnqueueIssueResponse)(nil), // 1: state.v1.EnqueueIssueResponse
|
(*EnqueueIssueResponse)(nil), // 1: state.v1.EnqueueIssueResponse
|
||||||
@@ -2865,91 +2976,96 @@ var file_state_v1_task_proto_goTypes = []any{
|
|||||||
(*TasksRequest)(nil), // 38: state.v1.TasksRequest
|
(*TasksRequest)(nil), // 38: state.v1.TasksRequest
|
||||||
(*TasksResponse)(nil), // 39: state.v1.TasksResponse
|
(*TasksResponse)(nil), // 39: state.v1.TasksResponse
|
||||||
(*EnqueueCallTaskRequest)(nil), // 40: state.v1.EnqueueCallTaskRequest
|
(*EnqueueCallTaskRequest)(nil), // 40: state.v1.EnqueueCallTaskRequest
|
||||||
(*EnqueueCallTaskResponse)(nil), // 41: state.v1.EnqueueCallTaskResponse
|
(*HandoffTaskRequest)(nil), // 41: state.v1.HandoffTaskRequest
|
||||||
(*WorkflowCallStatusRequest)(nil), // 42: state.v1.WorkflowCallStatusRequest
|
(*HandoffTaskResponse)(nil), // 42: state.v1.HandoffTaskResponse
|
||||||
(*WorkflowCallStatusResponse)(nil), // 43: state.v1.WorkflowCallStatusResponse
|
(*EnqueueCallTaskResponse)(nil), // 43: state.v1.EnqueueCallTaskResponse
|
||||||
(*TaskModelsRequest)(nil), // 44: state.v1.TaskModelsRequest
|
(*WorkflowCallStatusRequest)(nil), // 44: state.v1.WorkflowCallStatusRequest
|
||||||
(*TaskInstructionsRequest)(nil), // 45: state.v1.TaskInstructionsRequest
|
(*WorkflowCallStatusResponse)(nil), // 45: state.v1.WorkflowCallStatusResponse
|
||||||
(*TaskInstructionsResponse)(nil), // 46: state.v1.TaskInstructionsResponse
|
(*TaskModelsRequest)(nil), // 46: state.v1.TaskModelsRequest
|
||||||
(*TaskModelsResponse)(nil), // 47: state.v1.TaskModelsResponse
|
(*TaskInstructionsRequest)(nil), // 47: state.v1.TaskInstructionsRequest
|
||||||
(*ModelProvider)(nil), // 48: state.v1.ModelProvider
|
(*TaskInstructionsResponse)(nil), // 48: state.v1.TaskInstructionsResponse
|
||||||
nil, // 49: state.v1.TaskModelsResponse.AliasesEntry
|
(*TaskModelsResponse)(nil), // 49: state.v1.TaskModelsResponse
|
||||||
nil, // 50: state.v1.TaskModelsResponse.ProvidersEntry
|
(*ModelProvider)(nil), // 50: state.v1.ModelProvider
|
||||||
(*Task)(nil), // 51: state.v1.Task
|
nil, // 51: state.v1.TaskModelsResponse.AliasesEntry
|
||||||
(*Event)(nil), // 52: state.v1.Event
|
nil, // 52: state.v1.TaskModelsResponse.ProvidersEntry
|
||||||
(*timestamppb.Timestamp)(nil), // 53: google.protobuf.Timestamp
|
(*Task)(nil), // 53: state.v1.Task
|
||||||
|
(*Event)(nil), // 54: state.v1.Event
|
||||||
|
(*timestamppb.Timestamp)(nil), // 55: google.protobuf.Timestamp
|
||||||
}
|
}
|
||||||
var file_state_v1_task_proto_depIdxs = []int32{
|
var file_state_v1_task_proto_depIdxs = []int32{
|
||||||
51, // 0: state.v1.ActiveTasksByOriginResponse.tasks:type_name -> state.v1.Task
|
53, // 0: state.v1.ActiveTasksByOriginResponse.tasks:type_name -> state.v1.Task
|
||||||
51, // 1: state.v1.UnpostedOutcomesResponse.tasks:type_name -> state.v1.Task
|
53, // 1: state.v1.UnpostedOutcomesResponse.tasks:type_name -> state.v1.Task
|
||||||
51, // 2: state.v1.EnqueueChatTaskResponse.task:type_name -> state.v1.Task
|
53, // 2: state.v1.EnqueueChatTaskResponse.task:type_name -> state.v1.Task
|
||||||
51, // 3: state.v1.ClaimNextResponse.task:type_name -> state.v1.Task
|
53, // 3: state.v1.ClaimNextResponse.task:type_name -> state.v1.Task
|
||||||
51, // 4: state.v1.ClaimByIssueResponse.task:type_name -> state.v1.Task
|
53, // 4: state.v1.ClaimByIssueResponse.task:type_name -> state.v1.Task
|
||||||
51, // 5: state.v1.UpdateRequest.task:type_name -> state.v1.Task
|
53, // 5: state.v1.UpdateRequest.task:type_name -> state.v1.Task
|
||||||
52, // 6: state.v1.ArchiveTaskRequest.audit:type_name -> state.v1.Event
|
54, // 6: state.v1.ArchiveTaskRequest.audit:type_name -> state.v1.Event
|
||||||
51, // 7: state.v1.TaskByIssueResponse.task:type_name -> state.v1.Task
|
53, // 7: state.v1.TaskByIssueResponse.task:type_name -> state.v1.Task
|
||||||
51, // 8: state.v1.OpenTaskByPRResponse.task:type_name -> state.v1.Task
|
53, // 8: state.v1.OpenTaskByPRResponse.task:type_name -> state.v1.Task
|
||||||
51, // 9: state.v1.TaskByIDResponse.task:type_name -> state.v1.Task
|
53, // 9: state.v1.TaskByIDResponse.task:type_name -> state.v1.Task
|
||||||
51, // 10: state.v1.OpenPRsResponse.tasks:type_name -> state.v1.Task
|
53, // 10: state.v1.OpenPRsResponse.tasks:type_name -> state.v1.Task
|
||||||
53, // 11: state.v1.TasksRequest.after_updated_at:type_name -> google.protobuf.Timestamp
|
55, // 11: state.v1.TasksRequest.after_updated_at:type_name -> google.protobuf.Timestamp
|
||||||
51, // 12: state.v1.TasksResponse.tasks:type_name -> state.v1.Task
|
53, // 12: state.v1.TasksResponse.tasks:type_name -> state.v1.Task
|
||||||
51, // 13: state.v1.EnqueueCallTaskResponse.task:type_name -> state.v1.Task
|
53, // 13: state.v1.HandoffTaskResponse.task:type_name -> state.v1.Task
|
||||||
49, // 14: state.v1.TaskModelsResponse.aliases:type_name -> state.v1.TaskModelsResponse.AliasesEntry
|
53, // 14: state.v1.EnqueueCallTaskResponse.task:type_name -> state.v1.Task
|
||||||
50, // 15: state.v1.TaskModelsResponse.providers:type_name -> state.v1.TaskModelsResponse.ProvidersEntry
|
51, // 15: state.v1.TaskModelsResponse.aliases:type_name -> state.v1.TaskModelsResponse.AliasesEntry
|
||||||
48, // 16: state.v1.TaskModelsResponse.ProvidersEntry.value:type_name -> state.v1.ModelProvider
|
52, // 16: state.v1.TaskModelsResponse.providers:type_name -> state.v1.TaskModelsResponse.ProvidersEntry
|
||||||
0, // 17: state.v1.TaskService.EnqueueIssue:input_type -> state.v1.EnqueueIssueRequest
|
50, // 17: state.v1.TaskModelsResponse.ProvidersEntry.value:type_name -> state.v1.ModelProvider
|
||||||
8, // 18: state.v1.TaskService.EnqueueChatTask:input_type -> state.v1.EnqueueChatTaskRequest
|
0, // 18: state.v1.TaskService.EnqueueIssue:input_type -> state.v1.EnqueueIssueRequest
|
||||||
2, // 19: state.v1.TaskService.ActiveTasksByOrigin:input_type -> state.v1.ActiveTasksByOriginRequest
|
8, // 19: state.v1.TaskService.EnqueueChatTask:input_type -> state.v1.EnqueueChatTaskRequest
|
||||||
4, // 20: state.v1.TaskService.UnpostedOutcomes:input_type -> state.v1.UnpostedOutcomesRequest
|
2, // 20: state.v1.TaskService.ActiveTasksByOrigin:input_type -> state.v1.ActiveTasksByOriginRequest
|
||||||
6, // 21: state.v1.TaskService.MarkOutcomePosted:input_type -> state.v1.MarkOutcomePostedRequest
|
4, // 21: state.v1.TaskService.UnpostedOutcomes:input_type -> state.v1.UnpostedOutcomesRequest
|
||||||
10, // 22: state.v1.TaskService.ClaimNext:input_type -> state.v1.ClaimNextRequest
|
6, // 22: state.v1.TaskService.MarkOutcomePosted:input_type -> state.v1.MarkOutcomePostedRequest
|
||||||
12, // 23: state.v1.TaskService.ClaimByIssue:input_type -> state.v1.ClaimByIssueRequest
|
10, // 23: state.v1.TaskService.ClaimNext:input_type -> state.v1.ClaimNextRequest
|
||||||
14, // 24: state.v1.TaskService.Transition:input_type -> state.v1.TransitionRequest
|
12, // 24: state.v1.TaskService.ClaimByIssue:input_type -> state.v1.ClaimByIssueRequest
|
||||||
16, // 25: state.v1.TaskService.Update:input_type -> state.v1.UpdateRequest
|
14, // 25: state.v1.TaskService.Transition:input_type -> state.v1.TransitionRequest
|
||||||
44, // 26: state.v1.TaskService.TaskModels:input_type -> state.v1.TaskModelsRequest
|
16, // 26: state.v1.TaskService.Update:input_type -> state.v1.UpdateRequest
|
||||||
45, // 27: state.v1.TaskService.TaskInstructions:input_type -> state.v1.TaskInstructionsRequest
|
46, // 27: state.v1.TaskService.TaskModels:input_type -> state.v1.TaskModelsRequest
|
||||||
18, // 28: state.v1.TaskService.Requeue:input_type -> state.v1.RequeueRequest
|
47, // 28: state.v1.TaskService.TaskInstructions:input_type -> state.v1.TaskInstructionsRequest
|
||||||
20, // 29: state.v1.TaskService.ParkTask:input_type -> state.v1.ParkTaskRequest
|
18, // 29: state.v1.TaskService.Requeue:input_type -> state.v1.RequeueRequest
|
||||||
22, // 30: state.v1.TaskService.RecoverStale:input_type -> state.v1.RecoverStaleRequest
|
20, // 30: state.v1.TaskService.ParkTask:input_type -> state.v1.ParkTaskRequest
|
||||||
24, // 31: state.v1.TaskService.ArchiveTask:input_type -> state.v1.ArchiveTaskRequest
|
22, // 31: state.v1.TaskService.RecoverStale:input_type -> state.v1.RecoverStaleRequest
|
||||||
26, // 32: state.v1.TaskService.RetryTask:input_type -> state.v1.RetryTaskRequest
|
24, // 32: state.v1.TaskService.ArchiveTask:input_type -> state.v1.ArchiveTaskRequest
|
||||||
28, // 33: state.v1.TaskService.TaskByIssue:input_type -> state.v1.TaskByIssueRequest
|
26, // 33: state.v1.TaskService.RetryTask:input_type -> state.v1.RetryTaskRequest
|
||||||
30, // 34: state.v1.TaskService.OpenTaskByPR:input_type -> state.v1.OpenTaskByPRRequest
|
28, // 34: state.v1.TaskService.TaskByIssue:input_type -> state.v1.TaskByIssueRequest
|
||||||
32, // 35: state.v1.TaskService.TaskByID:input_type -> state.v1.TaskByIDRequest
|
30, // 35: state.v1.TaskService.OpenTaskByPR:input_type -> state.v1.OpenTaskByPRRequest
|
||||||
34, // 36: state.v1.TaskService.OpenPRs:input_type -> state.v1.OpenPRsRequest
|
32, // 36: state.v1.TaskService.TaskByID:input_type -> state.v1.TaskByIDRequest
|
||||||
36, // 37: state.v1.TaskService.ClearTerminalTasks:input_type -> state.v1.ClearTerminalTasksRequest
|
34, // 37: state.v1.TaskService.OpenPRs:input_type -> state.v1.OpenPRsRequest
|
||||||
38, // 38: state.v1.TaskService.Tasks:input_type -> state.v1.TasksRequest
|
36, // 38: state.v1.TaskService.ClearTerminalTasks:input_type -> state.v1.ClearTerminalTasksRequest
|
||||||
40, // 39: state.v1.TaskService.EnqueueCallTask:input_type -> state.v1.EnqueueCallTaskRequest
|
38, // 39: state.v1.TaskService.Tasks:input_type -> state.v1.TasksRequest
|
||||||
42, // 40: state.v1.TaskService.WorkflowCallStatus:input_type -> state.v1.WorkflowCallStatusRequest
|
40, // 40: state.v1.TaskService.EnqueueCallTask:input_type -> state.v1.EnqueueCallTaskRequest
|
||||||
1, // 41: state.v1.TaskService.EnqueueIssue:output_type -> state.v1.EnqueueIssueResponse
|
41, // 41: state.v1.TaskService.HandoffTask:input_type -> state.v1.HandoffTaskRequest
|
||||||
9, // 42: state.v1.TaskService.EnqueueChatTask:output_type -> state.v1.EnqueueChatTaskResponse
|
44, // 42: state.v1.TaskService.WorkflowCallStatus:input_type -> state.v1.WorkflowCallStatusRequest
|
||||||
3, // 43: state.v1.TaskService.ActiveTasksByOrigin:output_type -> state.v1.ActiveTasksByOriginResponse
|
1, // 43: state.v1.TaskService.EnqueueIssue:output_type -> state.v1.EnqueueIssueResponse
|
||||||
5, // 44: state.v1.TaskService.UnpostedOutcomes:output_type -> state.v1.UnpostedOutcomesResponse
|
9, // 44: state.v1.TaskService.EnqueueChatTask:output_type -> state.v1.EnqueueChatTaskResponse
|
||||||
7, // 45: state.v1.TaskService.MarkOutcomePosted:output_type -> state.v1.MarkOutcomePostedResponse
|
3, // 45: state.v1.TaskService.ActiveTasksByOrigin:output_type -> state.v1.ActiveTasksByOriginResponse
|
||||||
11, // 46: state.v1.TaskService.ClaimNext:output_type -> state.v1.ClaimNextResponse
|
5, // 46: state.v1.TaskService.UnpostedOutcomes:output_type -> state.v1.UnpostedOutcomesResponse
|
||||||
13, // 47: state.v1.TaskService.ClaimByIssue:output_type -> state.v1.ClaimByIssueResponse
|
7, // 47: state.v1.TaskService.MarkOutcomePosted:output_type -> state.v1.MarkOutcomePostedResponse
|
||||||
15, // 48: state.v1.TaskService.Transition:output_type -> state.v1.TransitionResponse
|
11, // 48: state.v1.TaskService.ClaimNext:output_type -> state.v1.ClaimNextResponse
|
||||||
17, // 49: state.v1.TaskService.Update:output_type -> state.v1.UpdateResponse
|
13, // 49: state.v1.TaskService.ClaimByIssue:output_type -> state.v1.ClaimByIssueResponse
|
||||||
47, // 50: state.v1.TaskService.TaskModels:output_type -> state.v1.TaskModelsResponse
|
15, // 50: state.v1.TaskService.Transition:output_type -> state.v1.TransitionResponse
|
||||||
46, // 51: state.v1.TaskService.TaskInstructions:output_type -> state.v1.TaskInstructionsResponse
|
17, // 51: state.v1.TaskService.Update:output_type -> state.v1.UpdateResponse
|
||||||
19, // 52: state.v1.TaskService.Requeue:output_type -> state.v1.RequeueResponse
|
49, // 52: state.v1.TaskService.TaskModels:output_type -> state.v1.TaskModelsResponse
|
||||||
21, // 53: state.v1.TaskService.ParkTask:output_type -> state.v1.ParkTaskResponse
|
48, // 53: state.v1.TaskService.TaskInstructions:output_type -> state.v1.TaskInstructionsResponse
|
||||||
23, // 54: state.v1.TaskService.RecoverStale:output_type -> state.v1.RecoverStaleResponse
|
19, // 54: state.v1.TaskService.Requeue:output_type -> state.v1.RequeueResponse
|
||||||
25, // 55: state.v1.TaskService.ArchiveTask:output_type -> state.v1.ArchiveTaskResponse
|
21, // 55: state.v1.TaskService.ParkTask:output_type -> state.v1.ParkTaskResponse
|
||||||
27, // 56: state.v1.TaskService.RetryTask:output_type -> state.v1.RetryTaskResponse
|
23, // 56: state.v1.TaskService.RecoverStale:output_type -> state.v1.RecoverStaleResponse
|
||||||
29, // 57: state.v1.TaskService.TaskByIssue:output_type -> state.v1.TaskByIssueResponse
|
25, // 57: state.v1.TaskService.ArchiveTask:output_type -> state.v1.ArchiveTaskResponse
|
||||||
31, // 58: state.v1.TaskService.OpenTaskByPR:output_type -> state.v1.OpenTaskByPRResponse
|
27, // 58: state.v1.TaskService.RetryTask:output_type -> state.v1.RetryTaskResponse
|
||||||
33, // 59: state.v1.TaskService.TaskByID:output_type -> state.v1.TaskByIDResponse
|
29, // 59: state.v1.TaskService.TaskByIssue:output_type -> state.v1.TaskByIssueResponse
|
||||||
35, // 60: state.v1.TaskService.OpenPRs:output_type -> state.v1.OpenPRsResponse
|
31, // 60: state.v1.TaskService.OpenTaskByPR:output_type -> state.v1.OpenTaskByPRResponse
|
||||||
37, // 61: state.v1.TaskService.ClearTerminalTasks:output_type -> state.v1.ClearTerminalTasksResponse
|
33, // 61: state.v1.TaskService.TaskByID:output_type -> state.v1.TaskByIDResponse
|
||||||
39, // 62: state.v1.TaskService.Tasks:output_type -> state.v1.TasksResponse
|
35, // 62: state.v1.TaskService.OpenPRs:output_type -> state.v1.OpenPRsResponse
|
||||||
41, // 63: state.v1.TaskService.EnqueueCallTask:output_type -> state.v1.EnqueueCallTaskResponse
|
37, // 63: state.v1.TaskService.ClearTerminalTasks:output_type -> state.v1.ClearTerminalTasksResponse
|
||||||
43, // 64: state.v1.TaskService.WorkflowCallStatus:output_type -> state.v1.WorkflowCallStatusResponse
|
39, // 64: state.v1.TaskService.Tasks:output_type -> state.v1.TasksResponse
|
||||||
41, // [41:65] is the sub-list for method output_type
|
43, // 65: state.v1.TaskService.EnqueueCallTask:output_type -> state.v1.EnqueueCallTaskResponse
|
||||||
17, // [17:41] is the sub-list for method input_type
|
42, // 66: state.v1.TaskService.HandoffTask:output_type -> state.v1.HandoffTaskResponse
|
||||||
17, // [17:17] is the sub-list for extension type_name
|
45, // 67: state.v1.TaskService.WorkflowCallStatus:output_type -> state.v1.WorkflowCallStatusResponse
|
||||||
17, // [17:17] is the sub-list for extension extendee
|
43, // [43:68] is the sub-list for method output_type
|
||||||
0, // [0:17] is the sub-list for field type_name
|
18, // [18:43] is the sub-list for method input_type
|
||||||
|
18, // [18:18] is the sub-list for extension type_name
|
||||||
|
18, // [18:18] is the sub-list for extension extendee
|
||||||
|
0, // [0:18] is the sub-list for field type_name
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { file_state_v1_task_proto_init() }
|
func init() { file_state_v1_task_proto_init() }
|
||||||
@@ -2964,7 +3080,7 @@ func file_state_v1_task_proto_init() {
|
|||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_state_v1_task_proto_rawDesc), len(file_state_v1_task_proto_rawDesc)),
|
RawDescriptor: unsafe.Slice(unsafe.StringData(file_state_v1_task_proto_rawDesc), len(file_state_v1_task_proto_rawDesc)),
|
||||||
NumEnums: 0,
|
NumEnums: 0,
|
||||||
NumMessages: 51,
|
NumMessages: 53,
|
||||||
NumExtensions: 0,
|
NumExtensions: 0,
|
||||||
NumServices: 1,
|
NumServices: 1,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ const (
|
|||||||
TaskService_ClearTerminalTasks_FullMethodName = "/state.v1.TaskService/ClearTerminalTasks"
|
TaskService_ClearTerminalTasks_FullMethodName = "/state.v1.TaskService/ClearTerminalTasks"
|
||||||
TaskService_Tasks_FullMethodName = "/state.v1.TaskService/Tasks"
|
TaskService_Tasks_FullMethodName = "/state.v1.TaskService/Tasks"
|
||||||
TaskService_EnqueueCallTask_FullMethodName = "/state.v1.TaskService/EnqueueCallTask"
|
TaskService_EnqueueCallTask_FullMethodName = "/state.v1.TaskService/EnqueueCallTask"
|
||||||
|
TaskService_HandoffTask_FullMethodName = "/state.v1.TaskService/HandoffTask"
|
||||||
TaskService_WorkflowCallStatus_FullMethodName = "/state.v1.TaskService/WorkflowCallStatus"
|
TaskService_WorkflowCallStatus_FullMethodName = "/state.v1.TaskService/WorkflowCallStatus"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -84,6 +85,9 @@ type TaskServiceClient interface {
|
|||||||
// (docs/prds/workflow-calls.md). CallStatus re-checks the parent-child
|
// (docs/prds/workflow-calls.md). CallStatus re-checks the parent-child
|
||||||
// relation server-side, so the grant only names the caller.
|
// relation server-side, so the grant only names the caller.
|
||||||
EnqueueCallTask(ctx context.Context, in *EnqueueCallTaskRequest, opts ...grpc.CallOption) (*EnqueueCallTaskResponse, error)
|
EnqueueCallTask(ctx context.Context, in *EnqueueCallTaskRequest, opts ...grpc.CallOption) (*EnqueueCallTaskResponse, error)
|
||||||
|
// HandoffTask completes a running run and starts its linked successor on
|
||||||
|
// the same work item under another workflow.
|
||||||
|
HandoffTask(ctx context.Context, in *HandoffTaskRequest, opts ...grpc.CallOption) (*HandoffTaskResponse, error)
|
||||||
WorkflowCallStatus(ctx context.Context, in *WorkflowCallStatusRequest, opts ...grpc.CallOption) (*WorkflowCallStatusResponse, error)
|
WorkflowCallStatus(ctx context.Context, in *WorkflowCallStatusRequest, opts ...grpc.CallOption) (*WorkflowCallStatusResponse, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -325,6 +329,16 @@ func (c *taskServiceClient) EnqueueCallTask(ctx context.Context, in *EnqueueCall
|
|||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *taskServiceClient) HandoffTask(ctx context.Context, in *HandoffTaskRequest, opts ...grpc.CallOption) (*HandoffTaskResponse, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(HandoffTaskResponse)
|
||||||
|
err := c.cc.Invoke(ctx, TaskService_HandoffTask_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (c *taskServiceClient) WorkflowCallStatus(ctx context.Context, in *WorkflowCallStatusRequest, opts ...grpc.CallOption) (*WorkflowCallStatusResponse, error) {
|
func (c *taskServiceClient) WorkflowCallStatus(ctx context.Context, in *WorkflowCallStatusRequest, opts ...grpc.CallOption) (*WorkflowCallStatusResponse, error) {
|
||||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
out := new(WorkflowCallStatusResponse)
|
out := new(WorkflowCallStatusResponse)
|
||||||
@@ -374,6 +388,9 @@ type TaskServiceServer interface {
|
|||||||
// (docs/prds/workflow-calls.md). CallStatus re-checks the parent-child
|
// (docs/prds/workflow-calls.md). CallStatus re-checks the parent-child
|
||||||
// relation server-side, so the grant only names the caller.
|
// relation server-side, so the grant only names the caller.
|
||||||
EnqueueCallTask(context.Context, *EnqueueCallTaskRequest) (*EnqueueCallTaskResponse, error)
|
EnqueueCallTask(context.Context, *EnqueueCallTaskRequest) (*EnqueueCallTaskResponse, error)
|
||||||
|
// HandoffTask completes a running run and starts its linked successor on
|
||||||
|
// the same work item under another workflow.
|
||||||
|
HandoffTask(context.Context, *HandoffTaskRequest) (*HandoffTaskResponse, error)
|
||||||
WorkflowCallStatus(context.Context, *WorkflowCallStatusRequest) (*WorkflowCallStatusResponse, error)
|
WorkflowCallStatus(context.Context, *WorkflowCallStatusRequest) (*WorkflowCallStatusResponse, error)
|
||||||
mustEmbedUnimplementedTaskServiceServer()
|
mustEmbedUnimplementedTaskServiceServer()
|
||||||
}
|
}
|
||||||
@@ -454,6 +471,9 @@ func (UnimplementedTaskServiceServer) Tasks(context.Context, *TasksRequest) (*Ta
|
|||||||
func (UnimplementedTaskServiceServer) EnqueueCallTask(context.Context, *EnqueueCallTaskRequest) (*EnqueueCallTaskResponse, error) {
|
func (UnimplementedTaskServiceServer) EnqueueCallTask(context.Context, *EnqueueCallTaskRequest) (*EnqueueCallTaskResponse, error) {
|
||||||
return nil, status.Error(codes.Unimplemented, "method EnqueueCallTask not implemented")
|
return nil, status.Error(codes.Unimplemented, "method EnqueueCallTask not implemented")
|
||||||
}
|
}
|
||||||
|
func (UnimplementedTaskServiceServer) HandoffTask(context.Context, *HandoffTaskRequest) (*HandoffTaskResponse, error) {
|
||||||
|
return nil, status.Error(codes.Unimplemented, "method HandoffTask not implemented")
|
||||||
|
}
|
||||||
func (UnimplementedTaskServiceServer) WorkflowCallStatus(context.Context, *WorkflowCallStatusRequest) (*WorkflowCallStatusResponse, error) {
|
func (UnimplementedTaskServiceServer) WorkflowCallStatus(context.Context, *WorkflowCallStatusRequest) (*WorkflowCallStatusResponse, error) {
|
||||||
return nil, status.Error(codes.Unimplemented, "method WorkflowCallStatus not implemented")
|
return nil, status.Error(codes.Unimplemented, "method WorkflowCallStatus not implemented")
|
||||||
}
|
}
|
||||||
@@ -892,6 +912,24 @@ func _TaskService_EnqueueCallTask_Handler(srv interface{}, ctx context.Context,
|
|||||||
return interceptor(ctx, in, info, handler)
|
return interceptor(ctx, in, info, handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func _TaskService_HandoffTask_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(HandoffTaskRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(TaskServiceServer).HandoffTask(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: TaskService_HandoffTask_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(TaskServiceServer).HandoffTask(ctx, req.(*HandoffTaskRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
func _TaskService_WorkflowCallStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
func _TaskService_WorkflowCallStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
in := new(WorkflowCallStatusRequest)
|
in := new(WorkflowCallStatusRequest)
|
||||||
if err := dec(in); err != nil {
|
if err := dec(in); err != nil {
|
||||||
@@ -1009,6 +1047,10 @@ var TaskService_ServiceDesc = grpc.ServiceDesc{
|
|||||||
MethodName: "EnqueueCallTask",
|
MethodName: "EnqueueCallTask",
|
||||||
Handler: _TaskService_EnqueueCallTask_Handler,
|
Handler: _TaskService_EnqueueCallTask_Handler,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
MethodName: "HandoffTask",
|
||||||
|
Handler: _TaskService_HandoffTask_Handler,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
MethodName: "WorkflowCallStatus",
|
MethodName: "WorkflowCallStatus",
|
||||||
Handler: _TaskService_WorkflowCallStatus_Handler,
|
Handler: _TaskService_WorkflowCallStatus_Handler,
|
||||||
|
|||||||
@@ -229,9 +229,13 @@ type Task struct {
|
|||||||
// recorded at the park site; empty when the park has no known fix.
|
// recorded at the park site; empty when the park has no known fix.
|
||||||
ParkBlocker string `protobuf:"bytes,48,opt,name=park_blocker,json=parkBlocker,proto3" json:"park_blocker,omitempty"`
|
ParkBlocker string `protobuf:"bytes,48,opt,name=park_blocker,json=parkBlocker,proto3" json:"park_blocker,omitempty"`
|
||||||
// plan_document is the structured plan (JSON) plan was rendered from.
|
// plan_document is the structured plan (JSON) plan was rendered from.
|
||||||
PlanDocument string `protobuf:"bytes,50,opt,name=plan_document,json=planDocument,proto3" json:"plan_document,omitempty"`
|
PlanDocument string `protobuf:"bytes,50,opt,name=plan_document,json=planDocument,proto3" json:"plan_document,omitempty"`
|
||||||
unknownFields protoimpl.UnknownFields
|
// handoff_from_task_id is the run that handed off to this one; 0 when none.
|
||||||
sizeCache protoimpl.SizeCache
|
HandoffFromTaskId int64 `protobuf:"varint,51,opt,name=handoff_from_task_id,json=handoffFromTaskId,proto3" json:"handoff_from_task_id,omitempty"`
|
||||||
|
// handoff_to_task_id is the run this one handed off to; 0 when none.
|
||||||
|
HandoffToTaskId int64 `protobuf:"varint,52,opt,name=handoff_to_task_id,json=handoffToTaskId,proto3" json:"handoff_to_task_id,omitempty"`
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Task) Reset() {
|
func (x *Task) Reset() {
|
||||||
@@ -608,6 +612,20 @@ func (x *Task) GetPlanDocument() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (x *Task) GetHandoffFromTaskId() int64 {
|
||||||
|
if x != nil {
|
||||||
|
return x.HandoffFromTaskId
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *Task) GetHandoffToTaskId() int64 {
|
||||||
|
if x != nil {
|
||||||
|
return x.HandoffToTaskId
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
// Event mirrors internal/events.Event. Data is carried as a JSON object
|
// Event mirrors internal/events.Event. Data is carried as a JSON object
|
||||||
// string (matching the store's own on-disk representation) rather than
|
// string (matching the store's own on-disk representation) rather than
|
||||||
// google.protobuf.Struct, to stay a direct mirror of the existing column.
|
// google.protobuf.Struct, to stay a direct mirror of the existing column.
|
||||||
@@ -784,7 +802,7 @@ const file_state_v1_types_proto_rawDesc = "" +
|
|||||||
"\n" +
|
"\n" +
|
||||||
"created_at\x18\x06 \x01(\v2\x1a.google.protobuf.TimestampR\tcreatedAt\x129\n" +
|
"created_at\x18\x06 \x01(\v2\x1a.google.protobuf.TimestampR\tcreatedAt\x129\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"updated_at\x18\a \x01(\v2\x1a.google.protobuf.TimestampR\tupdatedAt\"\x91\r\n" +
|
"updated_at\x18\a \x01(\v2\x1a.google.protobuf.TimestampR\tupdatedAt\"\xef\r\n" +
|
||||||
"\x04Task\x12\x0e\n" +
|
"\x04Task\x12\x0e\n" +
|
||||||
"\x02id\x18\x01 \x01(\x03R\x02id\x12\x14\n" +
|
"\x02id\x18\x01 \x01(\x03R\x02id\x12\x14\n" +
|
||||||
"\x05owner\x18\x02 \x01(\tR\x05owner\x12\x12\n" +
|
"\x05owner\x18\x02 \x01(\tR\x05owner\x12\x12\n" +
|
||||||
@@ -849,7 +867,9 @@ const file_state_v1_types_proto_rawDesc = "" +
|
|||||||
"\x11binding_signature\x18. \x01(\tR\x10bindingSignature\x12!\n" +
|
"\x11binding_signature\x18. \x01(\tR\x10bindingSignature\x12!\n" +
|
||||||
"\fbinding_addr\x18/ \x01(\tR\vbindingAddr\x12!\n" +
|
"\fbinding_addr\x18/ \x01(\tR\vbindingAddr\x12!\n" +
|
||||||
"\fpark_blocker\x180 \x01(\tR\vparkBlocker\x12#\n" +
|
"\fpark_blocker\x180 \x01(\tR\vparkBlocker\x12#\n" +
|
||||||
"\rplan_document\x182 \x01(\tR\fplanDocumentJ\x04\b1\x102R\tplan_view\"\xf8\x02\n" +
|
"\rplan_document\x182 \x01(\tR\fplanDocument\x12/\n" +
|
||||||
|
"\x14handoff_from_task_id\x183 \x01(\x03R\x11handoffFromTaskId\x12+\n" +
|
||||||
|
"\x12handoff_to_task_id\x184 \x01(\x03R\x0fhandoffToTaskIdJ\x04\b1\x102R\tplan_view\"\xf8\x02\n" +
|
||||||
"\x05Event\x12\x0e\n" +
|
"\x05Event\x12\x0e\n" +
|
||||||
"\x02id\x18\x01 \x01(\x03R\x02id\x12*\n" +
|
"\x02id\x18\x01 \x01(\x03R\x02id\x12*\n" +
|
||||||
"\x02at\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\x02at\x12\x12\n" +
|
"\x02at\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\x02at\x12\x12\n" +
|
||||||
|
|||||||
@@ -887,6 +887,7 @@ func (d *Daemon) drainNATS(ctx context.Context) {
|
|||||||
}
|
}
|
||||||
if err == nil {
|
if err == nil {
|
||||||
d.submitNATSTask(ctx, dispatcher, msg)
|
d.submitNATSTask(ctx, dispatcher, msg)
|
||||||
|
d.markPass("drain")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -894,15 +895,26 @@ func (d *Daemon) drainNATS(ctx context.Context) {
|
|||||||
// the SQLite fallback must run: requeued tasks (waiting_approval
|
// the SQLite fallback must run: requeued tasks (waiting_approval
|
||||||
// approval, retry-parked) never went through a NATS publish, so
|
// approval, retry-parked) never went through a NATS publish, so
|
||||||
// nothing will ever arrive on the stream to trigger them.
|
// nothing will ever arrive on the stream to trigger them.
|
||||||
task, claimErr := d.Store.ClaimNext(ctx)
|
d.claimRequeued(ctx, dispatcher)
|
||||||
if claimErr != nil {
|
return
|
||||||
d.Log.ErrorContext(ctx, "sqlite claim failed", "err", claimErr)
|
}
|
||||||
break
|
}
|
||||||
|
|
||||||
|
// claimRequeued submits every task the store's claim fallback holds. It does
|
||||||
|
// not go back to the stream between claims: each empty fetch waits a full poll
|
||||||
|
// timeout, so a backlog left by a restart would outlast the systemd watchdog.
|
||||||
|
func (d *Daemon) claimRequeued(ctx context.Context, dispatcher *taskDispatcher) {
|
||||||
|
for ctx.Err() == nil {
|
||||||
|
task, err := d.Store.ClaimNext(ctx)
|
||||||
|
if err != nil {
|
||||||
|
d.Log.ErrorContext(ctx, "sqlite claim failed", "err", err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
if task == nil {
|
if task == nil {
|
||||||
break
|
return
|
||||||
}
|
}
|
||||||
dispatcher.Submit(ctx, task, d.process)
|
dispatcher.Submit(ctx, task, d.process)
|
||||||
|
d.markPass("drain")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1753,7 +1765,9 @@ func (d *Daemon) cleanupTerminalTaskWorktree(ctx context.Context, task *workflow
|
|||||||
d.Log.WarnContext(ctx, "terminal worktree cleanup task lookup failed", "task", task.ID, "err", err)
|
d.Log.WarnContext(ctx, "terminal worktree cleanup task lookup failed", "task", task.ID, "err", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if latest == nil {
|
// A run that handed off shares its work item's worktree with its
|
||||||
|
// successor, which owns it from here.
|
||||||
|
if latest == nil || latest.HandoffToTaskID != 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Settled statuses. Keep the worktree while a PR exists.
|
// Settled statuses. Keep the worktree while a PR exists.
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"log/slog"
|
"log/slog"
|
||||||
"runtime"
|
"runtime"
|
||||||
"sync"
|
"sync"
|
||||||
|
"sync/atomic"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -573,3 +574,55 @@ func TestDrainPassDoesNotWaitForItsTasks(t *testing.T) {
|
|||||||
t.Fatal("WaitForTasks did not return after the task finished")
|
t.Fatal("WaitForTasks did not return after the task finished")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// countingTasks is an empty stream that counts how often a pass waits on it.
|
||||||
|
type countingTasks struct {
|
||||||
|
stubTasks
|
||||||
|
fetches atomic.Int32
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *countingTasks) Fetch(context.Context) (eventbus.Message, error) {
|
||||||
|
c.fetches.Add(1)
|
||||||
|
return nil, eventbus.ErrNoMessage
|
||||||
|
}
|
||||||
|
|
||||||
|
// queuedStore hands out its queue of claimed tasks one at a time.
|
||||||
|
type queuedStore struct {
|
||||||
|
stubStore
|
||||||
|
queue []*workflow.Task
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *queuedStore) ClaimNext(context.Context) (*workflow.Task, error) {
|
||||||
|
if len(s.queue) == 0 {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
task := s.queue[0]
|
||||||
|
s.queue = s.queue[1:]
|
||||||
|
return task, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// A backlog of requeued tasks is claimed without waiting on the empty stream
|
||||||
|
// between claims. Each wait is a full poll timeout, so after a restart left
|
||||||
|
// fourteen tasks running the first pass outlasted the systemd watchdog and
|
||||||
|
// archied was killed.
|
||||||
|
func TestDrainPassClaimsABacklogWithoutWaitingPerTask(t *testing.T) {
|
||||||
|
store := &queuedStore{park: func() {}}
|
||||||
|
for id := range int64(5) {
|
||||||
|
store.queue = append(store.queue, &workflow.Task{ID: id + 1, Owner: "acme", Repo: "app"})
|
||||||
|
}
|
||||||
|
tasks := &countingTasks{}
|
||||||
|
d := &Daemon{
|
||||||
|
Cfg: config.NewHolder(config.Config{}),
|
||||||
|
Log: slog.New(slog.DiscardHandler),
|
||||||
|
Store: store,
|
||||||
|
Tasks: tasks,
|
||||||
|
}
|
||||||
|
d.drainNATS(context.Background())
|
||||||
|
d.WaitForTasks()
|
||||||
|
if len(store.queue) != 0 {
|
||||||
|
t.Fatalf("%d tasks left unclaimed", len(store.queue))
|
||||||
|
}
|
||||||
|
if got := tasks.fetches.Load(); got != 1 {
|
||||||
|
t.Fatalf("the pass waited on the stream %d times for 5 claims, want 1", got)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -76,7 +76,7 @@ func mustKey(encoded string) ed25519.PublicKey {
|
|||||||
func DefaultCatalogue() Source {
|
func DefaultCatalogue() Source {
|
||||||
return Source{
|
return Source{
|
||||||
Reference: "git.catlow.cloud/sam/archipelago/catalogue",
|
Reference: "git.catlow.cloud/sam/archipelago/catalogue",
|
||||||
Key: mustKey("YL4nvn07uq/5mXZOt9cEmLYu/kB6C2+MLTnbHyoX4Pw="),
|
Key: mustKey("PLouShOzvRqy1QbYaJplaM41/ulgKFN8ZQ7g1rI02Fc="),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ type handoffSettings struct {
|
|||||||
Detail string `yaml:"detail" doc:"Why the task was handed off."`
|
Detail string `yaml:"detail" doc:"Why the task was handed off."`
|
||||||
}
|
}
|
||||||
|
|
||||||
// newHandoffStage requeues the task under another workflow: the same task,
|
// newHandoffStage completes the run and starts a linked run of another
|
||||||
// not a child run, so its history stays in one place.
|
// workflow on the same work item.
|
||||||
func newHandoffStage(settings yaml.Node) (Stage, error) {
|
func newHandoffStage(settings yaml.Node) (Stage, error) {
|
||||||
s, err := decodeSettings[handoffSettings](HandoffStepName, settings)
|
s, err := decodeSettings[handoffSettings](HandoffStepName, settings)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -47,8 +47,7 @@ func newHandoffStage(settings yaml.Node) (Stage, error) {
|
|||||||
return Stage{}, fmt.Errorf("%s: settings.workflow is required", HandoffStepName)
|
return Stage{}, fmt.Errorf("%s: settings.workflow is required", HandoffStepName)
|
||||||
}
|
}
|
||||||
return Stage{Name: HandoffStepName, Run: func(_ context.Context, tc *TaskContext) error {
|
return Stage{Name: HandoffStepName, Run: func(_ context.Context, tc *TaskContext) error {
|
||||||
tc.Task.Workflow = strings.TrimSpace(s.Workflow)
|
tc.Outcome = Outcome{Status: StatusCompleted, Detail: s.Detail, Handoff: strings.TrimSpace(s.Workflow)}
|
||||||
tc.Outcome = Outcome{Status: StatusQueued, Detail: s.Detail}
|
|
||||||
return nil
|
return nil
|
||||||
}}, nil
|
}}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -387,3 +387,37 @@ func hasStepType(node any, types []string) bool {
|
|||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RepairDefinitionCollection rebuilds a stored collection that no longer
|
||||||
|
// validates, keeping every entry it can: a valid entry is kept, an invalid
|
||||||
|
// shipped entry is replaced by this build's copy, and any other invalid or
|
||||||
|
// duplicate entry is removed and its id returned. An unreadable document or a
|
||||||
|
// repair that still fails validation is an error.
|
||||||
|
func RepairDefinitionCollection(value []byte, registry StepRegistry) (WorkflowDefinitionCollection, []string, error) {
|
||||||
|
var stored WorkflowDefinitionCollection
|
||||||
|
if err := json.Unmarshal(value, &stored); err != nil {
|
||||||
|
return WorkflowDefinitionCollection{}, nil, err
|
||||||
|
}
|
||||||
|
shipped := ShippedDefinitions()
|
||||||
|
seen := make(map[string]struct{}, len(stored.Definitions))
|
||||||
|
var repaired WorkflowDefinitionCollection
|
||||||
|
var removed []string
|
||||||
|
for _, entry := range stored.Definitions {
|
||||||
|
if _, dup := seen[entry.ID]; dup {
|
||||||
|
removed = append(removed, entry.ID)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
seen[entry.ID] = struct{}{}
|
||||||
|
if definition, err := ParseDefinition(entry.YAML, registry); err == nil && definition.ID == entry.ID {
|
||||||
|
repaired.Definitions = append(repaired.Definitions, entry)
|
||||||
|
} else if factory, ok := shipped.DefinitionByID(entry.ID); ok {
|
||||||
|
repaired.Definitions = append(repaired.Definitions, factory)
|
||||||
|
} else {
|
||||||
|
removed = append(removed, entry.ID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err := ValidateDefinitionCollection(repaired, registry); err != nil {
|
||||||
|
return WorkflowDefinitionCollection{}, nil, err
|
||||||
|
}
|
||||||
|
return repaired, removed, nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
package workflow
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"slices"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
// A stored collection that stopped validating keeps every entry it can: valid
|
||||||
|
// entries stay, a broken shipped entry is restored, a broken custom one goes.
|
||||||
|
func TestRepairDefinitionCollection(t *testing.T) {
|
||||||
|
shipped, _ := ShippedDefinitions().DefinitionByID("triage")
|
||||||
|
custom := strings.Replace(shipped.YAML, "id: triage", "id: mine", 1)
|
||||||
|
edited := shipped.YAML + "\n# edited by the operator\n"
|
||||||
|
broken := "id: broken\nsteps:\n - id: a\n type: removed.step\n"
|
||||||
|
// with is the shipped set with triage's YAML swapped and extra appended.
|
||||||
|
with := func(triage string, extra ...WorkflowDefinitionEntry) ([]WorkflowDefinitionEntry, map[string]string) {
|
||||||
|
entries, byID := []WorkflowDefinitionEntry{}, map[string]string{}
|
||||||
|
for _, entry := range ShippedDefinitions().Definitions {
|
||||||
|
if entry.ID == "triage" {
|
||||||
|
entry.YAML = triage
|
||||||
|
}
|
||||||
|
entries = append(entries, entry)
|
||||||
|
byID[entry.ID] = entry.YAML
|
||||||
|
}
|
||||||
|
for _, entry := range extra {
|
||||||
|
entries = append(entries, entry)
|
||||||
|
byID[entry.ID] = entry.YAML
|
||||||
|
}
|
||||||
|
return entries, byID
|
||||||
|
}
|
||||||
|
restoredStored, _ := with(broken, WorkflowDefinitionEntry{ID: "mine", YAML: custom})
|
||||||
|
_, restoredWant := with(shipped.YAML, WorkflowDefinitionEntry{ID: "mine", YAML: custom})
|
||||||
|
editedStored, _ := with(edited, WorkflowDefinitionEntry{ID: "broken", YAML: broken})
|
||||||
|
_, editedWant := with(edited)
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
stored []WorkflowDefinitionEntry
|
||||||
|
want map[string]string
|
||||||
|
wantRemoved []string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "broken shipped entry is restored, custom kept",
|
||||||
|
stored: restoredStored,
|
||||||
|
want: restoredWant,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "broken custom entry is removed, edited shipped kept",
|
||||||
|
stored: editedStored,
|
||||||
|
want: editedWant,
|
||||||
|
wantRemoved: []string{"broken"},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
value, err := json.Marshal(WorkflowDefinitionCollection{Definitions: tt.stored})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
got, removed, err := RepairDefinitionCollection(value, triageRegistry())
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
byID := map[string]string{}
|
||||||
|
for _, entry := range got.Definitions {
|
||||||
|
byID[entry.ID] = entry.YAML
|
||||||
|
}
|
||||||
|
if len(byID) != len(tt.want) {
|
||||||
|
t.Fatalf("kept %d entries, want %d", len(byID), len(tt.want))
|
||||||
|
}
|
||||||
|
for id, yaml := range tt.want {
|
||||||
|
if byID[id] != yaml {
|
||||||
|
t.Errorf("entry %q not kept as expected", id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !slices.Equal(removed, tt.wantRemoved) {
|
||||||
|
t.Errorf("removed %v, want %v", removed, tt.wantRemoved)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -113,7 +113,7 @@ func runRepoTooling(ctx context.Context, tc *TaskContext) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type repoCommitSettings struct {
|
type repoCommitSettings struct {
|
||||||
Message string `yaml:"message" doc:"The commit message."`
|
Message string `yaml:"message" doc:"The commit message. Hooks in the checkout never run, so commit-message policy (commitlint, DCO) is not applied."`
|
||||||
// Reference is the verb that links the commit to the task's issue
|
// Reference is the verb that links the commit to the task's issue
|
||||||
// ("Fixes", "Implements", "Refs"); empty links nothing.
|
// ("Fixes", "Implements", "Refs"); empty links nothing.
|
||||||
Reference string `yaml:"reference" enum:"Fixes,Implements,Refs" doc:"How the commit links to the task issue."`
|
Reference string `yaml:"reference" enum:"Fixes,Implements,Refs" doc:"How the commit links to the task issue."`
|
||||||
|
|||||||
@@ -16,4 +16,8 @@ type Caller interface {
|
|||||||
// call_parent_task_id is callerTaskID, so a caller reads only its own
|
// call_parent_task_id is callerTaskID, so a caller reads only its own
|
||||||
// callees.
|
// callees.
|
||||||
CallStatus(ctx context.Context, callerTaskID, callTaskID int64) (status, detail string, outputs map[string]any, err error)
|
CallStatus(ctx context.Context, callerTaskID, callTaskID int64) (status, detail string, outputs map[string]any, err error)
|
||||||
|
// Handoff completes the running task fromTaskID with detail and starts
|
||||||
|
// its linked successor on the same work item under workflow, returning
|
||||||
|
// the successor.
|
||||||
|
Handoff(ctx context.Context, fromTaskID int64, workflow, detail string) (*Task, error)
|
||||||
}
|
}
|
||||||
@@ -141,6 +141,10 @@ type Task struct {
|
|||||||
// one; 0 on a root run. A caller reads only the tasks it started,
|
// one; 0 on a root run. A caller reads only the tasks it started,
|
||||||
// through WorkflowCallStatus.
|
// through WorkflowCallStatus.
|
||||||
CallParentTaskID int64 `json:"call_parent_task_id,omitempty"`
|
CallParentTaskID int64 `json:"call_parent_task_id,omitempty"`
|
||||||
|
// HandoffFromTaskID is the run whose workflow.handoff started this one,
|
||||||
|
// and HandoffToTaskID the run this one handed off to; 0 when none.
|
||||||
|
HandoffFromTaskID int64 `json:"handoff_from_task_id,omitempty"`
|
||||||
|
HandoffToTaskID int64 `json:"handoff_to_task_id,omitempty"`
|
||||||
// CallDepth counts workflow.call hops from the root run. The engine
|
// CallDepth counts workflow.call hops from the root run. The engine
|
||||||
// refuses a call past workflow.MaxCallDepth, and the store re-checks on
|
// refuses a call past workflow.MaxCallDepth, and the store re-checks on
|
||||||
// insert, so no enqueue path can pass the limit.
|
// insert, so no enqueue path can pass the limit.
|
||||||
|
|||||||
@@ -279,6 +279,9 @@ func transcriptData(entry agentrun.TranscriptEntry) (map[string]any, error) {
|
|||||||
type Outcome struct {
|
type Outcome struct {
|
||||||
Status string // Status* value; empty = continue to next stage
|
Status string // Status* value; empty = continue to next stage
|
||||||
Detail string // park reason / close rationale / PR body context
|
Detail string // park reason / close rationale / PR body context
|
||||||
|
// Handoff names the workflow a linked successor run starts under once
|
||||||
|
// this run completes; empty starts none.
|
||||||
|
Handoff string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stage is one named step. Returning an error parks the task with the
|
// Stage is one named step. Returning an error parks the task with the
|
||||||
@@ -507,6 +510,26 @@ func publishEvent(ctx context.Context, tc *TaskContext, e events.Event) {
|
|||||||
tc.Bus.Publish(ctx, e)
|
tc.Bus.Publish(ctx, e)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handoff completes the run and starts its linked successor in one store
|
||||||
|
// write, so the work item keeps exactly one current run.
|
||||||
|
func handoff(ctx context.Context, tc *TaskContext, log *slog.Logger) {
|
||||||
|
if tc.Calls == nil {
|
||||||
|
park(ctx, tc, "workflow.handoff: this runner cannot start a linked run")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
next, err := tc.Calls.Handoff(ctx, tc.Task.ID, tc.Outcome.Handoff, tc.Outcome.Detail)
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorContext(ctx, "workflow handoff failed", "err", err)
|
||||||
|
park(ctx, tc, fmt.Sprintf("workflow.handoff to %s: %v", tc.Outcome.Handoff, err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
tc.Task.HandoffToTaskID = next.ID
|
||||||
|
tc.Emit(ctx, events.KindOutcome, tc.Stage, tc.Outcome.Detail, map[string]any{
|
||||||
|
"status": tc.Outcome.Status, "handoff_task_id": next.ID, "workflow": tc.Outcome.Handoff,
|
||||||
|
})
|
||||||
|
log.InfoContext(ctx, "workflow handed off", "workflow", tc.Outcome.Handoff, "task", next.ID)
|
||||||
|
}
|
||||||
|
|
||||||
func finish(ctx context.Context, tc *TaskContext, log *slog.Logger) {
|
func finish(ctx context.Context, tc *TaskContext, log *slog.Logger) {
|
||||||
t := tc.Task
|
t := tc.Task
|
||||||
if tc.Outcome.Status == StatusParked {
|
if tc.Outcome.Status == StatusParked {
|
||||||
@@ -525,6 +548,10 @@ func finish(ctx context.Context, tc *TaskContext, log *slog.Logger) {
|
|||||||
park(ctx, tc, fmt.Sprintf("persist workflow outcome: %v", err))
|
park(ctx, tc, fmt.Sprintf("persist workflow outcome: %v", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if tc.Outcome.Handoff != "" {
|
||||||
|
handoff(ctx, tc, log)
|
||||||
|
return
|
||||||
|
}
|
||||||
if err := tc.Store.Transition(ctx, t.ID, StatusRunning, tc.Outcome.Status, tc.Outcome.Detail); err != nil {
|
if err := tc.Store.Transition(ctx, t.ID, StatusRunning, tc.Outcome.Status, tc.Outcome.Detail); err != nil {
|
||||||
log.ErrorContext(ctx, "workflow outcome transition failed", "err", err)
|
log.ErrorContext(ctx, "workflow outcome transition failed", "err", err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -37,6 +37,10 @@ func (c *callSpy) StartCall(_ context.Context, callerTaskID int64, callKey, _ st
|
|||||||
return child, nil
|
return child, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *callSpy) Handoff(context.Context, int64, string, string) (*task.Task, error) {
|
||||||
|
return nil, errors.New("no handoff")
|
||||||
|
}
|
||||||
|
|
||||||
func (c *callSpy) CallStatus(context.Context, int64, int64) (string, string, map[string]any, error) {
|
func (c *callSpy) CallStatus(context.Context, int64, int64) (string, string, map[string]any, error) {
|
||||||
return StatusCompleted, "", nil, nil
|
return StatusCompleted, "", nil, nil
|
||||||
}
|
}
|
||||||
@@ -384,6 +388,10 @@ func (c *wobblyCaller) StartCall(_ context.Context, callerTaskID int64, _, _ str
|
|||||||
return &task.Task{ID: 42, CallParentTaskID: callerTaskID}, nil
|
return &task.Task{ID: 42, CallParentTaskID: callerTaskID}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *wobblyCaller) Handoff(context.Context, int64, string, string) (*task.Task, error) {
|
||||||
|
return nil, errors.New("no handoff")
|
||||||
|
}
|
||||||
|
|
||||||
func (c *wobblyCaller) CallStatus(context.Context, int64, int64) (string, string, map[string]any, error) {
|
func (c *wobblyCaller) CallStatus(context.Context, int64, int64) (string, string, map[string]any, error) {
|
||||||
c.mu.Lock()
|
c.mu.Lock()
|
||||||
defer c.mu.Unlock()
|
defer c.mu.Unlock()
|
||||||
|
|||||||
@@ -193,6 +193,12 @@ func (d deadlineCaller) StartCall(ctx context.Context, callerTaskID int64, callK
|
|||||||
return d.Caller.StartCall(ctx, callerTaskID, callKey, wf, inputs)
|
return d.Caller.StartCall(ctx, callerTaskID, callKey, wf, inputs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d deadlineCaller) Handoff(ctx context.Context, fromTaskID int64, wf, detail string) (*task.Task, error) {
|
||||||
|
ctx, cancel := d.withDeadline(ctx)
|
||||||
|
defer cancel()
|
||||||
|
return d.Caller.Handoff(ctx, fromTaskID, wf, detail)
|
||||||
|
}
|
||||||
|
|
||||||
func (d deadlineCaller) CallStatus(ctx context.Context, callerTaskID, callTaskID int64) (string, string, map[string]any, error) {
|
func (d deadlineCaller) CallStatus(ctx context.Context, callerTaskID, callTaskID int64) (string, string, map[string]any, error) {
|
||||||
ctx, cancel := d.withDeadline(ctx)
|
ctx, cancel := d.withDeadline(ctx)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|||||||
@@ -221,7 +221,7 @@ func (s *Server) resource(ctx context.Context, orgID, kind string) (storecontrac
|
|||||||
}
|
}
|
||||||
return resource, err
|
return resource, err
|
||||||
}
|
}
|
||||||
if _, err := s.seedKind(ctx, orgID, s.definitions[kind], config.Config{}); err != nil && !errors.Is(err, storecontract.ErrResourceVersionConflict) {
|
if _, _, err := s.seedKind(ctx, orgID, s.definitions[kind], config.Config{}); err != nil && !errors.Is(err, storecontract.ErrResourceVersionConflict) {
|
||||||
return storecontract.Resource{}, err
|
return storecontract.Resource{}, err
|
||||||
}
|
}
|
||||||
return s.store.Resource(ctx, orgID, kind)
|
return s.store.Resource(ctx, orgID, kind)
|
||||||
|
|||||||
@@ -28,6 +28,10 @@ type Definition struct {
|
|||||||
// Defaults is the factory value clients offer as "restore shipped". Only
|
// Defaults is the factory value clients offer as "restore shipped". Only
|
||||||
// resources that ship with content set it.
|
// resources that ship with content set it.
|
||||||
Defaults func() any
|
Defaults func() any
|
||||||
|
// Repair rebuilds a stored value this build no longer accepts, keeping what
|
||||||
|
// it can, and names what it removed. Nil means an invalid stored value of a
|
||||||
|
// shipped kind is replaced by the seed.
|
||||||
|
Repair func(stored []byte) (value []byte, removed []string, err error)
|
||||||
// SchemaExtensions are merged into the derived schema's top level, for
|
// SchemaExtensions are merged into the derived schema's top level, for
|
||||||
// vocabulary the document type alone cannot express.
|
// vocabulary the document type alone cannot express.
|
||||||
SchemaExtensions map[string]any
|
SchemaExtensions map[string]any
|
||||||
@@ -73,6 +77,9 @@ func (d Definition) Decode(input []byte) ([]byte, error) {
|
|||||||
type SeedSkip struct {
|
type SeedSkip struct {
|
||||||
Kind string
|
Kind string
|
||||||
Err error
|
Err error
|
||||||
|
// Removed names entries a repair dropped from a stored value; Err is nil
|
||||||
|
// then, because the kind was written.
|
||||||
|
Removed []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// seedActor is the audit identity seeds write under.
|
// seedActor is the audit identity seeds write under.
|
||||||
@@ -89,7 +96,10 @@ func (s *Server) ImportConfig(ctx context.Context, cfg config.Config) (map[strin
|
|||||||
versions := make(map[string]int64, len(s.ordered))
|
versions := make(map[string]int64, len(s.ordered))
|
||||||
var skipped []SeedSkip
|
var skipped []SeedSkip
|
||||||
for _, definition := range s.ordered {
|
for _, definition := range s.ordered {
|
||||||
version, err := s.seedKind(ctx, storecontract.DefaultOrgID, definition, cfg)
|
version, removed, err := s.seedKind(ctx, storecontract.DefaultOrgID, definition, cfg)
|
||||||
|
if len(removed) > 0 {
|
||||||
|
skipped = append(skipped, SeedSkip{Kind: definition.Kind, Removed: removed})
|
||||||
|
}
|
||||||
var refusal *seedRefusal
|
var refusal *seedRefusal
|
||||||
switch {
|
switch {
|
||||||
case errors.As(err, &refusal):
|
case errors.As(err, &refusal):
|
||||||
@@ -108,9 +118,13 @@ func (s *Server) ImportConfig(ctx context.Context, cfg config.Config) (map[strin
|
|||||||
if resource.OrgID == storecontract.DefaultOrgID || resource.Kind != WorkflowDefinitionsKind {
|
if resource.OrgID == storecontract.DefaultOrgID || resource.Kind != WorkflowDefinitionsKind {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if _, err := s.seedKind(ctx, resource.OrgID, s.definitions[resource.Kind], config.Config{}); err != nil {
|
_, removed, err := s.seedKind(ctx, resource.OrgID, s.definitions[resource.Kind], config.Config{})
|
||||||
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
if len(removed) > 0 {
|
||||||
|
skipped = append(skipped, SeedSkip{Kind: resource.Kind, Removed: removed})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return versions, skipped, nil
|
return versions, skipped, nil
|
||||||
}
|
}
|
||||||
@@ -127,30 +141,32 @@ func (r *seedRefusal) Unwrap() error { return r.err }
|
|||||||
|
|
||||||
// seedKind seeds, refreshes or leaves one kind and returns its version. A
|
// seedKind seeds, refreshes or leaves one kind and returns its version. A
|
||||||
// *seedRefusal means the seed failed validation and nothing was written.
|
// *seedRefusal means the seed failed validation and nothing was written.
|
||||||
func (s *Server) seedKind(ctx context.Context, orgID string, definition Definition, cfg config.Config) (int64, error) {
|
func (s *Server) seedKind(ctx context.Context, orgID string, definition Definition, cfg config.Config) (int64, []string, error) {
|
||||||
stored, storedErr := s.store.Resource(ctx, orgID, definition.Kind)
|
stored, storedErr := s.store.Resource(ctx, orgID, definition.Kind)
|
||||||
absent := errors.Is(storedErr, storecontract.ErrResourceNotFound)
|
absent := errors.Is(storedErr, storecontract.ErrResourceNotFound)
|
||||||
if storedErr != nil && !absent {
|
if storedErr != nil && !absent {
|
||||||
return 0, storedErr
|
return 0, nil, storedErr
|
||||||
}
|
}
|
||||||
value, err := definition.seededValue(cfg)
|
value, err := definition.seededValue(cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Skipped, not fatal.
|
// Skipped, not fatal.
|
||||||
return 0, &seedRefusal{err: err}
|
return 0, nil, &seedRefusal{err: err}
|
||||||
}
|
}
|
||||||
if !absent && bytes.Equal(stored.Value, value) {
|
if !absent && bytes.Equal(stored.Value, value) {
|
||||||
// The store already holds what this build seeds. Comparing the values
|
// The store already holds what this build seeds. Comparing the values
|
||||||
// rather than re-writing them is what keeps a boot from adding a
|
// rather than re-writing them is what keeps a boot from adding a
|
||||||
// revision for a document that did not change.
|
// revision for a document that did not change.
|
||||||
return stored.Version, nil
|
return stored.Version, nil, nil
|
||||||
}
|
}
|
||||||
|
var removed []string
|
||||||
if !absent {
|
if !absent {
|
||||||
refresh, err := s.shippedValueIsStale(ctx, orgID, definition)
|
var keep bool
|
||||||
|
value, removed, keep, err = s.replacement(ctx, orgID, definition, stored.Value, value)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, nil, err
|
||||||
}
|
}
|
||||||
if !refresh {
|
if keep {
|
||||||
return stored.Version, nil
|
return stored.Version, nil, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
write := storecontract.ResourceWrite{
|
write := storecontract.ResourceWrite{
|
||||||
@@ -161,9 +177,29 @@ func (s *Server) seedKind(ctx context.Context, orgID string, definition Definiti
|
|||||||
}
|
}
|
||||||
resource, err := s.store.PutResource(ctx, write)
|
resource, err := s.store.PutResource(ctx, write)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, fmt.Errorf("seed %s: %w", definition.Kind, err)
|
return 0, nil, fmt.Errorf("seed %s: %w", definition.Kind, err)
|
||||||
}
|
}
|
||||||
return resource.Version, nil
|
return resource.Version, removed, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// replacement decides what a seed writes over a stored value: nothing (keep),
|
||||||
|
// a repair of it, or the seeded value. A failed repair falls back to the seed:
|
||||||
|
// an invalid stored value breaks every reader, so keeping it protects nothing.
|
||||||
|
func (s *Server) replacement(ctx context.Context, orgID string, definition Definition, stored, seeded []byte) ([]byte, []string, bool, error) {
|
||||||
|
replace, err := s.storedValueIsReplaced(ctx, orgID, definition, stored)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, false, err
|
||||||
|
}
|
||||||
|
if !replace {
|
||||||
|
return nil, nil, true, nil
|
||||||
|
}
|
||||||
|
if definition.Repair == nil || definition.accepts(stored) {
|
||||||
|
return seeded, nil, false, nil
|
||||||
|
}
|
||||||
|
if repaired, removed, err := definition.Repair(stored); err == nil {
|
||||||
|
return repaired, removed, false, nil
|
||||||
|
}
|
||||||
|
return seeded, nil, false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// expectedVersion is the optimistic-concurrency guard a seed writes under: the
|
// expectedVersion is the optimistic-concurrency guard a seed writes under: the
|
||||||
@@ -175,15 +211,24 @@ func expectedVersion(stored storecontract.Resource, absent bool) int64 {
|
|||||||
return stored.Version
|
return stored.Version
|
||||||
}
|
}
|
||||||
|
|
||||||
// shippedValueIsStale reports whether the newest stored revision of a
|
// storedValueIsReplaced reports whether a stored shipped document is rewritten
|
||||||
// shipped document was written by the seed.
|
// at seed: the seed wrote it, or this build no longer accepts it.
|
||||||
func (s *Server) shippedValueIsStale(ctx context.Context, orgID string, definition Definition) (bool, error) {
|
func (s *Server) storedValueIsReplaced(ctx context.Context, orgID string, definition Definition, stored []byte) (bool, error) {
|
||||||
if definition.Defaults == nil {
|
if definition.Defaults == nil {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
if !definition.accepts(stored) {
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
return s.seedWroteNewest(ctx, orgID, definition.Kind)
|
return s.seedWroteNewest(ctx, orgID, definition.Kind)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// accepts reports whether input decodes under this build's validator.
|
||||||
|
func (d Definition) accepts(input []byte) bool {
|
||||||
|
_, err := d.Decode(input)
|
||||||
|
return err == nil
|
||||||
|
}
|
||||||
|
|
||||||
// seedWroteNewest reports whether the newest revision of kind was written by a
|
// seedWroteNewest reports whether the newest revision of kind was written by a
|
||||||
// seed. It reads the ledger rather than the current row because the ledger is
|
// seed. It reads the ledger rather than the current row because the ledger is
|
||||||
// what records who wrote a value, and the row does not.
|
// what records who wrote a value, and the row does not.
|
||||||
|
|||||||
@@ -0,0 +1,81 @@
|
|||||||
|
package controlplanestore
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"slices"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/samcharles93/archie-core/internal/config"
|
||||||
|
"github.com/samcharles93/archie-core/internal/domain/storecontract"
|
||||||
|
)
|
||||||
|
|
||||||
|
type memStore struct {
|
||||||
|
resource storecontract.Resource
|
||||||
|
history []storecontract.Resource
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *memStore) ListResources(context.Context) ([]storecontract.Resource, error) {
|
||||||
|
return []storecontract.Resource{m.resource}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *memStore) Resource(context.Context, string, string) (storecontract.Resource, error) {
|
||||||
|
return m.resource, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *memStore) ResourceHistory(context.Context, string, string, int) ([]storecontract.Resource, error) {
|
||||||
|
return m.history, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *memStore) PutResource(_ context.Context, w storecontract.ResourceWrite) (storecontract.Resource, error) {
|
||||||
|
m.resource = storecontract.Resource{OrgID: w.OrgID, Kind: w.Kind, Value: w.Value, Version: m.resource.Version + 1}
|
||||||
|
return m.resource, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// A shipped document an operator edited is kept, unless it no longer validates:
|
||||||
|
// then it is repaired, or replaced by the build's copy when it has no repair.
|
||||||
|
func TestSeedRefreshesStoredShippedDocumentOnlyWhenInvalid(t *testing.T) {
|
||||||
|
definition := Definition{
|
||||||
|
Kind: "shipped",
|
||||||
|
Seed: func(config.Config) any { return "current" },
|
||||||
|
Defaults: func() any { return "current" },
|
||||||
|
Validate: func(in []byte) error {
|
||||||
|
if string(in) != `"current"` && string(in) != `"edited"` {
|
||||||
|
return errors.New("names a deleted step type")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
repair := func([]byte) ([]byte, []string, error) { return []byte(`"edited"`), []string{"gone"}, nil }
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
stored string
|
||||||
|
repair func([]byte) ([]byte, []string, error)
|
||||||
|
want string
|
||||||
|
wantRemoved []string
|
||||||
|
}{
|
||||||
|
{"edited and valid is kept", `"edited"`, repair, `"edited"`, nil},
|
||||||
|
{"invalid is repaired", `"deleted-step"`, repair, `"edited"`, []string{"gone"}},
|
||||||
|
{"invalid without a repair is replaced", `"deleted-step"`, nil, `"current"`, nil},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
store := &memStore{
|
||||||
|
resource: storecontract.Resource{Kind: "shipped", Value: []byte(tt.stored), Version: 3},
|
||||||
|
history: []storecontract.Resource{{Actor: "operator", Source: "dashboard"}},
|
||||||
|
}
|
||||||
|
s := &Server{store: store}
|
||||||
|
definition.Repair = tt.repair
|
||||||
|
_, removed, err := s.seedKind(context.Background(), storecontract.DefaultOrgID, definition, config.Config{})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if !slices.Equal(removed, tt.wantRemoved) {
|
||||||
|
t.Fatalf("removed %v, want %v", removed, tt.wantRemoved)
|
||||||
|
}
|
||||||
|
if got := string(store.resource.Value); got != tt.want {
|
||||||
|
t.Fatalf("stored %s, want %s", got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -37,6 +37,14 @@ func workflowDefinitionsDefinition(steps workflow.StepRegistry, settings map[str
|
|||||||
_, err := workflow.DecodeDefinitionCollection(input, steps)
|
_, err := workflow.DecodeDefinitionCollection(input, steps)
|
||||||
return err
|
return err
|
||||||
},
|
},
|
||||||
|
Repair: func(stored []byte) ([]byte, []string, error) {
|
||||||
|
collection, removed, err := workflow.RepairDefinitionCollection(stored, steps)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
value, err := json.Marshal(collection)
|
||||||
|
return value, removed, err
|
||||||
|
},
|
||||||
SchemaExtensions: map[string]any{"x-step-types": stepTypeVocabulary(steps, settings), "x-intake-routes": workflow.IntakeRoutes()},
|
SchemaExtensions: map[string]any{"x-step-types": stepTypeVocabulary(steps, settings), "x-intake-routes": workflow.IntakeRoutes()},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,11 @@ package gatewayrpc
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"net/http"
|
||||||
"sync"
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
@@ -12,6 +16,7 @@ import (
|
|||||||
"github.com/samcharles93/archie-core/internal/domain/identity"
|
"github.com/samcharles93/archie-core/internal/domain/identity"
|
||||||
"github.com/samcharles93/archie-core/internal/domain/messaging"
|
"github.com/samcharles93/archie-core/internal/domain/messaging"
|
||||||
"github.com/samcharles93/archie-core/internal/domain/taskactions"
|
"github.com/samcharles93/archie-core/internal/domain/taskactions"
|
||||||
|
"github.com/samcharles93/archie-core/internal/infrastructure/alertwebhook"
|
||||||
"github.com/samcharles93/archie-core/internal/taskstate"
|
"github.com/samcharles93/archie-core/internal/taskstate"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -21,6 +26,8 @@ type server struct {
|
|||||||
sessions messaging.SessionStore
|
sessions messaging.SessionStore
|
||||||
catalog Catalog
|
catalog Catalog
|
||||||
asks pendingAsks
|
asks pendingAsks
|
||||||
|
// fetch reads the head of a URL-only attachment; it reaches public hosts only.
|
||||||
|
fetch *http.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// RegisterServer serves the Gateway chat contract. catalog supplies the
|
// RegisterServer serves the Gateway chat contract. catalog supplies the
|
||||||
@@ -28,7 +35,7 @@ type server struct {
|
|||||||
// reload) the dashboard reads over the same contract; a zero Catalog answers
|
// reload) the dashboard reads over the same contract; a zero Catalog answers
|
||||||
// empty lists and an Unavailable reload.
|
// empty lists and an Unavailable reload.
|
||||||
func RegisterServer(registrar grpc.ServiceRegistrar, chat messaging.ChatContract, sessions messaging.SessionStore, catalog Catalog) {
|
func RegisterServer(registrar grpc.ServiceRegistrar, chat messaging.ChatContract, sessions messaging.SessionStore, catalog Catalog) {
|
||||||
pb.RegisterChatServiceServer(registrar, &server{chat: chat, sessions: sessions, catalog: catalog})
|
pb.RegisterChatServiceServer(registrar, &server{chat: chat, sessions: sessions, catalog: catalog, fetch: alertwebhook.PublicClient()})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *server) sessionStore() (messaging.SessionStore, error) {
|
func (s *server) sessionStore() (messaging.SessionStore, error) {
|
||||||
@@ -72,7 +79,7 @@ func (s *server) RecentTurns(ctx context.Context, r *pb.RecentTurnsRequest) (*pb
|
|||||||
|
|
||||||
func (s *server) Route(ctx context.Context, r *pb.RouteRequest) (*pb.RouteResponse, error) {
|
func (s *server) Route(ctx context.Context, r *pb.RouteRequest) (*pb.RouteResponse, error) {
|
||||||
in := inboundValue(r.Message)
|
in := inboundValue(r.Message)
|
||||||
if err := checkInbound(in); err != nil {
|
if err := checkInbound(ctx, s.fetch, in); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
v, err := s.chat.Route(ctx, in)
|
v, err := s.chat.Route(ctx, in)
|
||||||
@@ -267,7 +274,7 @@ func (s *server) Stream(r *pb.StreamRequest, out grpc.ServerStreamingServer[pb.S
|
|||||||
}
|
}
|
||||||
ctx := withAsks(out.Context(), r, remoteAsker{pending: &s.asks, send: send})
|
ctx := withAsks(out.Context(), r, remoteAsker{pending: &s.asks, send: send})
|
||||||
in := inboundValue(r.Message)
|
in := inboundValue(r.Message)
|
||||||
if err := checkInbound(in); err != nil {
|
if err := checkInbound(ctx, s.fetch, in); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
events, err := s.chat.Stream(ctx, in)
|
events, err := s.chat.Stream(ctx, in)
|
||||||
@@ -295,11 +302,54 @@ func (s *server) Answer(_ context.Context, r *pb.AnswerRequest) (*pb.AnswerRespo
|
|||||||
|
|
||||||
// checkInbound refuses a self-contradicting attachment at the one seam every
|
// checkInbound refuses a self-contradicting attachment at the one seam every
|
||||||
// channel, in-tree or extension, crosses before the Gateway acts on it.
|
// channel, in-tree or extension, crosses before the Gateway acts on it.
|
||||||
func checkInbound(in messaging.Inbound) error {
|
func checkInbound(ctx context.Context, fetch *http.Client, in messaging.Inbound) error {
|
||||||
for _, m := range in.Media {
|
for _, m := range in.Media {
|
||||||
if err := messaging.ValidateInbound(m); err != nil {
|
m, err := withHead(ctx, fetch, m)
|
||||||
|
if err == nil {
|
||||||
|
err = messaging.ValidateInbound(m)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
return status.Error(codes.InvalidArgument, err.Error())
|
return status.Error(codes.InvalidArgument, err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// sniffBytes is enough to recognise an image or a clip container.
|
||||||
|
const sniffBytes = 512
|
||||||
|
|
||||||
|
// withHead gives a URL-only attachment of a sniffed type the first bytes of what
|
||||||
|
// its URL serves, so the type check sees the content rather than the claim. An
|
||||||
|
// unreadable URL is an error: the model provider would fetch it unchecked. The
|
||||||
|
// copy is for validation only; the attachment keeps no bytes.
|
||||||
|
func withHead(ctx context.Context, fetch *http.Client, m messaging.MediaAttachment) (messaging.MediaAttachment, error) {
|
||||||
|
switch m.Type {
|
||||||
|
case messaging.MediaTypeImage, messaging.MediaTypeAudio, messaging.MediaTypeVoice:
|
||||||
|
default:
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
|
if len(m.Data) > 0 || m.URL == "" {
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
|
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, m.URL, nil)
|
||||||
|
if err != nil {
|
||||||
|
return m, fmt.Errorf("%s attachment URL: %w", m.Type, err)
|
||||||
|
}
|
||||||
|
req.Header.Set("Range", fmt.Sprintf("bytes=0-%d", sniffBytes-1))
|
||||||
|
resp, err := fetch.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
return m, fmt.Errorf("%s attachment URL is unreadable: %w", m.Type, err)
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusPartialContent {
|
||||||
|
return m, fmt.Errorf("%s attachment URL answered %s", m.Type, resp.Status)
|
||||||
|
}
|
||||||
|
head, err := io.ReadAll(io.LimitReader(resp.Body, sniffBytes))
|
||||||
|
if err != nil || len(head) == 0 {
|
||||||
|
return m, fmt.Errorf("%s attachment URL served no content", m.Type)
|
||||||
|
}
|
||||||
|
m.Data = head
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
@@ -1,6 +1,9 @@
|
|||||||
package gatewayrpc
|
package gatewayrpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"net/http/httptest"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
@@ -22,18 +25,36 @@ func TestChatWireKeepsGatewayInputs(t *testing.T) {
|
|||||||
// TestCheckInboundRefusesContradictoryMedia pins that a channel extension
|
// TestCheckInboundRefusesContradictoryMedia pins that a channel extension
|
||||||
// cannot deliver an attachment whose declared type its bytes contradict.
|
// cannot deliver an attachment whose declared type its bytes contradict.
|
||||||
func TestCheckInboundRefusesContradictoryMedia(t *testing.T) {
|
func TestCheckInboundRefusesContradictoryMedia(t *testing.T) {
|
||||||
|
// The URL-only rows are served from a local host, which the production
|
||||||
|
// client refuses, so the test client is a plain one.
|
||||||
|
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
switch r.URL.Path {
|
||||||
|
case "/png":
|
||||||
|
_, _ = w.Write([]byte("\x89PNG\r\n\x1a\n"))
|
||||||
|
case "/html":
|
||||||
|
_, _ = w.Write([]byte("<!doctype html><script>"))
|
||||||
|
default:
|
||||||
|
http.NotFound(w, r)
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
t.Cleanup(srv.Close)
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
att messaging.MediaAttachment
|
att messaging.MediaAttachment
|
||||||
want codes.Code
|
want codes.Code
|
||||||
}{
|
}{
|
||||||
|
{"a url-only png", messaging.MediaAttachment{Type: messaging.MediaTypeImage, MIMEType: "image/png", URL: srv.URL + "/png"}, codes.OK},
|
||||||
|
{"a url-only png that serves html", messaging.MediaAttachment{Type: messaging.MediaTypeImage, MIMEType: "image/png", URL: srv.URL + "/html"}, codes.InvalidArgument},
|
||||||
|
{"a url-only voice note that serves html", messaging.MediaAttachment{Type: messaging.MediaTypeVoice, MIMEType: "audio/ogg", URL: srv.URL + "/html"}, codes.InvalidArgument},
|
||||||
|
{"a url-only image that cannot be read", messaging.MediaAttachment{Type: messaging.MediaTypeImage, MIMEType: "image/png", URL: srv.URL + "/gone"}, codes.InvalidArgument},
|
||||||
|
{"a url-only document is not fetched", messaging.MediaAttachment{Type: messaging.MediaTypeDocument, MIMEType: "application/pdf", URL: srv.URL + "/html"}, codes.OK},
|
||||||
{"a png", messaging.MediaAttachment{Type: messaging.MediaTypeImage, MIMEType: "image/png", Data: []byte("\x89PNG\r\n\x1a\n")}, codes.OK},
|
{"a png", messaging.MediaAttachment{Type: messaging.MediaTypeImage, MIMEType: "image/png", Data: []byte("\x89PNG\r\n\x1a\n")}, codes.OK},
|
||||||
{"html declared as png", messaging.MediaAttachment{Type: messaging.MediaTypeImage, MIMEType: "image/png", Data: []byte("<!doctype html><script>")}, codes.InvalidArgument},
|
{"html declared as png", messaging.MediaAttachment{Type: messaging.MediaTypeImage, MIMEType: "image/png", Data: []byte("<!doctype html><script>")}, codes.InvalidArgument},
|
||||||
{"an executable declared as png", messaging.MediaAttachment{Type: messaging.MediaTypeImage, MIMEType: "image/png", Data: []byte("\x7fELF\x02\x01\x01\x00")}, codes.InvalidArgument},
|
{"an executable declared as png", messaging.MediaAttachment{Type: messaging.MediaTypeImage, MIMEType: "image/png", Data: []byte("\x7fELF\x02\x01\x01\x00")}, codes.InvalidArgument},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
got := status.Code(checkInbound(messaging.Inbound{Media: []messaging.MediaAttachment{tt.att}}))
|
got := status.Code(checkInbound(context.Background(), srv.Client(), messaging.Inbound{Media: []messaging.MediaAttachment{tt.att}}))
|
||||||
if got != tt.want {
|
if got != tt.want {
|
||||||
t.Fatalf("code = %v, want %v", got, tt.want)
|
t.Fatalf("code = %v, want %v", got, tt.want)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
-- +goose Up
|
||||||
|
-- A workflow.handoff ends its run and starts a linked run of the next workflow
|
||||||
|
-- on the same work item. Only the current run of an item is unique; a run
|
||||||
|
-- that handed off points at its successor and leaves the key.
|
||||||
|
ALTER TABLE tasks
|
||||||
|
ADD COLUMN handoff_from_task_id bigint REFERENCES tasks (id) ON DELETE SET NULL,
|
||||||
|
ADD COLUMN handoff_to_task_id bigint;
|
||||||
|
ALTER TABLE tasks DROP CONSTRAINT tasks_org_identity_owner_repo_number_key;
|
||||||
|
CREATE UNIQUE INDEX tasks_current_item_key ON tasks (org_id, identity, owner, repo, issue_number)
|
||||||
|
WHERE handoff_to_task_id IS NULL;
|
||||||
|
|
||||||
|
-- +goose Down
|
||||||
|
DELETE FROM tasks WHERE handoff_to_task_id IS NOT NULL;
|
||||||
|
DROP INDEX tasks_current_item_key;
|
||||||
|
ALTER TABLE tasks ADD CONSTRAINT tasks_org_identity_owner_repo_number_key
|
||||||
|
UNIQUE (org_id, identity, owner, repo, issue_number);
|
||||||
|
ALTER TABLE tasks DROP COLUMN handoff_to_task_id, DROP COLUMN handoff_from_task_id;
|
||||||
@@ -24,7 +24,7 @@ func (q *Queries) CallStatusDetail(ctx context.Context, taskID int64) (string, e
|
|||||||
|
|
||||||
const enqueueCallTask = `-- name: EnqueueCallTask :one
|
const enqueueCallTask = `-- name: EnqueueCallTask :one
|
||||||
WITH caller AS (
|
WITH caller AS (
|
||||||
SELECT t.id, t.owner, t.repo, t.issue_number, t.title, t.body, t.labels, t.status, t.workflow, t.branch, t.plan, t.notes, t.pr_number, t.tokens_used, t.iterations, t.attempt, t.park_reason, t.watch_comment_id, t.park_class, t.remediation_rounds, t.retry_count, t.source, t.identity, t.binding_id, t.binding_version, t.review_payload, t.workflow_definition_version, t.workflow_definition_digest, t.workflow_definition_yaml, t.created_at, t.updated_at, t.review_cursor, t.inputs, t.org_id, t.workspace_id, t.call_parent_task_id, t.call_depth, t.outputs, t.review_gate, t.rereview_rounds, t.retry_mode, t.resume_from, t.resume_results, t.pending_reviews, t.origin, t.call_key, t.binding_signature, t.binding_addr, t.park_blocker, t.outcome_posted_status, t.plan_document FROM tasks t WHERE t.id = $1 FOR UPDATE
|
SELECT t.id, t.owner, t.repo, t.issue_number, t.title, t.body, t.labels, t.status, t.workflow, t.branch, t.plan, t.notes, t.pr_number, t.tokens_used, t.iterations, t.attempt, t.park_reason, t.watch_comment_id, t.park_class, t.remediation_rounds, t.retry_count, t.source, t.identity, t.binding_id, t.binding_version, t.review_payload, t.workflow_definition_version, t.workflow_definition_digest, t.workflow_definition_yaml, t.created_at, t.updated_at, t.review_cursor, t.inputs, t.org_id, t.workspace_id, t.call_parent_task_id, t.call_depth, t.outputs, t.review_gate, t.rereview_rounds, t.retry_mode, t.resume_from, t.resume_results, t.pending_reviews, t.origin, t.call_key, t.binding_signature, t.binding_addr, t.park_blocker, t.outcome_posted_status, t.plan_document, t.handoff_from_task_id, t.handoff_to_task_id FROM tasks t WHERE t.id = $1 FOR UPDATE
|
||||||
), number AS (
|
), number AS (
|
||||||
INSERT INTO chat_issue_numbers (owner, repo, last_number)
|
INSERT INTO chat_issue_numbers (owner, repo, last_number)
|
||||||
SELECT caller.owner, caller.repo, $9::bigint + 1 FROM caller
|
SELECT caller.owner, caller.repo, $9::bigint + 1 FROM caller
|
||||||
@@ -43,7 +43,7 @@ SELECT
|
|||||||
FROM caller, number
|
FROM caller, number
|
||||||
WHERE caller.status = 'running' AND caller.call_depth + 1 <= $8::int
|
WHERE caller.status = 'running' AND caller.call_depth + 1 <= $8::int
|
||||||
ON CONFLICT (call_parent_task_id, call_key) WHERE call_key <> '' AND status NOT IN ('dead', 'closed_wont_do') DO UPDATE SET call_key = EXCLUDED.call_key
|
ON CONFLICT (call_parent_task_id, call_key) WHERE call_key <> '' AND status NOT IN ('dead', 'closed_wont_do') DO UPDATE SET call_key = EXCLUDED.call_key
|
||||||
RETURNING id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_document
|
RETURNING id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_document, handoff_from_task_id, handoff_to_task_id
|
||||||
`
|
`
|
||||||
|
|
||||||
type EnqueueCallTaskParams struct {
|
type EnqueueCallTaskParams struct {
|
||||||
@@ -137,6 +137,8 @@ func (q *Queries) EnqueueCallTask(ctx context.Context, arg EnqueueCallTaskParams
|
|||||||
&i.ParkBlocker,
|
&i.ParkBlocker,
|
||||||
&i.OutcomePostedStatus,
|
&i.OutcomePostedStatus,
|
||||||
&i.PlanDocument,
|
&i.PlanDocument,
|
||||||
|
&i.HandoffFromTaskID,
|
||||||
|
&i.HandoffToTaskID,
|
||||||
)
|
)
|
||||||
return i, err
|
return i, err
|
||||||
}
|
}
|
||||||
@@ -584,6 +584,8 @@ type Task struct {
|
|||||||
ParkBlocker string
|
ParkBlocker string
|
||||||
OutcomePostedStatus string
|
OutcomePostedStatus string
|
||||||
PlanDocument string
|
PlanDocument string
|
||||||
|
HandoffFromTaskID pgtype.Int8
|
||||||
|
HandoffToTaskID pgtype.Int8
|
||||||
}
|
}
|
||||||
|
|
||||||
type ToolCall struct {
|
type ToolCall struct {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const activeTasksByOrigin = `-- name: ActiveTasksByOrigin :many
|
const activeTasksByOrigin = `-- name: ActiveTasksByOrigin :many
|
||||||
SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_document FROM tasks
|
SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_document, handoff_from_task_id, handoff_to_task_id FROM tasks
|
||||||
WHERE origin = $1 AND origin <> '' AND status IN ('queued', 'running') AND ($2::text IS NULL OR org_id = $2)
|
WHERE origin = $1 AND origin <> '' AND status IN ('queued', 'running') AND ($2::text IS NULL OR org_id = $2)
|
||||||
ORDER BY id
|
ORDER BY id
|
||||||
`
|
`
|
||||||
@@ -85,6 +85,8 @@ func (q *Queries) ActiveTasksByOrigin(ctx context.Context, arg ActiveTasksByOrig
|
|||||||
&i.ParkBlocker,
|
&i.ParkBlocker,
|
||||||
&i.OutcomePostedStatus,
|
&i.OutcomePostedStatus,
|
||||||
&i.PlanDocument,
|
&i.PlanDocument,
|
||||||
|
&i.HandoffFromTaskID,
|
||||||
|
&i.HandoffToTaskID,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -164,7 +166,7 @@ func (q *Queries) BeginRemediationTask(ctx context.Context, arg BeginRemediation
|
|||||||
const claimByIssue = `-- name: ClaimByIssue :one
|
const claimByIssue = `-- name: ClaimByIssue :one
|
||||||
UPDATE tasks SET status = 'running', attempt = attempt + 1, outputs = '', updated_at = now()
|
UPDATE tasks SET status = 'running', attempt = attempt + 1, outputs = '', updated_at = now()
|
||||||
WHERE owner = $1 AND repo = $2 AND issue_number = $3 AND status = 'queued'
|
WHERE owner = $1 AND repo = $2 AND issue_number = $3 AND status = 'queued'
|
||||||
RETURNING id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_document
|
RETURNING id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_document, handoff_from_task_id, handoff_to_task_id
|
||||||
`
|
`
|
||||||
|
|
||||||
type ClaimByIssueParams struct {
|
type ClaimByIssueParams struct {
|
||||||
@@ -230,6 +232,8 @@ func (q *Queries) ClaimByIssue(ctx context.Context, arg ClaimByIssueParams) (Tas
|
|||||||
&i.ParkBlocker,
|
&i.ParkBlocker,
|
||||||
&i.OutcomePostedStatus,
|
&i.OutcomePostedStatus,
|
||||||
&i.PlanDocument,
|
&i.PlanDocument,
|
||||||
|
&i.HandoffFromTaskID,
|
||||||
|
&i.HandoffToTaskID,
|
||||||
)
|
)
|
||||||
return i, err
|
return i, err
|
||||||
}
|
}
|
||||||
@@ -244,7 +248,7 @@ WHERE id = (
|
|||||||
FOR UPDATE SKIP LOCKED
|
FOR UPDATE SKIP LOCKED
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
)
|
)
|
||||||
RETURNING id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_document
|
RETURNING id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_document, handoff_from_task_id, handoff_to_task_id
|
||||||
`
|
`
|
||||||
|
|
||||||
// FOR UPDATE SKIP LOCKED replaces the SQLite single-writer assumption: two
|
// FOR UPDATE SKIP LOCKED replaces the SQLite single-writer assumption: two
|
||||||
@@ -308,6 +312,8 @@ func (q *Queries) ClaimNextTask(ctx context.Context) (Task, error) {
|
|||||||
&i.ParkBlocker,
|
&i.ParkBlocker,
|
||||||
&i.OutcomePostedStatus,
|
&i.OutcomePostedStatus,
|
||||||
&i.PlanDocument,
|
&i.PlanDocument,
|
||||||
|
&i.HandoffFromTaskID,
|
||||||
|
&i.HandoffToTaskID,
|
||||||
)
|
)
|
||||||
return i, err
|
return i, err
|
||||||
}
|
}
|
||||||
@@ -367,7 +373,7 @@ VALUES (
|
|||||||
),
|
),
|
||||||
'default'
|
'default'
|
||||||
)
|
)
|
||||||
ON CONFLICT (org_id, identity, owner, repo, issue_number) DO NOTHING
|
ON CONFLICT (org_id, identity, owner, repo, issue_number) WHERE handoff_to_task_id IS NULL DO NOTHING
|
||||||
`
|
`
|
||||||
|
|
||||||
type EnqueueIssueParams struct {
|
type EnqueueIssueParams struct {
|
||||||
@@ -427,7 +433,7 @@ FROM number, (SELECT COALESCE(
|
|||||||
'org-sys'
|
'org-sys'
|
||||||
) AS id) AS owner_org
|
) AS id) AS owner_org
|
||||||
WHERE $11::text IS NULL OR owner_org.id = $11
|
WHERE $11::text IS NULL OR owner_org.id = $11
|
||||||
RETURNING id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_document
|
RETURNING id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_document, handoff_from_task_id, handoff_to_task_id
|
||||||
`
|
`
|
||||||
|
|
||||||
type InsertChatTaskParams struct {
|
type InsertChatTaskParams struct {
|
||||||
@@ -525,6 +531,88 @@ func (q *Queries) InsertChatTask(ctx context.Context, arg InsertChatTaskParams)
|
|||||||
&i.ParkBlocker,
|
&i.ParkBlocker,
|
||||||
&i.OutcomePostedStatus,
|
&i.OutcomePostedStatus,
|
||||||
&i.PlanDocument,
|
&i.PlanDocument,
|
||||||
|
&i.HandoffFromTaskID,
|
||||||
|
&i.HandoffToTaskID,
|
||||||
|
)
|
||||||
|
return i, err
|
||||||
|
}
|
||||||
|
|
||||||
|
const insertHandoffTask = `-- name: InsertHandoffTask :one
|
||||||
|
INSERT INTO tasks (id, owner, repo, issue_number, title, body, labels, workflow, source, identity,
|
||||||
|
org_id, workspace_id, inputs, plan, plan_document, binding_id, binding_version, binding_signature,
|
||||||
|
binding_addr, origin, call_parent_task_id, call_depth, handoff_from_task_id)
|
||||||
|
SELECT $1, t.owner, t.repo, t.issue_number, t.title, t.body, t.labels, $2, t.source, t.identity,
|
||||||
|
t.org_id, t.workspace_id, t.inputs, t.plan, t.plan_document, t.binding_id, t.binding_version, t.binding_signature,
|
||||||
|
t.binding_addr, t.origin, t.call_parent_task_id, t.call_depth, t.id
|
||||||
|
FROM tasks t WHERE t.id = $3
|
||||||
|
RETURNING id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_document, handoff_from_task_id, handoff_to_task_id
|
||||||
|
`
|
||||||
|
|
||||||
|
type InsertHandoffTaskParams struct {
|
||||||
|
SuccessorID int64
|
||||||
|
Workflow string
|
||||||
|
ID int64
|
||||||
|
}
|
||||||
|
|
||||||
|
// The successor run carries the work item and the decisions made on it; its
|
||||||
|
// run state (attempts, branch, outputs, review state) starts fresh.
|
||||||
|
func (q *Queries) InsertHandoffTask(ctx context.Context, arg InsertHandoffTaskParams) (Task, error) {
|
||||||
|
row := q.db.QueryRow(ctx, insertHandoffTask, arg.SuccessorID, arg.Workflow, arg.ID)
|
||||||
|
var i Task
|
||||||
|
err := row.Scan(
|
||||||
|
&i.ID,
|
||||||
|
&i.Owner,
|
||||||
|
&i.Repo,
|
||||||
|
&i.IssueNumber,
|
||||||
|
&i.Title,
|
||||||
|
&i.Body,
|
||||||
|
&i.Labels,
|
||||||
|
&i.Status,
|
||||||
|
&i.Workflow,
|
||||||
|
&i.Branch,
|
||||||
|
&i.Plan,
|
||||||
|
&i.Notes,
|
||||||
|
&i.PrNumber,
|
||||||
|
&i.TokensUsed,
|
||||||
|
&i.Iterations,
|
||||||
|
&i.Attempt,
|
||||||
|
&i.ParkReason,
|
||||||
|
&i.WatchCommentID,
|
||||||
|
&i.ParkClass,
|
||||||
|
&i.RemediationRounds,
|
||||||
|
&i.RetryCount,
|
||||||
|
&i.Source,
|
||||||
|
&i.Identity,
|
||||||
|
&i.BindingID,
|
||||||
|
&i.BindingVersion,
|
||||||
|
&i.ReviewPayload,
|
||||||
|
&i.WorkflowDefinitionVersion,
|
||||||
|
&i.WorkflowDefinitionDigest,
|
||||||
|
&i.WorkflowDefinitionYaml,
|
||||||
|
&i.CreatedAt,
|
||||||
|
&i.UpdatedAt,
|
||||||
|
&i.ReviewCursor,
|
||||||
|
&i.Inputs,
|
||||||
|
&i.OrgID,
|
||||||
|
&i.WorkspaceID,
|
||||||
|
&i.CallParentTaskID,
|
||||||
|
&i.CallDepth,
|
||||||
|
&i.Outputs,
|
||||||
|
&i.ReviewGate,
|
||||||
|
&i.RereviewRounds,
|
||||||
|
&i.RetryMode,
|
||||||
|
&i.ResumeFrom,
|
||||||
|
&i.ResumeResults,
|
||||||
|
&i.PendingReviews,
|
||||||
|
&i.Origin,
|
||||||
|
&i.CallKey,
|
||||||
|
&i.BindingSignature,
|
||||||
|
&i.BindingAddr,
|
||||||
|
&i.ParkBlocker,
|
||||||
|
&i.OutcomePostedStatus,
|
||||||
|
&i.PlanDocument,
|
||||||
|
&i.HandoffFromTaskID,
|
||||||
|
&i.HandoffToTaskID,
|
||||||
)
|
)
|
||||||
return i, err
|
return i, err
|
||||||
}
|
}
|
||||||
@@ -609,7 +697,8 @@ const listTaskSummaries = `-- name: ListTaskSummaries :many
|
|||||||
SELECT id, owner, repo, issue_number, title, status, workflow,
|
SELECT id, owner, repo, issue_number, title, status, workflow,
|
||||||
pr_number, tokens_used, iterations, attempt, park_reason, retry_count,
|
pr_number, tokens_used, iterations, attempt, park_reason, retry_count,
|
||||||
created_at, updated_at, plan, plan_document, source, identity, binding_id, binding_version,
|
created_at, updated_at, plan, plan_document, source, identity, binding_id, binding_version,
|
||||||
outputs, review_gate, rereview_rounds, org_id, park_class, park_blocker
|
outputs, review_gate, rereview_rounds, org_id, park_class, park_blocker,
|
||||||
|
handoff_from_task_id, handoff_to_task_id
|
||||||
FROM tasks
|
FROM tasks
|
||||||
WHERE ($1::text IS NULL OR org_id = $1)
|
WHERE ($1::text IS NULL OR org_id = $1)
|
||||||
AND (cardinality($2::text[]) = 0 OR status = ANY($2::text[]))
|
AND (cardinality($2::text[]) = 0 OR status = ANY($2::text[]))
|
||||||
@@ -630,33 +719,35 @@ type ListTaskSummariesParams struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ListTaskSummariesRow struct {
|
type ListTaskSummariesRow struct {
|
||||||
ID int64
|
ID int64
|
||||||
Owner string
|
Owner string
|
||||||
Repo string
|
Repo string
|
||||||
IssueNumber int64
|
IssueNumber int64
|
||||||
Title string
|
Title string
|
||||||
Status string
|
Status string
|
||||||
Workflow string
|
Workflow string
|
||||||
PrNumber int64
|
PrNumber int64
|
||||||
TokensUsed int64
|
TokensUsed int64
|
||||||
Iterations int64
|
Iterations int64
|
||||||
Attempt int64
|
Attempt int64
|
||||||
ParkReason string
|
ParkReason string
|
||||||
RetryCount int64
|
RetryCount int64
|
||||||
CreatedAt time.Time
|
CreatedAt time.Time
|
||||||
UpdatedAt time.Time
|
UpdatedAt time.Time
|
||||||
Plan string
|
Plan string
|
||||||
PlanDocument string
|
PlanDocument string
|
||||||
Source string
|
Source string
|
||||||
Identity string
|
Identity string
|
||||||
BindingID string
|
BindingID string
|
||||||
BindingVersion int64
|
BindingVersion int64
|
||||||
Outputs string
|
Outputs string
|
||||||
ReviewGate string
|
ReviewGate string
|
||||||
RereviewRounds int64
|
RereviewRounds int64
|
||||||
OrgID string
|
OrgID string
|
||||||
ParkClass string
|
ParkClass string
|
||||||
ParkBlocker string
|
ParkBlocker string
|
||||||
|
HandoffFromTaskID pgtype.Int8
|
||||||
|
HandoffToTaskID pgtype.Int8
|
||||||
}
|
}
|
||||||
|
|
||||||
// The dashboard's list. This projection is deliberately narrow: Plan gates
|
// The dashboard's list. This projection is deliberately narrow: Plan gates
|
||||||
@@ -712,6 +803,8 @@ func (q *Queries) ListTaskSummaries(ctx context.Context, arg ListTaskSummariesPa
|
|||||||
&i.OrgID,
|
&i.OrgID,
|
||||||
&i.ParkClass,
|
&i.ParkClass,
|
||||||
&i.ParkBlocker,
|
&i.ParkBlocker,
|
||||||
|
&i.HandoffFromTaskID,
|
||||||
|
&i.HandoffToTaskID,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -763,6 +856,25 @@ func (q *Queries) LockTaskStatus(ctx context.Context, id int64) (string, error)
|
|||||||
return status, err
|
return status, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const markHandedOff = `-- name: MarkHandedOff :execrows
|
||||||
|
UPDATE tasks SET handoff_to_task_id = $1, updated_at = now()
|
||||||
|
WHERE id = $2 AND handoff_to_task_id IS NULL
|
||||||
|
`
|
||||||
|
|
||||||
|
type MarkHandedOffParams struct {
|
||||||
|
SuccessorID pgtype.Int8
|
||||||
|
ID int64
|
||||||
|
}
|
||||||
|
|
||||||
|
// The run leaves the item's unique key before its successor takes it.
|
||||||
|
func (q *Queries) MarkHandedOff(ctx context.Context, arg MarkHandedOffParams) (int64, error) {
|
||||||
|
result, err := q.db.Exec(ctx, markHandedOff, arg.SuccessorID, arg.ID)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return result.RowsAffected(), nil
|
||||||
|
}
|
||||||
|
|
||||||
const markOutcomePosted = `-- name: MarkOutcomePosted :exec
|
const markOutcomePosted = `-- name: MarkOutcomePosted :exec
|
||||||
UPDATE tasks SET outcome_posted_status = COALESCE(NULLIF($1::text, ''), status) WHERE id = $2
|
UPDATE tasks SET outcome_posted_status = COALESCE(NULLIF($1::text, ''), status) WHERE id = $2
|
||||||
`
|
`
|
||||||
@@ -780,6 +892,17 @@ func (q *Queries) MarkOutcomePosted(ctx context.Context, arg MarkOutcomePostedPa
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const nextTaskID = `-- name: NextTaskID :one
|
||||||
|
SELECT nextval(pg_get_serial_sequence('tasks', 'id'))::bigint
|
||||||
|
`
|
||||||
|
|
||||||
|
func (q *Queries) NextTaskID(ctx context.Context) (int64, error) {
|
||||||
|
row := q.db.QueryRow(ctx, nextTaskID)
|
||||||
|
var column_1 int64
|
||||||
|
err := row.Scan(&column_1)
|
||||||
|
return column_1, err
|
||||||
|
}
|
||||||
|
|
||||||
const parkTask = `-- name: ParkTask :execrows
|
const parkTask = `-- name: ParkTask :execrows
|
||||||
UPDATE tasks
|
UPDATE tasks
|
||||||
SET status = 'parked', park_reason = $2, park_class = $3, park_blocker = $5, updated_at = now()
|
SET status = 'parked', park_reason = $2, park_class = $3, park_blocker = $5, updated_at = now()
|
||||||
@@ -1014,7 +1137,7 @@ func (q *Queries) StampTaskBinding(ctx context.Context, arg StampTaskBindingPara
|
|||||||
}
|
}
|
||||||
|
|
||||||
const taskByID = `-- name: TaskByID :one
|
const taskByID = `-- name: TaskByID :one
|
||||||
SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_document FROM tasks WHERE id = $1 AND ($2::text IS NULL OR org_id = $2)
|
SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_document, handoff_from_task_id, handoff_to_task_id FROM tasks WHERE id = $1 AND ($2::text IS NULL OR org_id = $2)
|
||||||
`
|
`
|
||||||
|
|
||||||
type TaskByIDParams struct {
|
type TaskByIDParams struct {
|
||||||
@@ -1077,12 +1200,14 @@ func (q *Queries) TaskByID(ctx context.Context, arg TaskByIDParams) (Task, error
|
|||||||
&i.ParkBlocker,
|
&i.ParkBlocker,
|
||||||
&i.OutcomePostedStatus,
|
&i.OutcomePostedStatus,
|
||||||
&i.PlanDocument,
|
&i.PlanDocument,
|
||||||
|
&i.HandoffFromTaskID,
|
||||||
|
&i.HandoffToTaskID,
|
||||||
)
|
)
|
||||||
return i, err
|
return i, err
|
||||||
}
|
}
|
||||||
|
|
||||||
const taskByIssue = `-- name: TaskByIssue :one
|
const taskByIssue = `-- name: TaskByIssue :one
|
||||||
SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_document FROM tasks WHERE owner = $1 AND repo = $2 AND issue_number = $3
|
SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_document, handoff_from_task_id, handoff_to_task_id FROM tasks WHERE owner = $1 AND repo = $2 AND issue_number = $3 AND handoff_to_task_id IS NULL
|
||||||
AND ($4::text IS NULL OR org_id = $4)
|
AND ($4::text IS NULL OR org_id = $4)
|
||||||
`
|
`
|
||||||
|
|
||||||
@@ -1153,12 +1278,14 @@ func (q *Queries) TaskByIssue(ctx context.Context, arg TaskByIssueParams) (Task,
|
|||||||
&i.ParkBlocker,
|
&i.ParkBlocker,
|
||||||
&i.OutcomePostedStatus,
|
&i.OutcomePostedStatus,
|
||||||
&i.PlanDocument,
|
&i.PlanDocument,
|
||||||
|
&i.HandoffFromTaskID,
|
||||||
|
&i.HandoffToTaskID,
|
||||||
)
|
)
|
||||||
return i, err
|
return i, err
|
||||||
}
|
}
|
||||||
|
|
||||||
const taskByPR = `-- name: TaskByPR :one
|
const taskByPR = `-- name: TaskByPR :one
|
||||||
SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_document FROM tasks WHERE owner = $1 AND repo = $2 AND pr_number = $3 AND status = $4
|
SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_document, handoff_from_task_id, handoff_to_task_id FROM tasks WHERE owner = $1 AND repo = $2 AND pr_number = $3 AND status = $4
|
||||||
AND ($5::text IS NULL OR org_id = $5)
|
AND ($5::text IS NULL OR org_id = $5)
|
||||||
`
|
`
|
||||||
|
|
||||||
@@ -1234,6 +1361,8 @@ func (q *Queries) TaskByPR(ctx context.Context, arg TaskByPRParams) (Task, error
|
|||||||
&i.ParkBlocker,
|
&i.ParkBlocker,
|
||||||
&i.OutcomePostedStatus,
|
&i.OutcomePostedStatus,
|
||||||
&i.PlanDocument,
|
&i.PlanDocument,
|
||||||
|
&i.HandoffFromTaskID,
|
||||||
|
&i.HandoffToTaskID,
|
||||||
)
|
)
|
||||||
return i, err
|
return i, err
|
||||||
}
|
}
|
||||||
@@ -1273,9 +1402,10 @@ func (q *Queries) TransitionTask(ctx context.Context, arg TransitionTaskParams)
|
|||||||
}
|
}
|
||||||
|
|
||||||
const unpostedOutcomes = `-- name: UnpostedOutcomes :many
|
const unpostedOutcomes = `-- name: UnpostedOutcomes :many
|
||||||
SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_document FROM tasks
|
SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_document, handoff_from_task_id, handoff_to_task_id FROM tasks
|
||||||
WHERE origin <> '' AND outcome_posted_status <> status
|
WHERE origin <> '' AND outcome_posted_status <> status
|
||||||
AND status IN ('merged', 'rejected', 'dead', 'closed_wont_do', 'completed', 'waiting_approval', 'pr_open')
|
AND status IN ('merged', 'rejected', 'dead', 'closed_wont_do', 'completed', 'waiting_approval', 'pr_open')
|
||||||
|
AND handoff_to_task_id IS NULL
|
||||||
AND ($1::text IS NULL OR org_id = $1)
|
AND ($1::text IS NULL OR org_id = $1)
|
||||||
ORDER BY id
|
ORDER BY id
|
||||||
LIMIT 50
|
LIMIT 50
|
||||||
@@ -1344,6 +1474,8 @@ func (q *Queries) UnpostedOutcomes(ctx context.Context, scopeOrg pgtype.Text) ([
|
|||||||
&i.ParkBlocker,
|
&i.ParkBlocker,
|
||||||
&i.OutcomePostedStatus,
|
&i.OutcomePostedStatus,
|
||||||
&i.PlanDocument,
|
&i.PlanDocument,
|
||||||
|
&i.HandoffFromTaskID,
|
||||||
|
&i.HandoffToTaskID,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ RETURNING *;
|
|||||||
SELECT * FROM tasks WHERE id = sqlc.arg(id) AND (sqlc.narg(scope_org)::text IS NULL OR org_id = sqlc.narg(scope_org));
|
SELECT * FROM tasks WHERE id = sqlc.arg(id) AND (sqlc.narg(scope_org)::text IS NULL OR org_id = sqlc.narg(scope_org));
|
||||||
|
|
||||||
-- name: TaskByIssue :one
|
-- name: TaskByIssue :one
|
||||||
SELECT * FROM tasks WHERE owner = sqlc.arg(owner) AND repo = sqlc.arg(repo) AND issue_number = sqlc.arg(issue_number)
|
SELECT * FROM tasks WHERE owner = sqlc.arg(owner) AND repo = sqlc.arg(repo) AND issue_number = sqlc.arg(issue_number) AND handoff_to_task_id IS NULL
|
||||||
AND (sqlc.narg(scope_org)::text IS NULL OR org_id = sqlc.narg(scope_org));
|
AND (sqlc.narg(scope_org)::text IS NULL OR org_id = sqlc.narg(scope_org));
|
||||||
|
|
||||||
-- name: TaskByPR :one
|
-- name: TaskByPR :one
|
||||||
@@ -43,7 +43,8 @@ SELECT * FROM tasks WHERE owner = sqlc.arg(owner) AND repo = sqlc.arg(repo) AND
|
|||||||
SELECT id, owner, repo, issue_number, title, status, workflow,
|
SELECT id, owner, repo, issue_number, title, status, workflow,
|
||||||
pr_number, tokens_used, iterations, attempt, park_reason, retry_count,
|
pr_number, tokens_used, iterations, attempt, park_reason, retry_count,
|
||||||
created_at, updated_at, plan, plan_document, source, identity, binding_id, binding_version,
|
created_at, updated_at, plan, plan_document, source, identity, binding_id, binding_version,
|
||||||
outputs, review_gate, rereview_rounds, org_id, park_class, park_blocker
|
outputs, review_gate, rereview_rounds, org_id, park_class, park_blocker,
|
||||||
|
handoff_from_task_id, handoff_to_task_id
|
||||||
FROM tasks
|
FROM tasks
|
||||||
WHERE (sqlc.narg(scope_org)::text IS NULL OR org_id = sqlc.narg(scope_org))
|
WHERE (sqlc.narg(scope_org)::text IS NULL OR org_id = sqlc.narg(scope_org))
|
||||||
AND (cardinality(@statuses::text[]) = 0 OR status = ANY(@statuses::text[]))
|
AND (cardinality(@statuses::text[]) = 0 OR status = ANY(@statuses::text[]))
|
||||||
@@ -109,6 +110,7 @@ ORDER BY id;
|
|||||||
SELECT * FROM tasks
|
SELECT * FROM tasks
|
||||||
WHERE origin <> '' AND outcome_posted_status <> status
|
WHERE origin <> '' AND outcome_posted_status <> status
|
||||||
AND status IN ('merged', 'rejected', 'dead', 'closed_wont_do', 'completed', 'waiting_approval', 'pr_open')
|
AND status IN ('merged', 'rejected', 'dead', 'closed_wont_do', 'completed', 'waiting_approval', 'pr_open')
|
||||||
|
AND handoff_to_task_id IS NULL
|
||||||
AND (sqlc.narg(scope_org)::text IS NULL OR org_id = sqlc.narg(scope_org))
|
AND (sqlc.narg(scope_org)::text IS NULL OR org_id = sqlc.narg(scope_org))
|
||||||
ORDER BY id
|
ORDER BY id
|
||||||
LIMIT 50;
|
LIMIT 50;
|
||||||
@@ -199,7 +201,7 @@ VALUES (
|
|||||||
),
|
),
|
||||||
'default'
|
'default'
|
||||||
)
|
)
|
||||||
ON CONFLICT (org_id, identity, owner, repo, issue_number) DO NOTHING;
|
ON CONFLICT (org_id, identity, owner, repo, issue_number) WHERE handoff_to_task_id IS NULL DO NOTHING;
|
||||||
|
|
||||||
-- name: ClaimByIssue :one
|
-- name: ClaimByIssue :one
|
||||||
-- The claim starts the attempt's output set empty, as ClaimNextTask does:
|
-- The claim starts the attempt's output set empty, as ClaimNextTask does:
|
||||||
@@ -291,3 +293,23 @@ DELETE FROM tasks WHERE id = $1 AND status = $2;
|
|||||||
-- name: ListOpenPRs :many
|
-- name: ListOpenPRs :many
|
||||||
SELECT id, owner, repo, issue_number, pr_number, status, source, identity, attempt, review_cursor, watch_comment_id, outputs
|
SELECT id, owner, repo, issue_number, pr_number, status, source, identity, attempt, review_cursor, watch_comment_id, outputs
|
||||||
FROM tasks WHERE status = 'pr_open' AND (sqlc.narg(scope_org)::text IS NULL OR org_id = sqlc.narg(scope_org));
|
FROM tasks WHERE status = 'pr_open' AND (sqlc.narg(scope_org)::text IS NULL OR org_id = sqlc.narg(scope_org));
|
||||||
|
|
||||||
|
-- name: NextTaskID :one
|
||||||
|
SELECT nextval(pg_get_serial_sequence('tasks', 'id'))::bigint;
|
||||||
|
|
||||||
|
-- name: MarkHandedOff :execrows
|
||||||
|
-- The run leaves the item's unique key before its successor takes it.
|
||||||
|
UPDATE tasks SET handoff_to_task_id = sqlc.arg(successor_id), updated_at = now()
|
||||||
|
WHERE id = sqlc.arg(id) AND handoff_to_task_id IS NULL;
|
||||||
|
|
||||||
|
-- name: InsertHandoffTask :one
|
||||||
|
-- The successor run carries the work item and the decisions made on it; its
|
||||||
|
-- run state (attempts, branch, outputs, review state) starts fresh.
|
||||||
|
INSERT INTO tasks (id, owner, repo, issue_number, title, body, labels, workflow, source, identity,
|
||||||
|
org_id, workspace_id, inputs, plan, plan_document, binding_id, binding_version, binding_signature,
|
||||||
|
binding_addr, origin, call_parent_task_id, call_depth, handoff_from_task_id)
|
||||||
|
SELECT sqlc.arg(successor_id), t.owner, t.repo, t.issue_number, t.title, t.body, t.labels, sqlc.arg(workflow), t.source, t.identity,
|
||||||
|
t.org_id, t.workspace_id, t.inputs, t.plan, t.plan_document, t.binding_id, t.binding_version, t.binding_signature,
|
||||||
|
t.binding_addr, t.origin, t.call_parent_task_id, t.call_depth, t.id
|
||||||
|
FROM tasks t WHERE t.id = sqlc.arg(id)
|
||||||
|
RETURNING *;
|
||||||
@@ -124,6 +124,8 @@ func taskFromRow(t postgresdb.Task) *workflow.Task {
|
|||||||
ParkBlocker: t.ParkBlocker,
|
ParkBlocker: t.ParkBlocker,
|
||||||
RemediationRounds: int(t.RemediationRounds),
|
RemediationRounds: int(t.RemediationRounds),
|
||||||
CallParentTaskID: t.CallParentTaskID,
|
CallParentTaskID: t.CallParentTaskID,
|
||||||
|
HandoffFromTaskID: t.HandoffFromTaskID.Int64,
|
||||||
|
HandoffToTaskID: t.HandoffToTaskID.Int64,
|
||||||
CallDepth: int(t.CallDepth),
|
CallDepth: int(t.CallDepth),
|
||||||
Origin: t.Origin,
|
Origin: t.Origin,
|
||||||
CreatedAt: t.CreatedAt,
|
CreatedAt: t.CreatedAt,
|
||||||
@@ -790,6 +792,7 @@ func (s *Store) TasksPage(ctx context.Context, page storecontract.TaskPage) ([]w
|
|||||||
Outputs: outputs,
|
Outputs: outputs,
|
||||||
ReviewGate: r.ReviewGate, RereviewRounds: int(r.RereviewRounds),
|
ReviewGate: r.ReviewGate, RereviewRounds: int(r.RereviewRounds),
|
||||||
Org: org.OrgID(r.OrgID), ParkClass: r.ParkClass, ParkBlocker: r.ParkBlocker,
|
Org: org.OrgID(r.OrgID), ParkClass: r.ParkClass, ParkBlocker: r.ParkBlocker,
|
||||||
|
HandoffFromTaskID: r.HandoffFromTaskID.Int64, HandoffToTaskID: r.HandoffToTaskID.Int64,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return tasks, nil
|
return tasks, nil
|
||||||
@@ -886,6 +889,58 @@ func (s *Store) StartCall(ctx context.Context, callerTaskID int64, callKey, wf s
|
|||||||
return taskFromRow(callee), nil
|
return taskFromRow(callee), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handoff completes the running task fromTaskID and starts its linked
|
||||||
|
// successor on the same work item under wf, in one transaction: the item is
|
||||||
|
// never without a current run, and never has two.
|
||||||
|
func (s *Store) Handoff(ctx context.Context, fromTaskID int64, wf, detail string) (*workflow.Task, error) {
|
||||||
|
tx, err := s.pool.Begin(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer func() { _ = tx.Rollback(ctx) }()
|
||||||
|
q := postgresdb.New(tx)
|
||||||
|
from, to := workflow.StatusRunning, workflow.StatusCompleted
|
||||||
|
if err := guardTransition(ctx, q, fromTaskID, from, to); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
n, err := q.TransitionTask(ctx, postgresdb.TransitionTaskParams{
|
||||||
|
ID: fromTaskID, Status: to, ParkClass: taskstate.ParkNeedsDecision, Status_2: from,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if n == 0 {
|
||||||
|
return nil, storecontract.ErrStaleTransition
|
||||||
|
}
|
||||||
|
if err := recordTransition(ctx, q, postgresdb.InsertTransitionParams{
|
||||||
|
TaskID: fromTaskID, FromStatus: from, ToStatus: to, Detail: clip(detail, 4000),
|
||||||
|
}); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
successor, err := q.NextTaskID(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if n, err := q.MarkHandedOff(ctx, postgresdb.MarkHandedOffParams{ID: fromTaskID, SuccessorID: pgtype.Int8{Int64: successor, Valid: true}}); err != nil {
|
||||||
|
return nil, err
|
||||||
|
} else if n == 0 {
|
||||||
|
return nil, fmt.Errorf("store: task %d already handed off: %w", fromTaskID, storecontract.ErrStaleTransition)
|
||||||
|
}
|
||||||
|
row, err := q.InsertHandoffTask(ctx, postgresdb.InsertHandoffTaskParams{ID: fromTaskID, SuccessorID: successor, Workflow: wf})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if err := recordTransition(ctx, q, postgresdb.InsertTransitionParams{
|
||||||
|
TaskID: row.ID, FromStatus: "", ToStatus: workflow.StatusQueued, Detail: fmt.Sprintf("handed off from task %d", fromTaskID),
|
||||||
|
}); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if err := tx.Commit(ctx); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return taskFromRow(row), nil
|
||||||
|
}
|
||||||
|
|
||||||
// callerIdentity is the identity the caller's pinned workflow declares, the
|
// callerIdentity is the identity the caller's pinned workflow declares, the
|
||||||
// one its callees are started by. The pin does not change while the caller's
|
// one its callees are started by. The pin does not change while the caller's
|
||||||
// call step runs.
|
// call step runs.
|
||||||
|
|||||||
@@ -149,6 +149,13 @@ var taskScopedTargets = map[string]func(any) int64{
|
|||||||
}
|
}
|
||||||
return r.CallerTaskId
|
return r.CallerTaskId
|
||||||
},
|
},
|
||||||
|
pb.TaskService_HandoffTask_FullMethodName: func(req any) int64 {
|
||||||
|
r, ok := req.(*pb.HandoffTaskRequest)
|
||||||
|
if !ok {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
return r.TaskId
|
||||||
|
},
|
||||||
pb.TaskService_WorkflowCallStatus_FullMethodName: func(req any) int64 {
|
pb.TaskService_WorkflowCallStatus_FullMethodName: func(req any) int64 {
|
||||||
r, ok := req.(*pb.WorkflowCallStatusRequest)
|
r, ok := req.(*pb.WorkflowCallStatusRequest)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|||||||
@@ -267,6 +267,20 @@ func (s *taskServer) EnqueueCallTask(ctx context.Context, r *pb.EnqueueCallTaskR
|
|||||||
return &pb.EnqueueCallTaskResponse{Task: taskProto(t), Accepted: true}, nil
|
return &pb.EnqueueCallTaskResponse{Task: taskProto(t), Accepted: true}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *taskServer) HandoffTask(ctx context.Context, r *pb.HandoffTaskRequest) (*pb.HandoffTaskResponse, error) {
|
||||||
|
if s.deps.WorkflowCalls == nil {
|
||||||
|
return nil, errWorkflowCallerUnavailable
|
||||||
|
}
|
||||||
|
if r.TaskId <= 0 || r.Workflow == "" {
|
||||||
|
return nil, status.Error(codes.InvalidArgument, "task id and workflow are required")
|
||||||
|
}
|
||||||
|
t, err := s.deps.WorkflowCalls.Handoff(ctx, r.TaskId, r.Workflow, r.Detail)
|
||||||
|
if err != nil {
|
||||||
|
return nil, s.logErr("HandoffTask", err)
|
||||||
|
}
|
||||||
|
return &pb.HandoffTaskResponse{Task: taskProto(t)}, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (s *taskServer) WorkflowCallStatus(ctx context.Context, r *pb.WorkflowCallStatusRequest) (*pb.WorkflowCallStatusResponse, error) {
|
func (s *taskServer) WorkflowCallStatus(ctx context.Context, r *pb.WorkflowCallStatusRequest) (*pb.WorkflowCallStatusResponse, error) {
|
||||||
if s.deps.WorkflowCalls == nil {
|
if s.deps.WorkflowCalls == nil {
|
||||||
return nil, errWorkflowCallerUnavailable
|
return nil, errWorkflowCallerUnavailable
|
||||||
@@ -485,6 +499,14 @@ func (c *Client) StartCall(ctx context.Context, callerTaskID int64, callKey, wf
|
|||||||
return taskValue(r.Task), nil
|
return taskValue(r.Task), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Client) Handoff(ctx context.Context, fromTaskID int64, wf, detail string) (*task.Task, error) {
|
||||||
|
r, err := c.task.HandoffTask(ctx, &pb.HandoffTaskRequest{TaskId: fromTaskID, Workflow: wf, Detail: detail})
|
||||||
|
if err != nil {
|
||||||
|
return nil, unmapError(err)
|
||||||
|
}
|
||||||
|
return taskValue(r.Task), nil
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Client) CallStatus(ctx context.Context, callerTaskID, callTaskID int64) (string, string, map[string]any, error) {
|
func (c *Client) CallStatus(ctx context.Context, callerTaskID, callTaskID int64) (string, string, map[string]any, error) {
|
||||||
r, err := c.task.WorkflowCallStatus(ctx, &pb.WorkflowCallStatusRequest{CallerTaskId: callerTaskID, CallTaskId: callTaskID})
|
r, err := c.task.WorkflowCallStatus(ctx, &pb.WorkflowCallStatusRequest{CallerTaskId: callerTaskID, CallTaskId: callTaskID})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -85,6 +85,8 @@ func taskProto(t *task.Task) *pb.Task { // mirror-image field-by-field proto<->d
|
|||||||
Org: string(t.Org),
|
Org: string(t.Org),
|
||||||
Workspace: string(t.Workspace),
|
Workspace: string(t.Workspace),
|
||||||
CallParentTaskId: t.CallParentTaskID,
|
CallParentTaskId: t.CallParentTaskID,
|
||||||
|
HandoffFromTaskId: t.HandoffFromTaskID,
|
||||||
|
HandoffToTaskId: t.HandoffToTaskID,
|
||||||
CallDepth: int32(t.CallDepth),
|
CallDepth: int32(t.CallDepth),
|
||||||
Origin: t.Origin,
|
Origin: t.Origin,
|
||||||
BindingSignature: t.BindingSignature,
|
BindingSignature: t.BindingSignature,
|
||||||
@@ -122,6 +124,8 @@ func taskValue(t *pb.Task) *task.Task { // see taskProto above
|
|||||||
Org: org.OrgID(t.Org),
|
Org: org.OrgID(t.Org),
|
||||||
Workspace: org.WorkspaceID(t.Workspace),
|
Workspace: org.WorkspaceID(t.Workspace),
|
||||||
CallParentTaskID: t.CallParentTaskId,
|
CallParentTaskID: t.CallParentTaskId,
|
||||||
|
HandoffFromTaskID: t.HandoffFromTaskId,
|
||||||
|
HandoffToTaskID: t.HandoffToTaskId,
|
||||||
CallDepth: int(t.CallDepth),
|
CallDepth: int(t.CallDepth),
|
||||||
Origin: t.Origin,
|
Origin: t.Origin,
|
||||||
BindingSignature: t.BindingSignature,
|
BindingSignature: t.BindingSignature,
|
||||||
|
|||||||
@@ -39,6 +39,10 @@ type taskAttemptsView struct {
|
|||||||
Inputs map[string]any `json:"inputs,omitempty"`
|
Inputs map[string]any `json:"inputs,omitempty"`
|
||||||
Outputs map[string]any `json:"outputs,omitempty"`
|
Outputs map[string]any `json:"outputs,omitempty"`
|
||||||
CalledBy int64 `json:"called_by,omitempty"`
|
CalledBy int64 `json:"called_by,omitempty"`
|
||||||
|
// HandedOffFrom and HandedOffTo are the linked runs of the same work
|
||||||
|
// item before and after this one.
|
||||||
|
HandedOffFrom int64 `json:"handed_off_from,omitempty"`
|
||||||
|
HandedOffTo int64 `json:"handed_off_to,omitempty"`
|
||||||
// Recovery links a parked task to the page that fixes its blocker,
|
// Recovery links a parked task to the page that fixes its blocker,
|
||||||
// present only when the viewer may act there.
|
// present only when the viewer may act there.
|
||||||
Recovery *taskRecoveryView `json:"recovery,omitempty"`
|
Recovery *taskRecoveryView `json:"recovery,omitempty"`
|
||||||
@@ -117,6 +121,8 @@ func (a *tasksAPI) handleTaskAttempts(w http.ResponseWriter, r *http.Request) {
|
|||||||
Inputs: t.Inputs,
|
Inputs: t.Inputs,
|
||||||
Outputs: t.Outputs,
|
Outputs: t.Outputs,
|
||||||
CalledBy: t.CallParentTaskID,
|
CalledBy: t.CallParentTaskID,
|
||||||
|
HandedOffFrom: t.HandoffFromTaskID,
|
||||||
|
HandedOffTo: t.HandoffToTaskID,
|
||||||
Recovery: a.recovery(r, t),
|
Recovery: a.recovery(r, t),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,10 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/go-git/go-git/v6"
|
||||||
|
"github.com/go-git/go-git/v6/plumbing"
|
||||||
|
"github.com/go-git/go-git/v6/plumbing/object"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestPruneMirrorsRemovesOnlyIdleUnusedMirrorsInsideRoot(t *testing.T) {
|
func TestPruneMirrorsRemovesOnlyIdleUnusedMirrorsInsideRoot(t *testing.T) {
|
||||||
@@ -91,3 +95,55 @@ func mkdir(t *testing.T, dir string) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A forge may move a tag (a re-cut release, a rolling channel tag); the shared
|
||||||
|
// mirror must follow it rather than refuse every later fetch.
|
||||||
|
func TestEnsureMirrorFollowsAMovedTag(t *testing.T) {
|
||||||
|
// The developer's own git config (commit signing) must not reach the fixture.
|
||||||
|
t.Setenv("HOME", t.TempDir())
|
||||||
|
t.Setenv("XDG_CONFIG_HOME", t.TempDir())
|
||||||
|
t.Setenv("GIT_CONFIG_GLOBAL", os.DevNull)
|
||||||
|
base := t.TempDir()
|
||||||
|
upstream, err := git.PlainInit(filepath.Join(base, "o", "r.git"), false)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
commit := func(msg string) plumbing.Hash {
|
||||||
|
t.Helper()
|
||||||
|
wt, err := upstream.Worktree()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
h, err := wt.Commit(msg, &git.CommitOptions{AllowEmptyCommits: true, Author: &object.Signature{Name: "t", Email: "t@example.test", When: time.Now()}})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
return h
|
||||||
|
}
|
||||||
|
tagAt := func(h plumbing.Hash) {
|
||||||
|
t.Helper()
|
||||||
|
_ = upstream.DeleteTag("next")
|
||||||
|
if _, err := upstream.CreateTag("next", h, nil); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tagAt(commit("first"))
|
||||||
|
m := &Manager{WorkDir: t.TempDir(), BaseURL: "file://" + base}
|
||||||
|
if _, err := m.ensureMirror(context.Background(), "o", "r"); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
moved := commit("second")
|
||||||
|
tagAt(moved)
|
||||||
|
dir, err := m.ensureMirror(context.Background(), "o", "r")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("fetch after the tag moved: %v", err)
|
||||||
|
}
|
||||||
|
mirrored, err := git.PlainOpen(dir)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
ref, err := mirrored.Tag("next")
|
||||||
|
if err != nil || ref.Hash() != moved {
|
||||||
|
t.Fatalf("mirror tag = %v (%v), want %s", ref, err, moved)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -208,7 +208,9 @@ func (m *Manager) ensureMirror(ctx context.Context, owner, repo string) (string,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("open mirror %s/%s: %w", owner, repo, err)
|
return "", fmt.Errorf("open mirror %s/%s: %w", owner, repo, err)
|
||||||
}
|
}
|
||||||
if err := r.FetchContext(ctx, &git.FetchOptions{ClientOptions: m.auth(), Tags: plumbing.AllTags}); err != nil &&
|
// Force: the mirror copies the forge, so a moved tag or rewritten branch
|
||||||
|
// replaces the local ref instead of failing every later fetch.
|
||||||
|
if err := r.FetchContext(ctx, &git.FetchOptions{ClientOptions: m.auth(), Tags: plumbing.AllTags, Force: true}); err != nil &&
|
||||||
!errors.Is(err, git.NoErrAlreadyUpToDate) {
|
!errors.Is(err, git.NoErrAlreadyUpToDate) {
|
||||||
return "", fmt.Errorf("fetch mirror %s/%s: %w", owner, repo, err)
|
return "", fmt.Errorf("fetch mirror %s/%s: %w", owner, repo, err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,9 @@ service TaskService {
|
|||||||
// (docs/prds/workflow-calls.md). CallStatus re-checks the parent-child
|
// (docs/prds/workflow-calls.md). CallStatus re-checks the parent-child
|
||||||
// relation server-side, so the grant only names the caller.
|
// relation server-side, so the grant only names the caller.
|
||||||
rpc EnqueueCallTask(EnqueueCallTaskRequest) returns (EnqueueCallTaskResponse);
|
rpc EnqueueCallTask(EnqueueCallTaskRequest) returns (EnqueueCallTaskResponse);
|
||||||
|
// HandoffTask completes a running run and starts its linked successor on
|
||||||
|
// the same work item under another workflow.
|
||||||
|
rpc HandoffTask(HandoffTaskRequest) returns (HandoffTaskResponse);
|
||||||
rpc WorkflowCallStatus(WorkflowCallStatusRequest) returns (WorkflowCallStatusResponse);
|
rpc WorkflowCallStatus(WorkflowCallStatusRequest) returns (WorkflowCallStatusResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,6 +199,12 @@ message EnqueueCallTaskRequest {
|
|||||||
// cannot duplicate the child's work.
|
// cannot duplicate the child's work.
|
||||||
string call_key = 4;
|
string call_key = 4;
|
||||||
}
|
}
|
||||||
|
message HandoffTaskRequest {
|
||||||
|
int64 task_id = 1;
|
||||||
|
string workflow = 2;
|
||||||
|
string detail = 3;
|
||||||
|
}
|
||||||
|
message HandoffTaskResponse { Task task = 1; }
|
||||||
message EnqueueCallTaskResponse {
|
message EnqueueCallTaskResponse {
|
||||||
Task task = 1;
|
Task task = 1;
|
||||||
bool accepted = 2;
|
bool accepted = 2;
|
||||||
|
|||||||
@@ -128,6 +128,10 @@ message Task {
|
|||||||
reserved "plan_view";
|
reserved "plan_view";
|
||||||
// plan_document is the structured plan (JSON) plan was rendered from.
|
// plan_document is the structured plan (JSON) plan was rendered from.
|
||||||
string plan_document = 50;
|
string plan_document = 50;
|
||||||
|
// handoff_from_task_id is the run that handed off to this one; 0 when none.
|
||||||
|
int64 handoff_from_task_id = 51;
|
||||||
|
// handoff_to_task_id is the run this one handed off to; 0 when none.
|
||||||
|
int64 handoff_to_task_id = 52;
|
||||||
}
|
}
|
||||||
// Event mirrors internal/events.Event. Data is carried as a JSON object
|
// Event mirrors internal/events.Event. Data is carried as a JSON object
|
||||||
// string (matching the store's own on-disk representation) rather than
|
// string (matching the store's own on-disk representation) rather than
|
||||||
|
|||||||
+23
-3
@@ -1,6 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Button } from "@/components/ui/button";
|
import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from "vue";
|
||||||
import { computed, nextTick, onMounted, ref, watch } from "vue";
|
|
||||||
import { useRoute, useRouter } from "vue-router";
|
import { useRoute, useRouter } from "vue-router";
|
||||||
|
|
||||||
import AccountEntry from "@/accounts/AccountEntry.vue";
|
import AccountEntry from "@/accounts/AccountEntry.vue";
|
||||||
@@ -11,7 +10,10 @@ import AlertsBell from "@/alerts/AlertsBell.vue";
|
|||||||
import AppSidebar from "@/components/AppSidebar.vue";
|
import AppSidebar from "@/components/AppSidebar.vue";
|
||||||
import CommandPalette from "@/components/command-palette/CommandPalette.vue";
|
import CommandPalette from "@/components/command-palette/CommandPalette.vue";
|
||||||
import Brand from "@/components/topbar/Brand.vue";
|
import Brand from "@/components/topbar/Brand.vue";
|
||||||
|
import Logo from "@/components/topbar/Logo.vue";
|
||||||
import ConnectionPill from "@/components/topbar/ConnectionPill.vue";
|
import ConnectionPill from "@/components/topbar/ConnectionPill.vue";
|
||||||
|
import { Alert, AlertDescription } from "@/components/ui/alert";
|
||||||
|
import { Card } from "@/components/ui/card";
|
||||||
import { SidebarInset, SidebarProvider, SidebarTrigger } from "@/components/ui/sidebar";
|
import { SidebarInset, SidebarProvider, SidebarTrigger } from "@/components/ui/sidebar";
|
||||||
import NewTaskDialog from "@/tasks/NewTaskDialog.vue";
|
import NewTaskDialog from "@/tasks/NewTaskDialog.vue";
|
||||||
import SettingsShell from "@/settings/SettingsShell.vue";
|
import SettingsShell from "@/settings/SettingsShell.vue";
|
||||||
@@ -45,6 +47,14 @@ watch(() => route.path, async () => {
|
|||||||
}, { flush: "post" });
|
}, { flush: "post" });
|
||||||
|
|
||||||
onMounted(() => {void accounts.load();});
|
onMounted(() => {void accounts.load();});
|
||||||
|
// A failed startup read retries on an interval, so a proxy or daemon that
|
||||||
|
// comes back does not need a manual reload.
|
||||||
|
let retryTimer: ReturnType<typeof setInterval> | undefined;
|
||||||
|
watch(() => accounts.error, (message) => {
|
||||||
|
if (message && retryTimer === undefined) retryTimer = setInterval(() => void accounts.load(), 5000);
|
||||||
|
if (!message && retryTimer !== undefined) { clearInterval(retryTimer); retryTimer = undefined; }
|
||||||
|
});
|
||||||
|
onBeforeUnmount(() => { if (retryTimer !== undefined) clearInterval(retryTimer); });
|
||||||
watch(() => accounts.status?.user, (user) => {
|
watch(() => accounts.status?.user, (user) => {
|
||||||
if (!user || reauthenticate) return;
|
if (!user || reauthenticate) return;
|
||||||
session.initialize();
|
session.initialize();
|
||||||
@@ -64,7 +74,17 @@ watch(() => accounts.status?.user, (user) => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div v-if="!accounts.status" class="mx-auto max-w-md p-8" role="status"><p>{{accounts.error||'Connecting to Archie…'}}</p><Button v-if="accounts.error" variant="link" class="mt-3 px-0" @click="accounts.load">Retry</Button></div>
|
<main v-if="!accounts.status" class="mx-auto flex min-h-[90dvh] max-w-md flex-col justify-center px-5 py-10">
|
||||||
|
<Card class="gap-0 px-6 py-6 shadow-sm">
|
||||||
|
<div class="mb-2"><Logo /></div>
|
||||||
|
<template v-if="accounts.error">
|
||||||
|
<h1 class="text-title font-medium">Can't reach Archie</h1>
|
||||||
|
<Alert variant="destructive" class="mt-4"><AlertDescription>{{ accounts.error }}</AlertDescription></Alert>
|
||||||
|
<p class="text-caption mt-3 text-fg-muted">Retrying automatically…</p>
|
||||||
|
</template>
|
||||||
|
<p v-else class="mt-2" role="status">Connecting to Archie…</p>
|
||||||
|
</Card>
|
||||||
|
</main>
|
||||||
<AccountEntry v-else-if="!accounts.status.user || accounts.status.setup_required || reauthenticate" />
|
<AccountEntry v-else-if="!accounts.status.user || accounts.status.setup_required || reauthenticate" />
|
||||||
<TooltipProvider v-else :delay-duration="350">
|
<TooltipProvider v-else :delay-duration="350">
|
||||||
<SidebarProvider class="bg-[var(--workspace)]">
|
<SidebarProvider class="bg-[var(--workspace)]">
|
||||||
|
|||||||
@@ -11,14 +11,14 @@ import { passkeysAvailable, useAccountsStore, usePasskey } from "./accounts";
|
|||||||
const accounts=useAccountsStore();
|
const accounts=useAccountsStore();
|
||||||
const step=ref(1);const recovery=ref(false);const recoveryCode=ref("");
|
const step=ref(1);const recovery=ref(false);const recoveryCode=ref("");
|
||||||
const organisation=ref("");const workspace=ref("Default");const publicURL=ref(window.location.origin);
|
const organisation=ref("");const workspace=ref("Default");const publicURL=ref(window.location.origin);
|
||||||
const name=ref("");const email=ref("");const password=ref("");const busy=ref(false);const error=ref("");
|
const name=ref("");const email=ref("");const password=ref("");const busy=ref(false);const error=ref("");const notice=ref("");
|
||||||
const setup=computed(()=>accounts.status?.setup_required===true);
|
const setup=computed(()=>accounts.status?.setup_required===true);
|
||||||
const passkey=computed(()=>passkeysAvailable(accounts.status?.public_url??""));
|
const passkey=computed(()=>passkeysAvailable(accounts.status?.public_url??""));
|
||||||
async function submit(){
|
async function submit(){
|
||||||
if(setup.value&&step.value===1&&!recovery.value){step.value=2;return}
|
if(setup.value&&step.value===1&&!recovery.value){step.value=2;return}
|
||||||
busy.value=true;error.value="";
|
busy.value=true;error.value="";notice.value="";
|
||||||
try{
|
try{
|
||||||
if(recovery.value){await api.recoverAccount(email.value,recoveryCode.value,password.value);recovery.value=false;password.value="";error.value="Password changed. Sign in with your new password.";return}
|
if(recovery.value){await api.recoverAccount(email.value,recoveryCode.value,password.value);recovery.value=false;password.value="";notice.value="Password changed. Sign in with your new password.";return}
|
||||||
if(setup.value)await api.setupAccount({organisation_name:organisation.value,workspace_name:workspace.value,public_url:publicURL.value.replace(/\/$/,""),display_name:name.value,email:email.value,password:password.value});
|
if(setup.value)await api.setupAccount({organisation_name:organisation.value,workspace_name:workspace.value,public_url:publicURL.value.replace(/\/$/,""),display_name:name.value,email:email.value,password:password.value});
|
||||||
else await api.signIn(email.value,password.value);
|
else await api.signIn(email.value,password.value);
|
||||||
password.value="";
|
password.value="";
|
||||||
@@ -32,22 +32,23 @@ async function signInPasskey(){busy.value=true;error.value="";try{await usePassk
|
|||||||
<main class="mx-auto flex min-h-[90dvh] max-w-md flex-col justify-center px-5 py-10">
|
<main class="mx-auto flex min-h-[90dvh] max-w-md flex-col justify-center px-5 py-10">
|
||||||
<Card class="gap-0 py-6 px-6 shadow-sm">
|
<Card class="gap-0 py-6 px-6 shadow-sm">
|
||||||
<div class="mb-2"><Logo /></div>
|
<div class="mb-2"><Logo /></div>
|
||||||
<h1 class="text-2xl font-medium">{{setup?(step===1?'Set up your organisation':'Create your admin account'):recovery?'Recover your account':'Sign in'}}</h1>
|
<h1 class="text-title font-medium">{{setup?(step===1?'Set up your organisation':'Create your admin account'):recovery?'Recover your account':'Sign in'}}</h1>
|
||||||
<form class="mt-6 space-y-4" @submit.prevent="submit">
|
<form class="mt-6 space-y-4" @submit.prevent="submit">
|
||||||
<template v-if="setup&&step===1">
|
<template v-if="setup&&step===1">
|
||||||
<Label class="block space-y-1.5 text-sm" for="organisation">Organisation name<Input id="organisation" v-model="organisation" autocomplete="organization" required maxlength="200" /></Label>
|
<Label class="block space-y-1.5 text-label" for="organisation">Organisation name<Input id="organisation" v-model="organisation" autocomplete="organization" required maxlength="200" /></Label>
|
||||||
<Label class="block space-y-1.5 text-sm" for="workspace">First workspace<Input id="workspace" v-model="workspace" required maxlength="200" /></Label>
|
<Label class="block space-y-1.5 text-label" for="workspace">First workspace<Input id="workspace" v-model="workspace" required maxlength="200" /></Label>
|
||||||
<Label class="block space-y-1.5 text-sm" for="public-url">Instance URL<Input id="public-url" v-model="publicURL" type="url" required autocomplete="url" /></Label>
|
<Label class="block space-y-1.5 text-label" for="public-url">Instance URL<Input id="public-url" v-model="publicURL" type="url" required autocomplete="url" /></Label>
|
||||||
<p class="text-xs text-fg-muted">Use the address people will visit. Passkeys require HTTPS and a domain name, or localhost for development.</p>
|
<p class="text-caption text-fg-muted">Use the address people will visit. Passkeys require HTTPS and a domain name, or localhost for development.</p>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<Label v-if="setup" class="block space-y-1.5 text-sm" for="account-name">Your name<Input id="account-name" v-model="name" autocomplete="name" required maxlength="200" /></Label>
|
<Label v-if="setup" class="block space-y-1.5 text-label" for="account-name">Your name<Input id="account-name" v-model="name" autocomplete="name" required maxlength="200" /></Label>
|
||||||
<Label class="block space-y-1.5 text-sm" for="account-email">Email<Input id="account-email" v-model="email" type="email" autocomplete="username" :spellcheck="false" required /></Label>
|
<Label class="block space-y-1.5 text-label" for="account-email">Email<Input id="account-email" v-model="email" type="email" autocomplete="username" :spellcheck="false" required /></Label>
|
||||||
<Label v-if="recovery" class="block space-y-1.5 text-sm" for="recovery-code">Recovery code<Input id="recovery-code" v-model="recoveryCode" autocomplete="off" required /></Label>
|
<Label v-if="recovery" class="block space-y-1.5 text-label" for="recovery-code">Recovery code<Input id="recovery-code" v-model="recoveryCode" autocomplete="off" required /></Label>
|
||||||
<Label class="block space-y-1.5 text-sm" for="account-password">{{recovery?"New password":"Password"}}<Input id="account-password" v-model="password" type="password" :autocomplete="setup||recovery?'new-password':'current-password'" :minlength="setup||recovery?15:undefined" maxlength="1024" required /></Label>
|
<Label class="block space-y-1.5 text-label" for="account-password">{{recovery?"New password":"Password"}}<Input id="account-password" v-model="password" type="password" :autocomplete="setup||recovery?'new-password':'current-password'" :minlength="setup||recovery?15:undefined" maxlength="1024" required /></Label>
|
||||||
<p v-if="setup" class="text-xs text-fg-muted">At least 15 characters.</p>
|
<p v-if="setup" class="text-caption text-fg-muted">At least 15 characters.</p>
|
||||||
</template>
|
</template>
|
||||||
<Alert v-if="error" variant="destructive"><AlertDescription>{{error}}</AlertDescription></Alert>
|
<Alert v-if="error" variant="destructive"><AlertDescription>{{error}}</AlertDescription></Alert>
|
||||||
|
<Alert v-if="notice" class="mt-4"><AlertDescription>{{notice}}</AlertDescription></Alert>
|
||||||
<div class="flex gap-2"><Button v-if="setup&&step===2" type="button" variant="outline" :disabled="busy" @click="step=1">Back</Button><Button type="submit" class="flex-1" :disabled="busy">{{busy?'Please wait…':setup?(step===1?'Continue':'Create organisation and admin'):recovery?'Reset password':'Sign in'}}</Button></div>
|
<div class="flex gap-2"><Button v-if="setup&&step===2" type="button" variant="outline" :disabled="busy" @click="step=1">Back</Button><Button type="submit" class="flex-1" :disabled="busy">{{busy?'Please wait…':setup?(step===1?'Continue':'Create organisation and admin'):recovery?'Reset password':'Sign in'}}</Button></div>
|
||||||
</form>
|
</form>
|
||||||
<div v-if="!setup&&!recovery" class="mt-4 flex flex-col gap-2">
|
<div v-if="!setup&&!recovery" class="mt-4 flex flex-col gap-2">
|
||||||
|
|||||||
@@ -1,40 +1,42 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Item, ItemActions, ItemContent, ItemGroup } from "@/components/ui/item";
|
import { Item, ItemActions, ItemContent, ItemGroup } from "@/components/ui/item";
|
||||||
|
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from "@/components/ui/alert-dialog";
|
||||||
import { Alert, AlertDescription } from "@/components/ui/alert";
|
import { Alert, AlertDescription } from "@/components/ui/alert";
|
||||||
import { computed, onMounted, ref } from "vue";
|
import { computed, onMounted, ref } from "vue";
|
||||||
import PageHeader from "@/base/PageHeader.vue";
|
import PageHeader from "@/base/PageHeader.vue";
|
||||||
import PersonalTokensCard from "@/accounts/PersonalTokensCard.vue";
|
import PersonalTokensCard from "@/accounts/PersonalTokensCard.vue";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { Card } from "@/components/ui/card";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import { SettingRow } from "@/components/ui/setting-row";
|
import { SettingRow } from "@/components/ui/setting-row";
|
||||||
import { Section } from "@/components/ui/section";
|
import { Section } from "@/components/ui/section";
|
||||||
import { api } from "@/lib/api";
|
import { api, classifyActionError } from "@/lib/api";
|
||||||
import { passkeysAvailable,useAccountsStore,usePasskey } from "./accounts";
|
import { passkeysAvailable,useAccountsStore,usePasskey } from "./accounts";
|
||||||
const recovery=ref("");
|
const recovery=ref("");
|
||||||
const makeRecovery=()=>run(async()=>{recovery.value=(await api.recoveryCode()).code});
|
const makeRecovery=()=>run(async()=>{recovery.value=(await api.recoveryCode()).code});
|
||||||
const accounts=useAccountsStore();const keys=ref<{id:string;name:string}[]>([]);const error=ref("");const busy=ref(false);const keyName=ref("");const current=ref("");const next=ref("");
|
const accounts=useAccountsStore();const keys=ref<{id:string;name:string}[]>([]);const pending=ref<{id:string;name:string}|null>(null);const error=ref("");const sessionExpired=ref(false);const busy=ref(false);const keyName=ref("");const current=ref("");const next=ref("");
|
||||||
const eligible=computed(()=>passkeysAvailable(accounts.status?.public_url??""));
|
const eligible=computed(()=>passkeysAvailable(accounts.status?.public_url??""));
|
||||||
async function load(){try{keys.value=(await api.passkeys()).passkeys}catch(cause){error.value=String((cause as Error).message||cause)}}
|
async function load(){try{keys.value=(await api.passkeys()).passkeys}catch(cause){error.value=String((cause as Error).message||cause);sessionExpired.value=classifyActionError(cause).kind==="session-expired"}}
|
||||||
onMounted(load);
|
onMounted(load);
|
||||||
async function run(action:()=>Promise<unknown>){busy.value=true;error.value="";try{await action()}catch(cause){error.value=String((cause as Error).message||cause)}finally{busy.value=false}}
|
async function run(action:()=>Promise<unknown>){busy.value=true;error.value="";try{await action()}catch(cause){error.value=String((cause as Error).message||cause);sessionExpired.value=classifyActionError(cause).kind==="session-expired"}finally{busy.value=false}}
|
||||||
const enroll=()=>run(async()=>{await usePasskey(true,keyName.value);keyName.value="";await load()});
|
const enroll=()=>run(async()=>{await usePasskey(true,keyName.value);keyName.value="";await load()});
|
||||||
const remove=(id:string)=>run(async()=>{await api.deletePasskey(id);await load()});
|
const remove=(id:string)=>run(async()=>{await api.deletePasskey(id);await load()});
|
||||||
const change=()=>run(async()=>{await api.changePassword(current.value,next.value);current.value=next.value="";window.location.assign("/")});
|
const change=()=>run(async()=>{await api.changePassword(current.value,next.value);current.value=next.value="";window.location.assign("/")});
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div class="mx-auto max-w-[80ch]">
|
<div class="mx-auto max-w-[80ch]">
|
||||||
<PageHeader title="Your account"><span class="text-sm text-fg-muted">{{accounts.status?.user?.display_name}}</span></PageHeader>
|
<PageHeader title="Your account"><span class="text-label text-fg-muted">{{accounts.status?.user?.display_name}}</span></PageHeader>
|
||||||
<Alert v-if="$route.query.welcome" class="mb-4">Your organisation and admin account are ready. Add a passkey below, <RouterLink class="underline" to="/org/members">add members</RouterLink>, or <RouterLink class="underline" to="/settings/authentication">configure OIDC</RouterLink>.</Alert>
|
<Alert v-if="$route.query.welcome" class="mb-4">Your organisation and admin account are ready. Add a passkey below, <RouterLink class="underline" to="/org/members">add members</RouterLink>, or <RouterLink class="underline" to="/settings/authentication">configure OIDC</RouterLink>.</Alert>
|
||||||
<Alert v-if="error" variant="destructive" class="mb-4"><AlertDescription>{{error}} <a class="underline" href="/?reauth=1">Sign in again</a></AlertDescription></Alert>
|
<Alert v-if="error" variant="destructive" class="mb-4"><AlertDescription>{{error}}<a v-if="sessionExpired" class="underline" href="/?reauth=1"> Sign in again</a></AlertDescription></Alert>
|
||||||
<Section title="Passkeys">
|
<Section title="Passkeys">
|
||||||
<ItemGroup v-if="keys.length" class="mb-3"><Item v-for="key in keys" :key="key.id" as="li" variant="outline" size="xs"><ItemContent class="min-w-0 truncate"><span class="truncate">{{key.name}}</span></ItemContent><ItemActions><Button variant="ghost" size="sm" class="text-danger" :disabled="busy" @click="remove(key.id)">Remove</Button></ItemActions></Item></ItemGroup>
|
<ItemGroup v-if="keys.length" class="mb-3"><Item v-for="key in keys" :key="key.id" as="li" variant="outline" size="xs"><ItemContent class="min-w-0 truncate"><span class="truncate">{{key.name}}</span></ItemContent><ItemActions><Button variant="ghost" size="sm" class="text-danger" :disabled="busy" @click="pending = key">Remove</Button></ItemActions></Item></ItemGroup>
|
||||||
<form v-if="eligible" class="flex flex-wrap gap-2" @submit.prevent="enroll"><Input v-model="keyName" aria-label="Passkey name" placeholder="Passkey name (optional)" maxlength="200" class="min-w-40 flex-1"/><Button type="submit" :disabled="busy">Add passkey</Button></form>
|
<form v-if="eligible" class="flex flex-wrap gap-2" @submit.prevent="enroll"><Input v-model="keyName" aria-label="Passkey name" placeholder="Passkey name (optional)" maxlength="200" class="min-w-40 flex-1"/><Button type="submit" :disabled="busy">Add passkey</Button></form>
|
||||||
<p v-else class="text-fg-muted">Passkeys need an HTTPS domain or localhost. Set the instance URL in <RouterLink class="underline" to="/settings/authentication">Authentication settings</RouterLink>.</p>
|
<p v-else class="text-fg-muted">Passkeys need an HTTPS domain or localhost. Set the instance URL in <RouterLink class="underline" to="/settings/authentication">Authentication settings</RouterLink>.</p>
|
||||||
</Section>
|
</Section>
|
||||||
<PersonalTokensCard />
|
<PersonalTokensCard />
|
||||||
<Section title="Recovery code" description="Shown once. Use it to reset your password if you lose access. A new code replaces the old one.">
|
<Section title="Recovery code" description="Shown once. Use it to reset your password if you lose access. A new code replaces the old one.">
|
||||||
<template #action><Button size="sm" :disabled="busy" @click="makeRecovery">Generate</Button></template>
|
<template #action><Button size="sm" :disabled="busy" @click="makeRecovery">Generate</Button></template>
|
||||||
<p v-if="recovery" class="break-all rounded-md border border-border p-3 font-mono" role="status">{{recovery}}</p>
|
<Card v-if="recovery" size="sm"><p class="break-all font-mono" role="status">{{recovery}}</p></Card>
|
||||||
</Section>
|
</Section>
|
||||||
<Section title="Change password" description="Changing your password signs out all your sessions.">
|
<Section title="Change password" description="Changing your password signs out all your sessions.">
|
||||||
<form @submit.prevent="change">
|
<form @submit.prevent="change">
|
||||||
@@ -44,4 +46,16 @@ const change=()=>run(async()=>{await api.changePassword(current.value,next.value
|
|||||||
</form>
|
</form>
|
||||||
</Section>
|
</Section>
|
||||||
</div>
|
</div>
|
||||||
|
<AlertDialog :open="pending !== null" @update:open="(v: boolean) => { if (!v) pending = null; }">
|
||||||
|
<AlertDialogContent>
|
||||||
|
<AlertDialogHeader>
|
||||||
|
<AlertDialogTitle>Remove passkey?</AlertDialogTitle>
|
||||||
|
<AlertDialogDescription>Remove the passkey "{{ pending?.name }}"? You will no longer be able to sign in with it.</AlertDialogDescription>
|
||||||
|
</AlertDialogHeader>
|
||||||
|
<AlertDialogFooter>
|
||||||
|
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
||||||
|
<AlertDialogAction @click="if (pending) { const k = pending; pending = null; remove(k.id); }">Remove passkey</AlertDialogAction>
|
||||||
|
</AlertDialogFooter>
|
||||||
|
</AlertDialogContent>
|
||||||
|
</AlertDialog>
|
||||||
</template>
|
</template>
|
||||||
@@ -1,23 +1,26 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Alert, AlertDescription } from "@/components/ui/alert";
|
import { ReadError } from "@/components/ui/read-error";
|
||||||
|
import { Skeleton } from "@/components/ui/skeleton";
|
||||||
import { Check } from "@lucide/vue";
|
import { Check } from "@lucide/vue";
|
||||||
import { computed, onMounted, ref } from "vue";
|
import { computed, onMounted, ref } from "vue";
|
||||||
import PageHeader from "@/base/PageHeader.vue";
|
import PageHeader from "@/base/PageHeader.vue";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import CodeView from "@/base/CodeView.vue";
|
import CodeView from "@/base/CodeView.vue";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import { api } from "@/lib/api";
|
import { api, classifyActionError } from "@/lib/api";
|
||||||
import { SettingRow } from "@/components/ui/setting-row";
|
import { SettingRow } from "@/components/ui/setting-row";
|
||||||
import { Section } from "@/components/ui/section";
|
import { Section } from "@/components/ui/section";
|
||||||
interface Settings {public_url:string;oidc_issuer:string;oidc_audience:string;oidc_client_id:string}
|
interface Settings {public_url:string;oidc_issuer:string;oidc_audience:string;oidc_client_id:string}
|
||||||
const value=ref<Settings>({public_url:"",oidc_issuer:"",oidc_audience:"",oidc_client_id:""});const loaded=ref(false);const error=ref("");const busy=ref(false);const saved=ref(false);
|
const value=ref<Settings>({public_url:"",oidc_issuer:"",oidc_audience:"",oidc_client_id:""});const loaded=ref(false);const error=ref("");const sessionExpired=ref(false);const busy=ref(false);const saved=ref(false);
|
||||||
onMounted(async()=>{try{value.value=await api.authentication<Settings>();loaded.value=true}catch(cause){error.value=String((cause as Error).message||cause)}});
|
async function load(){try{value.value=await api.authentication<Settings>();loaded.value=true;error.value=""}catch(cause){error.value=String((cause as Error).message||cause)}finally{loaded.value=true}}
|
||||||
|
onMounted(load);
|
||||||
const redirectURI=computed(()=>`${value.value.public_url.replace(/\/$/,"")}/oauth2/callback`);
|
const redirectURI=computed(()=>`${value.value.public_url.replace(/\/$/,"")}/oauth2/callback`);
|
||||||
async function save(){busy.value=true;error.value="";saved.value=false;try{await api.saveAuthentication(value.value);saved.value=true}catch(cause){error.value=String((cause as Error).message||cause)}finally{busy.value=false}}
|
async function save(){busy.value=true;error.value="";saved.value=false;try{await api.saveAuthentication(value.value);saved.value=true}catch(cause){error.value=String((cause as Error).message||cause);sessionExpired.value=classifyActionError(cause).kind==="session-expired"}finally{busy.value=false}}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div><PageHeader title="Authentication"/>
|
<div><PageHeader title="Authentication"/>
|
||||||
<Alert v-if="error" variant="destructive" class="mb-4"><AlertDescription>{{error}} <a class="underline" href="/?reauth=1">Sign in again</a></AlertDescription></Alert>
|
<ReadError v-if="error" :message="error" retry-label="Retry" class="mb-4" @retry="load"><a v-if="sessionExpired" class="underline" href="/?reauth=1"> Sign in again</a></ReadError>
|
||||||
|
<div v-else-if="!loaded" role="status" aria-label="Loading settings" class="space-y-2 py-2"><Skeleton class="h-8 w-full" /><Skeleton class="h-8 w-full" /><Skeleton class="h-24 w-full" /></div>
|
||||||
<form v-if="loaded" @submit.prevent="save">
|
<form v-if="loaded" @submit.prevent="save">
|
||||||
<Section title="Instance URL">
|
<Section title="Instance URL">
|
||||||
<SettingRow label="Public address" for="instance-url" hint="Passkeys require HTTPS and a domain name, or localhost. Once passkeys are enrolled, their domain is fixed."><Input id="instance-url" v-model="value.public_url" type="url" required /></SettingRow>
|
<SettingRow label="Public address" for="instance-url" hint="Passkeys require HTTPS and a domain name, or localhost. Once passkeys are enrolled, their domain is fixed."><Input id="instance-url" v-model="value.public_url" type="url" required /></SettingRow>
|
||||||
|
|||||||
@@ -6,22 +6,22 @@ import { Input } from "@/components/ui/input";
|
|||||||
import { Section } from "@/components/ui/section";
|
import { Section } from "@/components/ui/section";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||||
import { api } from "@/lib/api";
|
import { api, classifyActionError } from "@/lib/api";
|
||||||
import { ROLE_LABELS, ROLES } from "@/org/org";
|
import { ROLE_LABELS, ROLES } from "@/org/org";
|
||||||
const emit=defineEmits<{created:[]}>();
|
const emit=defineEmits<{created:[]}>();
|
||||||
// Owner is granted from the member table, not when creating an account.
|
// Owner is granted from the member table, not when creating an account.
|
||||||
const assignable = ROLES.filter((role) => role !== "owner");
|
const assignable = ROLES.filter((role) => role !== "owner");
|
||||||
const name=ref("");const email=ref("");const password=ref("");const role=ref("viewer");const busy=ref(false);const error=ref("");
|
const name=ref("");const email=ref("");const password=ref("");const role=ref("viewer");const busy=ref(false);const error=ref("");const sessionExpired=ref(false);
|
||||||
async function create(){busy.value=true;error.value="";try{await api.createAccount({display_name:name.value,email:email.value,password:password.value,role:role.value});name.value=email.value=password.value="";emit("created")}catch(cause){error.value=String((cause as Error).message||cause)}finally{busy.value=false}}
|
async function create(){busy.value=true;error.value="";try{await api.createAccount({display_name:name.value,email:email.value,password:password.value,role:role.value});name.value=email.value=password.value="";emit("created")}catch(cause){error.value=String((cause as Error).message||cause);sessionExpired.value=classifyActionError(cause).kind==="session-expired"}finally{busy.value=false}}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<Section title="Create a local account">
|
<Section title="Create a local account">
|
||||||
<form class="grid gap-3 sm:grid-cols-2" @submit.prevent="create">
|
<form class="grid gap-3 sm:grid-cols-2" @submit.prevent="create">
|
||||||
<Label for="new-account-name" class="block space-y-1 text-sm">Name<Input id="new-account-name" v-model="name" required maxlength="200" autocomplete="off" /></Label>
|
<Label for="new-account-name" class="block space-y-1 text-label">Name<Input id="new-account-name" v-model="name" required maxlength="200" autocomplete="off" /></Label>
|
||||||
<Label for="new-account-email" class="block space-y-1 text-sm">Email<Input id="new-account-email" v-model="email" type="email" required autocomplete="off" :spellcheck="false" /></Label>
|
<Label for="new-account-email" class="block space-y-1 text-label">Email<Input id="new-account-email" v-model="email" type="email" required autocomplete="off" :spellcheck="false" /></Label>
|
||||||
<Label for="new-account-password" class="block space-y-1 text-sm">Initial password<Input id="new-account-password" v-model="password" type="password" required minlength="15" maxlength="1024" autocomplete="new-password" /></Label>
|
<Label for="new-account-password" class="block space-y-1 text-label">Initial password<Input id="new-account-password" v-model="password" type="password" required minlength="15" maxlength="1024" autocomplete="new-password" /></Label>
|
||||||
<div class="block space-y-1 text-sm"><Label for="new-account-role">Role</Label><Select v-model="role"><SelectTrigger id="new-account-role" class="w-full"><SelectValue /></SelectTrigger><SelectContent><SelectItem v-for="choice in assignable" :key="choice" :value="choice">{{ ROLE_LABELS[choice] }}</SelectItem></SelectContent></Select></div>
|
<div class="block space-y-1 text-label"><Label for="new-account-role">Role</Label><Select v-model="role"><SelectTrigger id="new-account-role" class="w-full"><SelectValue /></SelectTrigger><SelectContent><SelectItem v-for="choice in assignable" :key="choice" :value="choice">{{ ROLE_LABELS[choice] }}</SelectItem></SelectContent></Select></div>
|
||||||
<Alert v-if="error" variant="destructive" class="sm:col-span-2"><AlertDescription>{{error}} <a class="underline" href="/?reauth=1">Sign in again</a></AlertDescription></Alert>
|
<Alert v-if="error" variant="destructive" class="sm:col-span-2"><AlertDescription>{{error}}<a v-if="sessionExpired" class="underline" href="/?reauth=1"> Sign in again</a></AlertDescription></Alert>
|
||||||
<Button type="submit" :disabled="busy" class="justify-self-start sm:col-span-2">Create account</Button>
|
<Button type="submit" :disabled="busy" class="justify-self-start sm:col-span-2">Create account</Button>
|
||||||
</form>
|
</form>
|
||||||
</Section>
|
</Section>
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Item, ItemGroup } from "@/components/ui/item";
|
import { Item, ItemGroup } from "@/components/ui/item";
|
||||||
|
import { ReadError } from "@/components/ui/read-error";
|
||||||
|
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from "@/components/ui/alert-dialog";
|
||||||
import { onMounted, ref } from "vue";
|
import { onMounted, ref } from "vue";
|
||||||
import { Copy, Plus, X } from "@lucide/vue";
|
import { Copy, Plus, X } from "@lucide/vue";
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { Card } from "@/components/ui/card";
|
||||||
|
import { Empty, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import { NativeSelect, NativeSelectOption } from "@/components/ui/native-select";
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||||
import { api } from "@/lib/api";
|
import { api } from "@/lib/api";
|
||||||
import { Section } from "@/components/ui/section";
|
import { Section } from "@/components/ui/section";
|
||||||
import { Timestamp } from "@/components/ui/timestamp";
|
import { Timestamp } from "@/components/ui/timestamp";
|
||||||
@@ -61,6 +65,7 @@ const create = () =>
|
|||||||
|
|
||||||
const copy = () => navigator.clipboard.writeText(created.value);
|
const copy = () => navigator.clipboard.writeText(created.value);
|
||||||
|
|
||||||
|
const pending = ref<PersonalToken | null>(null);
|
||||||
const revoke = (id: string) =>
|
const revoke = (id: string) =>
|
||||||
run(async () => {
|
run(async () => {
|
||||||
await api.revokeToken(id);
|
await api.revokeToken(id);
|
||||||
@@ -73,33 +78,48 @@ onMounted(load);
|
|||||||
<template>
|
<template>
|
||||||
<Section title="API tokens">
|
<Section title="API tokens">
|
||||||
<template v-if="available" #action>
|
<template v-if="available" #action>
|
||||||
<form class="flex items-center gap-2" @submit.prevent="create">
|
<form class="flex flex-wrap items-center gap-2" @submit.prevent="create">
|
||||||
<Input v-model="name" class="w-40" maxlength="40" required placeholder="Name" aria-label="Token name" />
|
<Input v-model="name" class="w-40 min-w-0 flex-1 sm:flex-none" maxlength="40" required placeholder="Name" aria-label="Token name" />
|
||||||
<NativeSelect v-model="days" size="sm" aria-label="Lifetime">
|
<Select :model-value="String(days)" @update:model-value="(v) => (days = Number(v))">
|
||||||
<NativeSelectOption v-for="option in lifetimes" :key="option.days" :value="option.days">{{ option.label }}</NativeSelectOption>
|
<SelectTrigger size="sm" class="w-28" aria-label="Lifetime"><SelectValue /></SelectTrigger>
|
||||||
</NativeSelect>
|
<SelectContent>
|
||||||
|
<SelectItem v-for="option in lifetimes" :key="option.days" :value="String(option.days)">{{ option.label }}</SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
<Button type="submit" size="sm" :disabled="busy || !name.trim()"><Plus data-icon="inline-start" />New token</Button>
|
<Button type="submit" size="sm" :disabled="busy || !name.trim()"><Plus data-icon="inline-start" />New token</Button>
|
||||||
</form>
|
</form>
|
||||||
</template>
|
</template>
|
||||||
<p v-if="!available && !busy && !error" class="text-fg-subtle">Personal tokens need a signed-in person.</p>
|
<p v-if="!available && !busy && !error" class="text-fg-subtle">Personal tokens need a signed-in person.</p>
|
||||||
<p v-if="error" role="alert" class="mb-3 text-danger">{{ error }}</p>
|
<ReadError v-if="error" :message="error" retry-label="Retry" class="mb-3" @retry="load" />
|
||||||
<div v-if="created" class="mb-3 rounded-lg border border-border p-3">
|
<Card v-if="created" size="sm" class="mb-3">
|
||||||
<p class="mb-2 text-xs">Copy this token now. It cannot be shown again.</p>
|
<p class="text-caption text-fg-subtle">Copy this token now. It cannot be shown again.</p>
|
||||||
<div class="flex gap-2">
|
<div class="mt-2 flex gap-2">
|
||||||
<Input :model-value="created" readonly aria-label="New token" @focus="($event.target as HTMLInputElement).select()" />
|
<Input :model-value="created" readonly aria-label="New token" @focus="($event.target as HTMLInputElement).select()" />
|
||||||
<Button variant="outline" size="sm" aria-label="Copy token" @click="copy"><Copy /></Button>
|
<Button variant="outline" size="sm" aria-label="Copy token" @click="copy"><Copy /></Button>
|
||||||
<Button variant="ghost" size="sm" aria-label="Dismiss" @click="created = ''"><X /></Button>
|
<Button variant="ghost" size="sm" aria-label="Dismiss" @click="created = ''"><X /></Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</Card>
|
||||||
<p v-if="available && !tokens.length && !busy && !error" class="text-fg-subtle">No tokens yet.</p>
|
<Empty v-if="available && !tokens.length && !busy && !error"><EmptyHeader><EmptyTitle>No tokens yet.</EmptyTitle></EmptyHeader></Empty>
|
||||||
<ItemGroup v-if="tokens.length" aria-label="API tokens">
|
<ItemGroup v-if="tokens.length" aria-label="API tokens">
|
||||||
<Item v-for="token in tokens" :key="token.id" as="li" variant="outline" size="xs">
|
<Item v-for="token in tokens" :key="token.id" as="li" variant="outline" size="xs">
|
||||||
<span class="flex-1 truncate text-sm">{{ token.name || token.id.slice(0, 12) }}</span>
|
<span class="flex-1 truncate text-label">{{ token.name || token.id.slice(0, 12) }}</span>
|
||||||
<span class="text-xs text-fg-subtle">Created <Timestamp :at="token.created_at" /></span>
|
<span class="text-caption text-fg-subtle">Created <Timestamp :at="token.created_at" /></span>
|
||||||
<span class="text-xs text-fg-subtle">Expires <Timestamp v-if="token.expires_at" :at="token.expires_at" /><template v-else>Never</template></span>
|
<span class="text-caption text-fg-subtle">Expires <Timestamp v-if="token.expires_at" :at="token.expires_at" /><template v-else>Never</template></span>
|
||||||
<span class="text-xs text-fg-subtle">Last used <Timestamp v-if="token.last_used_at" :at="token.last_used_at" /><template v-else>Never</template></span>
|
<span class="text-caption text-fg-subtle">Last used <Timestamp v-if="token.last_used_at" :at="token.last_used_at" /><template v-else>Never</template></span>
|
||||||
<Button variant="ghost" size="sm" class="text-danger" :disabled="busy" @click="revoke(token.id)">Revoke</Button>
|
<Button variant="ghost" size="sm" class="text-danger" :disabled="busy" @click="pending = token">Revoke</Button>
|
||||||
</Item>
|
</Item>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Section>
|
</Section>
|
||||||
|
<AlertDialog :open="pending !== null" @update:open="(v: boolean) => { if (!v) pending = null; }">
|
||||||
|
<AlertDialogContent>
|
||||||
|
<AlertDialogHeader>
|
||||||
|
<AlertDialogTitle>Revoke token?</AlertDialogTitle>
|
||||||
|
<AlertDialogDescription>Revoke "{{ pending?.name || pending?.id.slice(0, 12) }}"? Anything using it stops working immediately.</AlertDialogDescription>
|
||||||
|
</AlertDialogHeader>
|
||||||
|
<AlertDialogFooter>
|
||||||
|
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
||||||
|
<AlertDialogAction @click="if (pending) { const t = pending; pending = null; revoke(t.id); }">Revoke token</AlertDialogAction>
|
||||||
|
</AlertDialogFooter>
|
||||||
|
</AlertDialogContent>
|
||||||
|
</AlertDialog>
|
||||||
</template>
|
</template>
|
||||||
@@ -8,7 +8,7 @@ export const useAccountsStore=defineStore("accounts",()=>{
|
|||||||
const status=ref<AuthStatus|null>(null);
|
const status=ref<AuthStatus|null>(null);
|
||||||
const error=ref("");
|
const error=ref("");
|
||||||
async function load():Promise<void>{try{status.value=await api.authStatus<AuthStatus>();error.value=""}catch(cause){error.value=String((cause as Error).message||cause)}}
|
async function load():Promise<void>{try{status.value=await api.authStatus<AuthStatus>();error.value=""}catch(cause){error.value=String((cause as Error).message||cause)}}
|
||||||
async function signOut():Promise<void>{await api.signOut();window.location.assign("/")}
|
async function signOut():Promise<void>{try{await api.signOut()}catch(cause){error.value=String((cause as Error).message||cause);return}window.location.assign("/")}
|
||||||
// Empty for the default instance, which needs no label.
|
// Empty for the default instance, which needs no label.
|
||||||
const instance=computed(()=>{const name=status.value?.instance||"";return name==="archie"?"":name});
|
const instance=computed(()=>{const name=status.value?.instance||"";return name==="archie"?"":name});
|
||||||
return {status,error,instance,load,signOut};
|
return {status,error,instance,load,signOut};
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import { Timestamp } from "@/components/ui/timestamp";
|
|||||||
import { groupBySeverity, type AlertSeverity, type OperatorAlert } from "./alerts";
|
import { groupBySeverity, type AlertSeverity, type OperatorAlert } from "./alerts";
|
||||||
import { useAlerts } from "./use-alerts";
|
import { useAlerts } from "./use-alerts";
|
||||||
|
|
||||||
const { alerts, failed, dismiss, dismissAll } = useAlerts();
|
const { alerts, failed, loaded, dismissError, dismiss, dismissAll } = useAlerts();
|
||||||
const open = ref(false);
|
const open = ref(false);
|
||||||
|
|
||||||
const groups = computed(() => groupBySeverity(alerts.value));
|
const groups = computed(() => groupBySeverity(alerts.value));
|
||||||
@@ -43,6 +43,8 @@ function failedDeliveries(alert: OperatorAlert): number {
|
|||||||
</PopoverTrigger>
|
</PopoverTrigger>
|
||||||
<PopoverContent align="end" :collision-padding="8" class="w-[calc(100vw-1rem)] max-w-none p-0 sm:w-96">
|
<PopoverContent align="end" :collision-padding="8" class="w-[calc(100vw-1rem)] max-w-none p-0 sm:w-96">
|
||||||
<Alert v-if="failed" variant="destructive" class="px-3 py-6 text-center"><AlertDescription>Alerts could not be loaded.</AlertDescription></Alert>
|
<Alert v-if="failed" variant="destructive" class="px-3 py-6 text-center"><AlertDescription>Alerts could not be loaded.</AlertDescription></Alert>
|
||||||
|
<Alert v-if="dismissError" variant="destructive" class="px-3 py-2"><AlertDescription>Dismiss failed: {{ dismissError }}</AlertDescription></Alert>
|
||||||
|
<p v-else-if="!loaded" class="px-3 py-6 text-center text-label text-fg-muted" role="status">Loading alerts…</p>
|
||||||
<Empty v-else-if="!groups.length" class="border-0"><EmptyHeader><EmptyTitle>No alerts</EmptyTitle></EmptyHeader></Empty>
|
<Empty v-else-if="!groups.length" class="border-0"><EmptyHeader><EmptyTitle>No alerts</EmptyTitle></EmptyHeader></Empty>
|
||||||
<div v-else class="relative max-h-[calc(100dvh-6rem)] overflow-y-auto">
|
<div v-else class="relative max-h-[calc(100dvh-6rem)] overflow-y-auto">
|
||||||
<Tooltip>
|
<Tooltip>
|
||||||
@@ -72,9 +74,9 @@ function failedDeliveries(alert: OperatorAlert): number {
|
|||||||
>
|
>
|
||||||
<span class="text-label font-medium group-hover:underline">{{ alert.title }}</span>
|
<span class="text-label font-medium group-hover:underline">{{ alert.title }}</span>
|
||||||
<span v-if="alert.body" class="text-label leading-snug text-fg-muted">{{ alert.body }}</span>
|
<span v-if="alert.body" class="text-label leading-snug text-fg-muted">{{ alert.body }}</span>
|
||||||
<span v-if="failedDeliveries(alert)" class="text-xs text-warn">Webhook delivery failed.</span>
|
<span v-if="failedDeliveries(alert)" class="text-caption text-warn">Webhook delivery failed.</span>
|
||||||
</component>
|
</component>
|
||||||
<Timestamp :at="alert.first_raised" class="mt-0.5 shrink-0 text-xs whitespace-nowrap text-fg-subtle" />
|
<Timestamp :at="alert.first_raised" class="mt-0.5 shrink-0 text-caption whitespace-nowrap text-fg-subtle" />
|
||||||
<Tooltip>
|
<Tooltip>
|
||||||
<TooltipTrigger as-child>
|
<TooltipTrigger as-child>
|
||||||
<Button variant="ghost" size="icon-sm" class="-mr-2 shrink-0" :aria-label="`Dismiss ${alert.title}`" @click="dismiss(alert)"><X /></Button>
|
<Button variant="ghost" size="icon-sm" class="-mr-2 shrink-0" :aria-label="`Dismiss ${alert.title}`" @click="dismiss(alert)"><X /></Button>
|
||||||
|
|||||||
+56
-37
@@ -6,50 +6,69 @@ import { useSessionStore } from "@/stores/session";
|
|||||||
import type { OperatorAlert } from "./alerts";
|
import type { OperatorAlert } from "./alerts";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The open alerts, following the event stream: the store records every alert
|
* The open alerts, shared by every caller (the bell and the dashboard card
|
||||||
* change as an event, so the newest alert event's id moving means the list
|
* must not hold separate copies): the refs live at module scope, like
|
||||||
* moved. A reconnect re-reads, since events may have been missed.
|
* captures/state.ts, and the stream wiring is registered once. The store
|
||||||
|
* records every alert change as an event, so the newest alert event's id
|
||||||
|
* moving means the list moved. A reconnect re-reads, since events may have
|
||||||
|
* been missed.
|
||||||
*/
|
*/
|
||||||
export function useAlerts() {
|
const alerts = ref<OperatorAlert[]>([]);
|
||||||
const alerts = ref<OperatorAlert[]>([]);
|
const failed = ref(false);
|
||||||
const failed = ref(false);
|
const loaded = ref(false);
|
||||||
// Loads overlap when alert events arrive close together; only the newest
|
const dismissError = ref("");
|
||||||
// may land, or an older list overwrites a newer one.
|
// Loads overlap when alert events arrive close together; only the newest
|
||||||
let latest = 0;
|
// may land, or an older list overwrites a newer one.
|
||||||
|
let latest = 0;
|
||||||
|
let wired = false;
|
||||||
|
|
||||||
async function load() {
|
async function load() {
|
||||||
const seq = ++latest;
|
const seq = ++latest;
|
||||||
try {
|
try {
|
||||||
const next = (await api.alerts<{ alerts: OperatorAlert[] }>()).alerts;
|
const next = (await api.alerts<{ alerts: OperatorAlert[] }>()).alerts;
|
||||||
if (seq !== latest) return;
|
if (seq !== latest) return;
|
||||||
alerts.value = next;
|
alerts.value = next;
|
||||||
failed.value = false;
|
failed.value = false;
|
||||||
} catch {
|
} catch {
|
||||||
if (seq === latest) failed.value = true;
|
if (seq === latest) failed.value = true;
|
||||||
}
|
} finally {
|
||||||
|
if (seq === latest) loaded.value = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function dismiss(alert: OperatorAlert) {
|
async function dismiss(alert: OperatorAlert) {
|
||||||
latest++;
|
latest++;
|
||||||
|
dismissError.value = "";
|
||||||
|
try {
|
||||||
|
await api.dismissAlert(alert.id);
|
||||||
alerts.value = alerts.value.filter((a) => a.id !== alert.id);
|
alerts.value = alerts.value.filter((a) => a.id !== alert.id);
|
||||||
try {
|
} catch (err) {
|
||||||
await api.dismissAlert(alert.id);
|
// The dismiss failed: the alert stays and the reason is shown.
|
||||||
} catch {
|
dismissError.value = String((err as Error).message || err);
|
||||||
await load();
|
await load();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function dismissAll() {
|
async function dismissAll() {
|
||||||
const ids = alerts.value.map((a) => a.id);
|
const ids = alerts.value.map((a) => a.id);
|
||||||
alerts.value = [];
|
dismissError.value = "";
|
||||||
const results = await Promise.allSettled(ids.map((id) => api.dismissAlert(id)));
|
const results = await Promise.allSettled(ids.map((id) => api.dismissAlert(id)));
|
||||||
if (results.some((r) => r.status === "rejected")) await load();
|
const rejected = results.find((r) => r.status === "rejected");
|
||||||
|
if (rejected && rejected.status === "rejected") {
|
||||||
|
dismissError.value = String((rejected.reason as Error)?.message || rejected.reason);
|
||||||
|
await load();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
alerts.value = [];
|
||||||
|
}
|
||||||
|
|
||||||
const { activity, connectionRevision } = storeToRefs(useSessionStore());
|
export function useAlerts() {
|
||||||
watch(() => activity.value.find((event) => event.kind === "alert")?.id, load);
|
if (!wired) {
|
||||||
watch(connectionRevision, load);
|
wired = true;
|
||||||
onMounted(load);
|
const { activity, connectionRevision } = storeToRefs(useSessionStore());
|
||||||
|
watch(() => activity.value.find((event) => event.kind === "alert")?.id, load);
|
||||||
return { alerts, failed, dismiss, dismissAll };
|
watch(connectionRevision, load);
|
||||||
|
onMounted(load);
|
||||||
|
}
|
||||||
|
return { alerts, failed, loaded, dismissError, dismiss, dismissAll };
|
||||||
}
|
}
|
||||||
@@ -49,13 +49,13 @@ watch(search, (value) => {
|
|||||||
onUnmounted(() => clearTimeout(searchTimer));
|
onUnmounted(() => clearTimeout(searchTimer));
|
||||||
|
|
||||||
const actor = ref(props.query.actor ?? "");
|
const actor = ref(props.query.actor ?? "");
|
||||||
const action = ref(props.query.actions[0] ?? "");
|
const action = ref((props.query.actions ?? []).join(", "));
|
||||||
const targetId = ref(props.query.target_id ?? "");
|
const targetId = ref(props.query.target_id ?? "");
|
||||||
const from = ref(props.query.from ?? "");
|
const from = ref(props.query.from ?? "");
|
||||||
const to = ref(props.query.to ?? "");
|
const to = ref(props.query.to ?? "");
|
||||||
|
|
||||||
watch(() => props.query.actor, (value) => (actor.value = value ?? ""));
|
watch(() => props.query.actor, (value) => (actor.value = value ?? ""));
|
||||||
watch(() => props.query.actions.join(","), () => (action.value = props.query.actions[0] ?? ""));
|
watch(() => props.query.actions.join(","), () => (action.value = props.query.actions.join(", ")));
|
||||||
watch(() => props.query.target_id, (value) => (targetId.value = value ?? ""));
|
watch(() => props.query.target_id, (value) => (targetId.value = value ?? ""));
|
||||||
watch(() => props.query.from, (value) => (from.value = value ?? ""));
|
watch(() => props.query.from, (value) => (from.value = value ?? ""));
|
||||||
watch(() => props.query.to, (value) => (to.value = value ?? ""));
|
watch(() => props.query.to, (value) => (to.value = value ?? ""));
|
||||||
@@ -86,8 +86,8 @@ function commitActor() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function commitAction() {
|
function commitAction() {
|
||||||
const value = action.value.trim();
|
const list = action.value.split(",").map((entry) => entry.trim()).filter(Boolean);
|
||||||
emit("change", { actions: value ? [value] : [] });
|
emit("change", { actions: list });
|
||||||
}
|
}
|
||||||
|
|
||||||
function commitTargetId() {
|
function commitTargetId() {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Alert, AlertDescription } from "@/components/ui/alert";
|
import { Alert, AlertDescription } from "@/components/ui/alert";
|
||||||
|
import { ReadError } from "@/components/ui/read-error";
|
||||||
import { computed, nextTick, onMounted, onUnmounted, ref, watch } from "vue";
|
import { computed, nextTick, onMounted, onUnmounted, ref, watch } from "vue";
|
||||||
import { useRoute, useRouter } from "vue-router";
|
import { useRoute, useRouter } from "vue-router";
|
||||||
import { storeToRefs } from "pinia";
|
import { storeToRefs } from "pinia";
|
||||||
@@ -223,6 +224,7 @@ function openSaveView(): void {
|
|||||||
function saveView(): void {
|
function saveView(): void {
|
||||||
const name = viewName.value.trim();
|
const name = viewName.value.trim();
|
||||||
if (!name || !identityId.value) return;
|
if (!name || !identityId.value) return;
|
||||||
|
if (views.value.some((view) => view.name === name) && activeView.value?.name !== name && !window.confirm(`Replace the saved view "${name}"?`)) return;
|
||||||
views.value = [
|
views.value = [
|
||||||
...views.value.filter((view) => view.name !== name),
|
...views.value.filter((view) => view.name !== name),
|
||||||
{ name, query: routeQueryFor(query.value) },
|
{ name, query: routeQueryFor(query.value) },
|
||||||
@@ -318,7 +320,7 @@ async function confirmRevert(): Promise<void> {
|
|||||||
// same versioned replace the settings pages use.
|
// same versioned replace the settings pages use.
|
||||||
const RETENTION_KIND = "audit-retention";
|
const RETENTION_KIND = "audit-retention";
|
||||||
const retentionOpen = ref(false);
|
const retentionOpen = ref(false);
|
||||||
const retentionHours = ref("0");
|
const retentionHours = ref("");
|
||||||
const retentionError = ref("");
|
const retentionError = ref("");
|
||||||
const retentionSaving = ref(false);
|
const retentionSaving = ref(false);
|
||||||
const retentionState = settings.stateFor(RETENTION_KIND);
|
const retentionState = settings.stateFor(RETENTION_KIND);
|
||||||
@@ -408,10 +410,7 @@ async function saveRetention(): Promise<void> {
|
|||||||
<div v-if="loading" class="space-y-2" role="status" aria-label="Loading audit">
|
<div v-if="loading" class="space-y-2" role="status" aria-label="Loading audit">
|
||||||
<Skeleton v-for="n in 6" :key="n" class="h-10 w-full" />
|
<Skeleton v-for="n in 6" :key="n" class="h-10 w-full" />
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="error" class="rounded-xl border border-border bg-card p-6" role="alert">
|
<ReadError v-else-if="error" :message="error" retry-label="Retry" @retry="reload" />
|
||||||
<p class="text-sm text-danger">{{ error }}</p>
|
|
||||||
<Button class="mt-3" variant="outline" size="sm" @click="reload">Retry</Button>
|
|
||||||
</div>
|
|
||||||
<Section v-else>
|
<Section v-else>
|
||||||
<DataTable :key="queryKey" :columns="columns" :rows="records" :row-key="recordKey" storage-key="audit">
|
<DataTable :key="queryKey" :columns="columns" :rows="records" :row-key="recordKey" storage-key="audit">
|
||||||
<template #cell-event="{ row }">
|
<template #cell-event="{ row }">
|
||||||
@@ -420,7 +419,7 @@ async function saveRetention(): Promise<void> {
|
|||||||
<span class="min-w-0 break-words">{{ row.summary || `${row.category} ${row.action}` }}</span>
|
<span class="min-w-0 break-words">{{ row.summary || `${row.category} ${row.action}` }}</span>
|
||||||
<Badge v-if="badgeFor(row)" :variant="badgeFor(row)!.variant">{{ badgeFor(row)!.label }}</Badge>
|
<Badge v-if="badgeFor(row)" :variant="badgeFor(row)!.variant">{{ badgeFor(row)!.label }}</Badge>
|
||||||
</div>
|
</div>
|
||||||
<p class="mt-0.5 text-xs text-fg-subtle sm:hidden">
|
<p class="mt-0.5 text-caption text-fg-subtle sm:hidden">
|
||||||
<template v-if="hasTarget(row.target)">
|
<template v-if="hasTarget(row.target)">
|
||||||
<RouterLink v-if="targetHref(row.target)" :to="targetHref(row.target)" class="hover:underline" @click.stop>{{ row.target.label || row.target.id }}</RouterLink>
|
<RouterLink v-if="targetHref(row.target)" :to="targetHref(row.target)" class="hover:underline" @click.stop>{{ row.target.label || row.target.id }}</RouterLink>
|
||||||
<span v-else>{{ row.target.label || row.target.id }}</span>
|
<span v-else>{{ row.target.label || row.target.id }}</span>
|
||||||
@@ -435,11 +434,11 @@ async function saveRetention(): Promise<void> {
|
|||||||
<template #cell-target="{ row }">
|
<template #cell-target="{ row }">
|
||||||
<RouterLink v-if="targetHref(row.target)" :to="targetHref(row.target)" class="hover:underline" @click.stop>{{ row.target.label || row.target.id }}</RouterLink>
|
<RouterLink v-if="targetHref(row.target)" :to="targetHref(row.target)" class="hover:underline" @click.stop>{{ row.target.label || row.target.id }}</RouterLink>
|
||||||
<span v-else>{{ row.target?.label || row.target?.id }}</span>
|
<span v-else>{{ row.target?.label || row.target?.id }}</span>
|
||||||
<span class="block text-xs text-fg-subtle">{{ targetDetail(row.target) }}</span>
|
<span class="block text-caption text-fg-subtle">{{ targetDetail(row.target) }}</span>
|
||||||
</template>
|
</template>
|
||||||
<template #cell-actor="{ row }">
|
<template #cell-actor="{ row }">
|
||||||
<span>{{ row.actor.name || row.actor.id }}</span>
|
<span>{{ row.actor.name || row.actor.id }}</span>
|
||||||
<span class="block text-xs text-fg-subtle">{{ row.actor.kind }}</span>
|
<span class="block text-caption text-fg-subtle">{{ row.actor.kind }}</span>
|
||||||
</template>
|
</template>
|
||||||
<template #cell-when="{ row }"><Timestamp :at="row.at" /></template>
|
<template #cell-when="{ row }"><Timestamp :at="row.at" /></template>
|
||||||
<template #detail="{ row }">
|
<template #detail="{ row }">
|
||||||
@@ -505,7 +504,7 @@ async function saveRetention(): Promise<void> {
|
|||||||
<div class="grid gap-1.5">
|
<div class="grid gap-1.5">
|
||||||
<Label for="audit-retention-hours">Runtime event retention (hours)</Label>
|
<Label for="audit-retention-hours">Runtime event retention (hours)</Label>
|
||||||
<Input id="audit-retention-hours" v-model="retentionHours" type="number" min="0" step="1" class="w-32" />
|
<Input id="audit-retention-hours" v-model="retentionHours" type="number" min="0" step="1" class="w-32" />
|
||||||
<p class="text-xs text-fg-subtle">0 keeps them forever. Minimum 168 hours.</p>
|
<p class="text-caption text-fg-subtle">0 keeps them forever. Minimum 168 hours.</p>
|
||||||
</div>
|
</div>
|
||||||
<Alert v-if="retentionError || retentionState.error" variant="destructive"><AlertDescription>{{ retentionError || retentionState.error }}</AlertDescription></Alert>
|
<Alert v-if="retentionError || retentionState.error" variant="destructive"><AlertDescription>{{ retentionError || retentionState.error }}</AlertDescription></Alert>
|
||||||
<DialogFooter>
|
<DialogFooter>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { onMounted } from "vue";
|
|||||||
|
|
||||||
import PageHeader from "@/base/PageHeader.vue";
|
import PageHeader from "@/base/PageHeader.vue";
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
|
import { ReadError } from "@/components/ui/read-error";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { DataTable, type DataTableColumn } from "@/components/ui/data-table";
|
import { DataTable, type DataTableColumn } from "@/components/ui/data-table";
|
||||||
import { Empty, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
|
import { Empty, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
|
||||||
@@ -35,21 +36,18 @@ onMounted(() => void store.load());
|
|||||||
<Button variant="outline" size="sm" :disabled="loading" @click="store.load()">Refresh</Button>
|
<Button variant="outline" size="sm" :disabled="loading" @click="store.load()">Refresh</Button>
|
||||||
</PageHeader>
|
</PageHeader>
|
||||||
|
|
||||||
<div v-if="error" role="alert" class="mb-4 text-sm text-danger">
|
<ReadError v-if="error" :message="error" retry-label="Retry" class="mb-4" @retry="store.load()" />
|
||||||
<p>{{ error }}</p>
|
|
||||||
<Button variant="outline" size="sm" @click="store.load()">Retry</Button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Section>
|
<Section>
|
||||||
<div class="flex flex-col gap-3">
|
<div class="flex flex-col gap-3">
|
||||||
<p v-if="loading && !denials.length" class="flex items-center gap-2 text-sm text-fg-muted">
|
<p v-if="loading && !denials.length" class="flex items-center gap-2 text-label text-fg-muted">
|
||||||
<Spinner />Loading denials…
|
<Spinner />Loading denials…
|
||||||
</p>
|
</p>
|
||||||
<Empty v-else-if="!error && !denials.length">
|
<Empty v-else-if="!error && !denials.length">
|
||||||
<EmptyHeader><EmptyTitle>No denials recorded</EmptyTitle></EmptyHeader>
|
<EmptyHeader><EmptyTitle>No denials recorded</EmptyTitle></EmptyHeader>
|
||||||
</Empty>
|
</Empty>
|
||||||
<DataTable
|
<DataTable
|
||||||
v-else
|
v-else-if="!error || denials.length"
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
:rows="denials"
|
:rows="denials"
|
||||||
:row-key="(d) => `${d.at}:${d.principal}:${d.action}:${d.kind}:${d.resource}`"
|
:row-key="(d) => `${d.at}:${d.principal}:${d.action}:${d.kind}:${d.resource}`"
|
||||||
@@ -59,11 +57,11 @@ onMounted(() => void store.load());
|
|||||||
<Empty><EmptyHeader><EmptyTitle>No denials recorded</EmptyTitle></EmptyHeader></Empty>
|
<Empty><EmptyHeader><EmptyTitle>No denials recorded</EmptyTitle></EmptyHeader></Empty>
|
||||||
</template>
|
</template>
|
||||||
<template #cell-at="{ row }"><Timestamp :at="row.at" /></template>
|
<template #cell-at="{ row }"><Timestamp :at="row.at" /></template>
|
||||||
<template #cell-principal="{ row }"><span class="font-mono text-xs">{{ row.principal }}</span></template>
|
<template #cell-principal="{ row }"><span class="font-mono text-caption">{{ row.principal }}</span></template>
|
||||||
<template #cell-resource="{ row }"><span class="font-mono text-xs">{{ denialResource(row) }}</span></template>
|
<template #cell-resource="{ row }"><span class="font-mono text-caption">{{ denialResource(row) }}</span></template>
|
||||||
<template #cell-level="{ row }"><Badge variant="idle">{{ row.level }}</Badge></template>
|
<template #cell-level="{ row }"><Badge variant="idle">{{ row.level }}</Badge></template>
|
||||||
<template #cell-policies="{ row }">
|
<template #cell-policies="{ row }">
|
||||||
<span class="font-mono text-xs text-fg-muted">{{ row.policies.join(", ") || "–" }}</span>
|
<span class="font-mono text-caption text-fg-muted">{{ row.policies.join(", ") || "–" }}</span>
|
||||||
</template>
|
</template>
|
||||||
<template #cell-count="{ row }"><span class="tabular-nums">{{ row.count }}</span></template>
|
<template #cell-count="{ row }"><span class="tabular-nums">{{ row.count }}</span></template>
|
||||||
</DataTable>
|
</DataTable>
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ import type { LocationQuery } from "vue-router";
|
|||||||
|
|
||||||
import type { QueryParams } from "@/lib/api";
|
import type { QueryParams } from "@/lib/api";
|
||||||
import { formatValue, type Change } from "@/lib/changes";
|
import { formatValue, type Change } from "@/lib/changes";
|
||||||
|
import { exactTime } from "../lib/format.ts";
|
||||||
|
import { useAppearanceStore } from "../stores/appearance";
|
||||||
|
|
||||||
/** One actor as the audit feed reports it. */
|
/** One actor as the audit feed reports it. */
|
||||||
export interface AuditActor {
|
export interface AuditActor {
|
||||||
@@ -296,7 +298,8 @@ function settingsKindLabel(options: SettingsKind[], value: string): string {
|
|||||||
|
|
||||||
function localTime(value: string): string {
|
function localTime(value: string): string {
|
||||||
const date = new Date(value);
|
const date = new Date(value);
|
||||||
return Number.isNaN(date.getTime()) ? value : date.toLocaleString();
|
// In the zone chosen under Appearance, like Timestamp, not the browser's.
|
||||||
|
return Number.isNaN(date.getTime()) ? value : exactTime(date, useAppearanceStore().timeZone);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The advanced and deep-link filters as removable chips. */
|
/** The advanced and deep-link filters as removable chips. */
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ const lines = useHighlightedCode(
|
|||||||
<CodeBlockActions>
|
<CodeBlockActions>
|
||||||
<CodeBlockCopyButton :value="code" />
|
<CodeBlockCopyButton :value="code" />
|
||||||
</CodeBlockActions>
|
</CodeBlockActions>
|
||||||
<CodeBlockContent wrap class="max-h-[60vh] pe-10 text-xs">
|
<CodeBlockContent wrap class="max-h-[60vh] pe-10 text-caption">
|
||||||
<CodeBlockLine v-for="(line, index) in lines" :key="index">
|
<CodeBlockLine v-for="(line, index) in lines" :key="index">
|
||||||
<CodeBlockToken v-for="(token, i) in line" :key="i" :token="token" />
|
<CodeBlockToken v-for="(token, i) in line" :key="i" :token="token" />
|
||||||
</CodeBlockLine>
|
</CodeBlockLine>
|
||||||
|
|||||||
@@ -3,7 +3,11 @@ import { DataTable, type DataTableColumn } from "@/components/ui/data-table";
|
|||||||
import { computed } from "vue";
|
import { computed } from "vue";
|
||||||
|
|
||||||
import { MetadataList } from "@/components/ui/metadata-list";
|
import { MetadataList } from "@/components/ui/metadata-list";
|
||||||
import { fmtValue, LEVEL_COLOR, levelKind, rowClass, shortTime, type LogEntry } from "@/lib/log";
|
import { fmtValue, LEVEL_COLOR, levelKind, rowClass, type LogEntry } from "@/lib/log";
|
||||||
|
import { shortTime } from "@/lib/format";
|
||||||
|
import { useAppearanceStore } from "@/stores/appearance";
|
||||||
|
|
||||||
|
const appearance = useAppearanceStore();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log entries as a table: time, level, stage, service and message, with an
|
* Log entries as a table: time, level, stage, service and message, with an
|
||||||
@@ -57,20 +61,20 @@ const details = (entry: LogEntry) =>
|
|||||||
:initial-sort="newestFirst ? { id: 'time', desc: true } : undefined"
|
:initial-sort="newestFirst ? { id: 'time', desc: true } : undefined"
|
||||||
sticky-header
|
sticky-header
|
||||||
>
|
>
|
||||||
<template #cell-time="{ row }"><span class="font-mono text-xs text-fg-subtle">{{ shortTime(row.time) }}</span></template>
|
<template #cell-time="{ row }"><span class="font-mono text-caption text-fg-subtle">{{ shortTime(row.time, appearance.timeZone) }}</span></template>
|
||||||
<template #cell-level="{ row }">
|
<template #cell-level="{ row }">
|
||||||
<span class="text-micro font-semibold tracking-[0.04em]" :class="LEVEL_COLOR[levelKind(row.level)]">{{ (row.level || "info").toUpperCase() }}</span>
|
<span class="text-micro font-semibold tracking-[0.04em]" :class="LEVEL_COLOR[levelKind(row.level)]">{{ (row.level || "info").toUpperCase() }}</span>
|
||||||
</template>
|
</template>
|
||||||
<template #cell-service="{ row }"><span class="block max-w-40 truncate font-mono text-xs text-fg-muted">{{ field(row, "service") }}</span></template>
|
<template #cell-service="{ row }"><span class="block max-w-40 truncate font-mono text-caption text-fg-muted">{{ field(row, "service") }}</span></template>
|
||||||
<template #cell-component="{ row }"><span class="block max-w-48 truncate font-mono text-xs text-fg-muted">{{ field(row, "component") }}</span></template>
|
<template #cell-component="{ row }"><span class="block max-w-48 truncate font-mono text-caption text-fg-muted">{{ field(row, "component") }}</span></template>
|
||||||
<template #cell-stage="{ row }"><span class="block max-w-48 truncate font-mono text-xs text-fg-muted" :title="field(row, 'stage')">{{ field(row, "stage") }}</span></template>
|
<template #cell-stage="{ row }"><span class="block max-w-48 truncate font-mono text-caption text-fg-muted" :title="field(row, 'stage')">{{ field(row, "stage") }}</span></template>
|
||||||
<template #cell-message="{ row }">
|
<template #cell-message="{ row }">
|
||||||
<span class="font-mono text-xs [overflow-wrap:anywhere]">{{ row.message || row.msg || "" }}</span>
|
<span class="font-mono text-caption [overflow-wrap:anywhere]">{{ row.message || row.msg || "" }}</span>
|
||||||
<span v-if="details(row).length" class="ml-2 text-xs text-fg-subtle">{{ details(row).length }} field{{ details(row).length === 1 ? "" : "s" }}</span>
|
<span v-if="details(row).length" class="ml-2 text-caption text-fg-subtle">{{ details(row).length }} field{{ details(row).length === 1 ? "" : "s" }}</span>
|
||||||
</template>
|
</template>
|
||||||
<template #detail="{ row }">
|
<template #detail="{ row }">
|
||||||
<MetadataList v-if="details(row).length" :rows="details(row)" class="text-xs" />
|
<MetadataList v-if="details(row).length" :rows="details(row)" class="text-caption" />
|
||||||
<span v-else class="text-xs text-fg-subtle">No fields</span>
|
<span v-else class="text-caption text-fg-subtle">No fields</span>
|
||||||
</template>
|
</template>
|
||||||
</DataTable>
|
</DataTable>
|
||||||
</template>
|
</template>
|
||||||
@@ -5,7 +5,7 @@ defineProps<{ title: string }>();
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<header class="mb-4 flex min-h-9 flex-wrap items-center justify-between gap-x-4 gap-y-2">
|
<header class="mb-4 flex min-h-9 flex-wrap items-center justify-between gap-x-4 gap-y-2">
|
||||||
<h1 class="text-lg leading-tight font-semibold tracking-tight sm:text-xl sm:leading-7">{{ title }}</h1>
|
<h1 class="text-title leading-tight font-semibold tracking-tight sm:text-title sm:leading-7">{{ title }}</h1>
|
||||||
<div v-if="$slots.default" class="flex flex-wrap items-center gap-2">
|
<div v-if="$slots.default" class="flex flex-wrap items-center gap-2">
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ const title = computed(() => (props.binding ? "Edit binding" : "New binding"));
|
|||||||
<Input
|
<Input
|
||||||
id="binding-filter"
|
id="binding-filter"
|
||||||
v-model="draft.filter"
|
v-model="draft.filter"
|
||||||
class="font-mono text-xs"
|
class="font-mono text-caption"
|
||||||
placeholder='severity in ["high", "critical"]'
|
placeholder='severity in ["high", "critical"]'
|
||||||
/>
|
/>
|
||||||
<FieldDescription
|
<FieldDescription
|
||||||
@@ -259,7 +259,8 @@ const title = computed(() => (props.binding ? "Edit binding" : "New binding"));
|
|||||||
<Input
|
<Input
|
||||||
v-if="!inputDraft(name).param"
|
v-if="!inputDraft(name).param"
|
||||||
v-model="inputDraft(name).value"
|
v-model="inputDraft(name).value"
|
||||||
class="font-mono text-xs"
|
class="font-mono text-caption"
|
||||||
|
:aria-label="`${name} value`"
|
||||||
placeholder="value"
|
placeholder="value"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { computed } from "vue";
|
|||||||
import { Check, Pause, Pencil, Play, Trash2 } from "@lucide/vue";
|
import { Check, Pause, Pencil, Play, Trash2 } from "@lucide/vue";
|
||||||
|
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
|
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { DropdownMenuItem } from "@/components/ui/dropdown-menu";
|
import { DropdownMenuItem } from "@/components/ui/dropdown-menu";
|
||||||
import { MoreMenu } from "@/components/ui/more-menu";
|
import { MoreMenu } from "@/components/ui/more-menu";
|
||||||
@@ -51,22 +52,24 @@ const emit = defineEmits<{
|
|||||||
<Badge v-if="props.binding.unsigned" variant="warn">Unsigned</Badge>
|
<Badge v-if="props.binding.unsigned" variant="warn">Unsigned</Badge>
|
||||||
</div>
|
</div>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell
|
<TableCell class="max-w-56 font-mono text-caption text-fg-muted">
|
||||||
class="max-w-56 truncate font-mono text-xs text-fg-muted"
|
<Tooltip>
|
||||||
:title="props.binding.filter"
|
<TooltipTrigger as-child>
|
||||||
>
|
<span tabindex="0" class="block truncate">{{ props.binding.filter || "–" }}</span>
|
||||||
{{ props.binding.filter || "–" }}
|
</TooltipTrigger>
|
||||||
|
<TooltipContent v-if="props.binding.filter">{{ props.binding.filter }}</TooltipContent>
|
||||||
|
</Tooltip>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
{{ props.binding.workflow || "–" }}
|
{{ props.binding.workflow || "–" }}
|
||||||
<Badge v-if="props.binding.workflow_disabled" variant="warn">Disabled</Badge>
|
<Badge v-if="props.binding.workflow_disabled" variant="warn">Disabled</Badge>
|
||||||
<Badge
|
<Tooltip v-if="failing">
|
||||||
v-if="failing"
|
<TooltipTrigger as-child>
|
||||||
variant="danger"
|
<span tabindex="0" class="inline-flex"><Badge variant="danger">Not dispatching</Badge></span>
|
||||||
:title="props.binding.last_outcome?.reason"
|
</TooltipTrigger>
|
||||||
>Not dispatching</Badge
|
<TooltipContent v-if="props.binding.last_outcome?.reason">{{ props.binding.last_outcome?.reason }}</TooltipContent>
|
||||||
>
|
</Tooltip>
|
||||||
</div>
|
</div>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell class="font-mono text-fg-muted">{{
|
<TableCell class="font-mono text-fg-muted">{{
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
import { ref, watch } from "vue";
|
import { ref, watch } from "vue";
|
||||||
|
|
||||||
import { api } from "@/lib/api";
|
import { api } from "@/lib/api";
|
||||||
|
import { Empty, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
|
||||||
import { Timestamp } from "@/components/ui/timestamp";
|
import { Timestamp } from "@/components/ui/timestamp";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -26,14 +27,19 @@ const props = defineProps<{
|
|||||||
|
|
||||||
const dispatches = ref<Dispatch[]>([]);
|
const dispatches = ref<Dispatch[]>([]);
|
||||||
const failed = ref(false);
|
const failed = ref(false);
|
||||||
|
let generation = 0;
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => [props.kind, props.id],
|
() => [props.kind, props.id],
|
||||||
async () => {
|
async () => {
|
||||||
|
const current = ++generation;
|
||||||
failed.value = false;
|
failed.value = false;
|
||||||
try {
|
try {
|
||||||
dispatches.value = await api.dispatches<Dispatch[]>(props.kind, props.id);
|
const res = await api.dispatches<Dispatch[]>(props.kind, props.id);
|
||||||
|
if (current !== generation) return;
|
||||||
|
dispatches.value = res;
|
||||||
} catch {
|
} catch {
|
||||||
|
if (current !== generation) return;
|
||||||
dispatches.value = [];
|
dispatches.value = [];
|
||||||
failed.value = true;
|
failed.value = true;
|
||||||
}
|
}
|
||||||
@@ -48,8 +54,8 @@ const captureLink = (id: string) => ({
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<p v-if="failed" class="text-xs text-fg-muted">Dispatches unavailable.</p>
|
<p v-if="failed" class="text-caption text-fg-muted">Dispatches unavailable.</p>
|
||||||
<ul v-else-if="dispatches.length" class="flex flex-col gap-1 text-xs">
|
<ul v-else-if="dispatches.length" class="flex flex-col gap-1 text-caption">
|
||||||
<li
|
<li
|
||||||
v-for="d in dispatches"
|
v-for="d in dispatches"
|
||||||
:key="d.binding_id + d.capture_id"
|
:key="d.binding_id + d.capture_id"
|
||||||
@@ -79,5 +85,5 @@ const captureLink = (id: string) => ({
|
|||||||
<Timestamp :at="d.dispatched_at" />
|
<Timestamp :at="d.dispatched_at" />
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p v-else-if="props.kind !== 'tasks'" class="text-xs text-fg-muted">No dispatches yet.</p>
|
<Empty v-else-if="props.kind !== 'tasks'"><EmptyHeader><EmptyTitle>No dispatches yet.</EmptyTitle></EmptyHeader></Empty>
|
||||||
</template>
|
</template>
|
||||||
@@ -20,7 +20,7 @@ const text = computed(() => prettyPrint(props.raw));
|
|||||||
>
|
>
|
||||||
{{ label }}
|
{{ label }}
|
||||||
</h3>
|
</h3>
|
||||||
<p v-if="!text" class="text-sm text-fg-muted">(empty)</p>
|
<p v-if="!text" class="text-label text-fg-muted">(empty)</p>
|
||||||
<CodeView v-else :code="text" lang="json" />
|
<CodeView v-else :code="text" lang="json" />
|
||||||
</section>
|
</section>
|
||||||
</template>
|
</template>
|
||||||
@@ -40,18 +40,18 @@ function open(): void {
|
|||||||
<template>
|
<template>
|
||||||
<TableRow
|
<TableRow
|
||||||
:data-state="isSelected ? 'selected' : undefined"
|
:data-state="isSelected ? 'selected' : undefined"
|
||||||
role="button"
|
class="cursor-pointer"
|
||||||
tabindex="0"
|
|
||||||
:aria-current="isSelected ? 'true' : undefined"
|
|
||||||
:aria-label="label"
|
|
||||||
class="cursor-pointer focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring"
|
|
||||||
@click="open"
|
@click="open"
|
||||||
@keydown.enter.prevent="open"
|
|
||||||
@keydown.space.prevent="open"
|
|
||||||
>
|
>
|
||||||
<TableCell class="font-mono">{{
|
<TableCell class="font-mono">
|
||||||
props.capture.source || "(unknown)"
|
<button
|
||||||
}}</TableCell>
|
type="button"
|
||||||
|
class="rounded-sm focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring"
|
||||||
|
:aria-label="label"
|
||||||
|
:aria-current="isSelected ? 'true' : undefined"
|
||||||
|
@click.stop="open"
|
||||||
|
>{{ props.capture.source || "(unknown)" }}</button>
|
||||||
|
</TableCell>
|
||||||
<TableCell><Timestamp :at="props.capture.received_at" /></TableCell>
|
<TableCell><Timestamp :at="props.capture.received_at" /></TableCell>
|
||||||
<!-- An unidentified capture is never dispatched. -->
|
<!-- An unidentified capture is never dispatched. -->
|
||||||
<TableCell>
|
<TableCell>
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ function onOpenChange(open: boolean) {
|
|||||||
<Textarea
|
<Textarea
|
||||||
id="event-type-headers"
|
id="event-type-headers"
|
||||||
v-model="draft.headersText"
|
v-model="draft.headersText"
|
||||||
class="min-h-20 font-mono text-xs"
|
class="min-h-20 font-mono text-caption"
|
||||||
placeholder="X-GitHub-Event: pull_request"
|
placeholder="X-GitHub-Event: pull_request"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -93,7 +93,7 @@ function onOpenChange(open: boolean) {
|
|||||||
<Textarea
|
<Textarea
|
||||||
id="event-type-body"
|
id="event-type-body"
|
||||||
v-model="draft.body"
|
v-model="draft.body"
|
||||||
class="min-h-40 font-mono text-xs"
|
class="min-h-40 font-mono text-caption"
|
||||||
placeholder="{ }"
|
placeholder="{ }"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Spinner } from "@/components/ui/spinner";
|
import { Spinner } from "@/components/ui/spinner";
|
||||||
|
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
||||||
import {
|
import {
|
||||||
ClipboardPaste,
|
ClipboardPaste,
|
||||||
Pencil,
|
Pencil,
|
||||||
@@ -94,11 +95,8 @@ function fieldCount(schema: Record<string, string> | null | undefined): number {
|
|||||||
<TableCell class="text-right tabular-nums">{{
|
<TableCell class="text-right tabular-nums">{{
|
||||||
fieldCount(p.schema)
|
fieldCount(p.schema)
|
||||||
}}</TableCell>
|
}}</TableCell>
|
||||||
<TableCell class="font-mono text-xs"
|
<TableCell class="font-mono text-caption"
|
||||||
><span
|
><Tooltip><TooltipTrigger as-child><span tabindex="0" class="block max-w-96 truncate">{{ ruleSummary(p.rule) }}</span></TooltipTrigger><TooltipContent>{{ ruleSummary(p.rule) }}</TooltipContent></Tooltip
|
||||||
class="block max-w-96 truncate"
|
|
||||||
:title="ruleSummary(p.rule)"
|
|
||||||
>{{ ruleSummary(p.rule) }}</span
|
|
||||||
></TableCell
|
></TableCell
|
||||||
>
|
>
|
||||||
<TableCell class="text-right">
|
<TableCell class="text-right">
|
||||||
@@ -125,11 +123,8 @@ function fieldCount(schema: Record<string, string> | null | undefined): number {
|
|||||||
<TableRow v-for="t in eventTypes" :key="t.id">
|
<TableRow v-for="t in eventTypes" :key="t.id">
|
||||||
<TableCell class="font-mono">{{ t.source }}</TableCell>
|
<TableCell class="font-mono">{{ t.source }}</TableCell>
|
||||||
<TableCell>{{ t.name }}</TableCell>
|
<TableCell>{{ t.name }}</TableCell>
|
||||||
<TableCell class="font-mono text-xs"
|
<TableCell class="font-mono text-caption"
|
||||||
><span
|
><Tooltip><TooltipTrigger as-child><span tabindex="0" class="block max-w-96 truncate">{{ ruleSummary(t.rule) }}</span></TooltipTrigger><TooltipContent>{{ ruleSummary(t.rule) }}</TooltipContent></Tooltip
|
||||||
class="block max-w-96 truncate"
|
|
||||||
:title="ruleSummary(t.rule)"
|
|
||||||
>{{ ruleSummary(t.rule) }}</span
|
|
||||||
></TableCell
|
></TableCell
|
||||||
>
|
>
|
||||||
<TableCell class="text-right whitespace-nowrap">
|
<TableCell class="text-right whitespace-nowrap">
|
||||||
@@ -152,7 +147,7 @@ function fieldCount(schema: Record<string, string> | null | undefined): number {
|
|||||||
</TableBody>
|
</TableBody>
|
||||||
</Table>
|
</Table>
|
||||||
|
|
||||||
<p v-if="eventTypesLoading" class="flex items-center gap-2 text-sm text-fg-muted"><Spinner />Loading event types…</p>
|
<p v-if="eventTypesLoading" class="flex items-center gap-2 text-label text-fg-muted"><Spinner />Loading event types…</p>
|
||||||
|
|
||||||
<Empty v-else-if="!eventTypesError && !proposals.length && !eventTypes.length">
|
<Empty v-else-if="!eventTypesError && !proposals.length && !eventTypes.length">
|
||||||
<EmptyHeader>
|
<EmptyHeader>
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ function asOp(value: unknown): PayloadCondition["op"] {
|
|||||||
<template>
|
<template>
|
||||||
<div class="flex flex-col gap-4">
|
<div class="flex flex-col gap-4">
|
||||||
<div class="flex flex-col gap-2">
|
<div class="flex flex-col gap-2">
|
||||||
<Label>Headers</Label>
|
<Label id="rule-headers-label">Headers</Label>
|
||||||
<div
|
<div role="group" aria-labelledby="rule-headers-label"
|
||||||
v-for="(h, i) in rule.headers || []"
|
v-for="(h, i) in rule.headers || []"
|
||||||
:key="`h${i}`"
|
:key="`h${i}`"
|
||||||
class="flex items-center gap-2"
|
class="flex items-center gap-2"
|
||||||
@@ -69,15 +69,15 @@ function asOp(value: unknown): PayloadCondition["op"] {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex flex-col gap-2">
|
<div class="flex flex-col gap-2">
|
||||||
<Label>Payload</Label>
|
<Label id="rule-payload-label">Payload</Label>
|
||||||
<div
|
<div role="group" aria-labelledby="rule-payload-label"
|
||||||
v-for="(p, i) in rule.payload || []"
|
v-for="(p, i) in rule.payload || []"
|
||||||
:key="`p${i}`"
|
:key="`p${i}`"
|
||||||
class="flex items-center gap-2"
|
class="flex flex-wrap items-center gap-2"
|
||||||
>
|
>
|
||||||
<Input
|
<Input
|
||||||
v-model="p.path"
|
v-model="p.path"
|
||||||
class="font-mono"
|
class="min-w-0 flex-1 font-mono"
|
||||||
aria-label="Payload path"
|
aria-label="Payload path"
|
||||||
placeholder="action"
|
placeholder="action"
|
||||||
/>
|
/>
|
||||||
@@ -85,7 +85,7 @@ function asOp(value: unknown): PayloadCondition["op"] {
|
|||||||
:model-value="p.op"
|
:model-value="p.op"
|
||||||
@update:model-value="(value) => (p.op = asOp(value))"
|
@update:model-value="(value) => (p.op = asOp(value))"
|
||||||
>
|
>
|
||||||
<SelectTrigger size="sm" class="w-28 shrink-0" aria-label="Condition">
|
<SelectTrigger size="sm" class="w-28 shrink-0 max-sm:w-full" aria-label="Condition">
|
||||||
<SelectValue />
|
<SelectValue />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
|
|||||||
@@ -49,14 +49,18 @@ export const draft = ref<Draft | null>(null);
|
|||||||
export const saving = ref(false);
|
export const saving = ref(false);
|
||||||
export const saveError = ref<string | null>(null);
|
export const saveError = ref<string | null>(null);
|
||||||
|
|
||||||
|
let generation = 0;
|
||||||
export async function loadEventTypes(): Promise<void> {
|
export async function loadEventTypes(): Promise<void> {
|
||||||
|
const current = ++generation;
|
||||||
try {
|
try {
|
||||||
const res = await api.eventTypes<EventTypesResponse>(useEventsStore().workspace);
|
const res = await api.eventTypes<EventTypesResponse>(useEventsStore().workspace);
|
||||||
|
if (current !== generation) return;
|
||||||
eventTypesEnabled.value = res.enabled !== false;
|
eventTypesEnabled.value = res.enabled !== false;
|
||||||
eventTypes.value = res.event_types || [];
|
eventTypes.value = res.event_types || [];
|
||||||
proposals.value = res.proposals || [];
|
proposals.value = res.proposals || [];
|
||||||
eventTypesError.value = null;
|
eventTypesError.value = null;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
if (current !== generation) return;
|
||||||
eventTypesError.value = (err as Error).message || String(err);
|
eventTypesError.value = (err as Error).message || String(err);
|
||||||
} finally {
|
} finally {
|
||||||
eventTypesLoading.value = false;
|
eventTypesLoading.value = false;
|
||||||
|
|||||||
@@ -61,13 +61,17 @@ export const selected = ref<Capture | null>(null);
|
|||||||
* are for a page with nothing on it yet, and a live refresh that put them back
|
* are for a page with nothing on it yet, and a live refresh that put them back
|
||||||
* would replace the rows an operator is reading several times a minute.
|
* would replace the rows an operator is reading several times a minute.
|
||||||
*/
|
*/
|
||||||
|
let generation = 0;
|
||||||
export async function load(): Promise<void> {
|
export async function load(): Promise<void> {
|
||||||
|
const current = ++generation;
|
||||||
try {
|
try {
|
||||||
const res = await api.captures<CapturesResponse>(LIST_LIMIT);
|
const res = await api.captures<CapturesResponse>(LIST_LIMIT);
|
||||||
|
if (current !== generation) return;
|
||||||
enabled.value = res.enabled !== false;
|
enabled.value = res.enabled !== false;
|
||||||
captures.value = res.captures || [];
|
captures.value = res.captures || [];
|
||||||
error.value = null;
|
error.value = null;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
if (current !== generation) return;
|
||||||
// The server's own message is the only part of a failure an operator can
|
// The server's own message is the only part of a failure an operator can
|
||||||
// act on, so it is what the list says instead of the captures.
|
// act on, so it is what the list says instead of the captures.
|
||||||
error.value = (err as Error).message || String(err);
|
error.value = (err as Error).message || String(err);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Alert, AlertDescription } from "@/components/ui/alert";
|
import { Alert, AlertDescription } from "@/components/ui/alert";
|
||||||
import ApplyStatusRows from "@/settings/ApplyStatusRows.vue";
|
import ApplyStatusRows from "@/settings/ApplyStatusRows.vue";
|
||||||
|
import KindGate from "@/settings/KindGate.vue";
|
||||||
import HistoryLink from "@/settings/HistoryLink.vue";
|
import HistoryLink from "@/settings/HistoryLink.vue";
|
||||||
import { computed, onMounted, reactive, ref } from "vue";
|
import { computed, onMounted, reactive, ref } from "vue";
|
||||||
import { storeToRefs } from "pinia";
|
import { storeToRefs } from "pinia";
|
||||||
@@ -73,13 +74,17 @@ const instance = computed(() => useSessionStore().sections?.settings !== false);
|
|||||||
const identities = useOrgStore();
|
const identities = useOrgStore();
|
||||||
const agents = ref<Identity[]>([]);
|
const agents = ref<Identity[]>([]);
|
||||||
const agentsError = ref("");
|
const agentsError = ref("");
|
||||||
|
let agentsGeneration = 0;
|
||||||
async function loadAgents(): Promise<void> {
|
async function loadAgents(): Promise<void> {
|
||||||
|
const current = ++agentsGeneration;
|
||||||
agentsError.value = "";
|
agentsError.value = "";
|
||||||
try {
|
try {
|
||||||
await identities.loadOrg();
|
await identities.loadOrg();
|
||||||
const response = await api.orgAgents<{ agents: Identity[] }>(identities.homeOrg);
|
const response = await api.orgAgents<{ agents: Identity[] }>(identities.homeOrg);
|
||||||
|
if (current !== agentsGeneration) return;
|
||||||
agents.value = response.agents.filter((agent) => agent.lifecycle === "active");
|
agents.value = response.agents.filter((agent) => agent.lifecycle === "active");
|
||||||
} catch (cause) {
|
} catch (cause) {
|
||||||
|
if (current !== agentsGeneration) return;
|
||||||
agentsError.value = String((cause as Error).message || cause);
|
agentsError.value = String((cause as Error).message || cause);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -90,11 +95,19 @@ const agentOptions = computed(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const statuses = ref<ChannelStatus[]>([]);
|
const statuses = ref<ChannelStatus[]>([]);
|
||||||
|
// A failed status read keeps the last known badges and flags the error, so a
|
||||||
|
// transient failure neither clears every badge nor passes as "all idle".
|
||||||
|
const statusError = ref(false);
|
||||||
|
let statusGeneration = 0;
|
||||||
async function loadStatus() {
|
async function loadStatus() {
|
||||||
|
const current = ++statusGeneration;
|
||||||
try {
|
try {
|
||||||
statuses.value = (await api.channels<{ channels?: ChannelStatus[] }>())?.channels ?? [];
|
statuses.value = (await api.channels<{ channels?: ChannelStatus[] }>())?.channels ?? [];
|
||||||
|
if (current !== statusGeneration) return;
|
||||||
|
statusError.value = false;
|
||||||
} catch {
|
} catch {
|
||||||
statuses.value = [];
|
if (current !== statusGeneration) return;
|
||||||
|
statusError.value = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
useLiveResource(null, () => void loadStatus());
|
useLiveResource(null, () => void loadStatus());
|
||||||
@@ -147,6 +160,11 @@ function setModels(list: string[]) {
|
|||||||
{{ catalogError || error }}
|
{{ catalogError || error }}
|
||||||
</AlertDescription></Alert>
|
</AlertDescription></Alert>
|
||||||
|
|
||||||
|
<Alert v-if="statusError" variant="destructive" class="mb-4"><AlertDescription>
|
||||||
|
Couldn't load channel status
|
||||||
|
<Button variant="link" size="xs" @click="loadStatus">Retry</Button>
|
||||||
|
</AlertDescription></Alert>
|
||||||
|
|
||||||
<template v-if="chat">
|
<template v-if="chat">
|
||||||
<Section v-for="channel in channels" :key="channel.id" :title="channel.title" :class="!shown(channel.id) && 'gap-0'">
|
<Section v-for="channel in channels" :key="channel.id" :title="channel.title" :class="!shown(channel.id) && 'gap-0'">
|
||||||
<template #action>
|
<template #action>
|
||||||
@@ -160,9 +178,10 @@ function setModels(list: string[]) {
|
|||||||
<FieldGroup v-if="form && shown(channel.id) && channel.id === 'telegram'" class="@container/field-group">
|
<FieldGroup v-if="form && shown(channel.id) && channel.id === 'telegram'" class="@container/field-group">
|
||||||
<form.Field v-if="!instance" v-slot="{ field }" name="agent">
|
<form.Field v-if="!instance" v-slot="{ field }" name="agent">
|
||||||
<Field orientation="responsive">
|
<Field orientation="responsive">
|
||||||
<FieldContent><FieldLabel>Runs as</FieldLabel></FieldContent>
|
<FieldContent><FieldLabel for="channel-agent">Runs as</FieldLabel></FieldContent>
|
||||||
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
||||||
<OptionSelect
|
<OptionSelect
|
||||||
|
id="channel-agent"
|
||||||
:model-value="field.state.value"
|
:model-value="field.state.value"
|
||||||
:options="agentOptions"
|
:options="agentOptions"
|
||||||
aria-label="Agent"
|
aria-label="Agent"
|
||||||
@@ -177,34 +196,34 @@ function setModels(list: string[]) {
|
|||||||
<form.Field v-if="instance" v-slot="{ field }" name="telegram.token_ref">
|
<form.Field v-if="instance" v-slot="{ field }" name="telegram.token_ref">
|
||||||
<Field orientation="responsive">
|
<Field orientation="responsive">
|
||||||
<FieldContent>
|
<FieldContent>
|
||||||
<FieldLabel>Bot token</FieldLabel>
|
<FieldLabel for="tg-token-field">Bot token</FieldLabel>
|
||||||
<FieldDescription>Empty disables Telegram.</FieldDescription>
|
<FieldDescription>Empty disables Telegram.</FieldDescription>
|
||||||
</FieldContent>
|
</FieldContent>
|
||||||
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
||||||
<SecretRefField :model-value="field.state.value" id-prefix="tg-token" @update:model-value="field.handleChange" />
|
<div id="tg-token-field" role="group" aria-label="Bot token" class="contents"><SecretRefField :model-value="field.state.value" id-prefix="tg-token" @update:model-value="field.handleChange" /></div>
|
||||||
</div>
|
</div>
|
||||||
</Field>
|
</Field>
|
||||||
</form.Field>
|
</form.Field>
|
||||||
<Field orientation="responsive">
|
<Field orientation="responsive">
|
||||||
<FieldContent>
|
<FieldContent>
|
||||||
<FieldLabel>Allowed users</FieldLabel>
|
<FieldLabel id="channel-allowed-label">Allowed users</FieldLabel>
|
||||||
<FieldDescription>Everyone else is ignored.</FieldDescription>
|
<FieldDescription>Everyone else is ignored.</FieldDescription>
|
||||||
</FieldContent>
|
</FieldContent>
|
||||||
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
||||||
<TagsInput :model-value="allowedUsers" aria-label="Allowed users" class="font-mono" @update:model-value="(ids) => setAllowedUsers(ids.map(String))">
|
<div role="group" aria-labelledby="channel-allowed-label" class="contents"><TagsInput :model-value="allowedUsers" class="font-mono" @update:model-value="(ids) => setAllowedUsers(ids.map(String))">
|
||||||
<TagsInputItem v-for="id in allowedUsers" :key="id" :value="id">
|
<TagsInputItem v-for="id in allowedUsers" :key="id" :value="id">
|
||||||
<TagsInputItemText />
|
<TagsInputItemText />
|
||||||
<TagsInputItemDelete />
|
<TagsInputItemDelete />
|
||||||
</TagsInputItem>
|
</TagsInputItem>
|
||||||
<TagsInputInput placeholder="Add user ID" />
|
<TagsInputInput placeholder="Add user ID" aria-label="Allowed users" />
|
||||||
</TagsInput>
|
</TagsInput></div>
|
||||||
</div>
|
</div>
|
||||||
</Field>
|
</Field>
|
||||||
<form.Field v-if="!instance" v-slot="{ field }" name="show_tool_calls">
|
<form.Field v-if="!instance" v-slot="{ field }" name="show_tool_calls">
|
||||||
<Field orientation="responsive">
|
<Field orientation="responsive">
|
||||||
<FieldContent><FieldLabel>Show tool calls</FieldLabel></FieldContent>
|
<FieldContent><FieldLabel :for="`channel-show-tools-${instance ? 'instance' : 'channel'}`">Show tool calls</FieldLabel></FieldContent>
|
||||||
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
||||||
<Switch :model-value="field.state.value" aria-label="Show tool calls" @update:model-value="field.handleChange" />
|
<Switch :id="`channel-show-tools-${instance ? 'instance' : 'channel'}`" :model-value="field.state.value" aria-label="Show tool calls" @update:model-value="field.handleChange" />
|
||||||
</div>
|
</div>
|
||||||
</Field>
|
</Field>
|
||||||
</form.Field>
|
</form.Field>
|
||||||
@@ -212,6 +231,7 @@ function setModels(list: string[]) {
|
|||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
<Section v-if="instance" title="Chat session defaults">
|
<Section v-if="instance" title="Chat session defaults">
|
||||||
|
<KindGate v-if="!form" :kind="KIND" />
|
||||||
<FieldGroup v-if="form" class="@container/field-group">
|
<FieldGroup v-if="form" class="@container/field-group">
|
||||||
<form.Field v-slot="{ field }" name="workspace">
|
<form.Field v-slot="{ field }" name="workspace">
|
||||||
<Field orientation="responsive">
|
<Field orientation="responsive">
|
||||||
@@ -229,31 +249,31 @@ function setModels(list: string[]) {
|
|||||||
orientation="responsive"
|
orientation="responsive"
|
||||||
:class="field.state.value && 'relative isolate before:pointer-events-none before:absolute before:inset-y-0 before:-inset-x-3 before:-z-10 before:rounded-md before:border before:border-danger/40 before:bg-danger-soft'"
|
:class="field.state.value && 'relative isolate before:pointer-events-none before:absolute before:inset-y-0 before:-inset-x-3 before:-z-10 before:rounded-md before:border before:border-danger/40 before:bg-danger-soft'"
|
||||||
>
|
>
|
||||||
<FieldContent><FieldLabel>Unrestricted filesystem</FieldLabel></FieldContent>
|
<FieldContent><FieldLabel for="channel-unrestricted">Unrestricted filesystem</FieldLabel></FieldContent>
|
||||||
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
||||||
<Switch :model-value="field.state.value" aria-label="Unrestricted filesystem" @update:model-value="field.handleChange" />
|
<Switch id="channel-unrestricted" :model-value="field.state.value" aria-label="Unrestricted filesystem" @update:model-value="field.handleChange" />
|
||||||
</div>
|
</div>
|
||||||
</Field>
|
</Field>
|
||||||
</form.Field>
|
</form.Field>
|
||||||
<form.Field v-slot="{ field }" name="show_tool_calls">
|
<form.Field v-slot="{ field }" name="show_tool_calls">
|
||||||
<Field orientation="responsive">
|
<Field orientation="responsive">
|
||||||
<FieldContent><FieldLabel>Show tool calls</FieldLabel></FieldContent>
|
<FieldContent><FieldLabel :for="`channel-show-tools-${instance ? 'instance' : 'channel'}`">Show tool calls</FieldLabel></FieldContent>
|
||||||
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
||||||
<Switch :model-value="field.state.value" aria-label="Show tool calls" @update:model-value="field.handleChange" />
|
<Switch :id="`channel-show-tools-${instance ? 'instance' : 'channel'}`" :model-value="field.state.value" aria-label="Show tool calls" @update:model-value="field.handleChange" />
|
||||||
</div>
|
</div>
|
||||||
</Field>
|
</Field>
|
||||||
</form.Field>
|
</form.Field>
|
||||||
<form.Field v-slot="{ field }" name="max_steps">
|
<form.Field v-slot="{ field }" name="max_steps">
|
||||||
<Field orientation="responsive">
|
<Field orientation="responsive">
|
||||||
<FieldContent>
|
<FieldContent>
|
||||||
<FieldLabel>Max steps</FieldLabel>
|
<FieldLabel for="channel-max-steps">Max steps</FieldLabel>
|
||||||
<FieldDescription>0 = default (100).</FieldDescription>
|
<FieldDescription>0 = default (100).</FieldDescription>
|
||||||
</FieldContent>
|
</FieldContent>
|
||||||
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
||||||
<NumberField :model-value="field.state.value" :min="0" class="w-32" @update:model-value="field.handleChange">
|
<NumberField :model-value="field.state.value" :min="0" class="w-32" @update:model-value="field.handleChange">
|
||||||
<NumberFieldContent>
|
<NumberFieldContent>
|
||||||
<NumberFieldDecrement />
|
<NumberFieldDecrement />
|
||||||
<NumberFieldInput class="font-mono" aria-label="Max steps" />
|
<NumberFieldInput id="channel-max-steps" class="font-mono" aria-label="Max steps" />
|
||||||
<NumberFieldIncrement />
|
<NumberFieldIncrement />
|
||||||
</NumberFieldContent>
|
</NumberFieldContent>
|
||||||
</NumberField>
|
</NumberField>
|
||||||
@@ -262,11 +282,11 @@ function setModels(list: string[]) {
|
|||||||
</form.Field>
|
</form.Field>
|
||||||
<Field orientation="responsive">
|
<Field orientation="responsive">
|
||||||
<FieldContent>
|
<FieldContent>
|
||||||
<FieldLabel>Rate limit</FieldLabel>
|
<FieldLabel id="channel-rate-label">Rate limit</FieldLabel>
|
||||||
<FieldDescription>Per sender. Off while either is 0.</FieldDescription>
|
<FieldDescription>Per sender. Off while either is 0.</FieldDescription>
|
||||||
</FieldContent>
|
</FieldContent>
|
||||||
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1" role="group" aria-labelledby="channel-rate-label">
|
||||||
<div class="flex flex-wrap items-center gap-2 text-sm text-fg-muted">
|
<div class="flex flex-wrap items-center gap-2 text-label text-fg-muted">
|
||||||
<form.Field v-slot="{ field }" name="rate_limit.max_requests">
|
<form.Field v-slot="{ field }" name="rate_limit.max_requests">
|
||||||
<NumberField :model-value="field.state.value" :min="0" class="w-28" @update:model-value="field.handleChange">
|
<NumberField :model-value="field.state.value" :min="0" class="w-28" @update:model-value="field.handleChange">
|
||||||
<NumberFieldContent>
|
<NumberFieldContent>
|
||||||
@@ -283,17 +303,17 @@ function setModels(list: string[]) {
|
|||||||
</Field>
|
</Field>
|
||||||
<Field orientation="responsive">
|
<Field orientation="responsive">
|
||||||
<FieldContent>
|
<FieldContent>
|
||||||
<FieldLabel>Models</FieldLabel>
|
<FieldLabel id="channel-models-label">Models</FieldLabel>
|
||||||
<FieldDescription>Empty: role models.</FieldDescription>
|
<FieldDescription>Empty: role models.</FieldDescription>
|
||||||
</FieldContent>
|
</FieldContent>
|
||||||
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
||||||
<TagsInput :model-value="models" aria-label="Models" class="font-mono" @update:model-value="(list) => setModels(list.map(String))">
|
<div role="group" aria-labelledby="channel-models-label" class="contents"><TagsInput :model-value="models" class="font-mono" @update:model-value="(list) => setModels(list.map(String))">
|
||||||
<TagsInputItem v-for="model in models" :key="model" :value="model">
|
<TagsInputItem v-for="model in models" :key="model" :value="model">
|
||||||
<TagsInputItemText />
|
<TagsInputItemText />
|
||||||
<TagsInputItemDelete />
|
<TagsInputItemDelete />
|
||||||
</TagsInputItem>
|
</TagsInputItem>
|
||||||
<TagsInputInput placeholder="provider/model" />
|
<TagsInputInput placeholder="provider/model" aria-label="Models" />
|
||||||
</TagsInput>
|
</TagsInput></div>
|
||||||
</div>
|
</div>
|
||||||
</Field>
|
</Field>
|
||||||
<form.Field v-slot="{ field }" name="operator">
|
<form.Field v-slot="{ field }" name="operator">
|
||||||
|
|||||||
+27
-12
@@ -5,41 +5,56 @@ import { ref } from "vue";
|
|||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import { Item, ItemActions, ItemContent, ItemDescription, ItemMedia, ItemTitle } from "@/components/ui/item";
|
import { Item, ItemActions, ItemContent, ItemDescription, ItemMedia, ItemTitle } from "@/components/ui/item";
|
||||||
|
import { ReadError } from "@/components/ui/read-error";
|
||||||
import ChatQuestionnaire from "./ChatQuestionnaire.vue";
|
import ChatQuestionnaire from "./ChatQuestionnaire.vue";
|
||||||
import { answerAsk, type ChatAsk } from "./state";
|
import { answerAsk, askError, type ChatAsk } from "./state";
|
||||||
|
|
||||||
defineProps<{ ask: ChatAsk }>();
|
defineProps<{ ask: ChatAsk }>();
|
||||||
|
|
||||||
const reply = ref("");
|
const reply = ref("");
|
||||||
function sendReply() {
|
// The last answer tried, so a failed send can be retried from the error.
|
||||||
|
const lastAnswer = ref("");
|
||||||
|
|
||||||
|
async function answer(value: string): Promise<boolean> {
|
||||||
|
lastAnswer.value = value;
|
||||||
|
return answerAsk(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function sendReply(): Promise<void> {
|
||||||
const text = reply.value.trim();
|
const text = reply.value.trim();
|
||||||
if (!text) return;
|
if (!text) return;
|
||||||
reply.value = "";
|
// The answer stays filled in until the server accepts it.
|
||||||
void answerAsk(text);
|
if (await answer(text)) reply.value = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
function retry(): void {
|
||||||
|
if (lastAnswer.value) void answer(lastAnswer.value);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<ChatQuestionnaire v-if="ask.kind === 'questionnaire'" :ask="ask" />
|
<ReadError v-if="askError" :message="askError" retry-label="Retry answer" class="mt-2" @retry="retry" />
|
||||||
|
|
||||||
|
<ChatQuestionnaire v-if="ask.kind === 'questionnaire'" :ask="ask" :send="answer" />
|
||||||
|
|
||||||
<Item v-else-if="ask.kind === 'approval'" variant="outline" size="sm" class="mt-2" role="group" :aria-label="ask.prompt">
|
<Item v-else-if="ask.kind === 'approval'" variant="outline" size="sm" class="mt-2" role="group" :aria-label="ask.prompt">
|
||||||
<ItemMedia variant="icon"><ShieldQuestion /></ItemMedia>
|
<ItemMedia variant="icon"><ShieldQuestion /></ItemMedia>
|
||||||
<ItemContent>
|
<ItemContent>
|
||||||
<ItemTitle>Allow {{ ask.prompt }}?</ItemTitle>
|
<ItemTitle>Allow {{ ask.prompt }}?</ItemTitle>
|
||||||
<ItemDescription v-if="ask.detail" class="font-mono text-xs break-all">{{ ask.detail }}</ItemDescription>
|
<ItemDescription v-if="ask.detail" class="font-mono text-caption break-all">{{ ask.detail }}</ItemDescription>
|
||||||
</ItemContent>
|
</ItemContent>
|
||||||
<ItemActions class="flex-wrap">
|
<ItemActions class="flex-wrap">
|
||||||
<Button size="sm" variant="outline" @click="answerAsk('deny')">Deny</Button>
|
<Button size="sm" variant="outline" @click="answer('deny')">Deny</Button>
|
||||||
<Button size="sm" variant="outline" @click="answerAsk('always')">Always this session</Button>
|
<Button size="sm" variant="outline" @click="answer('always')">Always this session</Button>
|
||||||
<Button size="sm" @click="answerAsk('approve')">Approve</Button>
|
<Button size="sm" @click="answer('approve')">Approve</Button>
|
||||||
</ItemActions>
|
</ItemActions>
|
||||||
</Item>
|
</Item>
|
||||||
|
|
||||||
<div v-else class="mt-2 rounded-lg border border-border bg-card p-3 text-sm" role="group" :aria-label="ask.prompt">
|
<div v-else class="mt-2 rounded-lg border border-border bg-card p-3 text-label" role="group" :aria-label="ask.prompt">
|
||||||
<template v-if="ask.kind === 'picker'">
|
<template v-if="ask.kind === 'picker'">
|
||||||
<p class="font-medium">{{ ask.prompt }}</p>
|
<p class="font-medium">{{ ask.prompt }}</p>
|
||||||
<div class="mt-3 flex flex-wrap gap-2">
|
<div class="mt-3 flex flex-wrap gap-2">
|
||||||
<Button v-for="choice in ask.choices" :key="choice.id" size="sm" variant="outline" @click="answerAsk(choice.id)">
|
<Button v-for="choice in ask.choices" :key="choice.id" size="sm" variant="outline" @click="answer(choice.id)">
|
||||||
{{ choice.label }}
|
{{ choice.label }}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
@@ -48,7 +63,7 @@ function sendReply() {
|
|||||||
<template v-else>
|
<template v-else>
|
||||||
<p class="font-medium">{{ ask.prompt }}</p>
|
<p class="font-medium">{{ ask.prompt }}</p>
|
||||||
<div v-if="ask.choices?.length" class="mt-3 flex flex-wrap gap-2">
|
<div v-if="ask.choices?.length" class="mt-3 flex flex-wrap gap-2">
|
||||||
<Button v-for="choice in ask.choices" :key="choice.id" size="sm" variant="outline" @click="answerAsk(choice.label)">
|
<Button v-for="choice in ask.choices" :key="choice.id" size="sm" variant="outline" @click="answer(choice.label)">
|
||||||
{{ choice.label }}
|
{{ choice.label }}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ defineProps<{ attachment: ChatMedia }>();
|
|||||||
:target="attachment.url ? '_blank' : undefined"
|
:target="attachment.url ? '_blank' : undefined"
|
||||||
:rel="attachment.url ? 'noopener noreferrer' : undefined"
|
:rel="attachment.url ? 'noopener noreferrer' : undefined"
|
||||||
:title="mediaDetail(attachment)"
|
:title="mediaDetail(attachment)"
|
||||||
class="inline-flex max-w-full items-center gap-1.5 rounded-md border border-border bg-muted px-2.5 py-1 text-xs font-medium text-fg-muted"
|
class="inline-flex max-w-full items-center gap-1.5 rounded-md border border-border bg-muted px-2.5 py-1 text-caption font-medium text-fg-muted"
|
||||||
>
|
>
|
||||||
<Paperclip aria-hidden="true" class="size-3.5 shrink-0" />
|
<Paperclip aria-hidden="true" class="size-3.5 shrink-0" />
|
||||||
<span class="truncate">{{ mediaLabel(attachment) }}</span>
|
<span class="truncate">{{ mediaLabel(attachment) }}</span>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed } from "vue";
|
import { computed } from "vue";
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||||
import { selectorData, setModel } from "./state";
|
import { selectorData, setModel } from "./state";
|
||||||
|
|
||||||
defineProps<{ choose: "model" }>();
|
defineProps<{ choose: "model" }>();
|
||||||
@@ -10,19 +10,14 @@ const options = computed(() => selectorData.value.models ?? []);
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="text-sm">
|
<div class="text-label">
|
||||||
<p class="font-medium">Choose a model</p>
|
<p class="text-label font-medium">Choose a model</p>
|
||||||
<p v-if="!options.length" class="mt-1 text-fg-muted">None configured.</p>
|
<p v-if="!options.length" class="mt-1 text-fg-muted">None configured.</p>
|
||||||
<div v-else class="mt-2 flex flex-wrap gap-2">
|
<Select v-else :model-value="selectorData.active_model" class="mt-2" @update:model-value="(v) => void setModel(String(v))">
|
||||||
<Button
|
<SelectTrigger class="w-full font-mono" aria-label="Model"><SelectValue placeholder="Choose a model" /></SelectTrigger>
|
||||||
v-for="option in options"
|
<SelectContent>
|
||||||
:key="option"
|
<SelectItem v-for="option in options" :key="option" :value="option" class="font-mono">{{ option }}</SelectItem>
|
||||||
size="sm"
|
</SelectContent>
|
||||||
:variant="option === selectorData.active_model ? 'default' : 'outline'"
|
</Select>
|
||||||
class="font-mono"
|
|
||||||
@click="void setModel(option)"
|
|
||||||
>{{ option }}</Button
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -51,13 +51,21 @@ const canRecord = computed(
|
|||||||
() => !!selectorData.value.voice_available && typeof MediaRecorder !== "undefined" && !!navigator.mediaDevices?.getUserMedia,
|
() => !!selectorData.value.voice_available && typeof MediaRecorder !== "undefined" && !!navigator.mediaDevices?.getUserMedia,
|
||||||
);
|
);
|
||||||
const recording = ref(false);
|
const recording = ref(false);
|
||||||
|
const recordError = ref("");
|
||||||
let recorder: MediaRecorder | null = null;
|
let recorder: MediaRecorder | null = null;
|
||||||
async function toggleRecording() {
|
async function toggleRecording() {
|
||||||
if (recorder) {
|
if (recorder) {
|
||||||
recorder.stop();
|
recorder.stop();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
recordError.value = "";
|
||||||
|
let stream: MediaStream;
|
||||||
|
try {
|
||||||
|
stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
||||||
|
} catch (err) {
|
||||||
|
recordError.value = `Microphone unavailable: ${(err as Error).message || err}`;
|
||||||
|
return;
|
||||||
|
}
|
||||||
const chunks: Blob[] = [];
|
const chunks: Blob[] = [];
|
||||||
recorder = new MediaRecorder(stream);
|
recorder = new MediaRecorder(stream);
|
||||||
recorder.ondataavailable = (e) => chunks.push(e.data);
|
recorder.ondataavailable = (e) => chunks.push(e.data);
|
||||||
@@ -172,7 +180,7 @@ function onKeydown(event: KeyboardEvent): void {
|
|||||||
<li
|
<li
|
||||||
v-for="(queued, index) in queuedMessages"
|
v-for="(queued, index) in queuedMessages"
|
||||||
:key="index"
|
:key="index"
|
||||||
class="flex items-center gap-1 rounded-md border border-dashed border-border px-2 py-1 text-sm text-fg-muted"
|
class="flex items-center gap-1 rounded-md border border-dashed border-border px-2 py-1 text-label text-fg-muted"
|
||||||
>
|
>
|
||||||
<Clock class="size-3.5 flex-none" aria-hidden="true" />
|
<Clock class="size-3.5 flex-none" aria-hidden="true" />
|
||||||
<span class="min-w-0 flex-1 truncate">{{ queued }}</span>
|
<span class="min-w-0 flex-1 truncate">{{ queued }}</span>
|
||||||
@@ -208,7 +216,11 @@ function onKeydown(event: KeyboardEvent): void {
|
|||||||
rows="1"
|
rows="1"
|
||||||
placeholder="Message Archie"
|
placeholder="Message Archie"
|
||||||
aria-label="Message Archie"
|
aria-label="Message Archie"
|
||||||
class="max-h-40 min-h-11 flex-1 resize-none border-0 bg-transparent! px-0 py-1 text-sm focus-visible:ring-0"
|
role="combobox"
|
||||||
|
aria-controls="slash-palette"
|
||||||
|
:aria-expanded="isCommandMenuOpen && commandMatches.length ? 'true' : 'false'"
|
||||||
|
:aria-activedescendant="isCommandMenuOpen && commandMatches.length ? `slash-palette-option-${commandSelection}` : undefined"
|
||||||
|
class="max-h-40 min-h-11 flex-1 resize-none border-0 bg-transparent! px-0 py-1 text-label focus-visible:ring-0"
|
||||||
@input="onInput"
|
@input="onInput"
|
||||||
@keydown="onKeydown"
|
@keydown="onKeydown"
|
||||||
/>
|
/>
|
||||||
@@ -236,6 +248,7 @@ function onKeydown(event: KeyboardEvent): void {
|
|||||||
@click="toggleRecording"
|
@click="toggleRecording"
|
||||||
><Mic data-icon="inline-start" />{{ recording ? "Send" : "" }}</Button
|
><Mic data-icon="inline-start" />{{ recording ? "Send" : "" }}</Button
|
||||||
>
|
>
|
||||||
|
<p v-if="recordError" class="px-1 text-caption text-danger" role="alert">{{ recordError }}</p>
|
||||||
<Button
|
<Button
|
||||||
v-else
|
v-else
|
||||||
size="sm"
|
size="sm"
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ defineProps<{ path: string; label?: string }>();
|
|||||||
<RouterLink
|
<RouterLink
|
||||||
:to="path"
|
:to="path"
|
||||||
:title="`Go to ${label || path}`"
|
:title="`Go to ${label || path}`"
|
||||||
class="inline-flex max-w-full items-center gap-1.5 rounded-md border border-primary/45 bg-primary-soft px-2.5 py-1 text-xs font-semibold text-link transition-colors hover:border-primary hover:bg-primary/15 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary"
|
class="inline-flex max-w-full items-center gap-1.5 rounded-md border border-primary/45 bg-primary-soft px-2.5 py-1 text-caption font-semibold text-link transition-colors hover:border-primary hover:bg-primary/15 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary"
|
||||||
>
|
>
|
||||||
<ArrowUpRight aria-hidden="true" class="size-3.5 shrink-0" />
|
<ArrowUpRight aria-hidden="true" class="size-3.5 shrink-0" />
|
||||||
<span class="truncate">{{ label || path }}</span>
|
<span class="truncate">{{ label || path }}</span>
|
||||||
|
|||||||
@@ -17,14 +17,15 @@ import {
|
|||||||
QuestionnaireSubmit,
|
QuestionnaireSubmit,
|
||||||
QuestionnaireTitle,
|
QuestionnaireTitle,
|
||||||
} from "@/components/ui/questionnaire";
|
} from "@/components/ui/questionnaire";
|
||||||
import { answerAsk, type ChatAsk } from "./state";
|
import type { ChatAsk } from "./state";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Several questions from one turn, answered in a single reply. The answers go
|
* Several questions from one turn, answered in a single reply. The answers go
|
||||||
* back as a JSON object of question name to the list of values given, the shape
|
* back as a JSON object of question name to the list of values given, the shape
|
||||||
* the server checks against the questions it asked.
|
* the server checks against the questions it asked. The card owns answerAsk so
|
||||||
|
* a failed submit is recorded for the card's retry.
|
||||||
*/
|
*/
|
||||||
const props = defineProps<{ ask: ChatAsk }>();
|
const props = defineProps<{ ask: ChatAsk; send: (answer: string) => Promise<boolean> }>();
|
||||||
|
|
||||||
const questions = computed(() => props.ask.questions ?? []);
|
const questions = computed(() => props.ask.questions ?? []);
|
||||||
const items = computed(() =>
|
const items = computed(() =>
|
||||||
@@ -44,7 +45,7 @@ function submit(event: Event): void {
|
|||||||
const values = form.getAll(q.name).map(String).filter((v) => v.trim());
|
const values = form.getAll(q.name).map(String).filter((v) => v.trim());
|
||||||
if (values.length) answers[q.name] = values;
|
if (values.length) answers[q.name] = values;
|
||||||
}
|
}
|
||||||
void answerAsk(JSON.stringify(answers));
|
void props.send(JSON.stringify(answers));
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -17,10 +17,17 @@ import {
|
|||||||
PopoverContent,
|
PopoverContent,
|
||||||
PopoverTrigger,
|
PopoverTrigger,
|
||||||
} from "@/components/ui/popover";
|
} from "@/components/ui/popover";
|
||||||
|
import {
|
||||||
|
Dialog,
|
||||||
|
DialogContent,
|
||||||
|
DialogFooter,
|
||||||
|
DialogHeader,
|
||||||
|
DialogTitle,
|
||||||
|
} from "@/components/ui/dialog";
|
||||||
|
import { Input } from "@/components/ui/input";
|
||||||
import ChatSettings from "./ChatSettings.vue";
|
import ChatSettings from "./ChatSettings.vue";
|
||||||
import {
|
import {
|
||||||
currentSession,
|
currentSession,
|
||||||
promptSessionCommand,
|
|
||||||
runSessionCommand,
|
runSessionCommand,
|
||||||
useEscapeLayer,
|
useEscapeLayer,
|
||||||
} from "./state";
|
} from "./state";
|
||||||
@@ -44,9 +51,22 @@ function run(command: string): void {
|
|||||||
void runSessionCommand(command);
|
void runSessionCommand(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Rename and branch ask for a value in a labelled dialog, not window.prompt.
|
||||||
|
const promptOpen = ref(false);
|
||||||
|
const promptCommand = ref("");
|
||||||
|
const promptMessage = ref("");
|
||||||
|
const promptValue = ref("");
|
||||||
function prompt(command: string, message: string): void {
|
function prompt(command: string, message: string): void {
|
||||||
open.value = false;
|
open.value = false;
|
||||||
promptSessionCommand(command, message);
|
promptCommand.value = command;
|
||||||
|
promptMessage.value = message;
|
||||||
|
promptValue.value = "";
|
||||||
|
promptOpen.value = true;
|
||||||
|
}
|
||||||
|
function submitPrompt(): void {
|
||||||
|
const value = promptValue.value.trim();
|
||||||
|
promptOpen.value = false;
|
||||||
|
if (value) void runSessionCommand(`${promptCommand.value} ${value}`);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -109,4 +129,14 @@ function prompt(command: string, message: string): void {
|
|||||||
<ChatSettings />
|
<ChatSettings />
|
||||||
</PopoverContent>
|
</PopoverContent>
|
||||||
</Popover>
|
</Popover>
|
||||||
|
<Dialog :open="promptOpen" @update:open="(v: boolean) => (promptOpen = v)">
|
||||||
|
<DialogContent>
|
||||||
|
<DialogHeader><DialogTitle>{{ promptMessage }}</DialogTitle></DialogHeader>
|
||||||
|
<Input v-model="promptValue" :aria-label="promptMessage" @keydown.enter.prevent="submitPrompt" />
|
||||||
|
<DialogFooter>
|
||||||
|
<Button variant="ghost" @click="promptOpen = false">Cancel</Button>
|
||||||
|
<Button :disabled="!promptValue.trim()" @click="submitPrompt">OK</Button>
|
||||||
|
</DialogFooter>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
</template>
|
</template>
|
||||||
@@ -38,7 +38,7 @@ const groups = computed(() => {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="grid gap-1 p-1">
|
<div class="grid gap-1 p-1">
|
||||||
<span v-if="statusText !== 'Ready'" class="text-xs text-fg-subtle">{{ statusText }}</span>
|
<span v-if="statusText !== 'Ready'" class="text-caption text-fg-subtle">{{ statusText }}</span>
|
||||||
<Select
|
<Select
|
||||||
:model-value="modelValue"
|
:model-value="modelValue"
|
||||||
@update:model-value="setModel($event === DEFAULT ? '' : String($event ?? ''))"
|
@update:model-value="setModel($event === DEFAULT ? '' : String($event ?? ''))"
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ watch(
|
|||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
ref="menu"
|
ref="menu"
|
||||||
|
id="slash-palette"
|
||||||
role="listbox"
|
role="listbox"
|
||||||
aria-label="Commands"
|
aria-label="Commands"
|
||||||
class="absolute inset-x-3 bottom-[calc(100%-0.25rem)] z-30 grid max-h-72 gap-0.5 overflow-auto rounded-lg border border-border-strong bg-popover p-1.5 shadow-md"
|
class="absolute inset-x-3 bottom-[calc(100%-0.25rem)] z-30 grid max-h-72 gap-0.5 overflow-auto rounded-lg border border-border-strong bg-popover p-1.5 shadow-md"
|
||||||
@@ -48,6 +49,7 @@ watch(
|
|||||||
:key="spec.command"
|
:key="spec.command"
|
||||||
type="button"
|
type="button"
|
||||||
role="option"
|
role="option"
|
||||||
|
:id="`slash-palette-option-${index}`"
|
||||||
:aria-selected="index === selection"
|
:aria-selected="index === selection"
|
||||||
class="grid grid-cols-[minmax(8rem,14rem)_1fr] items-center gap-2.5 rounded-md border border-transparent px-2.5 py-2 text-left text-fg-muted hover:bg-muted hover:text-foreground aria-selected:border-border aria-selected:bg-muted aria-selected:text-foreground"
|
class="grid grid-cols-[minmax(8rem,14rem)_1fr] items-center gap-2.5 rounded-md border border-transparent px-2.5 py-2 text-left text-fg-muted hover:bg-muted hover:text-foreground aria-selected:border-border aria-selected:bg-muted aria-selected:text-foreground"
|
||||||
@mousedown.prevent
|
@mousedown.prevent
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { CircleCheck, CircleX } from "@lucide/vue";
|
|||||||
import { computed } from "vue";
|
import { computed } from "vue";
|
||||||
|
|
||||||
import { CodeBlock, CodeBlockContent } from "@/components/ui/code-block";
|
import { CodeBlock, CodeBlockContent } from "@/components/ui/code-block";
|
||||||
|
import { duration as formatDuration } from "@/lib/format";
|
||||||
import {
|
import {
|
||||||
TraceCollapsible,
|
TraceCollapsible,
|
||||||
TraceCollapsibleContent,
|
TraceCollapsibleContent,
|
||||||
@@ -52,11 +53,7 @@ const outcome = computed(
|
|||||||
"",
|
"",
|
||||||
);
|
);
|
||||||
const running = computed(() => !outcome.value && !failed.value && !!props.streaming);
|
const running = computed(() => !outcome.value && !failed.value && !!props.streaming);
|
||||||
const duration = computed(() => {
|
const duration = computed(() => formatDuration(props.tool.duration_ms));
|
||||||
const ms = props.tool.duration_ms;
|
|
||||||
if (!ms) return "";
|
|
||||||
return ms < 1000 ? `${ms}ms` : `${(ms / 1000).toFixed(ms < 10000 ? 1 : 0)}s`;
|
|
||||||
});
|
|
||||||
// The row shows the call's main value, as "git diff --stat" rather than its
|
// The row shows the call's main value, as "git diff --stat" rather than its
|
||||||
// JSON: the first string argument, else its arguments as key: value pairs.
|
// JSON: the first string argument, else its arguments as key: value pairs.
|
||||||
const argument = computed(() => {
|
const argument = computed(() => {
|
||||||
@@ -87,11 +84,11 @@ const detail = computed(() =>
|
|||||||
<TraceIcon>
|
<TraceIcon>
|
||||||
<CircleX v-if="failed" />
|
<CircleX v-if="failed" />
|
||||||
<Spinner v-else-if="running" />
|
<Spinner v-else-if="running" />
|
||||||
<CircleCheck v-else class="text-success" />
|
<CircleCheck v-else class="text-ok" />
|
||||||
</TraceIcon>
|
</TraceIcon>
|
||||||
<span class="font-mono text-foreground">{{ name }}</span>
|
<span class="font-mono text-foreground">{{ name }}</span>
|
||||||
<TraceTitle class="font-mono text-xs">{{ argument }}</TraceTitle>
|
<TraceTitle class="font-mono text-caption">{{ argument }}</TraceTitle>
|
||||||
<span v-if="duration" class="shrink-0 text-xs tabular-nums">{{ duration }}</span>
|
<span v-if="duration" class="shrink-0 text-caption tabular-nums">{{ duration }}</span>
|
||||||
</TraceLine>
|
</TraceLine>
|
||||||
</TraceCollapsibleTrigger>
|
</TraceCollapsibleTrigger>
|
||||||
<TraceCollapsibleContent>
|
<TraceCollapsibleContent>
|
||||||
@@ -104,10 +101,10 @@ const detail = computed(() =>
|
|||||||
<TraceIcon>
|
<TraceIcon>
|
||||||
<CircleX v-if="failed" />
|
<CircleX v-if="failed" />
|
||||||
<Spinner v-else-if="running" />
|
<Spinner v-else-if="running" />
|
||||||
<CircleCheck v-else class="text-success" />
|
<CircleCheck v-else class="text-ok" />
|
||||||
</TraceIcon>
|
</TraceIcon>
|
||||||
<span class="font-mono text-foreground">{{ name }}</span>
|
<span class="font-mono text-foreground">{{ name }}</span>
|
||||||
<TraceTitle class="font-mono text-xs">{{ argument }}</TraceTitle>
|
<TraceTitle class="font-mono text-caption">{{ argument }}</TraceTitle>
|
||||||
<span v-if="duration" class="shrink-0 text-xs tabular-nums">{{ duration }}</span>
|
<span v-if="duration" class="shrink-0 text-caption tabular-nums">{{ duration }}</span>
|
||||||
</TraceLine>
|
</TraceLine>
|
||||||
</template>
|
</template>
|
||||||
@@ -16,11 +16,15 @@ import ChatBubble from "./ChatBubble.vue";
|
|||||||
import ChatChooseCard from "./ChatChooseCard.vue";
|
import ChatChooseCard from "./ChatChooseCard.vue";
|
||||||
import ChatUpdateCard from "./ChatUpdateCard.vue";
|
import ChatUpdateCard from "./ChatUpdateCard.vue";
|
||||||
import ChatEmptyState from "./ChatEmptyState.vue";
|
import ChatEmptyState from "./ChatEmptyState.vue";
|
||||||
|
import { Alert, AlertDescription } from "@/components/ui/alert";
|
||||||
import { Skeleton } from "@/components/ui/skeleton";
|
import { Skeleton } from "@/components/ui/skeleton";
|
||||||
import {
|
import {
|
||||||
|
currentSession,
|
||||||
isLoadingSession,
|
isLoadingSession,
|
||||||
messages,
|
messages,
|
||||||
|
selectSession,
|
||||||
sendMessage,
|
sendMessage,
|
||||||
|
sessionError,
|
||||||
streamingTurn,
|
streamingTurn,
|
||||||
type ChatMessage,
|
type ChatMessage,
|
||||||
reloadTranscript,
|
reloadTranscript,
|
||||||
@@ -90,6 +94,14 @@ useLiveResource("chat", () => void reloadTranscript());
|
|||||||
<Skeleton class="h-10 w-2/5 self-end rounded-xl" />
|
<Skeleton class="h-10 w-2/5 self-end rounded-xl" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-else-if="sessionError && !bubbles.length"
|
||||||
|
class="flex flex-col items-center gap-3 p-4"
|
||||||
|
>
|
||||||
|
<Alert variant="destructive" class="max-w-md"><AlertDescription>{{ sessionError }}</AlertDescription></Alert>
|
||||||
|
<Button variant="outline" size="sm" @click="selectSession(currentSession)">Retry</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<ChatEmptyState
|
<ChatEmptyState
|
||||||
v-else-if="!bubbles.length && !streamingTurn"
|
v-else-if="!bubbles.length && !streamingTurn"
|
||||||
@prompt="emit('prompt', $event)"
|
@prompt="emit('prompt', $event)"
|
||||||
|
|||||||
@@ -46,17 +46,17 @@ async function later() {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="text-sm">
|
<div class="text-label">
|
||||||
<p v-if="!available.length">Up to date</p>
|
<p v-if="!available.length">Up to date</p>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<p class="font-medium">An update is available</p>
|
<p class="font-medium">An update is available</p>
|
||||||
<ul class="mt-1 space-y-0.5">
|
<ul class="mt-1 space-y-0.5">
|
||||||
<li v-for="c in available" :key="c.ID">
|
<li v-for="c in available" :key="c.ID">
|
||||||
{{ c.Label || c.ID }}: <span class="font-mono">{{ c.Installed || "?" }} → {{ c.Available }}</span>
|
{{ c.Label || c.ID }}: <span class="font-mono">{{ c.Installed || "?" }} → {{ c.Available }}</span>
|
||||||
<a v-if="c.Changelog" :href="c.Changelog" target="_blank" rel="noopener" class="ml-1 text-xs underline">changes</a>
|
<a v-if="c.Changelog" :href="c.Changelog" target="_blank" rel="noopener" class="ml-1 text-caption underline">changes</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<div v-if="state === 'idle'" class="mt-3 flex gap-2">
|
<div v-if="state === 'idle' || state === 'failed'" class="mt-3 flex gap-2">
|
||||||
<Button v-if="update.can_install" size="sm" @click="install">Install</Button>
|
<Button v-if="update.can_install" size="sm" @click="install">Install</Button>
|
||||||
<Button size="sm" variant="ghost" @click="later">Not now</Button>
|
<Button size="sm" variant="ghost" @click="later">Not now</Button>
|
||||||
</div>
|
</div>
|
||||||
@@ -64,7 +64,7 @@ async function later() {
|
|||||||
<p v-else-if="state === 'deferred'" class="mt-2 text-fg-muted">Skipped until a newer release.</p>
|
<p v-else-if="state === 'deferred'" class="mt-2 text-fg-muted">Skipped until a newer release.</p>
|
||||||
<p v-else-if="state === 'done'" class="mt-2 text-ok">{{ result }}</p>
|
<p v-else-if="state === 'done'" class="mt-2 text-ok">{{ result }}</p>
|
||||||
<p v-else class="mt-2 text-danger">{{ result }}</p>
|
<p v-else class="mt-2 text-danger">{{ result }}</p>
|
||||||
<p v-if="state === 'idle' && !update.can_install" class="mt-2 text-xs text-fg-muted">No install script on this host.</p>
|
<p v-if="state === 'idle' && !update.can_install" class="mt-2 text-caption text-fg-muted">No install script on this host.</p>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
+11
-4
@@ -8,10 +8,17 @@ const CHANNEL_KEY = "archie.web.chat.channel";
|
|||||||
* the conversation instead of starting a second one beside it.
|
* the conversation instead of starting a second one beside it.
|
||||||
*/
|
*/
|
||||||
export function channelID(): string {
|
export function channelID(): string {
|
||||||
let id = localStorage.getItem(CHANNEL_KEY);
|
// Storage can be blocked (private mode, policy): fall back to a per-load id
|
||||||
if (!id) {
|
// rather than throwing a DOMException on every send.
|
||||||
id = randomUUID();
|
let id: string | null = null;
|
||||||
localStorage.setItem(CHANNEL_KEY, id);
|
try {
|
||||||
|
id = localStorage.getItem(CHANNEL_KEY);
|
||||||
|
if (!id) {
|
||||||
|
id = randomUUID();
|
||||||
|
localStorage.setItem(CHANNEL_KEY, id);
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
id = id ?? randomUUID();
|
||||||
}
|
}
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
+21
-7
@@ -1,16 +1,30 @@
|
|||||||
|
import { useAppearanceStore } from "../stores/appearance";
|
||||||
|
|
||||||
import type { ChatSession } from "./state";
|
import type { ChatSession } from "./state";
|
||||||
|
|
||||||
const started = new Intl.DateTimeFormat(undefined, {
|
// One formatter per zone, cached: the zone chosen under Appearance is applied
|
||||||
month: "short",
|
// here like Timestamp applies it, not the browser's zone.
|
||||||
day: "numeric",
|
const startedCache = new Map<string, Intl.DateTimeFormat>();
|
||||||
hour: "numeric",
|
function started(zone: string): Intl.DateTimeFormat {
|
||||||
minute: "2-digit",
|
const cached = startedCache.get(zone);
|
||||||
});
|
if (cached) return cached;
|
||||||
|
const format = new Intl.DateTimeFormat(undefined, {
|
||||||
|
month: "short",
|
||||||
|
day: "numeric",
|
||||||
|
hour: "numeric",
|
||||||
|
minute: "2-digit",
|
||||||
|
...(zone ? { timeZone: zone } : {}),
|
||||||
|
});
|
||||||
|
startedCache.set(zone, format);
|
||||||
|
return format;
|
||||||
|
}
|
||||||
|
|
||||||
// An untitled conversation is named by when it began, which tells two apart
|
// An untitled conversation is named by when it began, which tells two apart
|
||||||
// where a raw id cannot.
|
// where a raw id cannot.
|
||||||
export function sessionTitle(session: ChatSession): string {
|
export function sessionTitle(session: ChatSession): string {
|
||||||
const named = session.title || session.branch_name;
|
const named = session.title || session.branch_name;
|
||||||
if (named) return named;
|
if (named) return named;
|
||||||
return session.created_at ? started.format(new Date(session.created_at)) : "New chat";
|
return session.created_at
|
||||||
|
? started(useAppearanceStore().timeZone).format(new Date(session.created_at))
|
||||||
|
: "New chat";
|
||||||
}
|
}
|
||||||
+126
-44
@@ -167,13 +167,28 @@ interface ChatStreamFrame extends ChatToolCall {
|
|||||||
const STREAM_TIMEOUT_MS = 120000;
|
const STREAM_TIMEOUT_MS = 120000;
|
||||||
let rearmTimeout: (() => void) | null = null;
|
let rearmTimeout: (() => void) | null = null;
|
||||||
|
|
||||||
/** answerAsk sends the operator's answer to the question the turn waits on. */
|
// A failed answer keeps the question card up; the failure shows on the card.
|
||||||
export async function answerAsk(answer: string): Promise<void> {
|
export const askError = ref("");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* answerAsk sends the operator's answer to the question the turn waits on.
|
||||||
|
* Resolves true only when the answer was accepted: the question is cleared
|
||||||
|
* then, and only then. On failure the question stays, askError carries the
|
||||||
|
* message for the card, and the caller's answer stays filled in for a retry.
|
||||||
|
*/
|
||||||
|
export async function answerAsk(answer: string): Promise<boolean> {
|
||||||
const ask = streamingTurn.value?.ask;
|
const ask = streamingTurn.value?.ask;
|
||||||
if (!ask) return;
|
if (!ask) return false;
|
||||||
|
try {
|
||||||
|
await api.chatAnswer(ask.id, answer);
|
||||||
|
} catch (err) {
|
||||||
|
askError.value = (err as Error).message || "Could not send the answer";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
streamingTurn.value = streamingTurn.value ? { ...streamingTurn.value, ask: undefined } : null;
|
streamingTurn.value = streamingTurn.value ? { ...streamingTurn.value, ask: undefined } : null;
|
||||||
|
askError.value = "";
|
||||||
rearmTimeout?.();
|
rearmTimeout?.();
|
||||||
await api.chatAnswer(ask.id, answer);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const sessions = ref<ChatSession[]>([]);
|
export const sessions = ref<ChatSession[]>([]);
|
||||||
@@ -183,6 +198,9 @@ export const composerText = ref("");
|
|||||||
export const statusText = ref("Ready");
|
export const statusText = ref("Ready");
|
||||||
export const isSending = ref(false);
|
export const isSending = ref(false);
|
||||||
export const isLoadingSession = ref(false);
|
export const isLoadingSession = ref(false);
|
||||||
|
// A failed conversation load: shown in the transcript itself, with a Retry,
|
||||||
|
// rather than in the settings popover where statusText renders.
|
||||||
|
export const sessionError = ref("");
|
||||||
export const streamingTurn = ref<StreamingTurn | null>(null);
|
export const streamingTurn = ref<StreamingTurn | null>(null);
|
||||||
|
|
||||||
export const selectorData = ref<ChatSelectorData>({});
|
export const selectorData = ref<ChatSelectorData>({});
|
||||||
@@ -219,6 +237,10 @@ export function escapeOwnedByLayer(): boolean {
|
|||||||
|
|
||||||
let activeController: AbortController | null = null;
|
let activeController: AbortController | null = null;
|
||||||
|
|
||||||
|
// Bumped on every conversation switch: a turn started in an earlier
|
||||||
|
// conversation is detached and must not write into the one now open.
|
||||||
|
let sessionEpoch = 0;
|
||||||
|
|
||||||
// The send path holds a stream loop that outlives the click that started it; a
|
// The send path holds a stream loop that outlives the click that started it; a
|
||||||
// module-level controller is what a Stop, or an unmount, aborts.
|
// module-level controller is what a Stop, or an unmount, aborts.
|
||||||
function abortActiveTurn(): void {
|
function abortActiveTurn(): void {
|
||||||
@@ -250,21 +272,28 @@ export async function refreshSessions(): Promise<void> {
|
|||||||
|
|
||||||
export async function selectSession(id: string): Promise<void> {
|
export async function selectSession(id: string): Promise<void> {
|
||||||
if (!id) return;
|
if (!id) return;
|
||||||
|
// Switching conversation detaches the running turn: abort its stream and
|
||||||
|
// bump the epoch so its late writes land nowhere.
|
||||||
|
sessionEpoch++;
|
||||||
|
abortActiveTurn();
|
||||||
currentSession.value = id;
|
currentSession.value = id;
|
||||||
messages.value = [];
|
messages.value = [];
|
||||||
streamingTurn.value = null;
|
streamingTurn.value = null;
|
||||||
queuedMessages.value = [];
|
queuedMessages.value = [];
|
||||||
isLoadingSession.value = true;
|
isLoadingSession.value = true;
|
||||||
|
sessionError.value = "";
|
||||||
|
askError.value = "";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Resuming is the server's own command, so the transcript read below is of
|
// Resuming is the server's own command, so the transcript read below is of
|
||||||
// a conversation the server considers current rather than a stale one.
|
// a conversation the server considers current rather than a stale one.
|
||||||
await api.chatMessage(channelID(), `/resume ${id}`);
|
await api.chatMessage(channelID(), `/resume ${id}`);
|
||||||
messages.value = await readTranscript(id);
|
const transcript = await readTranscript(id);
|
||||||
|
if (isCurrentSession(id)) messages.value = transcript;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
statusText.value =
|
if (isCurrentSession(id))
|
||||||
(err as Error).message || "Could not load session messages";
|
sessionError.value =
|
||||||
|
(err as Error).message || "Could not load session messages";
|
||||||
} finally {
|
} finally {
|
||||||
if (isCurrentSession(id)) isLoadingSession.value = false;
|
if (isCurrentSession(id)) isLoadingSession.value = false;
|
||||||
}
|
}
|
||||||
@@ -299,10 +328,15 @@ async function readTranscript(id: string): Promise<ChatMessage[]> {
|
|||||||
*/
|
*/
|
||||||
export async function reloadTranscript(): Promise<void> {
|
export async function reloadTranscript(): Promise<void> {
|
||||||
const id = currentSession.value;
|
const id = currentSession.value;
|
||||||
if (!id || streamingTurn.value) return;
|
// A stopped turn is terminal, not in flight: it must not block reloads.
|
||||||
|
const stopped = streamingTurn.value?.text === "Turn stopped.";
|
||||||
|
if (!id || (streamingTurn.value && !stopped)) return;
|
||||||
try {
|
try {
|
||||||
const transcript = await readTranscript(id);
|
const transcript = await readTranscript(id);
|
||||||
if (isCurrentSession(id) && !streamingTurn.value) messages.value = transcript;
|
if (isCurrentSession(id) && (!streamingTurn.value || streamingTurn.value.text === "Turn stopped.")) {
|
||||||
|
messages.value = transcript;
|
||||||
|
if (stopped) streamingTurn.value = null;
|
||||||
|
}
|
||||||
} catch {
|
} catch {
|
||||||
// The next outcome or reopening the conversation reads it again.
|
// The next outcome or reopening the conversation reads it again.
|
||||||
}
|
}
|
||||||
@@ -341,26 +375,26 @@ export async function runSessionCommand(command: string): Promise<void> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rename and branch take a value the server has no form for, so the browser's
|
// Rename and branch take a value the server has no form for; the caller opens
|
||||||
// own prompt is the input: a modal built for two commands would be more UI than
|
// a labelled Dialog for it (see ChatSessionActions).
|
||||||
// the two commands are worth.
|
|
||||||
export function promptSessionCommand(command: string, message: string): void {
|
|
||||||
const value = window.prompt(message);
|
|
||||||
if (value?.trim()) void runSessionCommand(`${command} ${value.trim()}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function setModel(model: string): Promise<void> {
|
export async function setModel(model: string): Promise<void> {
|
||||||
selectedModel.value = model;
|
|
||||||
if (!model) return;
|
if (!model) return;
|
||||||
|
const previous = selectedModel.value;
|
||||||
try {
|
try {
|
||||||
const result = await api.chatMessage<{ reply?: string }>(
|
const result = await api.chatMessage<{ reply?: string }>(
|
||||||
channelID(),
|
channelID(),
|
||||||
`/model ${model}`,
|
`/model ${model}`,
|
||||||
);
|
);
|
||||||
|
selectedModel.value = model;
|
||||||
statusText.value = result.reply || "Model updated";
|
statusText.value = result.reply || "Model updated";
|
||||||
await refreshSessions();
|
await refreshSessions();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
statusText.value = `Model update failed: ${(err as Error).message || err}`;
|
// The selector keeps the model the server still has, and the failure is
|
||||||
|
// shown in the transcript, not only in status text.
|
||||||
|
selectedModel.value = previous;
|
||||||
|
sessionError.value = `Model update failed: ${(err as Error).message || err}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -376,14 +410,24 @@ export function newChat(): void {
|
|||||||
|
|
||||||
/** Messages sent while a turn runs, oldest first; each goes when the turn before it ends. */
|
/** Messages sent while a turn runs, oldest first; each goes when the turn before it ends. */
|
||||||
export const queuedMessages = ref<string[]>([]);
|
export const queuedMessages = ref<string[]>([]);
|
||||||
|
/** A voice clip recorded while a turn runs, sent when it ends. */
|
||||||
|
export const queuedVoice = ref<{ data: string; mime_type: string } | null>(null);
|
||||||
|
|
||||||
// A turn that ended, stopped included, sends the next queued message. A failed
|
// A turn that ended, stopped included, sends the next queued message. A failed
|
||||||
// one holds the queue so nothing overtakes its retry.
|
// one holds the queue so nothing overtakes its retry.
|
||||||
watch(isSending, (sending) => {
|
watch(isSending, (sending) => {
|
||||||
if (sending || !queuedMessages.value.length || streamingTurn.value?.isError) return;
|
if (sending || streamingTurn.value?.isError) return;
|
||||||
const [next, ...rest] = queuedMessages.value;
|
if (queuedMessages.value.length) {
|
||||||
queuedMessages.value = rest;
|
const [next, ...rest] = queuedMessages.value;
|
||||||
void sendMessage({ textOverride: next });
|
queuedMessages.value = rest;
|
||||||
|
void sendMessage({ textOverride: next });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const voice = queuedVoice.value;
|
||||||
|
if (voice) {
|
||||||
|
queuedVoice.value = null;
|
||||||
|
void sendMessage({ textOverride: "🎤 Voice message", voice });
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export function removeQueued(index: number): void {
|
export function removeQueued(index: number): void {
|
||||||
@@ -427,15 +471,22 @@ function currentPage(): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function sendMessage(retryOpts?: RetryOptions): Promise<void> {
|
export async function sendMessage(retryOpts?: RetryOptions): Promise<void> {
|
||||||
|
// The conversation this turn belongs to; a switch bumps sessionEpoch and
|
||||||
|
// detaches the turn, so its writes stop landing.
|
||||||
|
const epoch = sessionEpoch;
|
||||||
const explicitText = retryOpts?.textOverride;
|
const explicitText = retryOpts?.textOverride;
|
||||||
const rawValue =
|
const rawValue =
|
||||||
explicitText !== undefined ? explicitText : composerText.value;
|
explicitText !== undefined ? explicitText : composerText.value;
|
||||||
const { text, turn, isRetry } = resolveTurn(retryOpts, rawValue);
|
const { text, turn, isRetry } = resolveTurn(retryOpts, rawValue);
|
||||||
if (!text) return;
|
if (!text) return;
|
||||||
if (isSending.value) {
|
if (isSending.value) {
|
||||||
// A message typed during a turn waits for it; a retry or a voice clip
|
// A message typed during a turn waits for it; a retry has nothing to
|
||||||
// has nothing to wait for.
|
// wait for. A voice clip queues too, so it is not dropped.
|
||||||
if (isRetry || retryOpts?.voice) return;
|
if (isRetry) return;
|
||||||
|
if (retryOpts?.voice) {
|
||||||
|
queuedVoice.value = retryOpts.voice;
|
||||||
|
return;
|
||||||
|
}
|
||||||
queuedMessages.value = [...queuedMessages.value, text];
|
queuedMessages.value = [...queuedMessages.value, text];
|
||||||
if (explicitText === undefined) composerText.value = "";
|
if (explicitText === undefined) composerText.value = "";
|
||||||
closeCommandMenu();
|
closeCommandMenu();
|
||||||
@@ -481,20 +532,24 @@ export async function sendMessage(retryOpts?: RetryOptions): Promise<void> {
|
|||||||
|
|
||||||
let activeTools: ChatToolCall[] = [];
|
let activeTools: ChatToolCall[] = [];
|
||||||
streamingTurn.value = { text: "", tools: [], isError: false, turn, isRetry };
|
streamingTurn.value = { text: "", tools: [], isError: false, turn, isRetry };
|
||||||
|
askError.value = "";
|
||||||
|
|
||||||
let streamedText = "";
|
let streamedText = "";
|
||||||
let finished = false;
|
let finished = false;
|
||||||
let timedOut = false;
|
let timedOut = false;
|
||||||
|
let detached = false;
|
||||||
let timeoutId: ReturnType<typeof setTimeout> | undefined;
|
let timeoutId: ReturnType<typeof setTimeout> | undefined;
|
||||||
|
let controller: AbortController | null = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const controller = new AbortController();
|
const ctrl = new AbortController();
|
||||||
activeController = controller;
|
controller = ctrl;
|
||||||
|
activeController = ctrl;
|
||||||
const arm = () => {
|
const arm = () => {
|
||||||
clearTimeout(timeoutId);
|
clearTimeout(timeoutId);
|
||||||
timeoutId = setTimeout(() => {
|
timeoutId = setTimeout(() => {
|
||||||
timedOut = true;
|
timedOut = true;
|
||||||
controller.abort();
|
ctrl.abort();
|
||||||
}, STREAM_TIMEOUT_MS);
|
}, STREAM_TIMEOUT_MS);
|
||||||
};
|
};
|
||||||
arm();
|
arm();
|
||||||
@@ -510,7 +565,7 @@ export async function sendMessage(retryOpts?: RetryOptions): Promise<void> {
|
|||||||
page: currentPage(),
|
page: currentPage(),
|
||||||
voice: turn.voice,
|
voice: turn.voice,
|
||||||
},
|
},
|
||||||
{ signal: controller.signal },
|
{ signal: ctrl.signal },
|
||||||
);
|
);
|
||||||
const body = response.body;
|
const body = response.body;
|
||||||
if (!body) throw new Error("the chat stream returned no body");
|
if (!body) throw new Error("the chat stream returned no body");
|
||||||
@@ -525,6 +580,13 @@ export async function sendMessage(retryOpts?: RetryOptions): Promise<void> {
|
|||||||
// stream nobody collects.
|
// stream nobody collects.
|
||||||
for (;;) {
|
for (;;) {
|
||||||
const { value, done } = await reader.read();
|
const { value, done } = await reader.read();
|
||||||
|
if (epoch !== sessionEpoch) {
|
||||||
|
// Detached by a conversation switch mid-turn: stop reading and write
|
||||||
|
// nothing into the conversation now open.
|
||||||
|
detached = true;
|
||||||
|
await reader.cancel().catch(() => {});
|
||||||
|
return;
|
||||||
|
}
|
||||||
buffer += decoder.decode(value || new Uint8Array(), { stream: !done });
|
buffer += decoder.decode(value || new Uint8Array(), { stream: !done });
|
||||||
const frames = buffer.split("\n\n");
|
const frames = buffer.split("\n\n");
|
||||||
buffer = frames.pop() || "";
|
buffer = frames.pop() || "";
|
||||||
@@ -552,6 +614,7 @@ export async function sendMessage(retryOpts?: RetryOptions): Promise<void> {
|
|||||||
}
|
}
|
||||||
if (event.type === "ask" && event.ask) {
|
if (event.type === "ask" && event.ask) {
|
||||||
clearTimeout(timeoutId);
|
clearTimeout(timeoutId);
|
||||||
|
askError.value = "";
|
||||||
streamingTurn.value = streamingTurn.value
|
streamingTurn.value = streamingTurn.value
|
||||||
? { ...streamingTurn.value, ask: event.ask }
|
? { ...streamingTurn.value, ask: event.ask }
|
||||||
: null;
|
: null;
|
||||||
@@ -567,19 +630,30 @@ export async function sendMessage(retryOpts?: RetryOptions): Promise<void> {
|
|||||||
|
|
||||||
if (!finished) throw new Error("chat stream ended before completion");
|
if (!finished) throw new Error("chat stream ended before completion");
|
||||||
|
|
||||||
// /new opens an empty conversation, so the window clears instead of
|
if (epoch === sessionEpoch) {
|
||||||
// carrying the old one with a confirmation under it.
|
// /new opens an empty conversation, so the window clears instead of
|
||||||
messages.value =
|
// carrying the old one with a confirmation under it.
|
||||||
!isRetry && text.trim() === "/new"
|
messages.value =
|
||||||
? []
|
!isRetry && text.trim() === "/new"
|
||||||
: [
|
? []
|
||||||
...messages.value,
|
: [
|
||||||
{ from: "assistant", text: streamedText, tool_calls: activeTools },
|
...messages.value,
|
||||||
];
|
{ from: "assistant", text: streamedText, tool_calls: activeTools },
|
||||||
streamingTurn.value = null;
|
];
|
||||||
|
streamingTurn.value = null;
|
||||||
|
}
|
||||||
statusText.value = "Ready";
|
statusText.value = "Ready";
|
||||||
await refreshSessions();
|
// The turn succeeded; a failed session-list refresh is reported on its
|
||||||
|
// own and must not turn into a "retry this turn" error.
|
||||||
|
await refreshSessions().catch((err) => {
|
||||||
|
sessionError.value = `Could not refresh the session list: ${(err as Error).message || err}`;
|
||||||
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
// A detached turn (conversation switched mid-turn) writes nothing.
|
||||||
|
if (epoch !== sessionEpoch) {
|
||||||
|
detached = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
const failed = err as Error;
|
const failed = err as Error;
|
||||||
// What already streamed is kept; the stop or failure note follows it.
|
// What already streamed is kept; the stop or failure note follows it.
|
||||||
if (streamedText) {
|
if (streamedText) {
|
||||||
@@ -611,8 +685,14 @@ export async function sendMessage(retryOpts?: RetryOptions): Promise<void> {
|
|||||||
} finally {
|
} finally {
|
||||||
clearTimeout(timeoutId);
|
clearTimeout(timeoutId);
|
||||||
rearmTimeout = null;
|
rearmTimeout = null;
|
||||||
activeController = null;
|
// Only the turn that still owns the controller clears the sending flag: a
|
||||||
isSending.value = false;
|
// detached turn must not unlock the composer for a turn already running in
|
||||||
|
// the conversation now open.
|
||||||
|
if (controller && activeController === controller) {
|
||||||
|
activeController = null;
|
||||||
|
isSending.value = false;
|
||||||
|
if (detached) statusText.value = "Ready";
|
||||||
|
}
|
||||||
turnHooks.after?.();
|
turnHooks.after?.();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -620,7 +700,9 @@ export async function sendMessage(retryOpts?: RetryOptions): Promise<void> {
|
|||||||
export function stopTurn(): void {
|
export function stopTurn(): void {
|
||||||
statusText.value = "Stopping…";
|
statusText.value = "Stopping…";
|
||||||
if (currentSession.value) {
|
if (currentSession.value) {
|
||||||
void api.chatCancel(currentSession.value).catch(() => {});
|
void api.chatCancel(currentSession.value).catch((err) => {
|
||||||
|
sessionError.value = `Could not stop the turn: ${(err as Error).message || err}`;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
abortActiveTurn();
|
abortActiveTurn();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ defineEmits<{ revert: [change: Change] }>();
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<ItemGroup class="font-mono text-xs">
|
<ItemGroup class="font-mono text-caption">
|
||||||
<Item v-for="change in changes" :key="change.path" as="li" variant="outline" size="xs" class="group items-start">
|
<Item v-for="change in changes" :key="change.path" as="li" variant="outline" size="xs" class="group items-start">
|
||||||
<div class="min-w-0 flex-1">
|
<div class="min-w-0 flex-1">
|
||||||
<p class="mb-1 font-sans font-medium">{{ label ? label(change.path) : change.path }}</p>
|
<p class="mb-1 font-sans font-medium">{{ label ? label(change.path) : change.path }}</p>
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ watch(() => route.path, () => { if (isMobile.value) setOpenMobile(false); });
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<SidebarGroup>
|
<SidebarGroup>
|
||||||
<SidebarMenu aria-label="Sections">
|
<nav aria-label="Sections">
|
||||||
|
<SidebarMenu>
|
||||||
<SidebarMenuItem v-for="entry in links" :key="entry.path">
|
<SidebarMenuItem v-for="entry in links" :key="entry.path">
|
||||||
<SidebarMenuButton as-child :tooltip="entry.label" :is-active="activePath === entry.path" class="max-md:h-11">
|
<SidebarMenuButton as-child :tooltip="entry.label" :is-active="activePath === entry.path" class="max-md:h-11">
|
||||||
<RouterLink :to="entry.path" :aria-current="activePath === entry.path ? 'page' : undefined">
|
<RouterLink :to="entry.path" :aria-current="activePath === entry.path ? 'page' : undefined">
|
||||||
@@ -38,5 +39,6 @@ watch(() => route.path, () => { if (isMobile.value) setOpenMobile(false); });
|
|||||||
</SidebarMenuButton>
|
</SidebarMenuButton>
|
||||||
</SidebarMenuItem>
|
</SidebarMenuItem>
|
||||||
</SidebarMenu>
|
</SidebarMenu>
|
||||||
|
</nav>
|
||||||
</SidebarGroup>
|
</SidebarGroup>
|
||||||
</template>
|
</template>
|
||||||
@@ -47,10 +47,10 @@ async function choose(id: string): Promise<void> {
|
|||||||
class="data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground disabled:opacity-100"
|
class="data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground disabled:opacity-100"
|
||||||
>
|
>
|
||||||
<div class="bg-sidebar-primary text-sidebar-primary-foreground flex aspect-square size-8 items-center justify-center rounded-lg font-semibold">
|
<div class="bg-sidebar-primary text-sidebar-primary-foreground flex aspect-square size-8 items-center justify-center rounded-lg font-semibold">
|
||||||
{{ active ? initial(active.name) : "?" }}
|
{{ active ? initial(active.name) : failed ? "!" : "…" }}
|
||||||
</div>
|
</div>
|
||||||
<div class="grid flex-1 text-left leading-tight">
|
<div class="grid flex-1 text-left leading-tight">
|
||||||
<span class="truncate text-label font-medium">{{ active?.name ?? (failed ? "Organisations unavailable" : "") }}</span>
|
<span class="truncate text-label font-medium">{{ active?.name ?? (failed ? "Organisations unavailable" : "Loading…") }}</span>
|
||||||
</div>
|
</div>
|
||||||
<ChevronsUpDown v-if="choices.length > 1" class="ml-auto" aria-hidden="true" />
|
<ChevronsUpDown v-if="choices.length > 1" class="ml-auto" aria-hidden="true" />
|
||||||
</SidebarMenuButton>
|
</SidebarMenuButton>
|
||||||
@@ -61,9 +61,9 @@ async function choose(id: string): Promise<void> {
|
|||||||
:side="isMobile ? 'bottom' : 'right'"
|
:side="isMobile ? 'bottom' : 'right'"
|
||||||
:side-offset="4"
|
:side-offset="4"
|
||||||
>
|
>
|
||||||
<DropdownMenuLabel class="text-muted-foreground text-xs">Organisations</DropdownMenuLabel>
|
<DropdownMenuLabel class="text-muted-foreground text-caption">Organisations</DropdownMenuLabel>
|
||||||
<DropdownMenuItem v-for="o in choices" :key="o.id" class="gap-2 p-2" @select="choose(o.id)">
|
<DropdownMenuItem v-for="o in choices" :key="o.id" class="gap-2 p-2" @select="choose(o.id)">
|
||||||
<div class="flex size-6 items-center justify-center rounded-sm border text-xs">{{ initial(o.name) }}</div>
|
<div class="flex size-6 items-center justify-center rounded-sm border text-caption">{{ initial(o.name) }}</div>
|
||||||
{{ o.name }}
|
{{ o.name }}
|
||||||
<Check v-if="o.id === homeOrg" class="ml-auto" aria-label="Current" />
|
<Check v-if="o.id === homeOrg" class="ml-auto" aria-label="Current" />
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
|
|||||||
@@ -46,16 +46,23 @@ const workflows = ref<string[]>([]);
|
|||||||
const shortcut = navigator.platform.startsWith("Mac") ? "⌘K" : "Ctrl K";
|
const shortcut = navigator.platform.startsWith("Mac") ? "⌘K" : "Ctrl K";
|
||||||
const showWorkflows = computed(() => !props.hidden.includes("/workflows"));
|
const showWorkflows = computed(() => !props.hidden.includes("/workflows"));
|
||||||
|
|
||||||
// A failed read leaves that group empty: the pages still work, and the
|
// A failed read shows as an error item with Retry in that group, not as a
|
||||||
// palette is not the place to report a broken task list.
|
// missing group: the pages still work either way.
|
||||||
|
const tasksError = ref(false);
|
||||||
|
const workflowsError = ref(false);
|
||||||
|
let entriesGeneration = 0;
|
||||||
async function loadEntries(): Promise<void> {
|
async function loadEntries(): Promise<void> {
|
||||||
|
const current = ++entriesGeneration;
|
||||||
const [taskPage, workflowList] = await Promise.all([
|
const [taskPage, workflowList] = await Promise.all([
|
||||||
api.taskPage<TaskEntry>({ limit: 100 }).catch(() => null),
|
api.taskPage<TaskEntry>({ limit: 100 }).catch(() => null),
|
||||||
showWorkflows.value
|
showWorkflows.value
|
||||||
? api.workflows<{ definitions?: { id: string }[] }>().catch(() => null)
|
? api.workflows<{ definitions?: { id: string }[] }>().catch(() => null)
|
||||||
: null,
|
: null,
|
||||||
]);
|
]);
|
||||||
|
if (current !== entriesGeneration) return;
|
||||||
|
tasksError.value = taskPage === null;
|
||||||
tasks.value = taskPage?.tasks ?? [];
|
tasks.value = taskPage?.tasks ?? [];
|
||||||
|
workflowsError.value = showWorkflows.value && workflowList === null;
|
||||||
workflows.value = (workflowList?.definitions ?? []).map(({ id }) => id);
|
workflows.value = (workflowList?.definitions ?? []).map(({ id }) => id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,7 +136,10 @@ onUnmounted(() => document.removeEventListener("keydown", onGlobalKeydown));
|
|||||||
{{ entry.label }}
|
{{ entry.label }}
|
||||||
</CommandItem>
|
</CommandItem>
|
||||||
</CommandGroup>
|
</CommandGroup>
|
||||||
<CommandGroup v-if="workflows.length" heading="Workflows">
|
<CommandGroup v-if="workflowsError" heading="Workflows">
|
||||||
|
<CommandItem value="workflows-error" @select="loadEntries">Couldn't load workflows — Retry</CommandItem>
|
||||||
|
</CommandGroup>
|
||||||
|
<CommandGroup v-else-if="workflows.length" heading="Workflows">
|
||||||
<CommandItem
|
<CommandItem
|
||||||
v-for="id in workflows"
|
v-for="id in workflows"
|
||||||
:key="id"
|
:key="id"
|
||||||
@@ -139,7 +149,10 @@ onUnmounted(() => document.removeEventListener("keydown", onGlobalKeydown));
|
|||||||
{{ id }}
|
{{ id }}
|
||||||
</CommandItem>
|
</CommandItem>
|
||||||
</CommandGroup>
|
</CommandGroup>
|
||||||
<CommandGroup v-if="tasks.length" heading="Tasks">
|
<CommandGroup v-if="tasksError" heading="Tasks">
|
||||||
|
<CommandItem value="tasks-error" @select="loadEntries">Couldn't load tasks — Retry</CommandItem>
|
||||||
|
</CommandGroup>
|
||||||
|
<CommandGroup v-else-if="tasks.length" heading="Tasks">
|
||||||
<CommandItem
|
<CommandItem
|
||||||
v-for="task in tasks"
|
v-for="task in tasks"
|
||||||
:key="task.id"
|
:key="task.id"
|
||||||
@@ -148,7 +161,7 @@ onUnmounted(() => document.removeEventListener("keydown", onGlobalKeydown));
|
|||||||
>
|
>
|
||||||
<span class="text-fg-muted shrink-0 tabular-nums">#{{ task.id }}</span>
|
<span class="text-fg-muted shrink-0 tabular-nums">#{{ task.id }}</span>
|
||||||
<span class="truncate">{{ task.title }}</span>
|
<span class="truncate">{{ task.title }}</span>
|
||||||
<span v-if="task.status" class="text-fg-muted ml-auto shrink-0 text-xs">{{
|
<span v-if="task.status" class="text-fg-muted ml-auto shrink-0 text-caption">{{
|
||||||
statusLabel(task.status)
|
statusLabel(task.status)
|
||||||
}}</span>
|
}}</span>
|
||||||
</CommandItem>
|
</CommandItem>
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ onBeforeUnmount(() => clearTimeout(fold));
|
|||||||
<template>
|
<template>
|
||||||
<RouterLink
|
<RouterLink
|
||||||
to="/"
|
to="/"
|
||||||
class="flex items-center gap-2 rounded-md px-1 py-1 outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50"
|
class="flex items-center gap-2 rounded-md px-1 py-1 outline-none focus-visible:ring-[3px] focus-visible:ring-ring"
|
||||||
@mouseenter="hovered = true"
|
@mouseenter="hovered = true"
|
||||||
@mouseleave="hovered = false"
|
@mouseleave="hovered = false"
|
||||||
@focus="hovered = true"
|
@focus="hovered = true"
|
||||||
@@ -32,6 +32,6 @@ onBeforeUnmount(() => clearTimeout(fold));
|
|||||||
controls, so the mark alone carries the brand there (the sheet header
|
controls, so the mark alone carries the brand there (the sheet header
|
||||||
keeps the full logo). -->
|
keeps the full logo). -->
|
||||||
<Logo :open="intro || hovered" class="max-sm:[&>span:last-child]:hidden" />
|
<Logo :open="intro || hovered" class="max-sm:[&>span:last-child]:hidden" />
|
||||||
<Badge v-if="accounts.instance" variant="info">{{ accounts.instance }}</Badge>
|
<Badge v-if="accounts.instance" variant="info" class="max-w-28 truncate">{{ accounts.instance }}</Badge>
|
||||||
</RouterLink>
|
</RouterLink>
|
||||||
</template>
|
</template>
|
||||||
@@ -19,7 +19,7 @@ const label = computed(() => (streamState.value === "unavailable" ? "Disconnecte
|
|||||||
role="status"
|
role="status"
|
||||||
:aria-label="label"
|
:aria-label="label"
|
||||||
:title="label"
|
:title="label"
|
||||||
class="inline-flex items-center gap-1.5 px-1 text-xs max-sm:px-0"
|
class="inline-flex items-center gap-1.5 px-1 text-caption max-sm:px-0"
|
||||||
:class="streamState === 'unavailable' ? 'text-danger' : 'text-warn'"
|
:class="streamState === 'unavailable' ? 'text-danger' : 'text-warn'"
|
||||||
>
|
>
|
||||||
<StatusDot :tone="streamState === 'unavailable' ? 'danger' : 'warn'" live />
|
<StatusDot :tone="streamState === 'unavailable' ? 'danger' : 'warn'" live />
|
||||||
|
|||||||
Loaded 100 of 322 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user