diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 191bb4354..fdddfc509 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -70,7 +70,7 @@ one to open. | Run directories | `dw/runs.py`: `open_run`, `workflow_identity`, `new_run_id` | Each execution writes into `///` with a `manifest.json`, unless the flat layout is chosen (the test pins the flat-layout exception). | `tests/test_runs.py::TestRunDirectories::test_the_flat_layout_writes_where_it_always_did` | | A file's role (final / intermediate / input) | `dw/roles.py` | Decided per step: result.role, then a final/intermediate subfolder, then data flow (a step a media-writing or unsaved consumer reads is intermediate). Engine records it at run end, with `role_declared` where result.role stated it; a run that predates roles recorded none, so the listing falls back on the file's own `final`/`intermediate` subfolder, then the demotion below, and a file neither places has none. At read time the gallery (`GET /api/gallery`, its `role=` filter, the metadata route) also demotes a file a later run of the same workspace read - an `output:` input (an unpinned `latest` is the newest run started before the reader) or an `asset:` keep_output kept from it - unless its role was declared (`consumed_outputs`, `listed_role`, once per listing; no manifest is rewritten). | `tests/test_roles.py`, `tests/test_roles.py::test_a_file_a_later_run_read_is_consumed`, `tests/test_roles.py::test_listed_role`, `tests/test_roles.py::test_listed_role_of_a_run_that_recorded_none`, `tests/test_gallery_roles.py::test_older_run_reads_its_intermediate_subfolder_as_intermediate`, `tests/test_gallery_roles.py::test_a_pre_roles_file_a_later_run_read_lists_as_intermediate`, `tests/test_gallery_roles.py::test_metadata_agrees_with_the_listing_for_an_older_run`, `tests/test_gallery_roles.py::test_a_file_a_later_run_read_lists_as_intermediate`, `tests/test_gallery_roles.py::test_a_declared_final_stays_final` | | Notes on runs, files, assets, workspaces | `dw/notes.py` | A note is `notes.json` beside what it describes (run dir or asset dir; a file's own note, else the run's), or `workspace.json` at a workspace root. Only the server writes them, never the engine; at most 4000 characters, plain text. | `tests/test_notes.py` | -| Requests ledger | `dw/ledger.py` (the file, its writes and rules), `dw/ledger_views.py` (what a read derives), `dw/security.py`: `validate_ledger_key`, `dw/server/routes/requests.py` (the ledger and request-notes routes), `dw/server/outputs.py`: `proof_output`, `dw/server/jobs.py`: `JobManager.request_jobs`, `dw_mcp/ledger.py` | A workspace's requests are `requests.json` at its root, written only by the server, whole-request at the revision read (409 `stale_revision` otherwise), atomically under a per-directory thread lock and a file lock beside it; read without one. A file that is there but is not a ledger is never replaced (409 `ledger_unreadable`). `prompt` is write-once, item keys and request ids match `^[a-z0-9][a-z0-9-]{0,63}`, `depends_on` stays within one request and acyclic, and a user's notes, on an item or the request, are written only through their own routes (`request-notes`, user-only) and a whole-plan write keeps the stored ones. Only open requests and live items count toward the working caps; a closed request is deleted and a dropped item purged. A workspace with no root reads as empty and refuses writes. An item's status, readiness, attempts, result and spent/remaining minutes, each job's proof output and a list row's cover are derived from its linked jobs at read time and never stored; `accepted` is `{job, run_id}` of a succeeded job linked to that item. The ledger reads only the job dicts it is handed: a proof is a callable the job store answers from the manifest it already holds (a closed job's read once from its history row and kept), so a polled list reads no run directory. | `tests/test_ledger.py`, `tests/test_ledger_integrity.py`, `tests/test_ledger_job_link.py`, `tests/test_ledger_proof.py`, `tests/test_ledger_page_actions.py` | +| Requests ledger | `dw/ledger.py` (the file, its writes and rules), `dw/ledger_views.py` (what a read derives), `dw/security.py`: `validate_ledger_key`, `dw/server/routes/requests.py` (the ledger and request-notes routes), `dw/server/outputs.py`: `proof_output`, `dw/server/jobs.py`: `JobManager.request_jobs`, `dw_mcp/ledger.py` | A workspace's requests are `requests.json` at its root, written only by the server, whole-request at the revision read (409 `stale_revision` otherwise), atomically under a per-directory thread lock and a file lock beside it; read without one. A file that is there but is not a ledger is never replaced (409 `ledger_unreadable`). `prompt` is write-once, item keys and request ids match `^[a-z0-9][a-z0-9-]{0,63}`, `depends_on` stays within one request and acyclic, and a user's notes, on an item or the request, are written only through their own routes (`request-notes`, user-only) and a whole-plan write keeps the stored ones. Only open requests and live items count toward the working caps; a closed request is deleted and a dropped item purged. A workspace with no root reads as empty and refuses writes. An item's status, readiness, attempts, result and spent/remaining minutes, each job's proof output and a list row's cover are derived from its linked jobs at read time and never stored; `accepted` is `{job, run_id}` of a succeeded job linked to that item. The ledger reads only the job dicts it is handed: a proof is a callable the job store answers from the manifest it already holds (a closed job's read once from its history row and kept), so a polled list reads no run directory. A planned item can carry a review hold (#1521): `review_until` is a writable item field (the agent sets it; the server accepts it from any author) and bounded in `dw/ledger.py` (`_review_until`: 60 seconds to 24 hours ahead, an unchanged value keeps its `review_set_at` stamp), and `dw/ledger_views.py`: `_review` derives `review` (`redirected` when a note is at or after the stamp, else `due`, else `holding`) so the page and the channel read one answer; only a note redirects, and nothing on the server runs a job at the deadline. | `tests/test_ledger_review.py`, `tests/test_ledger.py`, `tests/test_ledger_integrity.py`, `tests/test_ledger_job_link.py`, `tests/test_ledger_proof.py`, `tests/test_ledger_page_actions.py` | | Run versions | `dw/runs.py`: `open_run`, `run_versions`, `record_run_versions`, `copy_runs_in` | A run takes its number once, when it opens (or, copied in from another workspace, when `copy_runs_in` places it), so deleting a middle run leaves a gap rather than renumbering. | `tests/test_runs.py::TestRunVersions::test_a_deleted_middle_run_leaves_a_gap_rather_than_renumbering`, `tests/test_runs.py::TestRunVersions::test_runs_started_in_the_same_second_still_number_upward` | | Run-version surfaces | `dw/runs.py`: `run_versions`, `dw/server/routes/gallery.py`, `dw/server/outputs.py`, `dw_mcp/tools_catalog.py`: `list_gallery`, `ui/src/lib/pages/GalleryPage.svelte` | Only `dw/runs.py` computes the number, and every other module reads it back. | `tests/test_runs.py::TestRunVersions::test_an_output_reference_can_name_a_run_by_its_version` | | What the server says about an output file | `dw/server/outputs.py`: `output_annotations` | The gallery listing (`dw/server/routes/gallery.py`) and the metadata route (`dw/server/routes/media.py`) describe an output file's `role`, `note`, `note_source`, `run_note`, `starred` and `version` through `output_annotations`, and neither builds those fields on its own. | `tests/test_gallery_roles.py::test_metadata_agrees_with_the_listing_on_a_starred_noted_demoted_file` | @@ -180,7 +180,8 @@ one to open. | Locations from a workflow | `dw/locations.py` | A local path in a workflow's media arguments (named like their media, or declared by the task's `@register_command(media_arguments=...)`, read through `TASK_MEDIA_ARGUMENTS`) is confined to a known root, a location written as a URL is one `security.validate_url` accepts, and a URL must not name a host inside the deployment. A host that does not resolve is refused. The requests themselves are `dw/outbound.py`'s. | `tests/test_locations.py::TestMediaPathContainment::test_absolute_path_outside_every_root_is_refused`, `tests/test_locations.py::TestMediaPathContainment::test_a_url_that_is_not_http_is_refused`, `tests/test_locations.py::TestMediaPathContainment::test_an_upper_case_https_url_is_not_refused_as_another_scheme`, `tests/test_security_ssrf.py::TestInternalAddressSpellings::test_a_name_that_resolves_inside`, `tests/test_locations.py::TestTaskMediaArguments::test_an_unreadable_source_is_an_error_at_its_path` | | Outbound requests | `dw/outbound.py`: `safe_get`, `safe_post` | Every outbound request is validated per hop against `dw/locations.py`'s policy, resolved once and dialed at the address the policy checked, capped and timed. No other module under `dw/` makes an HTTP request or builds a session or adapter. | `tests/test_outbound.py::TestSafeRequest::test_one_lookup_per_hop_and_the_dial_is_the_checked_address` | | Trust gate | `dw/trust.py`: `require_trusted_dotted_name` | In an untrusted workflow (the default), a dotted type outside the allowlist is a validation error before anything is imported. | `tests/test_security_trust_gate.py::TestValidationRefusesBeforeImport::test_a_dotted_type_is_a_validation_error` | -| Remote pipeline code | `dw/trust.py`: `require_trusted_block` (the worker's gate, via `workflow_run.require_trusted_steps`), `pipeline_remote_code_errors` (the same gate as the `pipeline_remote_code` check in `dw/validation.py`) | Untrusted, a pipeline step's `from_pretrained_arguments` (or a nested component block's) may not set `trust_remote_code` or `custom_pipeline`; validate refuses with the run's own message at `steps[N].pipeline`, one gate and no second key list. | `tests/test_validate_trust_gate.py::test_registry_pass_is_the_runs_gate` | +| Remote pipeline code | `dw/trust.py`: `require_trusted_block` (the worker's gate, via `workflow_run.require_trusted_steps`), `pipeline_remote_code_errors` (the same gate as the `pipeline_remote_code` check in `dw/validation.py`) | Untrusted, a pipeline step's `from_pretrained_arguments` (or a nested component block's) may not set `trust_remote_code` or `custom_pipeline`, nor its `configuration` name a `pre_load_modules` entry outside the allowed packages; validate refuses with the run's own message at `steps[N].pipeline`, one gate and no second key list, so a submit that fails it makes no job. | `tests/test_validate_trust_gate.py::test_registry_pass_is_the_runs_gate`, `tests/test_trust_precheck.py::test_submit_refuses_a_pre_load_module_with_no_job` | +| Worker trust pre-check | `dw/workflow_run.py`: `require_trusted_pipelines`, `require_trusted_steps`; `dw/type_references.py`: `require_trusted_type_references` | Before the worker releases the previous workflow's models it refuses what the run would: the pipeline gate above, and a dotted type or `constant:` outside the allowed packages, so a refused job leaves the warm models loaded. It reads validate's expansion (`Workflow.expanded_definition`) and loads no asset, clip or URL; trusted, it returns before preparing anything. It covers the top-level steps; a sub-workflow's are refused by validate at submit and by the loader at their own load. | `tests/test_trust_precheck.py::test_a_refused_job_keeps_the_warm_models`, `tests/test_trust_precheck.py::TestThePreCheckLoadsNoMedia::test_untrusted_reads_keys_only`, `tests/test_trust_precheck.py::TestThePreCheckLoadsNoMedia::test_trusted_does_no_work` | | Remote generate code | `dw/trust.py`: `require_trusted_generate_arguments`; `dw/tasks/text_generation.py`: `_validated_generate_kwargs`, `_validated_chat_template_kwargs` | Untrusted, `generate_kwargs` may not set `custom_generate` or `trust_remote_code` (transformers would download and run a repo's `custom_generate/generate.py`); both it and `chat_template_kwargs` hold only scalars (or, for `generate_kwargs`, lists of them) and none of the pipeline call's own keys. All checked before the model loads. | `tests/test_security_trust_gate.py::TestRemoteGenerateCodeUntrusted::test_refused_before_the_model_loads`, `tests/test_text_generation.py::TestGenerateKwargsAreFiltered::test_a_structural_key_is_refused_before_any_load`, `tests/test_text_generation.py::TestGenerateKwargsAreFiltered::test_a_nested_value_is_refused` | | Hub-file system prompts | `dw/tasks/text_generation.py`: `resolve_system_prompt` | A `system_prompt.from_hub` file is pinned to a full commit, asked of the Hub anonymously before every use (failing closed on any error, offline or under `HF_HUB_OFFLINE`), downloaded with `token=False`, and refused over 1 MiB or when the Hub reports no size. | `tests/test_text_generation.py::TestSystemPromptFromHub::test_a_file_the_hub_will_not_serve_publicly_is_refused`, `tests/test_text_generation.py::TestSystemPromptFromHub::test_the_download_never_carries_the_server_token`, `tests/test_text_generation.py::TestSystemPromptFromHub::test_a_file_of_unknown_size_is_refused_before_downloading` | | CodeQL path-injection model | `.github/codeql/dw-security/DwPathSanitizers.qll`, `.github/workflows/codeql.yml` | The local pack models the `dw/security.py` validators (and `dw/locations.py`'s `validate_media_path`) as sanitizers, so a validator that moves is re-modelled in the same commit. | `.github/codeql/dw-security/DwPathInjection.ql` | @@ -212,7 +213,7 @@ one to open. | --- | --- | --- | --- | | `dw_mcp` stays torch-free | `dw_mcp/` | `dw_mcp` reaches `dw.serve` over HTTP and imports no `dw` module, because `dw/__init__.py` pulls in torch. | `tests/test_mcp_server.py::TestStartupWeight::test_the_server_starts_without_importing_the_engine` | | Tool surface | `dw_mcp/server.py`, `dw_mcp/tools_*.py` | Only these modules import the MCP SDK, and each tool body is a one-line call into a handler; `run_workflow`'s `request` (`/`) is parsed in `dw_mcp/diagnose.py` before any HTTP call and sent as the body's `request` and `item`. | `tests/test_mcp_server.py::test_the_wiring_table_covers_every_registered_tool`, `tests/test_mcp_server.py::test_the_stated_tool_count_is_the_registered_one` | -| Notes channel | `dw_mcp/ledger.py`: `note_waiting`, `waiting_notes`, `NoteWatch`, `note_event`, `waiting_event`, `retry_delay`, `dw_mcp/server.py`: `serve_notes_channel`, `build_notes_channel`, `NOTES_INSTRUCTIONS`, `dw_mcp/__main__.py` (`--notes-channel`) | A second stdio process with no tools that declares `experimental["claude/channel"]` and sends `notifications/claude/channel` for each waiting note in one workspace, polled. A note waits by the UI's rule (`ui/src/lib/request/noteState.ts`: `noteWaiting`), per note: open request, live item, no agent write (the request's `agent_wrote_at`) after its `at`. The first poll that reaches the server sends one digest of what waits; after it each note is announced once per `(request, note id, at)`, its references named one per line. The poll carries `X-DW-Notes-Channel: 1`; `dw/server/listening.py` keeps the last marked poll per workspace in memory and `GET /api/workspaces/{name}/notes-channel` reports `listening` for 30 seconds after it - a session without the development-channels flag still polls, so it cannot say Claude Code passes the events on. It is served handshake-only, so a 2026-07-28 `server/discover` probe is refused and the client falls back to `initialize`; a failed poll is logged to stderr once and retried on a doubling delay, and nothing but JSON-RPC reaches stdout. Event `meta` keys are identifiers and values strings. | `tests/test_mcp_notes_channel.py`, `tests/test_mcp_notes_stdio.py`, `tests/test_ui_twins.py::test_the_notes_channel_decides_each_shared_waiting_note_case`, `tests/fixtures/note_waiting_cases.json` | +| Notes channel | `dw_mcp/ledger.py`: `note_waiting`, `waiting_notes`, `NoteWatch`, `note_event`, `waiting_event`, `due_reviews`, `review_event`, `retry_delay`, `dw_mcp/server.py`: `serve_notes_channel`, `build_notes_channel`, `NOTES_INSTRUCTIONS`, `dw_mcp/__main__.py` (`--notes-channel`) | A second stdio process with no tools that declares `experimental["claude/channel"]` and sends `notifications/claude/channel` for each waiting note, polled: in every workspace through one `GET /api/requests` read (`dw/server/routes/requests.py`: `list_open_requests`) unless `--workspace` pins it to one, falling back to the client's workspace on a server without that route and asking for it again every `ROUTE_RETRY_POLLS`; bookkeeping is keyed by workspace and request, and a workspace the read names as `unreadable` keeps its bookkeeping. Only a poll that read nothing backs off; a fault in part of the ledger is logged but polled at the interval. A note waits by the UI's rule (`ui/src/lib/request/noteState.ts`: `noteWaiting`), per note: open request, live item, no agent write (the request's `agent_wrote_at`) after its `at`. The first poll that reaches the server sends one digest of what waits; after it each note is announced once per `(request, note id, at)`, its references named one per line. The poll carries `X-DW-Notes-Channel: 1`; `dw/server/listening.py` keeps the last marked poll per workspace, and of the whole server (`seen_all`), in memory and `GET /api/workspaces/{name}/notes-channel` reports `listening` for 30 seconds after it - a session without the development-channels flag still polls, so it cannot say Claude Code passes the events on. It is served handshake-only, so a 2026-07-28 `server/discover` probe is refused and the client falls back to `initialize`; a failed poll is logged to stderr once and retried on a doubling delay, and nothing but JSON-RPC reaches stdout. Event `meta` keys are identifiers and values strings. A second event kind, `review_due` (`due_reviews`, `review_event`), announces held items whose deadline passed with no note, once per item and `review_until`, and `NoteWatch` re-reads a request at its earliest deadline though its revision did not move; a hold already on the item when the channel first read its request is marked `stale`, whatever its state then. | `tests/test_mcp_notes_channel.py`, `tests/test_mcp_notes_stdio.py`, `tests/test_notes_listening.py`, `tests/test_mcp_main.py`, `tests/test_ui_twins.py::test_the_notes_channel_decides_each_shared_waiting_note_case`, `tests/fixtures/note_waiting_cases.json` | | Surface text budget | the tool docstrings in `dw_mcp/tools_*.py`, the instructions in `dw_mcp/server.py` | The instructions and each tool description stay at or under 2,048 characters, and the whole surface stays within its token budget. | `tests/test_mcp_server.py`: `SURFACE_BUDGET`, `CLIENT_TEXT_LIMIT`; `tests/test_mcp_server.py::test_no_text_the_agent_reads_is_cut_off_by_the_client`, `tests/test_mcp_server.py::test_the_tool_surface_fits_the_budget` | | Guide pointers in resident text | the tool docstrings in `dw_mcp/tools_*.py`, the instructions in `dw_mcp/server.py`, each plugin `SKILL.md` and its `references/` | Every `get_guide(...)` / guide-section pointer opens a real section through `dw/server/guides.py`'s `get_guide`, and the tools that point at a guide keep their pointer when text is trimmed to fit the budget. | `tests/test_guide_pointers.py` (`TOOLS_THAT_POINT`) | | Spending needs consent | each handler behind a tool that takes `acknowledged_cost` (`dw_mcp/diagnose.py`, `models.py`, `prompts.py`, `workspaces.py`) | Every tool that takes `acknowledged_cost` refuses until it is set; `delete_workspace`'s refusal is the server's 409. `rerun_job(restart_batch=true)` passes through without it, and the server owns that gate: `POST /api/jobs/{id}/rerun-restart-batch` (`JobManager.rerun_restart_batch`) answers a preview that queues nothing. The jobs page's restart banner is the route's second caller and keeps the same order: a click previews, and only a confirm sends `acknowledged_cost` (`ui/src/lib/restartBatches.ts`). | `tests/test_mcp_twins.py::test_every_tool_that_takes_acknowledged_cost_refuses_without_it`, `tests/test_restart_tombstones.py::test_mcp_rerun_job_previews_queues_then_skips_a_restart_batch`, `ui/src/lib/pages/JobsPage.test.ts` | @@ -228,7 +229,7 @@ one to open. | Concept | Owner | Rule | Enforced by | | --- | --- | --- | --- | -| The UI reads engine fields | `ui/src/lib/plan.ts`: `describePlan`, `ui/src/lib/results.ts`: `sectionBySubfolder`, `ui/src/lib/editor.ts`: `constraintHints`, `presetView`, `presetPlaceholder` | The UI reads `plan`, `version` and `subfolder` as fields the server sends and derives nothing of its own, and it never sends `acknowledged_cost`. It reads `variable_constraints` off the definition only to *state* each rule under its field, in fixed labels with every number from the declaration, and `presets` to list a selector's bundles and what they set. Its one layering, for placeholders only, is the engine's `effective_variables` order (declared default, then the chosen bundle, then an explicit value); a bundle's values are never copied into `arguments`. Every verdict on a value stays the server's. The workflow page places a validate finding by its `arguments.`/`variables.` path prefix alone (`ui/src/lib/findings.ts`: `placeFindings`), under that field or in the general list, and derives, filters or rewrites nothing else of it. | `ui/src/lib/plan.test.ts`, `ui/src/lib/pages/WorkflowPage.test.ts`, `ui/src/lib/results.test.ts`, `ui/src/lib/editor.test.ts` (one case per key, and the schema-coverage case: every `variable_constraint` property in `dw/workflow_schema.json` has a label; the preset placeholder cases), `ui/src/lib/editor/VariablesForm.test.ts` | +| The UI reads engine fields | `ui/src/lib/plan.ts`: `describePlan`, `ui/src/lib/results.ts`: `sectionBySubfolder`, `ui/src/lib/editor.ts`: `constraintHints`, `presetView`, `presetPlaceholder` | The UI reads `plan`, `version` and `subfolder` as fields the server sends and derives nothing of its own, and it sends `acknowledged_cost` from only two surfaces: the Run dialog (`RunQueue`, the validate plan as the bound value) and the jobs page's restart banner (a confirm sends `true`). It reads `variable_constraints` off the definition only to *state* each rule under its field, in fixed labels with every number from the declaration, and `presets` to list a selector's bundles and what they set. Its one layering, for placeholders only, is the engine's `effective_variables` order (declared default, then the chosen bundle, then an explicit value); a bundle's values are never copied into `arguments`. Every verdict on a value stays the server's. The workflow page places a validate finding by its `arguments.`/`variables.` path prefix alone (`ui/src/lib/findings.ts`: `placeFindings`), under that field or in the general list, and derives, filters or rewrites nothing else of it. | `ui/src/lib/plan.test.ts`, `ui/src/lib/pages/WorkflowPage.test.ts`, `ui/src/lib/results.test.ts`, `ui/src/lib/editor.test.ts` (one case per key, and the schema-coverage case: every `variable_constraint` property in `dw/workflow_schema.json` has a label; the preset placeholder cases), `ui/src/lib/editor/VariablesForm.test.ts` | | Reference prefixes in the UI | `ui/src/lib/references.ts` | The only module in `ui/src` that spells a reference prefix; each equals `dw/references.py`'s. | `tests/test_ui_twins.py::test_the_ui_spells_every_reference_prefix_the_engine_does`; `prefix_literals` in `ui/scripts/arch-metrics.mjs` | | Output kinds on the job page | `dw/server/outputs.py`: `MEDIA_KINDS`, `output_kinds` | The page renders an output by the `output_kinds` the job detail carries, never by its extension. | `tests/test_server.py::test_a_job_reports_each_output_files_media_kind`, `ui/src/lib/pages/JobPage.test.ts` | | Step timing on the job page | `dw/pipeline_processors/timing.py`: `StepTimer`; the manifest entry's `timing` | The job page draws a step's load/encode/denoise/decode/save bar from `manifest[].timing` alone (history has no events), each part only when non-null, width its share of the parts' sum; `first_pass_s`/`pass_s`/`passes` sit inside `denoise_s` and appear in the title only. `host_memory_job_peak_committed_mb` shows in the header only when non-null. | `ui/src/lib/pages/JobPage.test.ts` (step timing bar and peak host RAM) | @@ -240,7 +241,7 @@ one to open. | The editors' document | `ui/src/lib/editorShell.svelte.ts`: `DocumentEditor` | The workflow and prompt editors keep one rule each for the view (remembered per editor), the JSON draft (a failed parse pins it), dirty against the last load or save, the save path, and the tab-close guard. | `ui/src/lib/editorShell.test.ts`, `ui/src/lib/pages/PromptEditorPage.test.ts`, `ui/src/lib/pages/EditorPage.test.ts` | | UI polling | `ui/src/lib/poll.ts`: `poll`, `sleep` | A page that refreshes on a timer starts it through `poll` and stops it with the function `poll` returns. | `ui/src/lib/poll.test.ts` | | Workspace state in the UI | `ui/src/lib/workspaceState.svelte.ts`: `workspace` | The current workspace is one `$state`; `api.ts` reads it from here, so the request layer imports no page state. | `import_cycles` in `ui/scripts/arch-metrics.mjs` | -| Requests in the UI | `ui/src/lib/request/intents.ts`: `apply`, `ui/src/lib/request/planStore.svelte.ts`: `PlanStore`, `ui/src/lib/request/itemState.ts`: `planState`, `ui/src/lib/request/ItemNote.svelte`, `ui/src/lib/request/attention.ts`: `attention`, `ui/src/lib/requestFilter.ts`, `ui/src/lib/job/JobHeader.svelte` | The request page edits the ledger only through intents - accept a take, drop, restore, reorder, a note for the agent (the request's own or an item's; written through the `request-notes` routes, not a plan PUT): `apply` turns one intent and the plan as last read into a PUT of the whole plan (no `prompt`) at that revision, `by: "user"`, and `PlanStore` sends them one at a time, the page showing its queue folded over the last read so a refresh undoes no edit. A plan read earlier is never sent again: on a 409 `stale_revision` the store reads the request again and makes the intent over that read (three more times at most) when its item is unchanged, holds a drop or an accept back and asks on the row when the item changed (`ui/src/lib/request/conflict.ts`: `itemDiff`), and says which edit no longer applies, keeping a note's words (any other refusal shows the server's message alone). A drop strips its key from the items that depend on it in the same write. Jobs are queued only from the priced dialog (`ui/src/lib/request/RunDialog.svelte`): `RunQueue` (`ui/src/lib/request/runQueue.svelte.ts`) validates every candidate before the spend button is enabled and submits each with `request`, `item` and the validate plan as its bound `acknowledged_cost`, so a row is queued only when the server says so and a 409 re-prices it in place; the page never starts a newly ready item itself. What it shows beyond the server's `status` and `ready` it derives in one place, `planState`: waiting on a dependency that is not done, cancelled apart from failed, which items need the user, which could be run; proofs come from the ledger's own `output` and `cover`, never a job read. It reads the request again every 20 s while its `state` is open and every 5 s while one of its jobs is queued or running (`ui/src/lib/request/refresh.ts`), keeps the higher `revision` of what it holds and what a read returns, says a refresh's changes in one polite live region (`ui/src/lib/request/announce.ts`), and keeps the plan it holds when a read fails; a draft - held in the note component, and in the tab's `sessionStorage` - outlives every read and a reload. Jobs and Gallery narrow to a request with one `req` hash value (`` or `/`, the server's `request`/`item` filters); a job's header links its request, as plain text with "request no longer exists" once `getRequest` is 404. | `ui/src/lib/request/intents.test.ts`, `ui/src/lib/request/planStore.svelte.test.ts`, `ui/src/lib/request/runQueue.svelte.test.ts`, `ui/src/lib/request/RunDialog.test.ts`, `ui/src/lib/pages/RequestPage.test.ts`, `ui/src/lib/pages/RequestPage.edit.test.ts`, `ui/src/lib/request/itemState.test.ts`, `ui/src/lib/request/ItemNote.test.ts`, `ui/src/lib/request/attention.test.ts`, `ui/src/lib/job/JobHeader.test.ts`, `ui/src/lib/requestFilter.test.ts` | +| Requests in the UI | `ui/src/lib/request/intents.ts`: `apply`, `ui/src/lib/request/planStore.svelte.ts`: `PlanStore`, `ui/src/lib/request/itemState.ts`: `planState`, `ui/src/lib/request/ItemNote.svelte`, `ui/src/lib/request/attention.ts`: `attention`, `ui/src/lib/requestFilter.ts`, `ui/src/lib/job/JobHeader.svelte` | The request page edits the ledger only through intents - accept a take, drop, restore, reorder, a note for the agent (the request's own or an item's; written through the `request-notes` routes, not a plan PUT): `apply` turns one intent and the plan as last read into a PUT of the whole plan (no `prompt`) at that revision, `by: "user"`, and `PlanStore` sends them one at a time, the page showing its queue folded over the last read so a refresh undoes no edit. A plan read earlier is never sent again: on a 409 `stale_revision` the store reads the request again and makes the intent over that read (three more times at most) when its item is unchanged, holds a drop or an accept back and asks on the row when the item changed (`ui/src/lib/request/conflict.ts`: `itemDiff`), and says which edit no longer applies, keeping a note's words (any other refusal shows the server's message alone). A drop strips its key from the items that depend on it in the same write. Jobs are queued only from the priced dialog (`ui/src/lib/request/RunDialog.svelte`): `RunQueue` (`ui/src/lib/request/runQueue.svelte.ts`) validates every candidate before the spend button is enabled and submits each with `request`, `item` and the validate plan as its bound `acknowledged_cost`, so a row is queued only when the server says so and a 409 re-prices it in place; the page never starts a newly ready item itself, and a held item (#1521) is no exception: the hold banner (`ui/src/lib/request/review.svelte.ts`, text in `reviewText.ts`) counts down to the server's `review` and its **Run now…** only opens that dialog. What it shows beyond the server's `status` and `ready` it derives in one place, `planState`: waiting on a dependency that is not done, cancelled apart from failed, which items need the user, which could be run; proofs come from the ledger's own `output` and `cover`, never a job read. It reads the request again every 20 s while its `state` is open and every 5 s while one of its jobs is queued or running (`ui/src/lib/request/refresh.ts`), keeps the higher `revision` of what it holds and what a read returns, says a refresh's changes in one polite live region (`ui/src/lib/request/announce.ts`), and keeps the plan it holds when a read fails; a draft - held in the note component, and in the tab's `sessionStorage` - outlives every read and a reload. Jobs and Gallery narrow to a request with one `req` hash value (`` or `/`, the server's `request`/`item` filters); a job's header links its request, as plain text with "request no longer exists" once `getRequest` is 404. | `ui/src/lib/request/intents.test.ts`, `ui/src/lib/request/planStore.svelte.test.ts`, `ui/src/lib/request/runQueue.svelte.test.ts`, `ui/src/lib/request/RunDialog.test.ts`, `ui/src/lib/request/review.svelte.test.ts`, `ui/src/lib/request/reviewText.test.ts`, `ui/src/lib/pages/RequestPage.test.ts`, `ui/src/lib/pages/RequestPage.edit.test.ts`, `ui/src/lib/request/itemState.test.ts`, `ui/src/lib/request/ItemNote.test.ts`, `ui/src/lib/request/attention.test.ts`, `ui/src/lib/job/JobHeader.test.ts`, `ui/src/lib/requestFilter.test.ts` | | The UI's response contract | `dw/server/api_models.py` (the models; it re-exports `dw/server/api_models_base.py`: `ApiModel`, `send_rejected_responses`, and the library routes' models in `dw/server/api_models_library.py`); `scripts/dump_openapi.py` | Every JSON route `api.ts` calls declares a response model, and `types.ts` re-exports the types generated from it (`ui/src/lib/generated/`). The payload does not change: an absent key stays absent (`response_model_exclude_unset`), a sometimes-sent key is `sometimes()`. Runtime is lenient - an undeclared key passes and a rejected response is logged and sent as built; tests, the e2e server and the dump run strict (`DW_STRICT_RESPONSES=1`). The document is generated under the FastAPI and Pydantic `constraints-openapi.txt` pins: CI installs them, and the dump refuses to write under others. | `tests/test_api_contract.py`, `tests/test_ui_twins.py::test_every_json_route_the_ui_calls_declares_its_response`, CI's "Response contract" step | | Where `--live` appears | `ui/src/app.css` (its header) | `--live` marks machine state only and `--select` the user's place only (focus ring, sidebar), each in the files `ui/scripts/design-rules.test.ts` lists. | `ui/scripts/design-rules.test.ts` | | UI architecture ratchet | `ui/scripts/arch-metrics.mjs` | No metric rises above `docs/stabilization/ui/baseline.json`. | the `ui` job in `.github/workflows/ci.yml`; `npm run preflight` | diff --git a/docs/MCP.md b/docs/MCP.md index 8e2453933..c5927e94e 100644 --- a/docs/MCP.md +++ b/docs/MCP.md @@ -28,7 +28,7 @@ the client needs a command it can find (see below). `dw-mcp` (or | `--workspace` | `$DW_MCP_WORKSPACE`, else the server's default | Which of the server's workspaces the session works in. A *name* on the server, not a local directory (`DW_WORKSPACE` means something else to the engine). `use_workspace` switches it mid-session | | `--timeout` | `30` | Seconds to wait on any one API request | | `--no-probe` | off | Skip the startup `GET /api/health` that confirms the server is reachable and the token is accepted | -| `--notes-channel` | off | Serve no tools: be [the notes channel](#the-notes-channel), which tells an open Claude Code session when the user saves a note for the agent | +| `--notes-channel` | off | Serve no tools: be [the notes channel](#the-notes-channel), which tells an open Claude Code session when the user saves a note for the agent. It watches every workspace unless `--workspace` is given | | `--interval` | `10` | With `--notes-channel`: seconds between reads of the request list, at least 2 | A non-loopback `--url` with no token makes `dw-mcp` exit 2. The startup probe @@ -163,8 +163,8 @@ When the user saves a **Note for the agent** on a request or one of its items in the web UI ([WORKSPACES.md](WORKSPACES.md#requests)), nothing is sent anywhere: the agent reads the note the next time it reads the plan. The notes channel closes that gap for an open Claude Code session. It is a -second, small stdio process, `dw-mcp --notes-channel`, that watches one -workspace's requests and tells the session about each note as it is saved. +second, small stdio process, `dw-mcp --notes-channel`, that watches the +server's requests and tells the session about each note as it is saved. A note can carry references to the items, takes and files it is about, so the event says which. This one was written from the request page and names two @@ -199,6 +199,29 @@ The tag's attributes are the event's `meta`: `kind` (`note`), `workspace`, item) and `items` (the item keys its references name, comma separated, only when it has any). Every value is a string. +A third kind, `review_due`, says a review hold has run out. When the agent +holds planned items for the user to look at ([WORKSPACES.md](WORKSPACES.md#requests), +*Review hold*), nothing on the server starts them at the deadline: the +channel announces them, once for each item and deadline, and the agent runs +what is still ready under the cost it quoted. The event lists the items +(`- shot3: Shot 3: lamp room (about 4 min)`) and tells the agent to run only +those still ready and without a newer note, and not to run one whose plan +changed or whose quote moved well off what the user was told: it clears the +hold and puts the new figure in the `why`, so the user runs it from the +request page or says yes in chat. Its `meta` +has `kind` (`review_due`), `workspace`, `request`, `revision`, `items` (the +due item keys, comma separated) and `until` (the earliest deadline among +them), all strings. A hold that was already on the item the first time +the channel read a request that the channel's first listing held, whatever its state then, is announced at its +deadline as the same kind with `stale` set to `1`; only a hold set while the +channel ran is announced fresh. A channel that connects, or restarts, after a +hold was set announces it as stale: the agent asks the user before spending. +If no session is listening at the deadline, nothing is announced and the items +wait. One poll can carry a stale event and a fresh one. An item held +behind a dependency is announced when the dependency finishes. A request +whose revision does not move still produces the event once its deadline +passes: the channel reads it again then. + It uses Claude Code [channels](https://code.claude.com/docs/en/channels-reference), a **research preview**: the flag, the capability and the notification below are Claude Code's and may change. It works only in an interactive session @@ -212,12 +235,25 @@ saved while no session is open waits as it always did. through the dw tools it already has (the `dw` registration above, or `dw.serve --mcp`); run the channel beside that connection, not instead of it. -- **One workspace.** It watches `--workspace` (`DW_MCP_WORKSPACE`, else the - server's default) and does not follow `use_workspace`. Run one channel per - workspace to watch several. +- **Every workspace.** With no `--workspace` it watches the whole server, so + a session that moves with `use_workspace`, or works in a workspace other + than the default, still hears its notes. Each event names its workspace, + and its `get_request` call passes it. `DW_MCP_WORKSPACE` does not narrow + the channel: it picks where a session starts, not what it hears. + `--workspace` pins the channel to one workspace. On a server older than + `GET /api/requests` it watches the default workspace (or + `DW_MCP_WORKSPACE`), as before, says so once on stderr, and asks for the + route again about every five minutes, so a server updated under a running + channel is found without restarting the session. +- **Two sessions on one server.** A channel that watches everything tells its + session about notes on every workspace's requests. Two sessions open on + one server both hear each note; the agent acts only on a request it is + working on (the event names it). Pin each session's channel with + `--workspace` to keep them apart. - **Polling.** Every `--interval` seconds (default 10, at least 2) it reads - the request list, and then only the open requests whose revision moved: an - idle ledger costs one request a tick. + the server's open requests (`GET /api/requests`, one read for every + workspace; the workspace's list when pinned), and then only the open + requests whose revision moved: an idle server costs one request a tick. - **Which notes.** A note *waits* while its request is open, its item is not dropped, and the agent has not written the request since the note was saved - the rule behind the page's "Nothing is sent to the agent" line. A @@ -227,7 +263,7 @@ saved while no session is open waits as it always did. has written (`set_request`) it is not announced again. - **At connect.** A few seconds after the handshake (one interval, at most 5 seconds, so Claude Code is listening), notes already waiting are - announced as one `kind="notes_waiting"` event that lists them (each + announced as one `kind="notes_waiting"` event per workspace that lists them (each clipped to 300 characters, its references on the lines under it). Those predate the session, so the agent is told to say what is waiting and to confirm before spending GPU time on them. A note saved after that is a `kind="note"` event, quoted whole (the ledger's 4000 @@ -240,7 +276,11 @@ saved while no session is open waits as it always did. is sent back through the channel. - **When the server is away.** An unreachable server, a rejected token, a timeout or an unreadable `requests.json` is written to stderr once and - retried, the delay doubling up to five minutes; the process stays up. + retried, the delay doubling up to five minutes; the process stays up. A + fault in part of the ledger (one request, or one workspace's unreadable + `requests.json`) is named on stderr once but does not slow the poll: the + rest is still read every interval, and what the channel knew of the part + it could not read is kept, so its notes are not announced twice. Events are not queued across a restart: a note is either still waiting (and in the next session's digest) or answered. @@ -249,11 +289,15 @@ saved while no session is open waits as it always did. The web UI labels the note's save button by whether a channel is running. The channel marks each read of the request list with an `X-DW-Notes-Channel: 1` header, and the server remembers, in memory only, when a marked read last -came for each workspace. `GET /api/workspaces/{name}/notes-channel` answers +came for each workspace; a marked `GET /api/requests` counts for every +workspace, including one made after it. `GET /api/workspaces/{name}/notes-channel` answers `{listening, last_seen}`: `listening` is true when a marked read came in the last 30 seconds (three intervals at the default 10). A server restart forgets it until the next read. The button reads **Send to agent** when a session is listening and **Save note** when none is; saving works either way. +The request page's review-hold banner reads the same answer: it says whether +a session is listening, and when none is, that nothing will run at the +deadline. "Listening" means a session has the channel set up and is polling, nothing more. A session started without `--dangerously-load-development-channels` @@ -304,6 +348,11 @@ If nothing arrives: - It is connected but no event comes: the session was started without the flag (Claude Code then drops the events silently), or an organization policy blocks channels. +- The request page says no session is listening while one is open: the + channel is pinned with `--workspace` to a workspace other than the + request's, or it is talking to a server older than `GET /api/requests` + and so watches only the default workspace. Drop `--workspace`, or update + the server. - **Protocol revision.** Claude Code does not register a server that negotiates MCP protocol revision 2026-07-28 as a channel. This process declines that revision by itself: it answers the `server/discover` probe diff --git a/docs/RELEASING.md b/docs/RELEASING.md index ba766309d..e4e200974 100644 --- a/docs/RELEASING.md +++ b/docs/RELEASING.md @@ -49,6 +49,81 @@ A PyPI install gets released `diffusers`, which may lag the newest pipelines; in GitHub generates notes from commits at tag time. The sections below are the hand-written notes: the newest is drafted at release prep and pasted into the GitHub release body once the tag has published (`gh release edit v --notes-file ...`). Items a branch's author wants the next note to name go in a new section at the top. +### 0.22.0 + + + +**The review hold** (#1521) + +- An agent that has planned and priced a request can hold its items for you + to look at before they run. Each held item carries a deadline, + `review_until`; the request page shows how many items are held, counts + down to the deadline and says whether an agent session is listening. A + note you leave on the request or the item redirects the hold: the agent + revises instead of running. **Run now** opens the same priced dialog as + any other run, so a held item is never started for you. +- A hold defers a run you already approved in chat; it does not replace + that approval. When the deadline passes with no note, the agent runs + exactly what it quoted, and a changed plan or a quote well off the one + you were given means no run and no new hold: the agent clears the hold and + gives the new figure, and you run it from the priced dialog or say yes. Nothing on the server starts + a job at the deadline: the notes channel tells the open session with a new + `review_due` event (`stale` when the hold was set before the session + connected). With no session listening, which needs Claude Code started + with the development-channels flag, nothing runs and the items wait for you. +- The `script-to-video` skill's request reference says when to hold and how + the agent answers each event. +- REST: a request item takes `review_until` (an ISO time with an offset, + 60 seconds to 24 hours ahead) and reads back `review_set_at` and a derived + `review` (`{until, state, seconds_left}`). The same fields are on the MCP + `set_request` and `get_request` items. + +**Notes reach the session whichever workspace it is in** (#1529, #1530) + +- The notes channel (`dw-mcp --notes-channel`) now watches every workspace + on the server unless `--workspace` pins it. Before, it watched only the + default workspace (or `DW_MCP_WORKSPACE`), so a session that worked in + another workspace never heard its notes and the request page said no + session was listening. Each event names its workspace. Against a server + older than this release the channel falls back to the default workspace. +- The note box puts your words first. Under the text, an **About** line + holds the items, takes and files the note is about, with a small "+ Add + an item" control that lists items by key; before, the item picker sat + above the text box and read as a list of suggested notes. A note goes + out only with words, and a closed box shows nothing pending, so nothing + looks sent that was not. +- REST: `GET /api/requests` lists every workspace's open requests in one + read (each row a request summary with its `workspace`; `unreadable` names + a workspace whose ledger cannot be read). Marked `X-DW-Notes-Channel: 1`, + it counts as a channel poll of every workspace for + `GET /api/workspaces/{name}/notes-channel`. + +**The request page, from a first real run** (#1532) + +- The header gives the agent's latest word under what needs you, so an + answer like "ready for take 2, not run" or "awaiting go-ahead" is on the + page, not only in Plan changes. A note's own status line now says when + the agent answered rather than quoting it. +- A done item has **Another take…** on its row. Open, an item shows its + takes once, its buttons lined up, and keeps its jobs and outputs links in + its menu. A take and its file are one reference chip on a note. +- The request skill: after a note at the same price the agent holds the + revised items again with a fresh countdown, and a note that changes + something the whole set shares is carried over to the other items. + +**Fixes** + +- The worker's trust check no longer decodes each input clip and fetches + each URL input a second time on every job; with `--trust-workflows` it + does no work at all (#1510). +- A workflow naming a refused `pre_load_modules` entry is refused at + validate and at submit, with no job, instead of being queued and evicting + the models warm on the card before the loader refused it (#1511). +- An H3 `references` entry that names no loadable reference class (a `type` + key instead of `reference_type`, or a bare class name) is now a validate + error at its path, instead of passing and being skipped by every + reference check (#1512). + ### 0.21.0 diff --git a/docs/SECURITY.md b/docs/SECURITY.md index 3fe739b6a..829830ed6 100644 --- a/docs/SECURITY.md +++ b/docs/SECURITY.md @@ -186,7 +186,15 @@ triggered it and pointing at `--trust-workflows`: the task does not take. `validate_workflow` reports each refusal at the key's path (a variable's -default at `variables.`), so nothing is queued to find out. Every +default at `variables.`, a `pre_load_modules` entry or a loader key at +the step's `pipeline`), so nothing is queued to find out, and a submit that +fails it makes no job. The worker repeats the pipeline, `pre_load_modules`, +dotted-type and `constant:` checks over the same expansion before it releases +the previous workflow's models (`workflow_run.require_trusted_pipelines`), so +a refused job leaves them loaded. That check reads keys only: it loads no +asset, clip or URL, and with `--trust-workflows` it does nothing. It covers +the top-level steps; a sub-workflow's steps are refused by validate at +submit and by the loader when they load. Every bundled workflow loads untrusted: `tests/test_workflow_trust.py` sweeps the catalog, and `tests/test_catalog_structure.py` refuses a catalog entry that sets `trust_remote_code` or `custom_pipeline`. `--trust-workflows` lifts all diff --git a/docs/SERVER.md b/docs/SERVER.md index e8954e972..4d4eb94d0 100644 --- a/docs/SERVER.md +++ b/docs/SERVER.md @@ -344,6 +344,13 @@ icon, a finish-alert toggle, the theme toggle, and links to these docs and one started without the development-channels flag still counts, and Claude Code drops its events ([MCP.md](MCP.md#is-a-session-listening)). + When the agent holds items for your review, a banner says how many are + held, counts down to the deadline, and says whether an agent session is + listening ([the notes channel](MCP.md#the-notes-channel)); with none, it + says nothing will run at the deadline. A note you leave redirects the hold, + and the banner then says the agent will revise. **Run now…** opens the + priced dialog below; the page never starts a held item itself. + The page queues jobs only when you ask, and only after pricing them. **Run {n} ready…** in the header takes every ready item; a ready row has **Run…**, a failed or cancelled one whose dependencies are done **Run @@ -1081,8 +1088,17 @@ The editor's forms come from these; they are just as usable from scripts: whole-plan write keeps the stored ones. `DELETE` removes the ledger entry at that revision and answers `{id, workspace, deleted, revision, linked_jobs}`; the linked jobs keep their rows, link and files. Reads - derive from the jobs linked through `POST /api/jobs` `request`/`item`: - each item carries `status` (`dropped`, `done`, `running`, `queued`, + derive from the jobs linked through `POST /api/jobs` `request`/`item`. + An item also takes `review_until` on write, an ISO time with an offset 60 + seconds to 24 hours ahead (422 `invalid_review_until`, `review_too_soon` + or `review_too_far` otherwise), and reads back `review_set_at` and a + derived `review` (`{until, state, seconds_left}`, `state` one of + `holding`, `redirected`, `due`; only while the item is `planned` on an + open request); the rules are under [WORKSPACES.md](WORKSPACES.md#requests). + `review_set_at` and `review` are ignored on write. The server never starts + a job at the deadline. + + Each item carries `status` (`dropped`, `done`, `running`, `queued`, `failed`, `planned`), `ready`, `attempts` (`[{job, status, note?, minutes, output}]`, oldest first), `result` (`{job, run_id, output}` or null), `accepted_missing` (only when true) and `spent_minutes`, where @@ -1114,9 +1130,18 @@ The editor's forms come from these; they are just as usable from scripts: linked to the item, an output not in its manifest, a job still running with an `output`), `too_many_refs`, `too_many_notes` (20 per item or request), `unknown_item`, `item_dropped`. +- `GET /api/requests` — every workspace's open requests, newest change + first, as `{requests, unreadable?}`: each row is a request summary (the + list route's) with its `workspace`, and `unreadable` maps a workspace + whose `requests.json` is not a ledger, or that could not be resolved + while it was listed, to why; the others still list. It + is the one read a notes channel makes when it watches the whole server, + and marked `X-DW-Notes-Channel: 1` it counts as a poll of every + workspace, including one made after it. - `GET /api/workspaces/{name}/notes-channel` — `{listening, last_seen}`: whether a notes channel polled this workspace's request list in the last - 30 seconds. The channel marks its polls with an `X-DW-Notes-Channel: 1` + 30 seconds. A marked `GET /api/requests` counts + for every workspace. The channel marks its polls with an `X-DW-Notes-Channel: 1` header, and the server keeps the time in memory only. It means a session has the channel set up, not that Claude Code is passing its events on ([MCP.md](MCP.md#is-a-session-listening)). diff --git a/docs/WORKFLOW_GUIDE.md b/docs/WORKFLOW_GUIDE.md index 0382ea1b7..61c27842d 100644 --- a/docs/WORKFLOW_GUIDE.md +++ b/docs/WORKFLOW_GUIDE.md @@ -772,6 +772,17 @@ by the source, and `validate_workflow` names the entries to add or drop. "minutes": plan.estimate.minutes, "downloads": [...]}`: the server refuses with 409 if the run's shape changed since the quote, and the refusal carries the new plan. `true` is for a plan that was null. + + A review hold on a request item (`review_until`) defers the run the user + approved; it does not replace the approval. Quote the total and get the + yes first. A deadline passing with no note permits exactly the run that + was quoted and nothing else: a refusal for a changed plan, or a quote + well off the one given (more than a quarter), means no run and no new hold: + clear the hold (`review_until: null`) and put the new figure in the `why`; + the user runs it from the request page or says yes in chat. Silence lets the + items run only when a Claude Code session is listening on + [the notes channel](MCP.md#the-notes-channel). The rules are under + [Requests](WORKSPACES.md#requests). 5. `wait_for_job` rather than a polling loop, with the job's `plan.estimate` (in seconds, plus a margin) as `timeout_seconds`, so one call can cover the whole run. The server caps a single call (the tool's description states the diff --git a/docs/WORKSPACES.md b/docs/WORKSPACES.md index c7b7ba72d..6356762aa 100644 --- a/docs/WORKSPACES.md +++ b/docs/WORKSPACES.md @@ -328,13 +328,13 @@ Read it with `get_request(request=None)` (MCP) or `GET to `open`. Closing changes nothing else. A closed request takes no new job (422 `request_closed`) until it is reopened, and stays writable. - **Items** are `{key, title, depends_on, estimate_minutes, workflow, - arguments, accepted, notes}`, matched across writes by `key`; the order - written is the order kept. An item left out of a write is deleted, or kept - as `dropped` (moved to the end) when jobs link to it; writing a dropped - key again, not dropped, brings it back with everything it held. Each item - reads back with derived fields (below). A field not listed is refused on - write, apart from the derived ones and `notes`, which are ignored - so a plan can be - written back as it was read. + arguments, accepted, notes, review_until}`, matched across writes by `key`; + the order written is the order kept. An item left out of a write is deleted, + or kept as `dropped` (moved to the end) when jobs link to it; writing a + dropped key again, not dropped, brings it back with everything it held. Each + item reads back with derived fields (below). A field not listed is refused on + write, apart from the derived ones and `notes`, which are ignored - so a plan + can be written back as it was read. - **`purge`** on a write lists keys of stored items the plan leaves out that are to be removed for good instead of kept as dropped. Their jobs keep their history rows, their link and their files; a key written again @@ -374,6 +374,30 @@ Read it with `get_request(request=None)` (MCP) or `GET Nothing is sent when one is saved, unless a Claude Code session is open with [the notes channel](MCP.md#the-notes-channel), which tells that session about each note as it is saved, with its references. +- **Review hold.** An agent can hold a planned item for the user to look at + before it runs. An item carries three fields: `review_until`, an ISO time + with an offset that the agent writes; `review_set_at`, the time the server + stamped when that value was set (ignored on write; writing the same + `review_until` back keeps it, so a plan the UI reads and writes unchanged + does not restart the hold); and `review`, derived on each read and ignored + on write. A new `review_until` must fall at least 60 seconds + (`MIN_REVIEW_SECONDS`) and at most 24 hours (`MAX_REVIEW_HOURS`) ahead, + or the write is refused with 422 `review_too_soon` or `review_too_far`; + a value that is not an ISO time with an offset is 422 + `invalid_review_until`. `review` is `{until, state, seconds_left}` and is + present only while the item's `status` is `planned`, the request is `open` + and `review_until` is set. `state` is the first that holds: `redirected` + (a note on the item, or one of the request's own notes, was saved at or + after `review_set_at`), `due` (the deadline has passed), else `holding`. + `seconds_left` is a whole number, never below 0. Only a note redirects: + rewriting the plan, even with the old `review_until` echoed back, does + not clear a redirect; only a new `review_until` starts the hold again. + A `review_until` left out of an item, or null, clears its hold, so a plan + rewrite must send each held item's `review_until` back as read. The + server runs nothing at the deadline: with + [the notes channel](MCP.md#the-notes-channel) open, a `review_due` event + tells the agent session, and the agent runs what it quoted. With no such + session listening, a due item simply stays `ready` until someone runs it. - **Keys** (request ids and item keys) match `^[a-z0-9][a-z0-9-]{0,63}$`. - **Caps.** Titles 200 characters, prompt and goal 20000, note 4000; `estimate_minutes` 0 to 10000; `arguments` at most 64, scalar values diff --git a/docs/superpowers/plans/2026-11-21-review-hold.md b/docs/superpowers/plans/2026-11-21-review-hold.md new file mode 100644 index 000000000..2e3877c85 --- /dev/null +++ b/docs/superpowers/plans/2026-11-21-review-hold.md @@ -0,0 +1,182 @@ +# Review Hold Implementation Plan + +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development to implement this plan task-by-task. + +**Goal:** An agent can hold planned request items for the user's review until a deadline; the request page shows the hold and a countdown; a note left before the deadline redirects the agent; silence lets the agent run the items at the deadline (#1521). + +**Architecture:** The hold is two additive item fields in `requests.json` (`dw/ledger.py`). Its state (`holding`, `redirected`, `due`) is derived on the server at read time (`dw/ledger_views.py`), so the UI and the notes channel read one answer and there is no twin rule. Nothing on the server runs a job at the deadline: the notes channel process (`dw_mcp/ledger.py`) announces a `review_due` event and the agent session runs the items through `run_workflow` with the cost it already quoted. The request page's existing priced Run dialog (shipped in 0.21.0, 7d091d81) is the person's own way to run them early. + +**Tech Stack:** Python 3 / FastAPI / pydantic (server), `dw_mcp` (MCP + channel), Svelte 5 + TypeScript + vitest + Playwright (UI), pytest. + +**Spec:** issue #1521, plan v1 and Don's approval of its six defaults (2026-11-21). This file is the binding detail. + +## Global Constraints + +- No new Python module (the module baseline stays 278), no new REST route, no new MCP tool or tool parameter. No server timer, thread or startup hook that submits a job. +- `dw/ledger.py` must stay at or under 1100 lines (it is 1062). `dw/server/api_models.py` is not touched. UI source files stay under 600 lines. If a ceiling cannot be met, report BLOCKED; do not split a file or add a module. +- Item fields, exact names: `review_until` (writable), `review_set_at` (server-stamped, ignored on write), `review` (derived, ignored on write). +- `MIN_REVIEW_SECONDS = 60`, `MAX_REVIEW_HOURS = 24`, both constants in `dw/ledger.py`. +- `review` is `{until, state, seconds_left}`; `state` is exactly one of `holding`, `redirected`, `due`. It is present only when the item's derived status is `planned`, the request's state is `open`, and `review_until` is set; otherwise the key is absent. +- State order, first that holds: `redirected` (a note on the item, or one of the request's own notes, has `at >= review_set_at`), `due` (now >= `review_until`), `holding`. Only a note redirects. +- `seconds_left` is a whole number, never negative, computed on the server at read time. +- Channel event kind, exact: `review_due`. Its `meta` values are all strings. +- The page never starts a held item on its own. The only control that spends GPU time is the existing Run dialog. +- Commands run from the worktree root with the main checkout's interpreter: `/Users/don/src/dkackman/diffusers-workflow/venv/bin/python -m pytest tests/ -q -n0`. Before each Python commit: `venv-python -m ruff format --check dw dw_mcp tests scripts` and `venv-python -m ruff check dw dw_mcp tests scripts`. UI: `cd ui && npx vitest run `, and `npm run check && npm run lint` before each UI commit. +- Stage files by name (`git add `); never `git add -A`. Commit messages follow the repo's `feat(scope): ...` style and must not contain `#1521` after `fix:` or `closes` wording (use `refs #1521`). +- Prose in docs, skills, UI strings and docstrings: plain sentences, no em dashes, matching the surrounding file. + +## Review Focus + +1. An agent answers a note with `set_request` but echoes the old, now past `review_until`: the item must not become runnable without review. The echo is accepted (unchanged value), `review_set_at` is kept, and the state stays `redirected` because the note's `at` is still >= `review_set_at`. Test in Task 1. +2. A plan read with GET and written back unchanged by the UI (`by: user`) keeps `review_until` and `review_set_at` exactly. Test in Task 1. +3. A request whose revision and `updated_at` do not change must still produce `review_due` once its deadline passes. Test in Task 3. +4. A held item whose dependency is unfinished at the deadline is announced when it becomes ready, not before. Test in Task 3. +5. A hold already due when the channel connects is announced as stale, with the confirm-before-spending wording. Test in Task 3. + +--- + +### Task 1: Ledger fields, derived `review`, REST models, generated types + +**Files:** +- Modify: `dw/ledger.py`, `dw/ledger_views.py`, `dw/server/api_models_library.py` +- Modify (generated): the OpenAPI document and `ui/src/lib/api` types, regenerated with `python scripts/dump_openapi.py` and `cd ui && npm run gen:api` (run `npm ci` in `ui/` first if `ui/node_modules` is missing; find the exact script names in `ui/package.json` and `docs/RELEASING.md` if these differ) +- Modify: `ui/e2e/serve_fixture.py` so one planned, ready item of the fixture's plan carries `review_until` one hour ahead (Task 2's e2e reads it) +- Create: `tests/test_ledger_review.py` +- Modify: an existing REST test file for the requests routes (the style of `tests/test_ledger_notes_api.py`) for one round trip + +**Write side (`dw/ledger.py`):** +- Add `review_until`, `review_set_at`, `review` to `_ITEM_FIELDS`. +- `_item(...)` stores `review_until` and `review_set_at`: + - `raw["review_until"]` absent or `None` stores both as `None`. + - Otherwise it must be a string that `datetime.fromisoformat` parses and that carries a UTC offset; anything else is refused. Normalize to UTC, whole seconds, `isoformat()` (the form `_now()` writes). + - If the normalized value equals `previous.get("review_until")`: keep it and keep `previous.get("review_set_at")`, whatever the clock says. + - If it differs: it must be at least `MIN_REVIEW_SECONDS` after `at` and at most `MAX_REVIEW_HOURS` after `at`; store it and set `review_set_at = at` (the write's own stamp, already passed to `_item`). + - `raw["review_set_at"]` and `raw["review"]` are never read. +- Refusals are `LedgerError` with `status=422` and codes `invalid_review_until` (not a string, unparseable, no offset), `review_too_soon`, `review_too_far`. Messages name the item key and the bound, in the file's existing voice. +- Dropped items keep whatever they had stored; no special handling. + +**Read side (`dw/ledger_views.py`):** +- `request_view(request, jobs=(), now=None)`: `now` is an aware `datetime` for tests, defaulting to the current UTC time. `item_view` gains what it needs to compute `review` (pass the request's own notes, the request state and `now`; keep its existing positional callers working). +- `review` per the Global Constraints. A note counts when its `at` parses and is `>=` `review_set_at`; compare as datetimes, not strings. Notes of dropped items do not exist on a live item, so only the item's own notes and the request's own notes are read. A missing `review_set_at` on a stored hold (hand-edited file) means no note redirects. +- `summary_view` is unchanged. + +**API models (`dw/server/api_models_library.py`):** +- `LedgerReview` (`until: str`, `state: Literal["holding","redirected","due"]`, `seconds_left: int`), and on `LedgerItem`: `review_until: str | None`, `review_set_at: str | None`, and `review` declared with the file's `sometimes(...)` helper (absent when no hold applies). Descriptions say what each is in one sentence. +- `RequestWrite.items` description names `review_until`. + +**Tests (`tests/test_ledger_review.py`), each a separate test:** +- setting a future `review_until` stamps `review_set_at` to the write's time and reads back `review.state == "holding"` with `seconds_left` matching an injected `now`; +- an input with a non-UTC offset is stored normalized to UTC; +- unchanged echo keeps `review_set_at` (write twice, second with a later clock); +- a changed value restamps `review_set_at`; +- refusals: not a string, unparseable, no offset, 59 s ahead, 24 h + 1 s ahead, each with its code and status 422; +- exactly 60 s ahead and exactly 24 h ahead are accepted; +- `null` clears both fields and `review` is absent; +- `redirected` by an item note saved after the hold; by a request note saved after the hold; not by a note saved before the hold; +- deleting the redirecting note returns the state to `holding`; +- `due` with injected `now` at and after the deadline; `seconds_left == 0`; +- `review` absent when the item has a queued job, is dropped, or the request is `done`; +- Review Focus 1 and 2, as written above; +- a client-sent `review_set_at` or `review` is ignored, not stored and not refused. +- REST: `PUT` then `GET` a request with a hold through the test client and assert the three fields on the item; a 59 s hold answers 422 with code `review_too_soon`. + +**Gate:** the new tests, plus `tests/test_ledger*.py`, the response-contract and OpenAPI-pin tests (find them with `grep -rl openapi tests | head`), and the architecture ratchet test (`grep -rl "modules" tests/test_arch* scripts | head`) pass; ruff clean; `wc -l dw/ledger.py` <= 1100. In `ui/`: `npm run check` passes with the regenerated types. + +**Commit:** one or two commits, e.g. `feat(ledger): a planned item can be held for review until a deadline (refs #1521)`. + +--- + +### Task 2: The request page shows the hold and its countdown + +**Files:** +- Create: `ui/src/lib/request/review.svelte.ts`, `ui/src/lib/request/review.svelte.test.ts`, `ui/src/lib/request/reviewText.ts`, `ui/src/lib/request/reviewText.test.ts` +- Modify: `ui/src/lib/request/itemState.ts`, `RequestHeader.svelte`, `RequestItem.svelte`, `runPlan.ts`, `RunDialog.svelte`, the request page that wires them, their tests, `ui/src/lib/request/fixtures.ts` / `fakeLedger.ts` as needed, `ui/e2e/requests.spec.ts` +- Read first: `ui/CLAUDE.md`, `listening.svelte.ts` (the pattern to copy for a shared, visibility-aware timer), `announce.ts`, `noteState.ts`, `runPlan.ts`, `scripts/design-rules.test.ts` + +**Behaviour:** +- `review.svelte.ts`: one shared one-second ticker, running only while a hold is on screen and the tab is visible (the `hold()` pattern of `NotesChannel`). A countdown is anchored to the moment the request was read plus the server's `seconds_left`; the browser's wall clock is never compared with `review.until`. When a countdown reaches zero the page re-reads the request once (through the page's existing refresh path) so the server's `due` state replaces the local guess. +- `reviewText.ts`: pure functions returning the strings below, so they are tested without a component. +- `itemState.ts`: each live row exposes its `review` (or null); the plan state exposes the held rows. The state shown is always the server's `review.state`. +- `RequestHeader.svelte`: a hold banner next to the notes, shown when any live row has a `review`. One banner for the request, worded by the most urgent state present (`due`, then `holding`, then `redirected`) and by `listening` from `listening.svelte.ts`. `N` counts the rows in that state; the minutes are the sum of those rows' `estimate_minutes`, omitted when none has one. Exact strings: + - holding, listening: `N items held for your review (about M min by the agent's estimate). A session is listening: they run at HH:MM (in MM:SS) unless you leave a note.` followed by a `Run now…` button + - holding, not listening: `N items held for your review. No session is listening, so nothing will run at HH:MM. Run them here, or leave a note.` followed by `Run now…` + - redirected: `You left a note after these were held: the agent will revise before running.` + - due, listening: `Review time is up: the agent should be starting these.` + - due, not listening: `Review time passed with no session listening: nothing ran.` followed by `Run now…` + - Singular forms where N is 1 (`1 item held`, `it runs at`, `Run it here`). `HH:MM` is the deadline in the browser's locale time; `MM:SS` becomes `H:MM:SS` past an hour. +- `Run now…` opens the existing Run dialog for the held rows that are `ready`; it is absent when none is ready. +- `RequestItem.svelte`: a chip on a held row: `held · MM:SS`, `held · note left`, or `review time up`. +- `runPlan.ts` / `RunDialog.svelte`: a row in the dialog for a held item carries the line `Held for review until HH:MM. Running it now is your go-ahead.`; when its state is `due` and a session is listening, the line is `Review time is up and a session is listening: it may be starting this now.` in the warn tone. +- Accessibility: the banner's state changes are announced once through `announce.ts`; the ticking digits are not in a live region. Follow whatever `scripts/design-rules.test.ts` requires for a live region and for the button. +- Nothing on the job page or the gallery changes. + +**Tests:** +- vitest: countdown anchoring and the zero-crossing refresh under fake timers; the ticker stops while the tab is hidden and when the last holder releases; every banner string above, singular and plural, with and without estimates; chips; the dialog lines; one announcement per state change and none per tick; `Run now…` absent when no held row is ready. +- e2e (`ui/e2e/requests.spec.ts`, using the fixture hold from Task 1): the held item shows the banner and a running countdown; `Run now…` opens the dialog with the held line; saving a note on the held item turns the banner to the redirected string after the refresh. +- Do not use `vi.resetModules` in Svelte component tests. + +**Gate:** `npx vitest run` (whole UI suite), `npm run check`, `npm run lint`, the UI architecture metrics script if `ui/package.json` has one, and the e2e spec `npx playwright test e2e/requests.spec.ts` (if Playwright cannot start in this environment, say so in the report with the error; do not skip silently). + +**Commit:** `feat(ui): the request page shows items held for review, with a countdown and a run-now (refs #1521)`. + +--- + +### Task 3: The notes channel announces a due hold + +**Files:** +- Modify: `dw_mcp/ledger.py`, `dw_mcp/server.py` (`NOTES_INSTRUCTIONS` only), `dw_mcp/tools_authoring.py` (`set_request` docstring only) +- Modify: `tests/test_mcp_notes_channel.py` (or the file that tests `NoteWatch`; find it with `grep -rl NoteWatch tests`), `tests/test_mcp_server.py` only if a pinned text needs its expectation updated +- Read first: `dw_mcp/CLAUDE.md` + +**Behaviour (`dw_mcp/ledger.py`):** +- `due_reviews(request)`: the live items of an open request whose `review.state == "due"` and whose `ready` is true, in plan order, as `{request, revision, item, title, until, estimate_minutes}`. +- `review_event(due, workspace, stale=False)`: one event for one request's due items. + - Content, fresh: a head line `Review time is up on request "" with no note from the user. Held items now due:`, one line per item `- : (about <M> min)` (the bracket omitted without an estimate), then: `Read the request with get_request("<id>", workspace="<ws>"). Run only the items still ready and without a new note, each with run_workflow(request="<id>/<key>", acknowledged_cost=<the plan you quoted>). If a run is refused for a changed plan, or validate_workflow now quotes a figure well off what you told the user, do not run it: set a new review_until with the new quote in the why.` + - Content, stale: the head line is `Review time passed on request "<id>" before this session connected. Held items:` and the last paragraph is `These holds were set before this session, so the user's go-ahead may be stale. Tell the user what is waiting and confirm before spending GPU time.` + - `meta`: `kind="review_due"`, `workspace`, `request`, `revision`, `items` (comma-joined keys), `until` (the earliest), and `stale="1"` only when stale. All values strings. +- `NoteWatch`: + - takes an injectable monotonic clock (`clock=time.monotonic`) for tests; + - the per-request stamp becomes `(revision, updated_at, ready)` using the listing row's `ready` count; + - after reading a request it records when its earliest `holding` item's `seconds_left` runs out (on the monotonic clock); a request is re-read when its stamp changed **or** that moment has passed; + - due items are announced once per `(item, until)`; a new `review_until` on the same item is announced again; the bookkeeping for a request is dropped when it leaves the open list, as for notes; + - on the first poll that reaches the server, due items go out as one stale `review_event` per request, after the notes digest; later polls send fresh ones, after any note events of the same poll. +- `NOTES_INSTRUCTIONS`: add one or two sentences: a `kind="review_due"` event means a hold the agent set has reached its deadline with no note, and the agent runs the named items now under the usual cost gate, unless the event says the hold is stale, in which case it confirms first. Keep any length limit the tests pin. +- `set_request` docstring: add `review_until` to the item fields and one clause: `review_until: an ISO time until which a planned item is held for the user's review`. The existing guide pointer stays last. `SURFACE_BUDGET` and `CLIENT_TEXT_LIMIT` tests must pass; if the budget fails, tighten this docstring's own wording, and report what you cut. + +**Tests:** fires once when due and ready; not while `holding`; not when `redirected`; Review Focus 3 (stamp unchanged, clock advanced past the recorded moment, the request is re-read and the event sent); Review Focus 4 (due but not ready sends nothing; the listing's `ready` count rises, the event is sent); a new `review_until` fires again; Review Focus 5 (first poll, stale wording and `stale="1"`); notes and due items in one poll keep notes first; every `meta` value is a `str`; a request that closes drops its bookkeeping. Plus the existing channel, server-text and guide-pointer tests (`tests/test_mcp_server.py`, `tests/test_guide_pointers.py`). + +**Gate:** those tests and ruff. + +**Commit:** `feat(mcp): the notes channel says when a review hold is due (refs #1521)`. + +--- + +### Task 4: Skill, guides, map and release note + +**Files:** +- Modify: `plugins/dw/skills/script-to-video/references/request.md`, `tests/test_plugin_skills.py` (`TestSkillRequests` pins for the new section) +- Modify: `docs/WORKSPACES.md` (Requests), `docs/WORKFLOW_GUIDE.md` (the cost-gate step that says to quote `plan.estimate`), `docs/MCP.md` (notes channel), `docs/SERVER.md` (request item fields), `docs/ARCHITECTURE.md`, `docs/RELEASING.md` +- Read first: `plugins/dw/README.md` (how skills are pinned and versioned; bump what it says to bump), the surrounding text of each section edited + +**Content:** +- `request.md`, a new section `## Hold items for the user's review`, between *Run each item* and *Accept the keeper*: + - when: the plan is written and priced, and the user wants to look at it on the request page before it runs; + - the user's go-ahead comes first: quote the total in chat and get a yes to "these run at T unless you leave a note". Silence on the page confirms that yes; it never replaces it; + - hold only when the dw-notes channel is connected in this session (its instructions are in your context); without it nothing will tell you the deadline passed, so run on the user's word as before; + - set the hold with `set_request`: each held item gets `review_until`, an ISO time with an offset, 15 minutes ahead unless the user says otherwise (the server refuses under 60 seconds or over 24 hours), and the `why` says so; + - then end the turn. Do not block in `wait_for_job` on something else; the event is what wakes the session; + - on a note event: do the revision, write the plan, and give the revised items a new `review_until` if the user should look again; + - on a `review_due` event: `get_request`, run only the named items that are still `ready` with no newer note, each with `run_workflow(request=..., acknowledged_cost=...)` for the plan you quoted. A refusal for a changed plan, or a quote well off what you told the user (more than a quarter), means a new hold with the new figure, not a run; + - an item held behind a dependency is announced when the dependency finishes; you run it then. The server never starts a job for you; + - a `review_due` event marked stale is from before this session: confirm with the user first. + Update the *When a note arrives mid-session* section only where it must mention the new event kind. Add pins in `TestSkillRequests` for the section's load-bearing phrases, in that class's existing style (a pinned phrase must not straddle a line wrap). +- `docs/WORKSPACES.md` Requests: the three fields, the three states and their order, the two bounds, that only a note redirects, and that the server runs nothing at the deadline. +- `docs/WORKFLOW_GUIDE.md`: a short paragraph at the cost-gate step: a hold defers the run the user approved; no note by the deadline permits exactly the run that was quoted and nothing else; pointer to the WORKSPACES section. +- `docs/MCP.md` notes channel: the `review_due` kind, its `meta`, the stale form, and that the page shows whether a session is listening. +- `docs/SERVER.md`: the item fields on the request routes, and the request page's hold banner in the web UI section if that section describes the page. +- `docs/ARCHITECTURE.md`: update the rows that own the requests ledger, the notes channel and the request page's run dialog to name the hold, its owning modules and the tests that enforce it. Also fix the row that says the UI never sends `acknowledged_cost` (the Run dialog and the restart banner do; say which surfaces send it). +- `docs/RELEASING.md`: under the next release's notes, a user-facing paragraph and a `- REST:` line naming `review_until`, `review_set_at` and `review` on the request item, in the style of the 0.21.0 entries. + +**Gate:** `tests/test_plugin_skills.py`, `tests/test_guide_pointers.py`, any docs tests that pin these files (`grep -rl "WORKSPACES.md\|ARCHITECTURE.md" tests | head`), ruff on `tests`. + +**Commit:** `docs: the review hold in the request skill, the guides, the map and the release notes (refs #1521)`. diff --git a/dw/ledger.py b/dw/ledger.py index 43f102254..a59bae479 100644 --- a/dw/ledger.py +++ b/dw/ledger.py @@ -76,6 +76,8 @@ MAX_HISTORY = 100 MAX_NOTES = 20 # live notes of one target: an item, or the request itself MAX_NOTE_REFS = 16 # references in one note +MIN_REVIEW_SECONDS = 60 # a review hold's shortest span +MAX_REVIEW_HOURS = 24 # and its longest # Seconds a write waits for another server's write to the same file LOCK_TIMEOUT = 10 @@ -88,8 +90,8 @@ _WORKFLOW_NAME_PATTERN = r"^[\w][\w.:-]*(/[\w][\w.:-]*)*\Z" # What an item may carry on a write. `status`, `ready`, `attempts`, -# `result`, `accepted_missing` and `spent_minutes` are derived and ignored, -# so a plan read with GET can be written back as it came. +# `result`, `accepted_missing`, `spent_minutes`, `review_set_at` and `review` +# are derived and ignored, so a plan read with GET can be written back. _ITEM_FIELDS = frozenset( ( "key", @@ -107,6 +109,9 @@ "result", "accepted_missing", "spent_minutes", + "review_until", + "review_set_at", + "review", ) ) @@ -642,8 +647,39 @@ def _depends_on(raw, key): return list(dict.fromkeys(keys)) +def _review_until(value, key, previous, at): + """`(review_until, review_set_at)` as stored, in UTC. A value equal to the + stored one keeps its stamp, so a plan written back unchanged does not + restart the hold; a new one falls MIN_REVIEW_SECONDS..MAX_REVIEW_HOURS out.""" + if value is None: + return None, None + try: + when = datetime.fromisoformat(value) + except (TypeError, ValueError): + when = None + if when is None or when.utcoffset() is None: + raise _review_error(key, "invalid_review_until", "an ISO time with an offset") + when = when.astimezone(timezone.utc).replace(microsecond=0) + if when.isoformat() == previous.get("review_until"): + return previous["review_until"], previous.get("review_set_at") + ahead = (when - datetime.fromisoformat(at)).total_seconds() + if ahead < MIN_REVIEW_SECONDS: + bound = f"at least {MIN_REVIEW_SECONDS} seconds from now" + raise _review_error(key, "review_too_soon", bound) + if ahead > MAX_REVIEW_HOURS * 3600: + raise _review_error(key, "review_too_far", f"within {MAX_REVIEW_HOURS} hours") + return when.isoformat(), at + + +def _review_error(key, code, must_be): + return LedgerError( + f"item {key!r} review_until must be {must_be}", status=422, code=code + ) + + def _item(raw, key, previous, linked, by, at): """One live item as stored.""" + until, set_at = _review_until(raw.get("review_until"), key, previous, at) return { "key": key, "title": _text( @@ -658,6 +694,8 @@ def _item(raw, key, previous, linked, by, at): raw.get("accepted"), key, previous.get("accepted"), linked ), "notes": list(previous.get("notes") or []), + "review_until": until, + "review_set_at": set_at, } diff --git a/dw/ledger_views.py b/dw/ledger_views.py index 1aa188eb4..2088c9699 100644 --- a/dw/ledger_views.py +++ b/dw/ledger_views.py @@ -12,6 +12,8 @@ and `ledger.summary_view`. """ +from datetime import datetime, timezone + # The list's `cover`: this many result outputs, found among at most # COVER_SCAN of a request's latest results - the bound on what one row of a # polled list may read @@ -175,12 +177,47 @@ def _live_keys(items): return {item.get("key") for item in items if not item.get("dropped")} -def item_view(item, jobs, ready=False): +def _moment(text): + """A stored time as an aware datetime, or None when it is not one.""" + try: + moment = datetime.fromisoformat(text) + except (TypeError, ValueError): + return None + return moment if moment.utcoffset() is not None else None + + +def _review(item, notes, now): + """The hold on a planned item of an open request, `{until, state, + seconds_left}`: `redirected` when a note (the item's or the request's, + in `notes`) is at or after the moment the hold was set (any note, when + the stamp is missing or unreadable), else `due` once + `now` reaches the deadline, else `holding`. None when the item has no + readable hold. `seconds_left` is whole and never negative.""" + until = _moment(item.get("review_until")) + if until is None: + return None + set_at = _moment(item.get("review_set_at")) + now = now or datetime.now(timezone.utc) + left = max(int((until - now).total_seconds()), 0) + if any( + set_at is None or ((at := _moment(note.get("at"))) is not None and at >= set_at) + for note in notes + ): + state = "redirected" + else: + state = "due" if now >= until else "holding" + return {"until": item["review_until"], "state": state, "seconds_left": left} + + +def item_view(item, jobs, ready=False, request_notes=(), state="open", now=None): """One item as read, with what its linked `jobs` derive: `status`, `ready`, `attempts` (every linked job, oldest first, as `{job, status, note, minutes, output}` - `note` only when set, `minutes` null until it has run, `output` its proof or null), `result` (`{job, run_id, - output}`), `accepted_missing` (only when true) and `spent_minutes`.""" + output}`), `accepted_missing` (only when true), `spent_minutes` and + `review` (only on a planned item of an open request with a hold: see + `_review`; `request_notes` are the request's own notes, `state` its + state, `now` the aware time to read it at).""" attempts = [ { "job": job.get("job"), @@ -197,15 +234,26 @@ def item_view(item, jobs, ready=False): "run_id": chosen.get("run_id"), "output": attempts[jobs.index(chosen)]["output"], } + status = _item_status(item, jobs) + review = ( + _review(item, [*(item.get("notes") or []), *request_notes], now) + if status == "planned" and state == "open" + else None + ) return { **item, + **{ + field: item.get(field) if isinstance(item.get(field), str) else None + for field in ("review_until", "review_set_at") + }, "notes": _noted(item.get("notes"), _positions(jobs), _live_keys([item])), - "status": _item_status(item, jobs), + "status": status, "ready": ready, "attempts": attempts, "result": result, **({"accepted_missing": True} if missing else {}), "spent_minutes": _spent(jobs), + **({"review": review} if review else {}), } @@ -224,11 +272,13 @@ def _remaining(request, grouped): return round(total, 2) -def request_view(request, jobs=()): +def request_view(request, jobs=(), now=None): """A stored request as read: every item with its derived fields (`item_view`) and the request's `spent_minutes` and `remaining_minutes`. `jobs` are the linked jobs (`{job, item, status, run_id, run_dir, - run_exists, note, created_at, started_at, finished_at, output}`).""" + run_exists, note, created_at, started_at, finished_at, output}`). `now` + is an aware datetime to read the review holds at, the current time when + omitted.""" grouped = _jobs_by_item(jobs) ready = _ready(request, grouped) positions = {} @@ -242,8 +292,16 @@ def request_view(request, jobs=()): ), "agent_wrote_at": request.get("agent_wrote_at"), } + now = now or datetime.now(timezone.utc) view["items"] = [ - item_view(item, grouped.get(item.get("key"), []), item.get("key") in ready) + item_view( + item, + grouped.get(item.get("key"), []), + item.get("key") in ready, + request.get("notes") or [], + request.get("state"), + now, + ) for item in request.get("items", []) ] view["spent_minutes"] = _spent(jobs) diff --git a/dw/reference_limits.py b/dw/reference_limits.py index de3bb13d2..d2e777671 100644 --- a/dw/reference_limits.py +++ b/dw/reference_limits.py @@ -198,6 +198,47 @@ def _untyped_message(index, entry): ) +def _unnamed_entries(entries): + """The indices of a reference list's dict entries that name no class. + + An entry with no `reference_type` key (`type` is the usual slip), or one + whose value is a bare class name with no dotted path, can never load: the + run refuses it late or passes it on as a plain dict, and every later + check skips it because it cannot read a class off it (#1512). A value + that is a reference, or dotted, is left to the passes that load it. + """ + if not isinstance(entries, list): + return [] + unnamed = [] + for index, entry in enumerate(entries): + if not isinstance(entry, dict): + continue + name = entry.get(REFERENCE_TYPE_KEY) + if name is None: + unnamed.append(index) + elif ( + isinstance(name, str) + and "." not in name + and not references.is_ref(references.UNRESOLVED, name) + ): + unnamed.append(index) + return unnamed + + +def _unnamed_message(index, entry): + given = entry.get(REFERENCE_TYPE_KEY) + seen = ( + f"names {given!r}, which is not a dotted path" + if given is not None + else f"has no '{REFERENCE_TYPE_KEY}' key (keys: {sorted(entry)})" + ) + return ( + f"references[{index}] {seen}. A reference needs '{REFERENCE_TYPE_KEY}' " + f"with the full dotted path, for example " + f'"{H3_FAMILY}.MiniMaxH3VideoReference"' + ) + + def reference_limit_errors(workflow_definition, source_indices=None): """Every reference list a pipeline would refuse, as [{path, message}]. @@ -218,6 +259,24 @@ def reference_limit_errors(workflow_definition, source_indices=None): continue if is_h3_step(pipeline): entries = arguments.get("references") + for index in _unnamed_entries(entries): + errors.append( + { + "path": render_path( + ( + "steps", + source, + "pipeline", + "arguments", + "references", + index, + ) + ), + "message": ( + f"{_unnamed_message(index, entries[index])}{where}." + ), + } + ) for index in _untyped_entries(entries): errors.append( { diff --git a/dw/server/api_models_library.py b/dw/server/api_models_library.py index 60bf5e167..51e70a30e 100644 --- a/dw/server/api_models_library.py +++ b/dw/server/api_models_library.py @@ -416,6 +416,17 @@ class LedgerResult(ApiModel): output: LedgerOutput | None +class LedgerReview(ApiModel): + until: str = Field(description="The deadline of the hold, an ISO time in UTC.") + state: Literal["holding", "redirected", "due"] = Field( + description="redirected when a note was left after the hold was set, " + "else due once the deadline has passed, else holding." + ) + seconds_left: int = Field( + description="Whole seconds to the deadline at read time, 0 once passed." + ) + + class LedgerItem(ApiModel): key: str title: str @@ -451,6 +462,18 @@ class LedgerItem(ApiModel): spent_minutes: int | float = Field( description="Minutes the item's linked jobs ran, summed." ) + review_until: str | None = Field( + description="When the user's review of the item ends, an ISO time in " + "UTC; null when it is not held." + ) + review_set_at: str | None = Field( + description="When the current deadline was set, stamped by the server; " + "null when it is not held." + ) + review: LedgerReview = sometimes( + "The hold as read now; absent unless the item is planned, its request " + "open and a deadline set." + ) class LedgerHistoryEntry(ApiModel): @@ -513,6 +536,20 @@ class LedgerList(ApiModel): ) +class OpenRequestSummary(LedgerSummary): + workspace: str = Field(description="The workspace the request is in.") + + +class OpenRequestList(ApiModel): + requests: list[OpenRequestSummary] = Field( + description="Every workspace's open requests, newest change first." + ) + unreadable: dict[str, str] = sometimes( + "Workspace name -> why its requests.json could not be read; its " + "requests are left out." + ) + + class LedgerDeleted(ApiModel): id: str workspace: str @@ -532,7 +569,9 @@ class RequestWrite(BaseModel): goal: str = Field(description="What done looks like") items: list[dict[str, Any]] = Field( description="The ordered plan; each item is key, title, depends_on, " - "estimate_minutes, workflow, arguments, accepted; an item's `notes` " + "estimate_minutes, workflow, arguments, accepted, review_until (an ISO " + "time with a UTC offset, 60 seconds to 24 hours ahead, holding the item " + "for the user's review; null clears it); an item's `notes` " "are ignored (the request-notes routes write them)" ) revision: int = Field(description="The revision read, or 0 to create") diff --git a/dw/server/listening.py b/dw/server/listening.py index ed037c53b..3fa6bb1f1 100644 --- a/dw/server/listening.py +++ b/dw/server/listening.py @@ -1,5 +1,7 @@ """Whether a notes channel is listening: the last time one polled each -workspace's request list. In memory only; a restart forgets it.""" +workspace's request list, or the whole server's (`seen_all`, the read a +channel that watches every workspace makes). In memory only; a restart +forgets it.""" import threading import time @@ -13,16 +15,23 @@ def __init__(self, clock=time.time): self._clock = clock self._lock = threading.Lock() self._last = {} + self._all = None # the last poll of every workspace at once def seen(self, workspace: str) -> None: with self._lock: self._last[workspace] = self._clock() + def seen_all(self) -> None: + """A poll that covers every workspace, those made after it too.""" + with self._lock: + self._all = self._clock() + def state(self, workspace: str) -> dict: with self._lock: - last = self._last.get(workspace) - if last is None: + polls = [t for t in (self._last.get(workspace), self._all) if t] + if not polls: return {"listening": False, "last_seen": None} + last = max(polls) stamp = datetime.fromtimestamp(last, timezone.utc).strftime( "%Y-%m-%dT%H:%M:%SZ" ) diff --git a/dw/server/routes/requests.py b/dw/server/routes/requests.py index 58c130d59..7daa56d3d 100644 --- a/dw/server/routes/requests.py +++ b/dw/server/routes/requests.py @@ -16,11 +16,12 @@ NoteEdit, NotesChannelState, NoteWritten, + OpenRequestList, RequestWrite, ) from ... import ledger from ...security import SecurityError, validate_path -from ...workspace import DEFAULT_WORKSPACE_NAME +from ...workspace import DEFAULT_WORKSPACE_NAME, workspace_names from ..deps import internal_error, workspace_for, workspace_root from ..outputs import shown_outputs @@ -86,6 +87,48 @@ def list_requests(request: Request, name: str): return {"workspace": name, **ledger.listing(root, _jobs_for(request, name))} +@router.get( + "/api/requests", + response_model=OpenRequestList, + response_model_exclude_unset=True, +) +def list_open_requests(request: Request): + """Every workspace's open requests, without their items, newest change + first: the one read a notes channel makes when it watches the whole + server. Marked `X-DW-Notes-Channel: 1`, it counts as a poll of every + workspace. `unreadable` names a workspace whose requests.json is there + but is not a ledger, or that could not be resolved while it was listed; + the others still list, and a watcher keeps what it knew of the named + ones rather than taking them for closed.""" + state = request.app.state + if request.headers.get("X-DW-Notes-Channel") == "1": + state.listening.seen_all() + names = ( + workspace_names(state.workspace_root) + if state.workspace_root + else [DEFAULT_WORKSPACE_NAME] + ) + rows, broken = [], {} + for name in names: + try: + root = _ledger_root(state, name) + except HTTPException as e: # removed since the root was listed + broken[name] = str(e.detail) + continue + problem = ledger.unreadable(root) + if problem is not None: + broken[name] = str(problem) + continue + jobs_for = _jobs_for(request, name) + rows += [ + {"workspace": name, **ledger.summary_view(r, jobs_for(r.get("id")))} + for r in ledger.read_requests(root).values() + if r.get("state") == "open" + ] + rows.sort(key=lambda row: row.get("updated_at") or "", reverse=True) + return {"requests": rows, **({"unreadable": broken} if broken else {})} + + @router.get( "/api/workspaces/{name}/notes-channel", response_model=NotesChannelState, diff --git a/dw/trust.py b/dw/trust.py index 7271a045f..eb07fe5dd 100644 --- a/dw/trust.py +++ b/dw/trust.py @@ -372,10 +372,14 @@ def require_trusted_lora_entries(loras) -> None: def require_trusted_block(block, what: str) -> None: """require_trusted_from_pretrained_arguments over a whole definition: every nested block's from_pretrained_arguments, so a gate that covers a - block added later without enumerating it. + block added later without enumerating it. A `pre_load_modules` list is + put to require_trusted_pre_load_modules wherever it sits, so validate, + submit and the worker's pre-release check refuse what the loader would + (#1511). Raises: - UntrustedWorkflowError: If untrusted and any block sets a remote-code key + UntrustedWorkflowError: If untrusted and any block sets a remote-code + key or names a pre_load_modules entry outside the ecosystem """ if not isinstance(block, dict): return @@ -384,6 +388,10 @@ def require_trusted_block(block, what: str) -> None: for key, value in block.items(): if key in LOADER_ARGUMENT_BLOCKS: continue + if key == "pre_load_modules" and isinstance(value, list): + require_trusted_pre_load_modules( + [name for name in value if isinstance(name, str)] + ) if key == "loras": require_trusted_lora_entries(value) if isinstance(value, dict): diff --git a/dw/type_references.py b/dw/type_references.py index fb4135a08..39cf7d73e 100644 --- a/dw/type_references.py +++ b/dw/type_references.py @@ -87,7 +87,7 @@ def _type_reference_error(key, value, path): try: load_type_from_name(value, key) except UntrustedWorkflowError as e: - return {"path": path, "message": str(e)} + return {"path": path, "message": str(e), "refusal": e} except (ImportError, AttributeError, ValueError): class_name = value.rsplit(".", 1)[-1] suggestions = difflib.get_close_matches( @@ -130,7 +130,7 @@ def _loose_type_reference_error(key, value, path, warnings=None): try: load_type_from_name(value, key) except UntrustedWorkflowError as e: - return {"path": path, "message": str(e)} + return {"path": path, "message": str(e), "refusal": e} except (ImportError, AttributeError, ValueError): if warnings is not None and "." not in value: warnings.append( @@ -178,7 +178,7 @@ def _per_component_dtype_error(key, value, path, warnings=None): try: load_type_from_name(dtype, key) except UntrustedWorkflowError as e: - return {"path": component_path, "message": str(e)} + return {"path": component_path, "message": str(e), "refusal": e} except (ImportError, AttributeError, ValueError): return { "path": component_path, @@ -211,7 +211,9 @@ def _constant_reference_error(value, path): return None try: fetch_constant(value) - except (ValueError, InvalidInputError, UntrustedWorkflowError) as e: + except UntrustedWorkflowError as e: + return {"path": path, "message": str(e), "refusal": e} + except (ValueError, InvalidInputError) as e: return {"path": path, "message": str(e)} return None @@ -285,6 +287,24 @@ def component_type_errors(workflow_definition, source_indices=None): return errors +def require_trusted_type_references(steps): + """component_type_errors' trust refusals over expanded steps, raised: a + dotted type or a 'constant:' outside the ecosystem, as the run's realize + pass would refuse it. The worker's check before it releases the warm + models (workflow_run.require_trusted_steps, #1511); a name that merely + fails to resolve is left for the run to report. + + Raises: + UntrustedWorkflowError: The first refusal found + """ + for step in steps or []: + found = [] + _walk_type_references(step, (), found) + for error in found: + if "refusal" in error: + raise error["refusal"] + + def unbraced_type_warnings(workflow_definition, source_indices=None): """Every bare name handed to a `*_type`/`*_dtype`/`dtype` key that is not a diffusers type, as warning strings (#926) - found by the same walk and diff --git a/dw/workflow_run.py b/dw/workflow_run.py index 87305e07b..184a79f61 100644 --- a/dw/workflow_run.py +++ b/dw/workflow_run.py @@ -72,8 +72,11 @@ step_pipeline_keys, ) from .subfolders import step_subfolder -from .trust import require_trusted_block +from .security import UntrustedWorkflowError +from .trust import require_trusted_block, workflows_are_trusted +from .type_references import require_trusted_type_references from .variable_constraints import apply_constraints +from .variables import ConstantError from .vram_estimate import apply_vram_estimate logger = logging.getLogger("dw") @@ -493,25 +496,43 @@ def _prepared_steps(workflow, arguments): def require_trusted_pipelines(workflow, arguments): - """Refuse an untrusted workflow whose pipeline steps reach for remote - code, before the worker releases the previous workflow's models: the run - would be refused at load, and a refusal should leave the warm cache where - it was. Raises what the loader's own gate raises; a definition that - cannot be prepared is left for the run to report.""" + """Refuse an untrusted workflow the run would refuse - a pipeline step + that reaches for remote code or names a pre_load_modules entry outside + the ecosystem, a dotted type or a 'constant:' outside it - before the + worker releases the previous workflow's models: a refusal should leave + the warm cache where it was (#1333, #1511). Raises what the run's own + gates raise; a definition that cannot be expanded is left for the run to + report. + + Reads keys only, over validate's expansion (Workflow.expanded_definition): + no asset, clip or URL is loaded, since the run realizes them itself. A + trusted server has nothing to refuse, so it does no work at all (#1510). + """ + if workflows_are_trusted(): + return try: - steps = _prepared_steps(workflow, arguments) + steps = workflow.expanded_definition(arguments or {}).get("steps", []) + except ConstantError as e: + # A 'constant:' variable default the gate refused + if isinstance(e.__cause__, UntrustedWorkflowError): + raise e.__cause__ + logger.debug(f"Could not expand the definition for the trust check: {e}") + return except Exception as e: - logger.debug(f"Could not prepare the definition for the trust check: {e}") + logger.debug(f"Could not expand the definition for the trust check: {e}") return require_trusted_steps(steps) def require_trusted_steps(steps): - """The gate over prepared steps - the one the worker runs before a load - and validate runs over its own expansion (#1410).""" + """The gate over expanded steps the worker runs before it releases the + warm models: each pipeline block as validate's pipeline_remote_code pass + reads it (#1410), and each step's type and 'constant:' references as its + component_types pass does.""" for step in steps: if isinstance(step, dict): require_trusted_block(step.get("pipeline"), "pipeline") + require_trusted_type_references(steps) def pipeline_keys(workflow, arguments): diff --git a/dw_mcp/__main__.py b/dw_mcp/__main__.py index d09c632b2..34e20d997 100644 --- a/dw_mcp/__main__.py +++ b/dw_mcp/__main__.py @@ -66,7 +66,8 @@ def main(argv=None, transport=None): default=False, help="Serve no tools: be a Claude Code channel that tells the open " "session when the user saves a note for the agent on a request in " - "--workspace (docs/MCP.md, 'The notes channel')", + "any workspace, or only in --workspace when given (docs/MCP.md, " + "'The notes channel')", ) parser.add_argument( "--interval", @@ -119,7 +120,7 @@ def main(argv=None, transport=None): if code: return code if args.notes_channel: - run_notes_channel(client, args.interval) + run_notes_channel(client, args.interval, workspace=args.workspace) else: build_server(client).run(transport="stdio") finally: diff --git a/dw_mcp/ledger.py b/dw_mcp/ledger.py index 812dba7c0..9c5455f33 100644 --- a/dw_mcp/ledger.py +++ b/dw_mcp/ledger.py @@ -7,6 +7,7 @@ refusal says which revision is current. """ +import time from datetime import datetime, timezone from dw_mcp.client import DwApiError, api_path @@ -99,6 +100,11 @@ def delete_request(client, request, revision, workspace=None): # Marks the channel's request-list poll, so the server can tell a session # is listening. A hint for the page, never an authority. CHANNEL_HEADER = {"X-DW-Notes-Channel": "1"} + +# Polls between asks for GET /api/requests on a server that answered 404: +# about five minutes at the default interval, so a server updated while a +# channel runs is found again without restarting the session +ROUTE_RETRY_POLLS = 30 # The ledger's own cap on a note (dw/notes.py); a note is quoted whole # up to it NOTE_QUOTE_CAP = 4000 @@ -318,6 +324,90 @@ def waiting_event(notes, workspace): return {"content": "\n\n".join([head, "\n".join(lines), tail]), "meta": meta} +def due_reviews(request): + """The held items of one open request whose deadline has passed with no + note on them and that are ready to run: live items in plan order, as + `{request, revision, item, title, until, estimate_minutes}`.""" + return [ + { + "request": request.get("id"), + "revision": request.get("revision"), + "item": item.get("key"), + "title": item.get("title") or "", + "until": item["review"]["until"], + "estimate_minutes": item.get("estimate_minutes"), + } + for item in request.get("items") or [] + if not item.get("dropped") + and (item.get("review") or {}).get("state") == "due" + and item.get("ready") + ] + + +def review_event(due, workspace, stale=False): + """The channel event for one request's due items (`due_reviews`). Fresh, + it tells the agent to run what is still ready under the cost it quoted; + `stale` (the hold was set before this session connected) tells it to + confirm with the user first. `meta` values are strings.""" + request = due[0]["request"] + if stale: + head = ( + f'Review time is up on request "{request}", on a hold set before ' + "this session connected. Held items:" + ) + tail = ( + "These holds were set before this session, so the user's go-ahead " + "may be stale. Tell the user what is waiting and confirm before " + "spending GPU time." + ) + else: + head = ( + f'Review time is up on request "{request}" with no note from the ' + "user. Held items now due:" + ) + tail = ( + f'Read the request with get_request("{request}", workspace="{workspace}"). ' + "Run only the items still ready and without a new note, each with " + f'run_workflow(request="{request}/<key>", acknowledged_cost=<the ' + "plan you quoted>). If a run is refused for a changed plan, or " + "validate_workflow now quotes a figure well off what you told the " + "user, do not run it and do not hold again: clear its " + "review_until and put the new figure in the why." + ) + lines = [] + for item in due: + minutes = item.get("estimate_minutes") + about = f" (about {minutes:g} min)" if minutes else "" + lines.append(f"- {item['item']}: {item['title']}{about}") + earliest = min( + due, + key=lambda d: _instant(d["until"]) or datetime.max.replace(tzinfo=timezone.utc), + ) + meta = { + "kind": "review_due", + "workspace": str(workspace), + "request": str(request), + "revision": str(due[0]["revision"]), + "items": ",".join(str(d["item"]) for d in due), + "until": str(earliest["until"]), + } + if stale: + meta["stale"] = "1" + return {"content": "\n\n".join([head, "\n".join(lines), tail]), "meta": meta} + + +def _holding_left(request): + """Seconds until the earliest still-`holding` item of `request` is due, + or None when none is.""" + left = [ + item["review"]["seconds_left"] + for item in request.get("items") or [] + if not item.get("dropped") + and (item.get("review") or {}).get("state") == "holding" + ] + return min(left) if left else None + + def retry_delay(interval, failures): """Seconds until the next poll: the interval, doubled for each failed poll in a row, up to MAX_BACKOFF_SECONDS.""" @@ -327,58 +417,161 @@ def retry_delay(interval, failures): class NoteWatch: - """Which waiting notes one channel process has yet to announce. - - `poll` reads the workspace's request list - one call when nothing - changed - and each open request whose revision moved since it was last - read. The first poll that reaches the server answers with one digest of - everything waiting; after it, each note is announced once, keyed by its - note id and `at`, so an edited note (a new `at`) is announced - again and one the agent has written after never is. + """Which waiting notes and due review holds one channel process has yet + to announce. + + `poll` reads a request list - one call when nothing changed - and each + open request whose stamp (revision, `updated_at`, count of ready items) + moved since it was last read, or whose earliest hold has run out on the + monotonic `clock` since (a deadline passing changes nothing the list + shows). With `everywhere`, the list is the server's (`/api/requests`: + every workspace's open requests, one read), so a note reaches the + session whichever workspace it works in; a server without that route + is read one workspace at a time, the client's, and asked again every + ROUTE_RETRY_POLLS polls. Otherwise it is the `workspace` list (the + client's when None). Requests are keyed by workspace and id, and a + workspace the read names as unreadable keeps what was known of it. The + first poll that reaches the server answers with one digest of the notes + waiting per workspace; after it, each note is announced once, keyed by + its note id and `at` (an edited note is announced again, one the agent + has written after never is), and each due item once per + `(item, review_until)`, after the notes of the same poll. A due hold is + stale when it was already on the item the first time this watch read a + request that the first listing held, fresh otherwise (a request that + first appears in a later listing was created, hold and all, while the + watch ran). """ - def __init__(self, workspace=None): + def __init__(self, workspace=None, everywhere=False, clock=time.monotonic): self.workspace = workspace - self.fault = None # why the last poll could not read a request + self.everywhere = everywhere + self.fault = None # why the last poll could not read part of the ledger + self.notice = None # what a person should know of how it is watching + self._skip_route = 0 # polls left before asking for the route again + self._clock = clock self._started = False - self._stamps = {} # request id -> (revision, updated_at) last read - self._announced = {} # request id -> {(note id, at)} still waiting - - def poll(self, client): - """The events to send now. Raises DwApiError when the list cannot - be read; a single request that cannot be is left for the next poll - and named in `fault`.""" - self.fault = None + # each keyed by (workspace, request id) + self._stamps = {} # -> (revision, updated_at, ready) last read + self._announced = {} # -> {(note id, at)} still waiting + self._due_at = {} # -> clock moment its earliest hold runs out + self._due_told = {} # -> {(item, review_until)} announced + self._inherited = {} # -> {(item, review_until)} held at first read + self._first_keys = None # the open requests in the first listing read + + def _rows(self, client): + """`(workspace, row)` for each open request the list names, and the + workspaces it could not read (name -> why), whose requests are kept + as they were rather than taken for closed. Raises DwApiError when no + list can be read.""" + if self.everywhere and self._skip_route > 0: + self._skip_route -= 1 + elif self.everywhere: + try: + listing = client.get_json( + api_path("api", "requests"), headers=CHANNEL_HEADER + ) + except DwApiError as e: + if e.status_code != 404: + raise + # a server older than the route: one workspace, asking again + # now and then in case it is updated under a running channel + self._skip_route = ROUTE_RETRY_POLLS - 1 + self.notice = ( + "the server has no GET /api/requests, so only workspace " + f'"{_workspace(client, self.workspace)}" is watched; ' + "update the server to hear every workspace" + ) + else: + self.notice = None + rows = [ + (row.get("workspace"), row) + for row in listing.get("requests") or [] + if row.get("state") == "open" + ] + return rows, dict(listing.get("unreadable") or {}) name = _workspace(client, self.workspace) listing = get_request(client, workspace=name, headers=CHANNEL_HEADER) if listing.get("unreadable"): raise DwApiError(str(listing["unreadable"])) - fresh, open_ids = [], set() - for row in listing.get("requests") or []: - if row.get("state") != "open": - continue - request_id = row.get("id") - open_ids.add(request_id) - stamp = (row.get("revision"), row.get("updated_at")) - if self._stamps.get(request_id) == stamp: + rows = [ + (name, row) + for row in listing.get("requests") or [] + if row.get("state") == "open" + ] + return rows, {} + + def _read_due(self, key, stamp): + """Whether request `key` must be read again: its stamp moved, or its + earliest hold has run out.""" + if self._stamps.get(key) != stamp: + return True + due_at = self._due_at.get(key) + return due_at is not None and self._clock() >= due_at + + def poll(self, client): + """The events to send now. Raises DwApiError when the list cannot + be read; a single request or workspace that cannot be is left for + the next poll and named in `fault`.""" + rows, broken = self._rows(client) + self.fault = "; ".join(f"{n}: {why}" for n, why in broken.items()) or None + fresh, reviews, open_keys = [], [], set() + if self._first_keys is None: + self._first_keys = {(name, row.get("id")) for name, row in rows} + for name, row in rows: + key = (name, row.get("id")) + open_keys.add(key) + stamp = (row.get("revision"), row.get("updated_at"), row.get("ready")) + if not self._read_due(key, stamp): continue try: - request = get_request(client, request_id, name) + request = get_request(client, key[1], name) except DwApiError as e: if e.status_code != 404: # deleted since the list was read self.fault = str(e) continue waiting = waiting_notes(request) - told = self._announced.get(request_id, ()) - fresh += [n for n in waiting if (n["note"], n["at"]) not in told] - self._announced[request_id] = {(n["note"], n["at"]) for n in waiting} - self._stamps[request_id] = stamp - for request_id in set(self._stamps) - open_ids: - del self._stamps[request_id] - del self._announced[request_id] + told = self._announced.get(key, ()) + fresh += [(name, n) for n in waiting if (n["note"], n["at"]) not in told] + self._announced[key] = {(n["note"], n["at"]) for n in waiting} + if key not in self._inherited: + held = key in self._first_keys + self._inherited[key] = { + (item.get("key"), item["review_until"]) + for item in request.get("items") or [] + if held and not item.get("dropped") and item.get("review_until") + } + inherited = self._inherited[key] + due = due_reviews(request) + seen = self._due_told.setdefault(key, set()) + new = [d for d in due if (d["item"], d["until"]) not in seen] + seen.update((d["item"], d["until"]) for d in new) + old = [d for d in new if (d["item"], d["until"]) in inherited] + if old: + reviews.append((name, old, True)) + if len(old) < len(new): + reviews.append((name, [d for d in new if d not in old], False)) + left = _holding_left(request) + if left is None: + self._due_at.pop(key, None) + else: + self._due_at[key] = self._clock() + left + self._stamps[key] = stamp + for key in set(self._stamps) - open_keys: + if key[0] in broken: # not read this time, not closed + continue + del self._stamps[key] + del self._announced[key] + self._due_at.pop(key, None) + self._due_told.pop(key, None) + self._inherited.pop(key, None) started, self._started = self._started, True - if not fresh: - return [] if not started: - return [waiting_event(fresh, name)] - return [note_event(note, name) for note in fresh] + by_workspace = {} + for name, note in fresh: + by_workspace.setdefault(name, []).append(note) + events = [ + waiting_event(notes, name) for name, notes in by_workspace.items() + ] + else: + events = [note_event(note, name) for name, note in fresh] + return events + [review_event(d, name, stale=s) for name, d, s in reviews] diff --git a/dw_mcp/server.py b/dw_mcp/server.py index e8a537ad9..5739c24da 100644 --- a/dw_mcp/server.py +++ b/dw_mcp/server.py @@ -252,20 +252,22 @@ def tool(fn, annotations): NOTES_INSTRUCTIONS = ( 'Events from this channel (<channel source="dw-notes" ...>) are notes ' - "the user saved on a dw request, or on one of its items, in the dw web " - "UI. A note is the user's own instruction for that request or item. " - '`kind="note"` is one saved just now: act on it. ' + "the user saved on a dw request or item in the web UI; a note is " + "their own instruction. " + '`kind="note"` was saved just now: act on it. ' '`kind="notes_waiting"` lists notes saved before this session ' - "connected: say what is waiting and confirm before spending GPU time on " - "them.\n" + "connected: say what is waiting and confirm before spending GPU time. " + '`kind="review_due"` means a hold on planned items reached its ' + "deadline with no note from the user: run the named items under the " + 'usual cost gate, but `stale="1"` means the hold was set before this ' + "session, so confirm with them first.\n" "\n" - "Before acting, read the current plan with the dw tools' " - "`get_request(request, workspace)` - the note may have been edited or " - "cleared since. Act through the normal dw tools under their usual cost " - "gate, then record what you did in the `why` of `set_request`. That " - "write is the answer: the user is watching the request page and sees " - "nothing typed in this session, so do not reply here instead of updating " - "the plan. This channel is one-way and has no tools of its own." + "Before acting, read the plan with `get_request(request, workspace)`: " + "it may have been edited or cleared. Act through the dw tools " + "under their cost gate, then record what you did in the `why` of " + "`set_request`. That write is the answer: the user watches the page, " + "not this chat; don't reply here. This channel is one-way, with no " + "tools." ) @@ -290,13 +292,14 @@ async def _announce(connection, client, watch, interval, sleep, say): reason and retried on a growing delay; it never ends the loop.""" await connection.initialized.wait() await sleep(min(interval, CONNECT_GRACE_SECONDS)) - failures, reported = 0, None + failures, reported, noticed = 0, None, None while True: + failed = True try: events = await anyio.to_thread.run_sync( watch.poll, client, abandon_on_cancel=True ) - fault = watch.fault + fault, failed = watch.fault, False except (DwApiError, httpx.HTTPError) as e: events, fault = [], str(e) except Exception as e: @@ -305,11 +308,17 @@ async def _announce(connection, client, watch, interval, sleep, say): events, fault = [], f"{type(e).__name__}: {e}" for event in events: await connection.notify(CHANNEL_NOTIFICATION, event) + notice = getattr(watch, "notice", None) + if notice and notice != noticed: + say(notice) + noticed = notice if fault is None and reported is not None: say("reading the ledger again") elif fault is not None and fault != reported: say(f"could not read the ledger, will keep trying: {fault}") - failures, reported = (failures + 1 if fault else 0), fault + # Only a poll that read nothing backs off: a fault in part of the + # ledger (one request, one workspace) must not slow the rest + failures, reported = (failures + 1 if failed else 0), fault await sleep(retry_delay(interval, failures)) @@ -325,7 +334,9 @@ async def serve_notes_channel(client, interval, workspace=None, sleep=anyio.slee what a notification outside any request is sent on. """ server, options = build_notes_channel() - watch = NoteWatch(workspace) + # No workspace named: every one, so a session that moves with + # use_workspace still hears its notes + watch = NoteWatch(workspace, everywhere=workspace is None) async with stdio_server() as (read_stream, write_stream): dispatcher = JSONRPCDispatcher( read_stream, write_stream, inline_methods=frozenset({"initialize"}) diff --git a/dw_mcp/tools_authoring.py b/dw_mcp/tools_authoring.py index c027780bf..8ef1f9a51 100644 --- a/dw_mcp/tools_authoring.py +++ b/dw_mcp/tools_authoring.py @@ -94,15 +94,15 @@ def set_request( workspace: str | None = None, purge: list[str] | None = None, ) -> dict: - """Write the whole plan for what the user asked, so it outlives this - session. revision: the one you read, 0 to create; stale is refused. - prompt: the user's ask, on create only. items: ordered {key, title, - depends_on, estimate_minutes, workflow, arguments, accepted}; one - left out is dropped. accepted: {job}, the keeper. Act on the user's - `notes` (request and items, each may carry `refs` to the takes and - files it is about) in what you read; never write them. - why: one line. state: open, done or abandoned. purge: dropped keys - to remove for good. get_guide("workspaces", section="Requests").""" + """Write the whole plan for the user's ask; it outlives this session. + revision: the one you read, 0 to create; stale refused. + prompt: the user's ask, on create. items: ordered {key, title, + depends_on, estimate_minutes, workflow, arguments, accepted, + review_until}; one left out is dropped. accepted: {job}, the keeper. + review_until: an ISO time until which a planned item is held for the + user's review. Act on the user's `notes` (request and items, with + `refs`); never write them. why: one line. state: open, done or + abandoned. purge: dropped keys to delete. get_guide("workspaces", section="Requests").""" return ledger.set_request( self.client, request, diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 000000000..54b8e6880 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "diffusers-workflow", + "lockfileVersion": 3, + "requires": true, + "packages": {} +} diff --git a/plugins/dw/.claude-plugin/plugin.json b/plugins/dw/.claude-plugin/plugin.json index d340e22f2..756b9f6c1 100644 --- a/plugins/dw/.claude-plugin/plugin.json +++ b/plugins/dw/.claude-plugin/plugin.json @@ -1,7 +1,7 @@ { "name": "dw", "description": "Compose MiniMax H3 video, MiniMax Music 3, LTX-2.5, Kandinsky 6.0, FLUX 3 Klein and MiniMax-H3-Image workflows over a dw MCP server, cut a multi-episode series from them, direct camera and look in each family's caption format, storyboard a scene before it is filmed, and plan a piece longer than one clip from measured levers: which template fits which shape, the hard rules, cost, and how to judge the output. Prompt format comes from the vendors' own guides.", - "version": "0.21.0", + "version": "0.22.0-alpha.1", "author": { "name": "Don Kackman" }, diff --git a/plugins/dw/skills/script-to-video/references/request.md b/plugins/dw/skills/script-to-video/references/request.md index 19e6263f3..6746aa87d 100644 --- a/plugins/dw/skills/script-to-video/references/request.md +++ b/plugins/dw/skills/script-to-video/references/request.md @@ -58,6 +58,48 @@ with its `note` as before. A rerun (`rerun_job`) keeps the link by itself. `spent_minutes` and `remaining_minutes`. Quote what is left from `remaining_minutes` when the user asks. +## Hold items for the user's review + +Use this when the plan is written and priced and the user wants to look at it +on the request page before it runs. A hold defers a run the user already +approved; it never stands in for the approval. + +1. Quote the total in chat and get a yes to "these run at T unless you leave + a note". Silence on the page confirms that yes; it never replaces it. +2. Hold only when the dw-notes channel is connected in this session (its + instructions are in your context). Without it nothing tells you the + deadline passed, so run on the user's word as before. +3. Set the hold with `set_request`: each held item gets `review_until`, an + ISO time with an offset, 15 minutes ahead unless the user says otherwise + (the server refuses under 60 seconds or over 24 hours), and the `why` + says so. A `review_until` left out of an item, or null, clears its hold, + so a plan rewrite sends each held item's `review_until` back as read. Then + end the turn. Do not block in `wait_for_job` on something + else; the channel event is what wakes the session. + +What wakes you: + +- **A note.** Do the revision, write the plan, and, when the total is still + what the user agreed to, hold the revised items again with a fresh + `review_until` (the same length of hold) and say so in the `why`: the user + asked for a change, not for a second approval. When the total moved, + clear the hold and give the new figure in the `why`. A note redirects the + hold; nothing else does. +- **A `review_due` event.** `get_request`, then run only the named items that + are still `ready` with no newer note, each with + `run_workflow(request=..., acknowledged_cost=...)` for the plan you quoted. + A refusal for a changed plan, or a quote well off what the user agreed to + (more than a quarter), means no run and no new hold: clear the hold + (`review_until: null`) and put the new figure in the `why`; the user runs + it from the request page's priced Run dialog, or says yes in chat. +- **A dependency finishing.** An item held behind a dependency is announced + when the dependency finishes; you run it then. The server never starts a + job for you. +- **A `review_due` event marked stale** is for a hold set before this session + connected, even one that was still counting down when you connected. If the + channel restarts or a new session picks up the request, the hold is + announced as stale: confirm with the user before spending. + ## Accept the keeper The keeper is accepted in the request, **not with `set_note`**: @@ -92,11 +134,23 @@ saved, delivered by dw's notes channel; its text lists the items, takes and files it is about, and its `request`, `note` and `items` attributes name the target (`item` too, for a note written on an item). Do the revision pass above for that item now: `get_request` first (the note may have changed since), then the rerun or -fix it asks for, under the usual cost gate. Finish with a `set_request` +fix it asks for, under the usual cost gate. When the note changes something +the whole set shares (the place, the light, the time of day, the subject's +look), it is about more than the item it was written on: say in the `why` +which other items it affects, and carry it over to them in the same plan +write unless that would change what is already accepted; then ask in chat +before rendering them. Finish with a `set_request` whose `why` says what you did - the user watches the request page, not this session, and that write is what marks the note answered. A `kind="notes_waiting"` event lists notes from before the session: say what -is waiting and confirm before spending on them. +is waiting and confirm before spending on them. A `kind="review_due"` event +is the hold above running out. + +The channel watches every workspace on the server, so an event's +`workspace` attribute may name one other than the session's: pass it to +`get_request` and to the run, as the event's own text does. A note on a +request this session is not working on belongs to another session; leave +it alone. ## Changing the plan diff --git a/pyproject.toml b/pyproject.toml index 6be3c4a64..51cc5ae90 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,11 +8,12 @@ name = "diffusers-workflow" # runtime (static in TOML because importing dw at build time would drag # torch into the build environment). Release tags must match it - see # docs/RELEASING.md -version = "0.21.0" +version = "0.22.0-alpha.1" description = "Declarative workflow engine and web UI for Hugging Face Diffusers" readme = "README.md" requires-python = ">=3.12" -license = { text = "Apache-2.0" } +license = "Apache-2.0" +license-files = ["LICENSE"] authors = [{ name = "dkackman" }] classifiers = [ "Development Status :: 3 - Alpha", @@ -83,7 +84,7 @@ dependencies = [ "facexlib>=0.3.0", # Imaging and media "numpy>=2.5.4", - "Pillow>=12.3.0", + "Pillow>=13.0.0", "piexif>=1.1.3", "imageio>=2.38.1", "imageio-ffmpeg>=0.6.0", diff --git a/tests/test_ledger.py b/tests/test_ledger.py index b72cb8424..06a3ea29f 100644 --- a/tests/test_ledger.py +++ b/tests/test_ledger.py @@ -4,6 +4,7 @@ import json import os import threading +from datetime import datetime, timedelta, timezone import pytest from fastapi.testclient import TestClient @@ -462,6 +463,24 @@ def test_refusals_carry_their_code(self, server): assert client.get(f"{URL}/A").status_code == 400 assert client.put(f"{URL}/A", json=plan()).status_code == 400 + def test_a_review_hold_round_trips_and_a_short_one_is_refused(self, server): + def until(seconds): + when = datetime.now(timezone.utc) + timedelta(seconds=seconds) + return when.isoformat(timespec="seconds") + + with server() as client: + hold = until(3600) + body = plan(items=[item("a", review_until=hold)]) + assert client.put(f"{URL}/cats", json=body).status_code == 200 + got = client.get(f"{URL}/cats").json()["items"][0] + assert got["review_until"] == hold + assert got["review_set_at"] is not None + assert got["review"]["state"] == "holding" + short = plan(revision=1, items=[item("a", review_until=until(59))]) + refusal = client.put(f"{URL}/cats", json=short) + assert refusal.status_code == 422 + assert refusal.json()["detail"]["code"] == "review_too_soon" + @pytest.mark.parametrize( "request_id", ["", "../x", "a/b", "/etc/hosts", "../../etc/hosts", "..", "."] ) @@ -528,7 +547,9 @@ def test_no_ledger_route_is_marked_query_token_ok(self, server): routes = [ r for r in client.app.routes if "/requests" in getattr(r, "path", "") ] - assert len(routes) == 4 + # a workspace's list, a request's read, write and delete, and the + # server-wide list of open requests (#1529) + assert len(routes) == 5 for route in routes: assert not getattr(route.endpoint, "query_token_ok", False), route.path diff --git a/tests/test_ledger_review.py b/tests/test_ledger_review.py new file mode 100644 index 000000000..f3fd18019 --- /dev/null +++ b/tests/test_ledger_review.py @@ -0,0 +1,276 @@ +"""A planned item held for review until a deadline: what the ledger stores +(`review_until`, `review_set_at`), the bounds it enforces, and the `review` +the views derive from the item's notes and the clock.""" + +from datetime import datetime, timedelta, timezone + +import pytest + +from dw import ledger + +from .test_ledger import item, plan, refused, write + +T0 = datetime(2026, 11, 21, 10, 0, 0, tzinfo=timezone.utc) + + +def stamp(moment): + return moment.isoformat(timespec="seconds") + + +@pytest.fixture +def clock(monkeypatch): + """The ledger's write clock, set with `clock.at(moment)`.""" + state = {"now": T0} + monkeypatch.setattr(ledger, "_now", lambda: stamp(state["now"])) + + class Clock: + def at(self, moment): + state["now"] = moment + + return Clock() + + +def held(until, **fields): + return plan(items=[item("a", review_until=until), item("b", ["a"])], **fields) + + +def stored(tmp_path, key="a"): + request = ledger._load(str(tmp_path))["cats"] + return next(i for i in request["items"] if i["key"] == key) + + +def read(tmp_path, now, jobs=()): + request = ledger._load(str(tmp_path))["cats"] + view = ledger.request_view(request, jobs, now=now) + return next(i for i in view["items"] if i["key"] == "a") + + +def note(tmp_path, text="warmer", item_key="a"): + ledger.add_note( + str(tmp_path), + "cats", + item=item_key, + text=text, + refs=[], + check_ref=lambda request_id, ref: ref, + ) + + +def hold(tmp_path, clock, seconds=3600): + clock.at(T0) + until = stamp(T0 + timedelta(seconds=seconds)) + write(tmp_path, held(until)) + return until + + +def test_a_future_hold_stamps_the_write_time_and_reads_as_holding(tmp_path, clock): + until = hold(tmp_path, clock) + assert stored(tmp_path)["review_until"] == until + assert stored(tmp_path)["review_set_at"] == stamp(T0) + got = read(tmp_path, T0 + timedelta(seconds=600)) + assert got["review"] == {"until": until, "state": "holding", "seconds_left": 3000} + + +def test_an_offset_input_is_stored_in_utc(tmp_path, clock): + zone = timezone(timedelta(hours=-5)) + local = (T0 + timedelta(hours=1)).astimezone(zone) + write(tmp_path, held(local.isoformat())) + assert stored(tmp_path)["review_until"] == stamp(T0 + timedelta(hours=1)) + + +def test_an_unchanged_echo_keeps_review_set_at(tmp_path, clock): + until = hold(tmp_path, clock) + clock.at(T0 + timedelta(minutes=10)) + write(tmp_path, held(until, revision=1)) + assert stored(tmp_path)["review_until"] == until + assert stored(tmp_path)["review_set_at"] == stamp(T0) + + +def test_a_changed_value_restamps_review_set_at(tmp_path, clock): + hold(tmp_path, clock) + clock.at(T0 + timedelta(minutes=10)) + later = stamp(T0 + timedelta(hours=2)) + write(tmp_path, held(later, revision=1)) + assert stored(tmp_path)["review_until"] == later + assert stored(tmp_path)["review_set_at"] == stamp(T0 + timedelta(minutes=10)) + + +@pytest.mark.parametrize( + "value, code", + [ + (5, "invalid_review_until"), + (True, "invalid_review_until"), + ("tomorrow", "invalid_review_until"), + ("2026-11-21T11:00:00", "invalid_review_until"), + (stamp(T0 + timedelta(seconds=59)), "review_too_soon"), + (stamp(T0 + timedelta(hours=24, seconds=1)), "review_too_far"), + ], +) +def test_a_bad_deadline_is_refused(tmp_path, clock, value, code): + error = refused(tmp_path, held(value), code=code) + assert error.status == 422 + assert "'a'" in str(error) + + +def test_the_bounds_are_inclusive(tmp_path, clock): + write(tmp_path, held(stamp(T0 + timedelta(seconds=60)))) + write(tmp_path, held(stamp(T0 + timedelta(hours=24)), revision=1)) + assert stored(tmp_path)["review_until"] == stamp(T0 + timedelta(hours=24)) + + +def test_null_clears_both_fields_and_the_review(tmp_path, clock): + hold(tmp_path, clock) + write(tmp_path, held(None, revision=1)) + assert stored(tmp_path)["review_until"] is None + assert stored(tmp_path)["review_set_at"] is None + assert "review" not in read(tmp_path, T0) + + +def test_an_item_note_after_the_hold_redirects(tmp_path, clock): + hold(tmp_path, clock) + clock.at(T0 + timedelta(minutes=5)) + note(tmp_path) + assert read(tmp_path, T0 + timedelta(minutes=6))["review"]["state"] == "redirected" + + +def test_a_request_note_after_the_hold_redirects(tmp_path, clock): + hold(tmp_path, clock) + clock.at(T0 + timedelta(minutes=5)) + note(tmp_path, item_key=None) + assert read(tmp_path, T0 + timedelta(minutes=6))["review"]["state"] == "redirected" + + +def test_a_note_from_before_the_hold_does_not_redirect(tmp_path, clock): + clock.at(T0) + write(tmp_path, plan()) + note(tmp_path) + note(tmp_path, item_key=None) + clock.at(T0 + timedelta(minutes=5)) + until = stamp(T0 + timedelta(hours=1)) + write(tmp_path, held(until, revision=3)) + assert read(tmp_path, T0 + timedelta(minutes=6))["review"]["state"] == "holding" + + +def test_deleting_the_redirecting_note_returns_to_holding(tmp_path, clock): + hold(tmp_path, clock) + clock.at(T0 + timedelta(minutes=5)) + note(tmp_path) + ledger.delete_note(str(tmp_path), "cats", "n1") + assert read(tmp_path, T0 + timedelta(minutes=6))["review"]["state"] == "holding" + + +def test_the_hold_is_due_at_and_after_the_deadline(tmp_path, clock): + until = hold(tmp_path, clock) + at = read(tmp_path, T0 + timedelta(hours=1))["review"] + assert at == {"until": until, "state": "due", "seconds_left": 0} + after = read(tmp_path, T0 + timedelta(hours=3))["review"] + assert after["state"] == "due" + assert after["seconds_left"] == 0 + + +def test_a_queued_job_ends_the_review(tmp_path, clock): + hold(tmp_path, clock) + jobs = [{"job": "j1", "item": "a", "status": "queued"}] + assert "review" not in read(tmp_path, T0, jobs) + + +def test_a_dropped_item_has_no_review(tmp_path, clock): + hold(tmp_path, clock) + jobs = [{"job": "j1", "item": "a", "status": "failed"}] + clock.at(T0 + timedelta(minutes=1)) + write(tmp_path, plan(revision=1, items=[item("b")]), linked_jobs=lambda r, k: jobs) + request = ledger._load(str(tmp_path))["cats"] + dropped = next(i for i in request["items"] if i["key"] == "a") + assert dropped["dropped"] is True and dropped["review_until"] + assert "review" not in read(tmp_path, T0, jobs) + + +def test_a_done_request_has_no_review(tmp_path, clock): + hold(tmp_path, clock) + clock.at(T0 + timedelta(minutes=1)) + write(tmp_path, held(stamp(T0 + timedelta(hours=1)), revision=1, state="done")) + assert "review" not in read(tmp_path, T0) + + +def test_an_echoed_past_deadline_stays_redirected(tmp_path, clock): + """An agent answers a note and echoes the old, now past deadline: the + item must not become runnable without review.""" + until = hold(tmp_path, clock) + clock.at(T0 + timedelta(minutes=5)) + note(tmp_path) + clock.at(T0 + timedelta(hours=2)) + write(tmp_path, held(until, revision=2)) + assert stored(tmp_path)["review_set_at"] == stamp(T0) + got = read(tmp_path, T0 + timedelta(hours=2)) + assert got["review"]["state"] == "redirected" + + +def test_a_plan_written_back_unchanged_by_the_user_keeps_the_hold(tmp_path, clock): + hold(tmp_path, clock) + view = ledger.get_request(str(tmp_path), "cats") + clock.at(T0 + timedelta(minutes=30)) + body = {key: view[key] for key in ("title", "goal", "items", "revision")} | { + "why": "reordered" + } + write(tmp_path, body, by="user") + assert stored(tmp_path)["review_until"] == stamp(T0 + timedelta(hours=1)) + assert stored(tmp_path)["review_set_at"] == stamp(T0) + + +def test_a_client_sent_review_set_at_and_review_are_ignored(tmp_path, clock): + until = stamp(T0 + timedelta(hours=1)) + body = plan( + items=[ + item( + "a", + review_until=until, + review_set_at="2020-01-01T00:00:00+00:00", + review={"until": until, "state": "due", "seconds_left": 0}, + ) + ] + ) + write(tmp_path, body) + assert stored(tmp_path)["review_set_at"] == stamp(T0) + assert "review" not in stored(tmp_path) + + +def test_a_hold_without_review_set_at_is_redirected_by_any_note(tmp_path, clock): + hold(tmp_path, clock) + clock.at(T0 + timedelta(minutes=5)) + note(tmp_path) + request = ledger._load(str(tmp_path))["cats"] + del request["items"][0]["review_set_at"] + got = ledger.request_view(request, now=T0 + timedelta(minutes=6))["items"][0] + assert got["review"]["state"] == "redirected" + request["items"][0]["notes"] = [] + request["notes"] = [] + got = ledger.request_view(request, now=T0 + timedelta(minutes=6))["items"][0] + assert got["review"]["state"] == "holding" + + +def test_a_hand_edited_non_string_hold_reads_as_none(tmp_path, clock): + from dw.server.api_models_library import LedgerRequest + + hold(tmp_path, clock) + request = ledger._load(str(tmp_path))["cats"] + request["items"][0]["review_until"] = 5 + request["items"][0]["review_set_at"] = 7 + view = ledger.request_view(request, now=T0) + got = LedgerRequest.model_validate(view) + assert got.items[0].review_until is None + assert got.items[0].review_set_at is None + + +def test_a_request_stored_before_the_hold_still_reads(tmp_path, clock): + from dw.server.api_models_library import LedgerRequest + + write(tmp_path, plan()) + request = ledger._load(str(tmp_path))["cats"] + for stored_item in request["items"]: + stored_item.pop("review_until", None) + stored_item.pop("review_set_at", None) + view = ledger.request_view(request, now=T0) + got = LedgerRequest.model_validate(view) + assert got.items[0].review_until is None + assert got.items[0].review_set_at is None + assert "review" not in view["items"][0] diff --git a/tests/test_mcp_main.py b/tests/test_mcp_main.py index 1d3d54eb7..c5ce8c598 100644 --- a/tests/test_mcp_main.py +++ b/tests/test_mcp_main.py @@ -162,7 +162,9 @@ def no_channel(monkeypatch): monkeypatch.setattr( cli, "run_notes_channel", - lambda client, interval: ran.update(interval=interval, url=client.base_url), + lambda client, interval, workspace=None: ran.update( + interval=interval, url=client.base_url, workspace=workspace + ), ) monkeypatch.setattr(cli, "build_server", lambda client: pytest.fail("tools")) return ran @@ -171,7 +173,25 @@ def no_channel(monkeypatch): def test_notes_channel_mode_serves_the_channel_and_no_tools(no_channel): code = cli.main(["--notes-channel"], transport=httpx.MockTransport(healthy)) assert code == 0 - assert no_channel == {"interval": 10.0, "url": "http://127.0.0.1:8765"} + assert no_channel == { + "interval": 10.0, + "url": "http://127.0.0.1:8765", + "workspace": None, + } + + +def test_a_notes_channel_with_no_workspace_watches_every_one(no_channel, monkeypatch): + """$DW_MCP_WORKSPACE picks where a session starts, not what its channel + hears: a session can move with use_workspace, so the channel watches + the whole server unless --workspace pins it (#1529).""" + monkeypatch.setenv("DW_MCP_WORKSPACE", "notes") + cli.main(["--notes-channel"], transport=httpx.MockTransport(healthy)) + assert no_channel["workspace"] is None + cli.main( + ["--notes-channel", "--workspace", "notes"], + transport=httpx.MockTransport(healthy), + ) + assert no_channel["workspace"] == "notes" def test_the_notes_channel_refuses_a_remote_url_without_a_token_too(no_channel, capsys): diff --git a/tests/test_mcp_notes_channel.py b/tests/test_mcp_notes_channel.py index 14a192116..35e75c56c 100644 --- a/tests/test_mcp_notes_channel.py +++ b/tests/test_mcp_notes_channel.py @@ -6,6 +6,7 @@ import json import os import re +from datetime import datetime import pytest @@ -48,6 +49,7 @@ def __init__(self, root): self.headers = [] # (path, headers) of every read self.fail = {} # path suffix -> DwApiError to raise self.jobs = [] # the linked jobs every request read is given + self.now = None # the aware time a read derives review holds at def get_json(self, path, params=None, workspace=None, headers=None): self.calls.append(path) @@ -59,11 +61,14 @@ def get_json(self, path, params=None, workspace=None, headers=None): assert path.startswith(prefix), path request_id = path[len(prefix) :].lstrip("/") if not request_id: - return {"workspace": WORKSPACE, **store.listing(self.root)} - found = store.get_request(self.root, request_id, jobs_for=self.linked) - if found is None: + return { + "workspace": WORKSPACE, + **store.listing(self.root, jobs_for=self.linked), + } + stored = store._load(self.root).get(request_id) + if stored is None: raise DwApiError(f"No request {request_id!r}", status_code=404) - return found + return store.request_view(stored, self.linked(request_id), now=self.now) def linked(self, request_id): return self.jobs @@ -602,3 +607,543 @@ def test_a_queued_jobs_reference_is_not_stale(client, clock): (event,) = watch.poll(client) assert '- item "shot1" (Shot shot1), take 1 of 1 (job jq)\n' in event["content"] assert "no longer" not in event["content"] + + +# --- review holds ---------------------------------------------------------- + + +class Mono: + """The monotonic clock a NoteWatch reads, moved by the test.""" + + def __init__(self): + self.t = 1000.0 + + def __call__(self): + return self.t + + +@pytest.fixture +def mono(): + return Mono() + + +def moment(minute): + return datetime.fromisoformat(f"2026-11-20T14:{minute:02d}:00+00:00") + + +def held_plan(client, until_minute, request_id="lighthouse", **fields): + """The plan with shot1 held until 14:<until_minute>, shot2 after it, as + the agent wrote it at the clock's now. Both items have a workflow.""" + stored = store._load(client.root).get(request_id) + keys = ("shot1", "shot2") + plan_items = [ + { + "key": key, + "title": f"Shot {key}", + "depends_on": ["shot1"] if key == "shot2" else [], + "workflow": "txt2img", + **({"estimate_minutes": 2.5} if key == "shot1" else {}), + **( + {"review_until": f"2026-11-20T14:{until_minute:02d}:00+00:00"} + if key == "shot1" + else {} + ), + } + for key in keys + ] + return write( + client, + request_id, + by="agent", + items=plan_items, + revision=stored["revision"] if stored else 0, + **fields, + ) + + +def watching(client, mono): + watch = ledger.NoteWatch(clock=mono) + assert watch.poll(client) == [] + client.calls.clear() + return watch + + +def test_a_due_ready_hold_is_announced_once(client, clock, mono): + write(client) + client.now = moment(0) + watch = watching(client, mono) + held_plan(client, 10) + client.now = moment(11) + mono.t += 11 * 60 + + (event,) = watch.poll(client) + + assert event["content"] == ( + 'Review time is up on request "lighthouse" with no note from the user. ' + "Held items now due:\n\n" + "- shot1: Shot shot1 (about 2.5 min)\n\n" + 'Read the request with get_request("lighthouse", workspace="studio"). ' + "Run only the items still ready and without a new note, each with " + 'run_workflow(request="lighthouse/<key>", acknowledged_cost=<the plan ' + "you quoted>). If a run is refused for a changed plan, or " + "validate_workflow now quotes a figure well off what you told the user, " + "do not run it and do not hold again: clear its review_until and put " + "the new figure in the why." + ) + assert event["meta"] == { + "kind": "review_due", + "workspace": WORKSPACE, + "request": "lighthouse", + "revision": "2", + "items": "shot1", + "until": "2026-11-20T14:10:00+00:00", + } + assert all(isinstance(v, str) for v in event["meta"].values()) + mono.t += 60 + assert watch.poll(client) == [] + assert watch.poll(client) == [] + + +def test_a_line_without_an_estimate_has_no_bracket(): + due = [ + { + "request": "r", + "revision": 3, + "item": "a", + "title": "A", + "until": "2026-11-20T14:10:00+00:00", + "estimate_minutes": None, + } + ] + assert "- a: A\n\nRead" in ledger.review_event(due, "w")["content"] + + +def test_nothing_is_announced_while_holding(client, clock, mono): + write(client) + client.now = moment(0) + watch = watching(client, mono) + held_plan(client, 10) + client.now = moment(5) + mono.t += 5 * 60 + assert watch.poll(client) == [] + + +def test_a_redirected_hold_is_not_announced(client, clock, mono): + write(client) + client.now = moment(0) + watch = watching(client, mono) + held_plan(client, 10) + clock.tick(3) + note(client, "warmer first", "shot1") + client.now = moment(11) + mono.t += 11 * 60 + (event,) = watch.poll(client) # the note, and no review_due after it + assert event["meta"]["kind"] == "note" + + +def test_a_deadline_passing_rereads_a_request_whose_stamp_did_not_move( + client, clock, mono +): + write(client) + client.now = moment(0) + watch = watching(client, mono) + held_plan(client, 10) + assert watch.poll(client) == [] # reads the new hold, still counting down + client.calls.clear() + assert watch.poll(client) == [] + assert client.reads() == [] # unchanged and not yet due: the list only + client.now = moment(10) + mono.t += 10 * 60 + 1 + (event,) = watch.poll(client) + assert event["meta"]["kind"] == "review_due" + assert client.reads() == ["lighthouse"] + + +def test_due_but_not_ready_says_nothing_until_it_is(client, clock, mono): + held_plan(client, 10) + client.jobs = [{"job": "j", "item": "shot1", "status": "running"}] + client.now = moment(0) + watch = watching(client, mono) + client.now = moment(11) + mono.t += 11 * 60 + assert watch.poll(client) == [] + client.jobs = [] # the running job went away: shot1 is ready again + (event,) = watch.poll(client) + assert event["meta"]["items"] == "shot1" + + +def test_a_new_review_until_is_announced_again(client, clock, mono): + write(client) + client.now = moment(0) + watch = watching(client, mono) + held_plan(client, 10) + client.now = moment(11) + mono.t += 11 * 60 + assert len(watch.poll(client)) == 1 + clock.minute = 12 + held_plan(client, 20) # a later hold on the same item + client.now = moment(13) + assert watch.poll(client) == [] + client.now = moment(21) + mono.t += 9 * 60 + (event,) = watch.poll(client) + assert event["meta"]["until"] == "2026-11-20T14:20:00+00:00" + + +def test_the_first_poll_sends_a_stale_event_after_the_digest(client, clock, mono): + held_plan(client, 10) + note(client, "from before", "shot2") + client.now = moment(20) + digest, event = ledger.NoteWatch(clock=mono).poll(client) + assert digest["meta"]["kind"] == "notes_waiting" + assert event["content"].startswith( + 'Review time is up on request "lighthouse", on a hold set before this ' + "session connected. Held items:\n\n- shot1: Shot shot1 (about 2.5 min)\n\n" + ) + assert event["content"].endswith( + "These holds were set before this session, so the user's go-ahead may " + "be stale. Tell the user what is waiting and confirm before spending " + "GPU time." + ) + assert event["meta"]["stale"] == "1" + assert event["meta"]["kind"] == "review_due" + assert ( + "stale" + not in ledger.review_event( + [ + { + "request": "r", + "revision": 1, + "item": "a", + "title": "A", + "until": "u", + "estimate_minutes": 1, + } + ], + "w", + )["meta"] + ) + + +def test_a_note_and_a_due_hold_in_one_poll_send_the_note_first(client, clock, mono): + held_plan(client, 10) + write(client, "other") + client.now = moment(0) + watch = watching(client, mono) + clock.tick(2) + note(client, "look at this", "shot3", request_id="other") + client.now = moment(11) + mono.t += 11 * 60 + note_ev, review_ev = watch.poll(client) + assert note_ev["meta"]["kind"] == "note" + assert review_ev["meta"]["kind"] == "review_due" + + +def test_a_closed_request_drops_its_hold_bookkeeping(client, clock, mono): + held_plan(client, 10) + client.now = moment(0) + watch = watching(client, mono) + stored = store._load(client.root)["lighthouse"] + write(client, state="done", revision=stored["revision"]) + watch.poll(client) + assert "lighthouse" not in watch._due_at + assert "lighthouse" not in watch._due_told + assert "lighthouse" not in watch._stamps + + +def test_a_hold_due_at_connect_but_blocked_is_stale_when_it_becomes_ready( + client, clock, mono +): + held_plan(client, 10) + client.jobs = [{"job": "j", "item": "shot1", "status": "running"}] + client.now = moment(20) + watch = ledger.NoteWatch(clock=mono) + assert watch.poll(client) == [] + client.jobs = [] + (event,) = watch.poll(client) + assert event["meta"]["stale"] == "1" + assert event["content"].startswith( + 'Review time is up on request "lighthouse", on a hold set before this ' + "session connected. Held items:" + ) + + +def test_a_request_whose_first_read_failed_is_stale_when_it_later_reads( + client, clock, mono +): + held_plan(client, 10) + client.now = moment(20) + client.fail["/requests/lighthouse"] = DwApiError("boom", status_code=500) + watch = ledger.NoteWatch(clock=mono) + assert watch.poll(client) == [] + client.fail.clear() + (event,) = watch.poll(client) + assert event["meta"]["stale"] == "1" + + +def test_a_hold_still_counting_down_at_connect_is_stale_when_due(client, clock, mono): + held_plan(client, 10) + client.now = moment(0) + watch = watching(client, mono) + client.now = moment(11) + mono.t += 11 * 60 + (event,) = watch.poll(client) + assert event["meta"]["stale"] == "1" + + +def test_a_hold_set_after_the_first_read_is_fresh_even_on_a_new_revision( + client, clock, mono +): + held_plan(client, 10) + client.now = moment(0) + watch = watching(client, mono) + clock.minute = 1 + held_plan(client, 30) # same item, a new review_until + client.now = moment(31) + mono.t += 31 * 60 + (event,) = watch.poll(client) + assert event["meta"]["until"] == "2026-11-20T14:30:00+00:00" + assert "stale" not in event["meta"] + + +def test_one_request_splits_into_a_stale_and_a_fresh_event(client, clock, mono): + write(client) + stored = store._load(client.root)["lighthouse"] + plan = [ + { + "key": key, + "title": f"Shot {key}", + "depends_on": [], + "workflow": "txt2img", + "review_until": "2026-11-20T14:10:00+00:00", + } + for key in ("shot1",) + ] + [ + {"key": "shot2", "title": "Shot shot2", "depends_on": [], "workflow": "txt2img"} + ] + write(client, items=plan, revision=stored["revision"]) + client.now = moment(0) + watch = watching(client, mono) + stored = store._load(client.root)["lighthouse"] + plan[1]["review_until"] = "2026-11-20T14:12:00+00:00" + write(client, items=plan, revision=stored["revision"]) + client.now = moment(13) + mono.t += 13 * 60 + stale, fresh = watch.poll(client) + assert stale["meta"]["items"] == "shot1" and stale["meta"]["stale"] == "1" + assert fresh["meta"]["items"] == "shot2" and "stale" not in fresh["meta"] + + +def test_a_hold_set_in_the_write_that_creates_its_request_is_fresh(client, clock, mono): + client.now = moment(0) + watch = watching(client, mono) # the first listing: no request yet + held_plan(client, 10, request_id="newer") + client.now = moment(11) + mono.t += 11 * 60 + (event,) = watch.poll(client) + assert "stale" not in event["meta"] + assert event["content"].startswith( + 'Review time is up on request "newer" with no note from the user.' + ) + + +# --- a channel that watches every workspace (#1529) ------------------------- + + +class ServerClient: + """What the channel needs of a DwClient on a server with several + workspaces, each a ledger folder; `/api/requests` answers as the + server-wide list does, or 404 when `old` (a server without it).""" + + def __init__(self, base, names=("default", "notes")): + self.roots = {} + for name in names: + path = base / name + path.mkdir() + self.roots[name] = str(path) + self.workspace = "default" + self.calls = [] # (path, headers) + self.old = False + self.broken = set() + + def get_json(self, path, params=None, workspace=None, headers=None): + self.calls.append((path, headers)) + if path == "/api/requests": + if self.old: + raise DwApiError("Not Found", status_code=404) + rows, broken = [], {} + for name, root in self.roots.items(): + if name in self.broken: + broken[name] = "requests.json is not a ledger" + continue + rows += [ + {"workspace": name, **store.summary_view(r, [])} + for r in store.read_requests(root).values() + if r.get("state") == "open" + ] + return {"requests": rows, **({"unreadable": broken} if broken else {})} + parts = path.split("/") # "", api, workspaces, <name>, requests[, id] + root = self.roots[parts[3]] + if len(parts) == 5: + return {"workspace": parts[3], **store.listing(root)} + found = store.get_request(root, parts[5]) + if found is None: + raise DwApiError(f"No request {parts[5]!r}", status_code=404) + return found + + +@pytest.fixture +def server(tmp_path, clock): + return ServerClient(tmp_path) + + +def put_in(server, name, request_id="turbine", by="agent", why="w"): + root = server.roots[name] + current = store.get_request(root, request_id) + return store.put_request( + root, + request_id, + { + "title": "Wind turbine", + "goal": "three boards", + "items": current["items"] if current else items("b1", "b2"), + "revision": current["revision"] if current else 0, + "why": why, + }, + by=by, + ) + + +def note_in(server, name, text, item=None, request_id="turbine"): + put_in(server, name, request_id, by="user", why="note") + save_note(server.roots[name], request_id, text, item) + + +def watching_all(server): + watch = ledger.NoteWatch(everywhere=True) + assert watch.poll(server) == [] + server.calls.clear() + return watch + + +def test_a_note_in_any_workspace_reaches_a_whole_server_channel(server, clock): + put_in(server, "notes") + watch = watching_all(server) + clock.tick() + note_in(server, "notes", "lower the camera", item="b2") + [event] = watch.poll(server) + assert event["meta"]["workspace"] == "notes" + assert event["meta"]["request"] == "turbine" + assert 'get_request("turbine", workspace="notes")' in event["content"] + assert "lower the camera" in event["content"] + + +def test_an_idle_whole_server_channel_costs_one_marked_read_per_poll(server): + put_in(server, "notes") + watch = watching_all(server) + assert watch.poll(server) == [] + assert server.calls == [("/api/requests", ledger.CHANNEL_HEADER)] + + +def test_the_same_request_id_in_two_workspaces_is_kept_apart(server, clock): + put_in(server, "default") + put_in(server, "notes") + watch = watching_all(server) + clock.tick() + note_in(server, "notes", "from notes") + [event] = watch.poll(server) + assert event["meta"]["workspace"] == "notes" + clock.tick() + note_in(server, "default", "from default") + [event] = watch.poll(server) + assert event["meta"]["workspace"] == "default" + assert watch.poll(server) == [] + + +def test_startup_digests_each_workspaces_waiting_notes_apart(server, clock): + put_in(server, "default") + put_in(server, "notes") + clock.tick() + note_in(server, "default", "one") + note_in(server, "notes", "two") + events = ledger.NoteWatch(everywhere=True).poll(server) + assert [e["meta"]["kind"] for e in events] == ["notes_waiting"] * 2 + assert {e["meta"]["workspace"] for e in events} == {"default", "notes"} + + +def test_a_request_made_after_startup_in_another_workspace_is_watched(server, clock): + watch = watching_all(server) + put_in(server, "notes", "fresh") + assert watch.poll(server) == [] + clock.tick() + note_in(server, "notes", "warmer", request_id="fresh") + [event] = watch.poll(server) + assert event["meta"]["request"] == "fresh" + + +def test_a_server_without_the_whole_server_list_falls_back_to_one_workspace( + server, clock +): + server.old = True + put_in(server, "default") + watch = watching_all(server) + clock.tick() + note_in(server, "default", "still heard") + [event] = watch.poll(server) + assert event["meta"]["workspace"] == "default" + assert watch.fault is None + # the fallback sticks: the missing route is not asked for every poll + server.calls.clear() + watch.poll(server) + assert ("/api/requests", ledger.CHANNEL_HEADER) not in server.calls + + +def test_one_unreadable_workspace_is_a_fault_and_the_others_still_announce( + server, clock +): + put_in(server, "default") + watch = watching_all(server) + server.broken.add("notes") + clock.tick() + note_in(server, "default", "heard anyway") + [event] = watch.poll(server) + assert event["meta"]["workspace"] == "default" + assert "notes" in watch.fault + + +def test_a_pinned_channel_reads_only_its_workspace(client): + watch = ledger.NoteWatch(WORKSPACE) + watch.poll(client) + assert all(p.startswith(f"/api/workspaces/{WORKSPACE}/") for p in client.calls) + + +def test_a_workspace_that_reads_again_after_a_break_does_not_repeat_its_notes( + server, clock +): + put_in(server, "notes") + watch = watching_all(server) + clock.tick() + note_in(server, "notes", "lower the camera") + assert len(watch.poll(server)) == 1 + server.broken.add("notes") + assert watch.poll(server) == [] + server.broken.discard("notes") + assert watch.poll(server) == [] + assert watch.fault is None + + +def test_an_old_server_is_asked_for_the_whole_server_list_again_later(server, clock): + server.old = True + put_in(server, "notes") + watch = watching_all(server) + assert "GET /api/requests" in watch.notice + for _ in range(ledger.ROUTE_RETRY_POLLS - 1): + watch.poll(server) + assert ("/api/requests", ledger.CHANNEL_HEADER) not in server.calls + # the server was updated while the channel ran + server.old = False + clock.tick() + note_in(server, "notes", "heard after the upgrade") + [event] = watch.poll(server) + assert event["meta"]["workspace"] == "notes" + assert watch.notice is None diff --git a/tests/test_mcp_notes_stdio.py b/tests/test_mcp_notes_stdio.py index 41e3ff358..37851879c 100644 --- a/tests/test_mcp_notes_stdio.py +++ b/tests/test_mcp_notes_stdio.py @@ -424,11 +424,14 @@ def announce(polls): class Watch: fault = None + notice = None + def poll(self, client): step = next(script) if isinstance(step, Exception): raise step self.fault = step.get("fault") + self.notice = step.get("notice") return step["events"] class Connection: @@ -481,7 +484,9 @@ def test_a_failing_server_is_logged_once_backed_off_and_recovered_from(): {"events": []}, ] ) - assert delays[1:] == [10.0, 20.0, 40.0, 80.0, 160.0, 300.0, 10.0, 20.0, 10.0] + # a fault in part of the ledger (one request, one workspace) is said but + # not backed off: the rest is still read every interval (#1529) + assert delays[1:] == [10.0, 20.0, 40.0, 80.0, 160.0, 300.0, 10.0, 10.0, 10.0] assert said == [ f"could not read the ledger, will keep trying: {down}", "could not read the ledger, will keep trying: bad token", @@ -493,3 +498,16 @@ def test_a_failing_server_is_logged_once_backed_off_and_recovered_from(): "reading the ledger again", ] assert sent == [("notifications/claude/channel", event)] + + +def test_a_notice_is_said_once_when_it_changes_and_is_not_a_fault(): + note = "the server has no GET /api/requests: watching default only" + sent, delays, said = announce( + [ + {"events": [], "notice": note}, + {"events": [], "notice": note}, + {"events": []}, + ] + ) + assert said == [note] + assert delays[1:] == [10.0, 10.0, 10.0] diff --git a/tests/test_notes_listening.py b/tests/test_notes_listening.py index 4e1cb620d..bfd78a620 100644 --- a/tests/test_notes_listening.py +++ b/tests/test_notes_listening.py @@ -90,3 +90,104 @@ def test_an_unknown_workspace_is_refused_and_not_recorded(client): assert r.status_code == 404 assert client.get("/api/workspaces/nope/notes-channel").status_code == 404 assert client.app.state.listening.state("nope")["last_seen"] is None + + +# --- a channel that watches the whole server (GET /api/requests, #1529) --- + + +def put(client, workspace, request_id, state="open"): + body = { + "title": request_id, + "goal": "g", + "items": [{"key": "a", "title": "A", "depends_on": []}], + "revision": 0, + "why": "w", + "by": "agent", + } + r = client.put(f"/api/workspaces/{workspace}/requests/{request_id}", json=body) + assert r.status_code == 200, r.text + if state != "open": + r = client.put( + f"/api/workspaces/{workspace}/requests/{request_id}", + json={**body, "revision": 1, "state": state}, + ) + assert r.status_code == 200, r.text + + +def add_workspace(client, name): + r = client.post("/api/workspaces", json={"name": name}) + assert r.status_code == 201, r.text + + +def test_the_server_wide_list_has_every_workspaces_open_requests(client): + add_workspace(client, "notes") + put(client, "default", "first") + put(client, "notes", "turbine") + put(client, "notes", "shipped", state="done") + r = client.get("/api/requests") + assert r.status_code == 200, r.text + got = {(row["workspace"], row["id"]) for row in r.json()["requests"]} + assert got == {("default", "first"), ("notes", "turbine")} + row = next(row for row in r.json()["requests"] if row["id"] == "turbine") + assert row["state"] == "open" and row["items"] == 1 and "ready" in row + assert "unreadable" not in r.json() + + +def test_a_marked_server_wide_read_means_listening_in_every_workspace(client, clock): + add_workspace(client, "notes") + assert client.get("/api/requests", headers=MARK).status_code == 200 + assert state(client)["listening"] is True + assert state(client, "notes")["listening"] is True + # a workspace made after the poll is covered too: the channel reads it + # on its next poll + add_workspace(client, "later") + assert state(client, "later")["listening"] is True + clock.now += LISTENING_WINDOW + 1 + assert state(client, "notes")["listening"] is False + + +def test_an_unmarked_server_wide_read_records_nothing(client): + client.get("/api/requests") + assert state(client) == {"listening": False, "last_seen": None} + + +def test_one_workspaces_broken_ledger_is_named_and_the_others_still_list( + client, tmp_path +): + add_workspace(client, "notes") + put(client, "default", "first") + (tmp_path / "studio" / "notes" / "requests.json").write_text("not json") + r = client.get("/api/requests") + assert r.status_code == 200, r.text + assert [row["id"] for row in r.json()["requests"]] == ["first"] + assert set(r.json()["unreadable"]) == {"notes"} + + +def test_a_workspace_poll_still_marks_only_its_own_after_a_server_wide_one(clock): + listening = Listening(clock=clock) + listening.seen_all() + clock.now += LISTENING_WINDOW + 1 + listening.seen("a") + assert listening.state("a")["listening"] is True + assert listening.state("b")["listening"] is False + + +def test_a_workspace_that_cannot_be_resolved_is_named_not_skipped(client, monkeypatch): + from fastapi import HTTPException + + from dw.server.routes import requests as routes + + add_workspace(client, "notes") + put(client, "default", "first") + real = routes._ledger_root + + def gone(state, name): + if name == "notes": + raise HTTPException(status_code=404, detail="no workspace 'notes'") + return real(state, name) + + monkeypatch.setattr(routes, "_ledger_root", gone) + r = client.get("/api/requests") + assert r.status_code == 200, r.text + assert [row["id"] for row in r.json()["requests"]] == ["first"] + assert set(r.json()["unreadable"]) == {"notes"} diff --git a/tests/test_plugin_skills.py b/tests/test_plugin_skills.py index 7f0e00be2..3f2639835 100644 --- a/tests/test_plugin_skills.py +++ b/tests/test_plugin_skills.py @@ -2482,6 +2482,42 @@ def test_the_reference_holds_the_procedure(self): "`notes`", "creative source", "`dropped`", + "watches every workspace on the server", + "belongs to another session", + "hold the revised items again with a fresh", + "the whole set shares", + ): + assert claim in text, claim + + def test_the_reference_holds_the_review_hold_rules(self): + """The review hold (#1521): the user's yes comes first, the hold needs + the notes channel, the server runs nothing at the deadline.""" + text = _flat(_read(SCRIPT_REQUEST)) + assert "## Hold items for the user's review" in text + assert text.index("## Run each item") < text.index( + "## Hold items for the user's review" + ) + assert text.index("## Hold items for the user's review") < text.index( + "## Accept the keeper" + ) + for claim in ( + "get a yes to", + "Silence on the page confirms that yes; it never replaces it", + "only when the dw-notes channel is connected", + "`review_until`", + "an ISO time with an offset", + "15 minutes ahead", + "under 60 seconds or over 24 hours", + "end the turn", + "`wait_for_job`", + "`review_due`", + "still `ready` with no newer note", + "acknowledged_cost=...", + "more than a quarter", + "no run and no new hold: clear the hold", + "left out of an item, or null, clears its hold", + "The server never starts a job for you", + "marked stale", ): assert claim in text, claim diff --git a/tests/test_reference_limits.py b/tests/test_reference_limits.py index 30911a685..d96ac578f 100644 --- a/tests/test_reference_limits.py +++ b/tests/test_reference_limits.py @@ -65,6 +65,53 @@ def test_an_unknown_family_is_not_checked(self): assert messages([{"reference_type": "json.JSONDecoder"}]) == [] +class TestUnnamedReferenceClass: + """An entry naming no loadable reference class is refused (#1512).""" + + def found(self, entry): + return reference_limit_errors(workflow_with([entry])) + + def test_the_type_key_is_refused_at_its_index(self): + entry = {"type": "MiniMaxH3VideoReference", "from_previous_result": "w"} + found = self.found(entry) + assert len(found) == 1 + assert found[0]["path"].endswith("references[0]") + assert "reference_type" in found[0]["message"] + assert "dotted path" in found[0]["message"] + + def test_a_bare_class_name_is_refused(self): + entry = {"reference_type": "MiniMaxH3VideoReference", "from_file": "asset:x"} + found = self.found(entry) + assert len(found) == 1 + assert found[0]["path"].endswith("references[0]") + assert "MiniMaxH3VideoReference" in found[0]["message"] + + def test_a_dotted_entry_passes(self): + assert self.found(reference(VIDEO)) == [] + + def test_a_variable_reference_type_is_left_to_its_value(self): + entry = {"reference_type": "variable:kind", "from_file": "asset:x.mp4"} + assert self.found(entry) == [] + + def test_a_string_entry_is_not_reported_twice(self): + found = self.found("asset:x.mp4") + assert not any("dotted path" in f["message"] for f in found) + + def test_another_families_references_are_left_alone(self): + # H3 is known by its from_pretrained `workflow`; without one the + # step is another family's, and its references are its own + workflow = workflow_with([{"type": "Whatever"}]) + del workflow["steps"][0]["pipeline"]["from_pretrained_arguments"]["workflow"] + assert reference_limit_errors(workflow) == [] + + def test_workflow_validation_reports_it(self): + entry = {"type": "MiniMaxH3VideoReference", "from_file": "x.mp4"} + errors = Workflow( + workflow_with([entry]), "outputs", "x.json" + ).validation_errors() + assert any("reference_type" in str(e) for e in errors) + + class TestH3ReferenceSets: def test_audio_cannot_be_the_only_reference(self): found = messages([reference(AUDIO)]) diff --git a/tests/test_trust_precheck.py b/tests/test_trust_precheck.py new file mode 100644 index 000000000..319626040 --- /dev/null +++ b/tests/test_trust_precheck.py @@ -0,0 +1,211 @@ +"""The worker's trust pre-check (workflow_run.require_trusted_pipelines), the +gate it runs before it releases the previous workflow's models (#1333). + +It reads the definition's keys only, so it loads no media and, trusted, +does no work at all (#1510); and it refuses everything the loader's own +pre-flight refuses - pre_load_modules included - as validate and submit do, +so a refused job neither queues nor evicts the warm models (#1511). +""" + +import queue +from unittest.mock import patch + +import pytest + +from dw import arguments, workflow_run +from dw.security import UntrustedWorkflowError +from dw.workflow import Workflow + + +def _media_workflow(tmp_path, **pipeline_extra): + (tmp_path / "clip.mp4").write_bytes(b"placeholder") + (tmp_path / "still.png").write_bytes(b"placeholder") + definition = { + "id": "media", + "steps": [ + { + "name": "gen", + "pipeline": { + "configuration": {"component_type": "StableDiffusionPipeline"}, + "from_pretrained_arguments": {"model_name": "a/b"}, + "arguments": { + "prompt": "x", + "image": "still.png", + "source_video": "clip.mp4", + }, + **pipeline_extra, + }, + } + ], + } + return Workflow(definition, str(tmp_path), str(tmp_path / "w.json"), None) + + +@pytest.fixture +def media_calls(monkeypatch): + calls = [] + + def fetch_image(value, base_dir, key): + calls.append(("image", value)) + return value + + def fetch_video(value, base_dir, key, with_audio=False): + calls.append(("video", value)) + return value + + monkeypatch.setattr(arguments, "fetch_image_with_context", fetch_image) + monkeypatch.setattr(arguments, "fetch_video_with_context", fetch_video) + return calls + + +class TestThePreCheckLoadsNoMedia: + """#1510""" + + def test_untrusted_reads_keys_only(self, tmp_path, monkeypatch, media_calls): + monkeypatch.setenv("DW_TRUST_WORKFLOWS", "0") + workflow_run.require_trusted_pipelines(_media_workflow(tmp_path), {}) + assert media_calls == [] + + def test_untrusted_still_refuses_remote_code( + self, tmp_path, monkeypatch, media_calls + ): + monkeypatch.setenv("DW_TRUST_WORKFLOWS", "0") + workflow = _media_workflow(tmp_path) + pipeline = workflow.workflow_definition["steps"][0]["pipeline"] + pipeline["from_pretrained_arguments"]["trust_remote_code"] = True + with pytest.raises(UntrustedWorkflowError, match="trust_remote_code"): + workflow_run.require_trusted_pipelines(workflow, {}) + assert media_calls == [] + + def test_trusted_does_no_work(self, tmp_path, monkeypatch, media_calls): + monkeypatch.setenv("DW_TRUST_WORKFLOWS", "1") + workflow = _media_workflow(tmp_path) + # The pre-check swallows a preparation failure, so count the calls + # rather than raising from them + with ( + patch.object(workflow_run, "prepare_definition") as prepared, + patch.object(Workflow, "expanded_definition") as expanded, + ): + workflow_run.require_trusted_pipelines(workflow, {}) + assert prepared.call_count == 0 and expanded.call_count == 0 + assert media_calls == [] + + +# --- #1511: pre_load_modules, and the refusals beside it ------------------- + + +def _refused_definition(kind): + pipeline = { + "configuration": {"component_type": "StableDiffusionPipeline"}, + "from_pretrained_arguments": {"model_name": "a/b"}, + "arguments": {"prompt": "x"}, + } + if kind == "pre_load_modules": + pipeline["configuration"]["pre_load_modules"] = ["json"] + elif kind == "dotted type": + pipeline["configuration"]["scheduler_type"] = "os.path.join" + elif kind == "constant": + pipeline["arguments"]["separator"] = "constant:os.sep" + elif kind == "variable constant": + pipeline["arguments"]["separator"] = "variable:sep" + return { + "id": "hostile", + "variables": {"sep": "constant:os.sep"}, + "steps": [{"name": "gen", "pipeline": pipeline}], + } + return {"id": "hostile", "steps": [{"name": "gen", "pipeline": pipeline}]} + + +KINDS = ["pre_load_modules", "dotted type", "constant", "variable constant"] + + +@pytest.mark.parametrize("kind", KINDS) +def test_the_pre_check_refuses(tmp_path, monkeypatch, kind): + monkeypatch.setenv("DW_TRUST_WORKFLOWS", "0") + workflow = Workflow( + _refused_definition(kind), str(tmp_path), str(tmp_path / "w.json"), None + ) + with pytest.raises(UntrustedWorkflowError): + workflow_run.require_trusted_pipelines(workflow, {}) + + +@pytest.mark.parametrize("kind", KINDS) +def test_trusted_lets_each_through(tmp_path, monkeypatch, kind): + monkeypatch.setenv("DW_TRUST_WORKFLOWS", "1") + workflow = Workflow( + _refused_definition(kind), str(tmp_path), str(tmp_path / "w.json"), None + ) + workflow_run.require_trusted_pipelines(workflow, {}) + + +def test_an_allowed_pre_load_module_passes(tmp_path, monkeypatch): + monkeypatch.setenv("DW_TRUST_WORKFLOWS", "0") + definition = _refused_definition("pre_load_modules") + definition["steps"][0]["pipeline"]["configuration"]["pre_load_modules"] = ["sdnq"] + workflow = Workflow(definition, str(tmp_path), str(tmp_path / "w.json"), None) + workflow_run.require_trusted_pipelines(workflow, {}) + + +@pytest.mark.parametrize("kind", KINDS) +def test_a_refused_job_keeps_the_warm_models(tmp_path, monkeypatch, kind): + """#1333's rule through the worker: no release, no run, just the refusal.""" + from dw import worker as worker_module + + monkeypatch.setenv("DW_TRUST_WORKFLOWS", "0") + with patch.object(worker_module, "setup_logging"): + worker = worker_module.WorkflowWorker(queue.Queue(), queue.Queue()) + worker.workflow_identity = ("path", "/w/warm.json") + worker.loaded_pipelines["warm"] = object() + definition = _refused_definition(kind) + command = { + "definition": definition, + "file_spec": "/w/hostile.json", + "source": "path", + "arguments": {}, + "output_dir": str(tmp_path), + } + with patch.object(worker_module, "workflow_from_snapshot") as admit: + admit.return_value = Workflow( + definition, str(tmp_path), "/w/hostile.json", None + ) + worker._handle_execute(command) + messages = [] + while not worker.result_queue.empty(): + messages.append(worker.result_queue.get_nowait()) + assert "warm" in worker.loaded_pipelines + assert worker.workflow_identity == ("path", "/w/warm.json") + assert not any("Workflow changed" in str(m) for m in messages) + assert not any("run_start" in str(m) for m in messages) + failed = [m for m in messages if m["type"] == "error"] + assert failed and "--trust-workflows" in str(failed[0]) + + +def _validate(client, workflow): + response = client.post("/api/validate?sizes=false", json={"workflow": workflow}) + assert response.status_code == 200, response.text + return response.json() + + +def test_validate_reports_a_refused_pre_load_module(gallery_client, monkeypatch): + monkeypatch.setenv("DW_TRUST_WORKFLOWS", "0") + body = _validate(gallery_client, _refused_definition("pre_load_modules")) + assert body["valid"] is False + errors = [e for e in body["errors"] if "pre_load_modules" in e["message"]] + assert errors and errors[0]["path"] == "steps[0].pipeline", body["errors"] + assert "--trust-workflows" in errors[0]["message"] + + +def test_trusted_validate_passes_a_pre_load_module(gallery_client, monkeypatch): + monkeypatch.setenv("DW_TRUST_WORKFLOWS", "1") + body = _validate(gallery_client, _refused_definition("pre_load_modules")) + assert not any("pre_load_modules" in e["message"] for e in body["errors"]) + + +def test_submit_refuses_a_pre_load_module_with_no_job(gallery_client, monkeypatch): + monkeypatch.setenv("DW_TRUST_WORKFLOWS", "0") + response = gallery_client.post( + "/api/jobs", json={"workflow": _refused_definition("pre_load_modules")} + ) + assert response.status_code == 400, response.text + assert "pre_load_modules" in response.text + assert gallery_client.get("/api/jobs").json()["jobs"] == [] diff --git a/ui/e2e/requests.spec.ts b/ui/e2e/requests.spec.ts index 8507d8ae1..a07237f66 100644 --- a/ui/e2e/requests.spec.ts +++ b/ui/e2e/requests.spec.ts @@ -152,26 +152,17 @@ test('a done item shows its takes as pictures, the latest marked as the result', await page.goto(REQUEST) const hero = item(page, 'Hero poster') await expect(hero.locator('.row .chip')).toHaveText('done') - // the row's proof is the result, and leads to the job that made it - const proof = hero.locator('.proofcell').getByRole('img', { - name: 'result of Hero poster', - }) - await loaded(proof) - await expect(hero.locator('.proofcell a')).toHaveAttribute( - 'href', - '#/ws/default/jobs/e2ereqdone02', - ) - // two good takes and none accepted: it says so, and opens to show them + // two good takes and none accepted: it says so, and opens to show them; + // open, the row's own picture steps aside for the takes await expect(hero.locator('.row')).toContainText('2 takes') await expect(hero.locator('.row')).toContainText('latest, none accepted') await expect(hero.locator('.title')).toHaveAttribute('aria-expanded', 'true') + await expect(hero.locator('.proofcell')).toHaveClass(/under/) const takes = hero.locator('.strip .tile') await expect(takes).toHaveCount(2) await expect(takes.nth(0)).toContainText('take 1') await expect(takes.nth(0).locator('.mark')).toHaveCount(0) - await expect(takes.nth(1).locator('.mark')).toHaveText( - 'shown as the result (latest)', - ) + await expect(takes.nth(1).locator('.mark')).toHaveText('result (latest)') await loaded(takes.nth(0).getByRole('img')) await expect(takes.nth(0).getByRole('link')).toHaveAttribute( 'href', @@ -184,6 +175,16 @@ test('a done item shows its takes as pictures, the latest marked as the result', await expect( hero.getByRole('button', { name: 'Accept take 1 for Hero poster' }), ).toHaveAttribute('aria-pressed', 'false') + // closed, the row's proof is the result, and leads to the job that made it + await hero.locator('.title').click() + const proof = hero.locator('.proofcell').getByRole('img', { + name: 'result of Hero poster', + }) + await loaded(proof) + await expect(hero.locator('.proofcell a')).toHaveAttribute( + 'href', + '#/ws/default/jobs/e2ereqdone02', + ) }) test('a note for the agent says whether a session listens, and is in the ledger after a reload', async ({ @@ -301,8 +302,9 @@ test("an item's jobs link narrows the Jobs page to that item", async ({ }) => { await page.goto(REQUEST) const hero = item(page, 'Hero poster') - await expand(hero, 'Hero poster') - await hero.getByRole('link', { name: 'its jobs' }).click() + // the item's menu holds its jobs and outputs, not the take strip + await hero.getByRole('button', { name: /^More actions for/ }).click() + await page.getByRole('dialog').getByRole('link', { name: 'Its jobs' }).click() await expect(page.getByTestId('req-filter')).toContainText(`${ID} › hero`) await expect(page.locator('.chip.succeeded')).toHaveCount(2) await expect(page.locator('.chip.failed')).toHaveCount(0) @@ -609,13 +611,56 @@ test('the run dialog prices what is ready, says what will not run, and spends no expect(submitted).toBe(0) }) +test('a held item says so, counts down, runs only when asked, and a note turns it back to the agent', async ({ + page, +}) => { + let submitted = 0 + page.on('request', (r) => { + if (r.method() === 'POST' && new URL(r.url()).pathname === '/api/jobs') + submitted++ + }) + await page.goto(BOARD) + // the fixture holds `title` for an hour, and no session listens here + const banner = page.locator('.reqhead .hold p') + await expect(banner).toHaveText( + /^1 item held for your review\. No session is listening, so nothing will run at .+\. Run it here, or leave a note\.$/, + ) + const title = boardRow(page, 'title') + const chip = title.locator('.chip.held') + await expect(chip).toHaveText(/^held · \d\d:\d\d$/) + const first = await chip.textContent() + await expect(chip).not.toHaveText(first ?? '', { timeout: 5000 }) + + await page.getByRole('button', { name: 'Run now…' }).click() + const dialog = page.getByRole('dialog', { name: 'Run what is ready' }) + await expect( + dialog.locator('.runrow[data-key="title"] .held span'), + ).toHaveText(/^Held for review until .+\. Running it now is your go-ahead\.$/) + await dialog.getByRole('button', { name: 'Cancel' }).click() + await expect(dialog).toHaveCount(0) + expect(submitted).toBe(0) + + await expand(title, 'Title card') + await title.getByRole('button', { name: 'Add a note for the agent' }).click() + await title + .getByRole('textbox', { name: 'Note for the agent on Title card' }) + .fill('make the title bolder') + await title.getByRole('button', { name: 'Save note' }).click() + await expect(banner).toHaveText( + 'You left a note after these were held: the agent will revise before running.', + ) + await expect(chip).toHaveText('held · note left') + await expect(page.getByRole('button', { name: 'Run now…' })).toHaveCount(0) + expect(submitted).toBe(0) +}) + test('running a ready item queues a job bound to its quote, and the job appears on the item', async ({ page, request, }) => { await page.goto(BOARD) const title = boardRow(page, 'title') - await expect(title.locator('.row .chip')).toHaveText('ready') + await expect(title.locator('.chipcell .chip')).toHaveText('ready') await page.getByRole('button', { name: 'Run 1 ready…' }).click() const dialog = page.getByRole('dialog', { name: 'Run what is ready' }) const submit = page.waitForResponse( @@ -645,13 +690,15 @@ test('running a ready item queues a job bound to its quote, and the job appears await expect(dialog).toHaveCount(0) // read again at once: the item carries the job, in whatever state it // has reached, and is no longer something to run - await expect(title.locator('.row .chip')).toHaveText(/queued|running|done/) + await expect(title.locator('.chipcell .chip')).toHaveText( + /queued|running|done/, + ) await expect(page.getByRole('button', { name: /ready…$/ })).toHaveCount(0) const stored = await ledger(request) const item = stored.items.find((i: Stored) => i.key === 'title') expect(item.attempts.map((a: { job: string }) => a.job)).toEqual([job.id]) // a text task with no model: it finishes, and the page follows it there - await expect(title.locator('.row .chip')).toHaveText('done', { + await expect(title.locator('.chipcell .chip')).toHaveText('done', { timeout: 25_000, }) await expect(title.locator('.proofcell a')).toHaveAttribute( diff --git a/ui/e2e/serve_fixture.py b/ui/e2e/serve_fixture.py index ad8f1a93c..33e9dca75 100644 --- a/ui/e2e/serve_fixture.py +++ b/ui/e2e/serve_fixture.py @@ -25,6 +25,7 @@ import sqlite3 import sys import tempfile +from datetime import datetime, timedelta, timezone root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) scratch = tempfile.mkdtemp(prefix="dw-e2e-") @@ -306,6 +307,10 @@ def jobs_linked(_request, key): **plan_item("title", "Title card", estimate_minutes=3), "workflow": "e2e-card", "arguments": {"line": "The opening"}, + # held for review for the next hour, for the hold's specs + "review_until": ( + datetime.now(timezone.utc) + timedelta(hours=1) + ).isoformat(timespec="seconds"), }, plan_item("score", "Score"), ], diff --git a/ui/package-lock.json b/ui/package-lock.json index 9db3db951..a56b89da1 100644 --- a/ui/package-lock.json +++ b/ui/package-lock.json @@ -8,33 +8,33 @@ "name": "ui", "version": "0.0.0", "dependencies": { - "@lucide/svelte": "^1.55.0", - "bits-ui": "^2.19.5", + "@lucide/svelte": "^1.77.0", + "bits-ui": "^2.22.0", "monaco-editor": "^0.57.0", - "svelte-sonner": "^1.2.1" + "svelte-sonner": "^1.2.3" }, "devDependencies": { "@eslint/js": "^10.0.1", - "@playwright/test": "^1.64.0", + "@playwright/test": "^1.65.1", "@sveltejs/vite-plugin-svelte": "^7.3.1", - "@testing-library/jest-dom": "^7.0.1", + "@testing-library/jest-dom": "^8.0.0", "@testing-library/svelte": "^5.4.2", - "@tsconfig/svelte": "^5.0.8", + "@tsconfig/svelte": "^5.0.9", "@types/node": "^24.13.3", - "eslint": "^10.12.0", + "eslint": "^10.15.0", "eslint-config-prettier": "^10.1.8", - "eslint-plugin-svelte": "^3.23.1", - "globals": "^17.13.0", - "jsdom": "^30.1.2", + "eslint-plugin-svelte": "^3.24.1", + "globals": "^17.14.0", + "jsdom": "^31.0.1", "openapi-typescript": "^7.13.0", - "prettier": "^3.9.10", - "prettier-plugin-svelte": "^4.1.1", - "svelte": "^5.57.2", - "svelte-check": "^4.7.6", + "prettier": "^3.10.1", + "prettier-plugin-svelte": "^4.2.0", + "svelte": "^5.59.1", + "svelte-check": "^4.7.8", "typescript": "~6.0.2", - "typescript-eslint": "^8.71.2", - "vite": "^8.3.4", - "vitest": "^5.0.4" + "typescript-eslint": "^8.73.0", + "vite": "^8.3.8", + "vitest": "^5.1.1" }, "engines": { "node": ">=24.20.0" @@ -47,39 +47,6 @@ "dev": true, "license": "MIT" }, - "node_modules/@asamuzakjp/css-color": { - "version": "7.1.4", - "resolved": "https://registry.npmjs.org/@asamuzakjp/css-color/-/css-color-7.1.4.tgz", - "integrity": "sha512-KdNhWlAh2sbYB8Of0Yw84/a+LO/vsBOHJcIg8BpyXo2RGrFWVJvEMRviMON+ysQu0KpV7wxrWrq9jaX0P21GzA==", - "dev": true, - "license": "MIT", - "dependencies": { - "@csstools/css-calc": "^3.4.3", - "@csstools/css-color-parser": "^4.2.6", - "@csstools/css-parser-algorithms": "^4.0.2", - "@csstools/css-tokenizer": "^4.0.2", - "lru-cache": "^11.5.3" - }, - "engines": { - "node": "^22.22.2 || ^24.15.0 || >=26.0.0" - } - }, - "node_modules/@asamuzakjp/dom-selector": { - "version": "9.2.4", - "resolved": "https://registry.npmjs.org/@asamuzakjp/dom-selector/-/dom-selector-9.2.4.tgz", - "integrity": "sha512-YnVzxDxLaqL0t7Q4wfcgHZjg55Wm6y5EaO7Bhu3q9J7wq/8iw3PhsnWiOQhYekx4VexnbkgWpTT6n+QIV7kczw==", - "dev": true, - "license": "MIT", - "dependencies": { - "bidi-js": "^1.1.0", - "css-tree": "^3.2.1", - "is-potential-custom-element-name": "^1.0.1", - "lru-cache": "^11.5.3" - }, - "engines": { - "node": "^22.22.2 || ^24.15.0 || >=26.0.0" - } - }, "node_modules/@babel/code-frame": { "version": "7.29.7", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.29.7.tgz", @@ -106,28 +73,15 @@ } }, "node_modules/@babel/runtime": { - "version": "7.29.10", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.29.10.tgz", - "integrity": "sha512-NpugTzbKgGrNe45Ui32cN8vCFFMxVtP/9rtfwv0nP5FRDAjvYBxJcLVpYA9mr1jxP6cnIT7x9LUzuDTbWYYNRA==", + "version": "7.29.15", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.29.15.tgz", + "integrity": "sha512-304gsbbGVmQc+cNGHzwHBlqepYdWLKj3VXCQBGt/EGcV7PUPfKI7kAUNW1FZEOCwlQiLvQjg1JEaAlRQ616h+Q==", "dev": true, "license": "MIT", "engines": { "node": ">=6.9.0" } }, - "node_modules/@bramus/specificity": { - "version": "2.4.3", - "resolved": "https://registry.npmjs.org/@bramus/specificity/-/specificity-2.4.3.tgz", - "integrity": "sha512-0GEz8qJWokkUVYQYRukmkSHIFNoBH8QTreeHrAFbvz1XFYc3Y+puhMs8PQ5x8GNugiC2l5jvDBXKLbBIByeSBw==", - "dev": true, - "license": "MIT", - "dependencies": { - "css-tree": "^3.2.1" - }, - "bin": { - "specificity": "bin/cli.js" - } - }, "node_modules/@cacheable/memory": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/@cacheable/memory/-/memory-2.2.0.tgz", @@ -152,144 +106,38 @@ "keyv": "^5.6.0" } }, - "node_modules/@csstools/color-helpers": { - "version": "6.1.2", - "resolved": "https://registry.npmjs.org/@csstools/color-helpers/-/color-helpers-6.1.2.tgz", - "integrity": "sha512-grhRy3OKmniaAEKXMjua5z/EODX0MSqBGjunw8+j/3HQjOnahs2AGhvEOIYVUWcU6ScApbhLhVrQTX8XqrMrow==", + "node_modules/@emnapi/core": { + "version": "2.0.0-beta.2", + "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-2.0.0-beta.2.tgz", + "integrity": "sha512-MzCVoWtcg4Pm2B3je5mMvYMvj3MmBKw+fU7vbsJc9/iT8ip6/eYIHo/Dsm/mr+wsHB6SEyJDuxB09Yy6r/8+4A==", "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/csstools" - }, - { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - } - ], - "license": "MIT-0", - "engines": { - "node": ">=20.19.0" - } - }, - "node_modules/@csstools/css-calc": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/@csstools/css-calc/-/css-calc-3.4.3.tgz", - "integrity": "sha512-iex20d8CHVkyvg6B7UKV7uHnI2Bqo9g+EFfT9E0y+GvTvhZ/DwONJ+9aKb1dlqm0ZiGsL5RXjp0fCoJYnkeDjA==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/csstools" - }, - { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - } - ], - "license": "MIT", - "engines": { - "node": ">=20.19.0" - }, - "peerDependencies": { - "@csstools/css-parser-algorithms": "^4.0.2", - "@csstools/css-tokenizer": "^4.0.2" - } - }, - "node_modules/@csstools/css-color-parser": { - "version": "4.2.6", - "resolved": "https://registry.npmjs.org/@csstools/css-color-parser/-/css-color-parser-4.2.6.tgz", - "integrity": "sha512-iiPQ3iRWwnJkeEn6RIu6SJPr7hYrLz6XZ9s/QZl+2/LI5KQVjpl2fdmDSZKuD4xP6GMmMPgHFFXg6k1Wkz0Trg==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/csstools" - }, - { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - } - ], "license": "MIT", + "optional": true, "dependencies": { - "@csstools/color-helpers": "^6.1.2", - "@csstools/css-calc": "^3.4.3" - }, - "engines": { - "node": ">=20.19.0" - }, - "peerDependencies": { - "@csstools/css-parser-algorithms": "^4.0.2", - "@csstools/css-tokenizer": "^4.0.2" + "@emnapi/wasi-threads": "2.2.0", + "tslib": "^2.4.0" } }, - "node_modules/@csstools/css-parser-algorithms": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/@csstools/css-parser-algorithms/-/css-parser-algorithms-4.0.2.tgz", - "integrity": "sha512-40cSKyMvK+tq4qz6Awrlye2WGuOKt3FwPgtGg6KTfbHOWNw+Rk1rzbAtZnZ6IBhsY491HLRnDXwoyBAijmmILA==", + "node_modules/@emnapi/runtime": { + "version": "2.0.0-beta.2", + "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-2.0.0-beta.2.tgz", + "integrity": "sha512-JcrSPzPvZuNZvJqPTF9Fw25LbOJ8avzFVlaf2grmH4Cku0oGP47tRgqPZadcfj3YoZMHkFVnCYFbQM8I+i5QEw==", "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/csstools" - }, - { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - } - ], "license": "MIT", - "engines": { - "node": ">=20.19.0" - }, - "peerDependencies": { - "@csstools/css-tokenizer": "^4.0.2" - } - }, - "node_modules/@csstools/css-syntax-patches-for-csstree": { - "version": "1.1.15", - "resolved": "https://registry.npmjs.org/@csstools/css-syntax-patches-for-csstree/-/css-syntax-patches-for-csstree-1.1.15.tgz", - "integrity": "sha512-J0u7HkVl2nzSlhsiTOp4AmwcUQ3D+mGEEKfBy/7To5/y7F2OHwyLrXfrhR0SMgr4p5Lo+eaMVSeai24zUcBIxA==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/csstools" - }, - { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - } - ], - "license": "MIT-0", - "peerDependencies": { - "css-tree": "^3.2.1" - }, - "peerDependenciesMeta": { - "css-tree": { - "optional": true - } + "optional": true, + "dependencies": { + "tslib": "^2.4.0" } }, - "node_modules/@csstools/css-tokenizer": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/@csstools/css-tokenizer/-/css-tokenizer-4.0.2.tgz", - "integrity": "sha512-OoKoR0f76dCY666JlcbhmVTs2drYj1GUXZTYTcbUgJjh9Nv41aFfZ21bPQTERm5+L5cBDo466NltB2lplS5GBw==", + "node_modules/@emnapi/wasi-threads": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-2.2.0.tgz", + "integrity": "sha512-JP7OYH38Q7+pyTAe14raZHLQIK7BDKbdwji+Xi3pcd/6QkJYQH3SX4wu6EplGrGJWRepoNzedfm0G3B9Z4e9Rw==", "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/csstools" - }, - { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - } - ], "license": "MIT", - "engines": { - "node": ">=20.19.0" + "optional": true, + "dependencies": { + "tslib": "^2.4.0" } }, "node_modules/@eslint-community/eslint-utils": { @@ -325,9 +173,9 @@ } }, "node_modules/@eslint-community/regexpp": { - "version": "4.12.2", - "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.12.2.tgz", - "integrity": "sha512-EriSTlt5OC9/7SXkRSCAhfSxxoSUgBm33OH+IkwbdpgoqsSsUg7y3uh+IICI/Qg4BBWr3U2i39RpmycbxMq4ew==", + "version": "4.12.3", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.12.3.tgz", + "integrity": "sha512-R76UKbvsqI68DJJVTVyqFKqU98CN4+B+acxNfEA2IFarSzP0SjtKf/3+fFiXzTyv5Fj3PxLkGHe2wnVWWMxobQ==", "dev": true, "license": "MIT", "engines": { @@ -335,15 +183,15 @@ } }, "node_modules/@eslint/config-array": { - "version": "0.23.5", - "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.23.5.tgz", - "integrity": "sha512-Y3kKLvC1dvTOT+oGlqNQ1XLqK6D1HU2YXPc52NmAlJZbMMWDzGYXMiPRJ8TYD39muD/OTjlZmNJ4ib7dvSrMBA==", + "version": "0.23.6", + "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.23.6.tgz", + "integrity": "sha512-WrTH7nioI9QPY4NZGnsywmecswJdgeq4BCM76qok9VgjTO29ZgUzUvcuJLVPYVQM4uDbaPBU0M33R9DIxI8X3w==", "dev": true, "license": "Apache-2.0", "dependencies": { "@eslint/object-schema": "^3.0.5", "debug": "^4.3.1", - "minimatch": "^10.2.4" + "minimatch": "^11.0.5" }, "engines": { "node": "^20.19.0 || ^22.13.0 || >=24" @@ -540,9 +388,9 @@ } }, "node_modules/@isaacs/nonrecursive-glob-match": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@isaacs/nonrecursive-glob-match/-/nonrecursive-glob-match-1.0.3.tgz", - "integrity": "sha512-SI7kyKHq4XXDRozw+r9GlRZkia1ZkFrpLW98r2IC2Bpr8YkFGE3fvjzmxCG0x78A++69HmDNrDvSMYBZmHGpKA==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@isaacs/nonrecursive-glob-match/-/nonrecursive-glob-match-1.1.0.tgz", + "integrity": "sha512-GPm/Dbvk5RLmhRnxXIa7nTpK0xtl4E0wj0MslsuNiJ1FIROU+2+9lgUC/dgF7Ey4QCWhfEsgxilMRMCdHPfDfw==", "dev": true, "license": "BlueOak-1.0.0" }, @@ -567,9 +415,9 @@ } }, "node_modules/@jridgewell/resolve-uri": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", - "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.3.tgz", + "integrity": "sha512-lhTtjtoEArWBjismtfS761S9Hlyn+nIZqOZVYoZ1Xn82PMNMVnk+jj/NhC4fAXGTs7ydONcJiR5vyQBTMDu27g==", "license": "MIT", "engines": { "node": ">=6.0.0" @@ -616,18 +464,40 @@ "license": "MIT" }, "node_modules/@lucide/svelte": { - "version": "1.55.0", - "resolved": "https://registry.npmjs.org/@lucide/svelte/-/svelte-1.55.0.tgz", - "integrity": "sha512-CTxJ3qbkDK2oCW1VJYKhqAUfOongRJqc9YWmJZn8E06QpCU7i5yAnUny4h/zMNy/iYpMtGiJDRSb6AVIornuXg==", + "version": "1.77.0", + "resolved": "https://registry.npmjs.org/@lucide/svelte/-/svelte-1.77.0.tgz", + "integrity": "sha512-gXjmQ4VK3Mh/M11Nn/XCeln3XZByR4MxX5o+NMfr/Wg9MQs+BffvXTnW+0WvmjV1u58TXJhXvgJZHrMASUnqow==", "license": "ISC", "peerDependencies": { "svelte": "^5" } }, + "node_modules/@napi-rs/wasm-runtime": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.2.6.tgz", + "integrity": "sha512-mRyDmEw9/fCDXCGfL1sbgIw/GUK0PVxRW4YwgPN61F3LQ+fSyoBFarJVzgGyhF6kRzEQZ0FejDqm4WLXSeqQmw==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@tybys/wasm-util": "^0.10.3" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=23.5.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/Brooooooklyn" + }, + "peerDependencies": { + "@emnapi/core": "^1.7.1 || 2.0.0-beta.2", + "@emnapi/runtime": "^1.7.1 || 2.0.0-beta.2" + } + }, "node_modules/@oxc-project/types": { - "version": "0.153.0", - "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.153.0.tgz", - "integrity": "sha512-jSNrRIyvPVLL5E1z/tS5zLAprosGz/FuI1PWwEOz59j3E4TTTzSpqKb/RDGqJhhW0QHYISGXxq582wGx6T11Tw==", + "version": "0.156.0", + "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.156.0.tgz", + "integrity": "sha512-1Duyg48TdJNdyhEB8Xn1L36bT9Pv6GUtlKjHxOys8xkaF/rQq3XJE+bAurSK/AgIz5mGFsb77cn9Pb20+WCScw==", "dev": true, "license": "MIT", "funding": { @@ -635,13 +505,13 @@ } }, "node_modules/@playwright/test": { - "version": "1.64.0", - "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.64.0.tgz", - "integrity": "sha512-oTN9FNYuN6bqQMwiho6jJKLCG2/QOYCixGXuCjRmzOq23eODeukuY2XiAVoVpAECbuezMt1MHQjAiQxK8F+Y+g==", + "version": "1.65.1", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.65.1.tgz", + "integrity": "sha512-y+NCIRm2LvY4slUVWvGh1nujJ8RF/hEisIsq2mtUPgdQC4L701bq5hZGMhrpeXjACvwvO9tj5dJqhvM6TP9lbw==", "dev": true, "license": "Apache-2.0", "dependencies": { - "playwright": "1.64.0" + "playwright": "1.65.1" }, "bin": { "playwright": "cli.js" @@ -682,9 +552,9 @@ "license": "MIT" }, "node_modules/@redocly/openapi-core": { - "version": "1.34.20", - "resolved": "https://registry.npmjs.org/@redocly/openapi-core/-/openapi-core-1.34.20.tgz", - "integrity": "sha512-ypeBZ/6BKXR9+7/TtbKhbl4UgD7raHhPS12oknlKno2A8+lnFkxIwiE/Aklu6L2cd/ioH+fCWuMxi9/p3EyAPw==", + "version": "1.34.24", + "resolved": "https://registry.npmjs.org/@redocly/openapi-core/-/openapi-core-1.34.24.tgz", + "integrity": "sha512-jDFMu4zirFVOF9nEWCT31s7OzzVhkxZkb4lO3yZhkdPXAOspLo10ED9thVgm6gtI0dJBTLa+mNP0IYeZpVSYGA==", "dev": true, "license": "MIT", "dependencies": { @@ -711,9 +581,9 @@ "license": "MIT" }, "node_modules/@redocly/openapi-core/node_modules/brace-expansion": { - "version": "2.1.7", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.7.tgz", - "integrity": "sha512-uZbew1NqdmPDTMJ8ah1y+b+9QEJrfkXFk3RcTQw3X0jW/xRUvFKsg1CfQdSYGdTbXZWExtU3J3ccxtnfw1Fi0g==", + "version": "2.1.8", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.8.tgz", + "integrity": "sha512-BnlDzDYQoplTsZSvPi86CNzmbcb07X8ufR8fk1zivaiEJlXJkiq1MQyDCVmlWcsWbj6aWXqHnrwwevbrm/Saig==", "dev": true, "license": "MIT", "dependencies": { @@ -734,9 +604,9 @@ } }, "node_modules/@rolldown/binding-android-arm-eabi": { - "version": "1.2.13", - "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm-eabi/-/binding-android-arm-eabi-1.2.13.tgz", - "integrity": "sha512-Vu/NICrgdRvUOeaJZIyB2FP63s6fO/4ud5l8dXmxDx9yDyn+mN0y+gsvsVviSli+T361Aqo0h46EuMoobrwawA==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm-eabi/-/binding-android-arm-eabi-1.2.19.tgz", + "integrity": "sha512-e+Ebe0WT+9tbXmNKPIiC8YrWAHYwug3m6i4p3rZGGulfZri1jtI4HslT+OZnFf/OIHowWF71DTlHwXBP2SiA7A==", "cpu": [ "arm" ], @@ -751,9 +621,9 @@ } }, "node_modules/@rolldown/binding-android-arm64": { - "version": "1.2.13", - "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.2.13.tgz", - "integrity": "sha512-6LEoIrGy5vvCd2boNnv2soPSUZj/PRvhp8R/t9KlX+mIZxThIE/ZqxrGXxmuNX0FuvQFvLdZr7S4HrYpYBVhEQ==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.2.19.tgz", + "integrity": "sha512-hOombrTJ+szt2ciEzS7oCA78lMPBgF5UMQWCJIyNfnrI7GLl8HYoFqCnpL2gcPOaXMqryGCU5ExdQKyDDcC+yA==", "cpu": [ "arm64" ], @@ -768,9 +638,9 @@ } }, "node_modules/@rolldown/binding-darwin-arm64": { - "version": "1.2.13", - "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.2.13.tgz", - "integrity": "sha512-CaJSRzlQ6Q+zkDMVA9OkVxBjVoPRCDEE3v0FSJ9kIQBgRjFApA3Si4ijhbNVUji7ZJt+PfO0e46qy4nPInHUPA==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.2.19.tgz", + "integrity": "sha512-XoMA2pwCKGTQzUjPgtRwkedH4WmXhdIPKT6l6oOxd1PUbNodGI6DcBekgN7EC//+x3pfBYX/qL1gNmZAqivw5g==", "cpu": [ "arm64" ], @@ -785,9 +655,9 @@ } }, "node_modules/@rolldown/binding-darwin-x64": { - "version": "1.2.13", - "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.2.13.tgz", - "integrity": "sha512-e4r340I5hxSzJkD3YJBxgzq/rJ3wwxwdLLb2FPt1Zpyem20nrQPT11DDEEkazwxaHumH8wpglsp/Ozgj/wT6mw==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.2.19.tgz", + "integrity": "sha512-zo8EsSSwMZCY/e+fRnGaX02YGgvJD0yvhNi/9hpGPA2MJ9ZF8dPCw75UGfpI6OpQ/myR/dIYmogRvqiZD0TrXg==", "cpu": [ "x64" ], @@ -802,9 +672,9 @@ } }, "node_modules/@rolldown/binding-freebsd-x64": { - "version": "1.2.13", - "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.2.13.tgz", - "integrity": "sha512-hoBWDZ4/K/mJKVMbsgUd1jfpA2DiOrJ54mpegObU9TBHBBrtX4FLIXJJQRDPZ/2Dn91GvPob+Z2hwKJzf4E5SQ==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.2.19.tgz", + "integrity": "sha512-O8ISAOfI1nj7AuBPd30FSF47z7f7lzlk5poQVGgiikvQuGEBFYvW8ki+UEnT+YJPnNGjQzn304klt4O9FUE7mA==", "cpu": [ "x64" ], @@ -819,9 +689,9 @@ } }, "node_modules/@rolldown/binding-linux-arm-gnueabihf": { - "version": "1.2.13", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.2.13.tgz", - "integrity": "sha512-oF9fZu3vTWnTiVAkDFxU9PJLt1nh20K9RRpuHsR7ZnE2L7XookBbDBVLojCVSLGbvtSlxeUNnjAj6DbNsKyzbg==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.2.19.tgz", + "integrity": "sha512-/lYCba5NO0yq4S0jGMH8QTBtkvQxoXjoQWzF5BcWp9MjB9jxVRD1GQDNofkVjcOj30DWyhLIN/4Oe60JKzaONw==", "cpu": [ "arm" ], @@ -836,9 +706,9 @@ } }, "node_modules/@rolldown/binding-linux-arm64-gnu": { - "version": "1.2.13", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.2.13.tgz", - "integrity": "sha512-DTpb/+jMiqWMPgphn4ksW1zW+XLJ6dJJ9FMvnIk9I291LhCctMPhMYJrP5t9p6C9qa3KXadDdUEZHBaPh3kNxQ==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.2.19.tgz", + "integrity": "sha512-pm/apFMBnSbFb3O6nG5pHO1iqHhZrjGDFEjSm+ot9J17XXPvH9L90y5h+jgfHCE+Qdlsvy8qKEcU4VKxgjD+vA==", "cpu": [ "arm64" ], @@ -856,9 +726,9 @@ } }, "node_modules/@rolldown/binding-linux-arm64-musl": { - "version": "1.2.13", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.2.13.tgz", - "integrity": "sha512-xU+Kvv9N2A3SY35zFh1FWWNjxbadE/BKeqnkXe7vScU4GZsw757BlVmDLITZEq8DPpk6m7uoDYkK7P+x/uU5Ow==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.2.19.tgz", + "integrity": "sha512-K1SmQp3FFichn8oqrNIwvFoZ5wcvjC7goBzpaMNvLf9FZc+QB/QvLmnpJZgAAGHiD980tP8FZZnXk2K94rvlxg==", "cpu": [ "arm64" ], @@ -876,9 +746,9 @@ } }, "node_modules/@rolldown/binding-linux-ppc64-gnu": { - "version": "1.2.13", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.2.13.tgz", - "integrity": "sha512-XMk/hnhh25oQ756Lclb1Q11h4ll0xC0Esa5w4Vzp+mAE2S3AGJgeM0SonrIgY8fHhjarb6hcoTuwoFG0VVP2ig==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.2.19.tgz", + "integrity": "sha512-I0xwD57jP/3A7+5UPZin2w8Y7XHEmEM5zqpYZOcQ45MlNW6tUJUziymV3yRr7rL4vwyfEcRsRksC4a7Kc08p5Q==", "cpu": [ "ppc64" ], @@ -896,9 +766,9 @@ } }, "node_modules/@rolldown/binding-linux-s390x-gnu": { - "version": "1.2.13", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.2.13.tgz", - "integrity": "sha512-U1BoTHYmlywE2n3HUWjzZ+8EQsKr+OwpxYuDWaubx42tUL8QSL7nOqRz/NVHanibbFP3M1Rxuprz/wNcbMKjqw==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.2.19.tgz", + "integrity": "sha512-BrtEHT24SNXj9HiXqy+s/kXiSiQGt6EKCPUlRirAoIioVxKGnbXBUEkbZASAei7iZJB0/Ynm+0JP00Ipx7AnSw==", "cpu": [ "s390x" ], @@ -916,9 +786,9 @@ } }, "node_modules/@rolldown/binding-linux-x64-gnu": { - "version": "1.2.13", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.2.13.tgz", - "integrity": "sha512-J4cm80Pc6wEwV5AZ42o62sIQgDk+Y7R2s646jIwuvO+4V46QB58N4vVuMPWCBaNgursXLpmUWJV//WQAkPvHBQ==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.2.19.tgz", + "integrity": "sha512-rm75/9DkHKeU2WnA8w4X94WGYgLlDCFCfkQC+4bguVJmC/jvDRv2B+2wLOYhyE0fVuv7//Ckk39OoOufyCu76Q==", "cpu": [ "x64" ], @@ -936,9 +806,9 @@ } }, "node_modules/@rolldown/binding-linux-x64-musl": { - "version": "1.2.13", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.2.13.tgz", - "integrity": "sha512-W0euZS40U4V6JkmEnVCIX9mcsL6cbXQ4X8c2w+MMOIjFg68TXUW+u3RT+2e1t1pv9mg/EP3pDtK3POXdQ7Rxyw==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.2.19.tgz", + "integrity": "sha512-irh/4+iYFM4GAzpluDErgjz89bj6NDtqqMAG/6O1LG38Ed3NpyebzCpcVNkFW8uhy+/3/BocUvnXDR33CXWe9A==", "cpu": [ "x64" ], @@ -956,9 +826,9 @@ } }, "node_modules/@rolldown/binding-openharmony-arm64": { - "version": "1.2.13", - "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.2.13.tgz", - "integrity": "sha512-do/AF/4n9MRshia3a5aXoy8xM2c6mgfT6D7H/dY6my5z+hfCIR4ab7mk4IRj++nsEQpKy39kd0DQnDq+r692tw==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.2.19.tgz", + "integrity": "sha512-+KWTWNoPt+CfSq94CiceWu3yPE+QzkaG+phPyz9G60tmZLwfQkcA4AeksafzvJAw4pvg1mcd5a1TkUqVv0s4JA==", "cpu": [ "arm64" ], @@ -972,10 +842,29 @@ "node": "^20.19.0 || >=22.12.0" } }, + "node_modules/@rolldown/binding-wasm32-wasi": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-wasm32-wasi/-/binding-wasm32-wasi-1.2.19.tgz", + "integrity": "sha512-7EH+skOsl5qpWnK0vzamgJFhOv1cwxQpsxm8tI883K9fur5c27p8q87fzEO6BbBPabA2/+s/zR63/pLc137iOg==", + "cpu": [ + "wasm32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/core": "2.0.0-beta.2", + "@emnapi/runtime": "2.0.0-beta.2", + "@napi-rs/wasm-runtime": "1.2.6" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=23.5.0" + } + }, "node_modules/@rolldown/binding-win32-arm64-msvc": { - "version": "1.2.13", - "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.2.13.tgz", - "integrity": "sha512-6FtUf2cJZobutJdxnGYX8z0vtbgqU0b2v8vfBhkXb9wp2MppMFtkunE+IaOntyi01rkIQoPW2GHABtfzsC0BRQ==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.2.19.tgz", + "integrity": "sha512-3Q1Yg1Q7tEvBWoZf5rFvG/GKZQPgwfru+p4wBajDfJFBs0SHCpL++dfTjW9gyAKd1T7ZpIYvdaUax7Pa/IhFVQ==", "cpu": [ "arm64" ], @@ -990,9 +879,9 @@ } }, "node_modules/@rolldown/binding-win32-x64-msvc": { - "version": "1.2.13", - "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.2.13.tgz", - "integrity": "sha512-UKhFaZTeTcbKrb3iU82m17jVcPEAoqDkCN5MBqgPyZSwp/cQmib21crTS0DdH7T1B7wZRWEI89YQAOJMet5yhg==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.2.19.tgz", + "integrity": "sha512-y/sqRRc6d7hECzOFc5n3LSeqctmIp9mMjY1Kq4s14uLPd/LZ4z7i1zrW6fMtp2mPeuQIC4e6ULMcwQzMomqQag==", "cpu": [ "x64" ], @@ -1007,9 +896,9 @@ } }, "node_modules/@rolldown/pluginutils": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.1.tgz", - "integrity": "sha512-2j9bGt5Jh8hj+vPtgzPtl72j0yRxHAyumoo6TNfAjsLB04UtpSvPbPcDcBMxz7n+9CYB0c1GxQFxYRg2jimqGw==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.1.1.tgz", + "integrity": "sha512-glFIJDvLNDtJhT9qrMFWLPbvS+skxgt4L0K8Ei2YtnhPysAJnsI7nyxSJxKj4ADeKX0OLjC4ntRkwpLOoS3rwA==", "dev": true, "license": "MIT" }, @@ -1053,14 +942,11 @@ } }, "node_modules/@swc/helpers": { - "version": "0.5.23", - "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.23.tgz", - "integrity": "sha512-5lSsMOTXURePglDfvuAQUqkGek9Hg2kksOYay2m0+XR++b2NWYL/4sWyuvVBIs8oKnJaxkdi9whaL/sqN13afw==", + "version": "0.5.24", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.24.tgz", + "integrity": "sha512-6tcXo4kA8HgGO7AVmawB57RYi/piBPYVHVcO6dXjX+SZw8GoHmi262sp4v2Ha2kNP9Cx84qei27yT+fjS1lxgg==", "license": "Apache-2.0", - "peer": true, - "dependencies": { - "tslib": "^2.8.0" - } + "peer": true }, "node_modules/@testing-library/dom": { "version": "10.4.2", @@ -1083,9 +969,9 @@ } }, "node_modules/@testing-library/jest-dom": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-7.0.1.tgz", - "integrity": "sha512-oMDTC3oA+6CXSO2JZnvOI7CA6oVub6kij5ggk9ohwye5slmkwxYDXcPOVxgMw/RQlticjtO0C1RZkR97HgrWMw==", + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-8.0.0.tgz", + "integrity": "sha512-Nu45KEeFgP/ydCMipnisMblq6YHViqEFi3fKN0a40s+zdKDDD7vEPCEavS0i7i4RxmclcEIL8q2o42pu+WgNgg==", "dev": true, "license": "MIT", "dependencies": { @@ -1103,7 +989,7 @@ }, "peerDependencies": { "@testing-library/dom": ">=10 <11", - "vitest": ">= 0.32" + "vitest": ">=5 <6" }, "peerDependenciesMeta": { "vitest": { @@ -1159,12 +1045,23 @@ } }, "node_modules/@tsconfig/svelte": { - "version": "5.0.8", - "resolved": "https://registry.npmjs.org/@tsconfig/svelte/-/svelte-5.0.8.tgz", - "integrity": "sha512-UkNnw1/oFEfecR8ypyHIQuWYdkPvHiwcQ78sh+ymIiYoF+uc5H1UBetbjyqT+vgGJ3qQN6nhucJviX6HesWtKQ==", + "version": "5.0.9", + "resolved": "https://registry.npmjs.org/@tsconfig/svelte/-/svelte-5.0.9.tgz", + "integrity": "sha512-gbtbqsEFq9gFzGmgJMIB3+leXVmkUttoFjzeHsbqN6qFKst40fvxnN9+3Ajdl8VlIGwPevs9LNJ8YUhQgchqaw==", "dev": true, "license": "MIT" }, + "node_modules/@tybys/wasm-util": { + "version": "0.10.5", + "resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.5.tgz", + "integrity": "sha512-dOGOPxlaNV+G046mZzN+9C0dAcQZeSKcXiVaM0TYy/LM4ttTmgSBDxYfovcYI8Em3+eAbiAYpvWLOv8+ZVRJKA==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, "node_modules/@types/aria-query": { "version": "5.0.4", "resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-5.0.4.tgz", @@ -1198,9 +1095,9 @@ "license": "MIT" }, "node_modules/@types/estree": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.9.tgz", - "integrity": "sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==", + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.10.tgz", + "integrity": "sha512-lTyOMnOcmRBzdCv6/4zUZCrEhV0xrqQiUZBZtVcbmLHBXKLnN8q89v/wKRF/Q0HbwVsqbIG3o5HDoFl9sduM+g==", "license": "MIT" }, "node_modules/@types/json-schema": { @@ -1211,9 +1108,9 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "24.19.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-24.19.1.tgz", - "integrity": "sha512-aS3/DG0oM05K0RIXXP+hKjinGG5IgSSVGzswZxW3O0sS3pH4/fycXundUC9XsszgKCk4gHXylTEK6hyFxVxnoQ==", + "version": "24.19.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-24.19.2.tgz", + "integrity": "sha512-93d49wCWJkCyN87MxLpNN6KXPCwFw7bVUg79mGUV1OS40JGWwVCr8n61DXCSqz7CV6/VfPkb7xec7uP2M+QHWQ==", "dev": true, "license": "MIT", "dependencies": { @@ -1228,17 +1125,17 @@ "optional": true }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "8.71.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.71.2.tgz", - "integrity": "sha512-K72/pvT7qpm8q3k8G5u93NCSN1RcLxX5h7Gw0bQpbMXviBHeY6Nx1WEwmk9wP+eKTSQ8ecxvcgt/ZX/rB938xQ==", + "version": "8.73.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.73.0.tgz", + "integrity": "sha512-UkygMFer53Yzn29MCYFTHf34hGXf5KJhiDWfIm1tXtXRrym1CS6l5H9Y3yCtPWChpC0/f93H88gdj8tN0dd4kw==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/regexpp": "^4.12.2", - "@typescript-eslint/scope-manager": "8.71.2", - "@typescript-eslint/type-utils": "8.71.2", - "@typescript-eslint/utils": "8.71.2", - "@typescript-eslint/visitor-keys": "8.71.2", + "@typescript-eslint/scope-manager": "8.73.0", + "@typescript-eslint/type-utils": "8.73.0", + "@typescript-eslint/utils": "8.73.0", + "@typescript-eslint/visitor-keys": "8.73.0", "ignore": "^7.0.5", "natural-compare": "^1.4.0", "ts-api-utils": "^2.5.0" @@ -1251,15 +1148,15 @@ "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "@typescript-eslint/parser": "^8.71.2", + "@typescript-eslint/parser": "^8.73.0", "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", "typescript": ">=4.8.4 <6.1.0" } }, "node_modules/@typescript-eslint/eslint-plugin/node_modules/ignore": { - "version": "7.0.12", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.12.tgz", - "integrity": "sha512-/8UvqAPU9DGTI9k4mxtf49U37Isfwr8Uts96+SBHIkFxPJnHS0Ew4f00sM4Scd8V8EjM0jUNtVDdv1kPdt35lg==", + "version": "7.0.16", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.16.tgz", + "integrity": "sha512-52N+Y4HRMOJmbLmr+DqO4iSRyyB7N52gm7PWCT6h0p978+oKbqHCB7gIJIwZvBUsjlSdWbrBFqUSmIFNZMpn0A==", "dev": true, "license": "MIT", "engines": { @@ -1267,16 +1164,16 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "8.71.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.71.2.tgz", - "integrity": "sha512-aTtmZjp/x3gsGHkDs04/1I8kNogBJkpQaeGaN0PfiG43NzDEmW2n+OP5im9wfsvyX0yP1UZWBrAGtDBfH9jEVw==", + "version": "8.73.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.73.0.tgz", + "integrity": "sha512-AuL45bVcmssHfZ3Di3cs9Q0l4gBm4ZFVrJOQEE7VpqW+PVgQaEwSwazz4TVIiFabXkk6U51EprYDwqw+HR8ePw==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/scope-manager": "8.71.2", - "@typescript-eslint/types": "8.71.2", - "@typescript-eslint/typescript-estree": "8.71.2", - "@typescript-eslint/visitor-keys": "8.71.2", + "@typescript-eslint/scope-manager": "8.73.0", + "@typescript-eslint/types": "8.73.0", + "@typescript-eslint/typescript-estree": "8.73.0", + "@typescript-eslint/visitor-keys": "8.73.0", "debug": "^4.4.3" }, "engines": { @@ -1292,14 +1189,14 @@ } }, "node_modules/@typescript-eslint/project-service": { - "version": "8.71.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.71.2.tgz", - "integrity": "sha512-Pd68GsLVh5ZXlcEccFPdhSOvtHZ/2WU0XsA8zmXOS3F158lVlcTLhfQ6qvtL1RzbMie0Kp8xtbVwAg4nejKPHw==", + "version": "8.73.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.73.0.tgz", + "integrity": "sha512-/pEf8Rc4Mjk+qJnY0uO1+Gadeal8uv50xpuic+srG2vIVatA0XxvWMUeMtFvs6OCHqftiQ7/+qH4aehG5stzIA==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/tsconfig-utils": "^8.71.2", - "@typescript-eslint/types": "^8.71.2", + "@typescript-eslint/tsconfig-utils": "^8.73.0", + "@typescript-eslint/types": "^8.73.0", "debug": "^4.4.3" }, "engines": { @@ -1314,14 +1211,14 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "8.71.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.71.2.tgz", - "integrity": "sha512-YF4wgg5iUX5Obywoac27B56FhozMNFhdJSbh11H5GBAwmBtfyRhmgTQqW9tRNNmHDvsZ2CX6UGzoz+YfYn2Leg==", + "version": "8.73.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.73.0.tgz", + "integrity": "sha512-/TjD738Iq2rzj5z0ixVOi+TsvgjAzZPLPaH1yWdDBytR/HTR5gMpyYWZeCe5WTQZLwk3ho8AV7U3muoQCRtXBQ==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.71.2", - "@typescript-eslint/visitor-keys": "8.71.2" + "@typescript-eslint/types": "8.73.0", + "@typescript-eslint/visitor-keys": "8.73.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -1332,9 +1229,9 @@ } }, "node_modules/@typescript-eslint/tsconfig-utils": { - "version": "8.71.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.71.2.tgz", - "integrity": "sha512-jz49TAWokm/7yWD9/o837nYax9DyALxIPOImdImvVzo6canBCZYzin8zJyqNR5k1j9K1DE0bVvr0XYB+99uAdg==", + "version": "8.73.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.73.0.tgz", + "integrity": "sha512-lmtCFOfYaJfpqZywGuXi4FpNtE+NQ+YLe3T0K9rtEDcW8ZuGWvfI++pj8r05sYMI8vWT2CYK4rWyedmD6Rp4og==", "dev": true, "license": "MIT", "engines": { @@ -1349,15 +1246,15 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "8.71.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.71.2.tgz", - "integrity": "sha512-cC8UaalCViJkb3rH/xLIvidEwoFRtMZMUqDjjJMGEKaTFwYRHYBcoczlEGHuvkHEO8svRDrgZ0yQgOArFmwang==", + "version": "8.73.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.73.0.tgz", + "integrity": "sha512-MOC9i4xy1F7KcDde7Ip8jf1SrRiALb2Km4UWxGNjUE2YlhjIEo1ayE27GHIwIQyfWuHTmEonQT14uyurlyC6aA==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.71.2", - "@typescript-eslint/typescript-estree": "8.71.2", - "@typescript-eslint/utils": "8.71.2", + "@typescript-eslint/types": "8.73.0", + "@typescript-eslint/typescript-estree": "8.73.0", + "@typescript-eslint/utils": "8.73.0", "debug": "^4.4.3", "ts-api-utils": "^2.5.0" }, @@ -1374,9 +1271,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "8.71.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.71.2.tgz", - "integrity": "sha512-y5Ukl3oVp7e/VGxqIoEXoeb/Roj71PAJ4WG/N/RGj+eeDvKRLM15kGr9MijLbN0i03S52zxu31Z98E5gWChJKw==", + "version": "8.73.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.73.0.tgz", + "integrity": "sha512-O/1ytYzflF16QDKXx4/qOXg1IuZp+n7hr9t+S0nv7N/2Tl8rJiNCshztV1gcSUvHbPtoX3+zmNbtSAyVbzxVfw==", "devOptional": true, "license": "MIT", "engines": { @@ -1388,18 +1285,18 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "8.71.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.71.2.tgz", - "integrity": "sha512-DgNOEsl4pdYzwSL+N/Cl33tX1Hlw3FvId73LnKXfq7jnrF2viOEn7X+P7RBkkSWCVm92gnWd28GIC5vJuLREeA==", + "version": "8.73.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.73.0.tgz", + "integrity": "sha512-InjlBkSdWceIwIBWSwS3ENUp+i0O02PGX3Zv2wnihWJC1WDVGvG7mTHuf8b57uAaITj94d6tRPDH+sUEtXdRQQ==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/project-service": "8.71.2", - "@typescript-eslint/tsconfig-utils": "8.71.2", - "@typescript-eslint/types": "8.71.2", - "@typescript-eslint/visitor-keys": "8.71.2", + "@typescript-eslint/project-service": "8.73.0", + "@typescript-eslint/tsconfig-utils": "8.73.0", + "@typescript-eslint/types": "8.73.0", + "@typescript-eslint/visitor-keys": "8.73.0", "debug": "^4.4.3", - "minimatch": "^10.2.2", + "minimatch": "^11.0.1", "semver": "^7.7.3", "tinyglobby": "^0.2.15", "ts-api-utils": "^2.5.0" @@ -1412,20 +1309,26 @@ "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { + "@typescript/native": "npm:typescript@>=7.1.0-dev.20261009.1 || >=7.1.0-beta <7.1.0-dev", "typescript": ">=4.8.4 <6.1.0" + }, + "peerDependenciesMeta": { + "@typescript/native": { + "optional": true + } } }, "node_modules/@typescript-eslint/utils": { - "version": "8.71.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.71.2.tgz", - "integrity": "sha512-RyKa1G1M9rKHDhrk+HJtiF1MvLD5Ux2JW3TSkzw+02pRALdpJb+QzG1Y5em+LvCgzGwgg8H7mBRFKljNz7ImPw==", + "version": "8.73.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.73.0.tgz", + "integrity": "sha512-j2SVJJvVkXdUL0WcEzo4vEH1mO1vIi8KlVukcYA2MgMZvYN2LlZR4PmsW+GTSxSW24j6Q/EP7+MOifLtg5hmsA==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/eslint-utils": "^4.9.1", - "@typescript-eslint/scope-manager": "8.71.2", - "@typescript-eslint/types": "8.71.2", - "@typescript-eslint/typescript-estree": "8.71.2" + "@typescript-eslint/scope-manager": "8.73.0", + "@typescript-eslint/types": "8.73.0", + "@typescript-eslint/typescript-estree": "8.73.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -1440,13 +1343,13 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "8.71.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.71.2.tgz", - "integrity": "sha512-zozlN0UA32bSG2zkKAgQyRYSbEISVoyU6vvkKYo2aSny74D8Jh4e+POkJ6Lk0dlezZi5x7TtD+88Xb06IB8nhg==", + "version": "8.73.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.73.0.tgz", + "integrity": "sha512-k4lsFVpRZICbltkIEEH4hZRkwXkqDF1GHBpClKQOHQY+RkoZAAuyc1ci3I6p+CB6v3U4jaHIUshc4RzzQXZWLg==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.71.2", + "@typescript-eslint/types": "8.73.0", "eslint-visitor-keys": "^5.0.0" }, "engines": { @@ -1458,16 +1361,16 @@ } }, "node_modules/@vitest/mocker": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-5.0.4.tgz", - "integrity": "sha512-tqAlrYWce4iUxhr3ncNohejtCTOcHeE8XWrSNZY3OhPoDn01yeGv+gnaBy64ATp7o6pb03eIbBAjzmibpc9vIQ==", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-5.1.1.tgz", + "integrity": "sha512-b2OgTB4+3ImWIVafXKazJXwLKwQxUNnix6b3xUvUTMh7RyXlrtzoxfZr8aEz9zkHOMAS4K5lu3TvFWoiVeVTQg==", "dev": true, "license": "MIT", "dependencies": { "@jridgewell/trace-mapping": "0.3.31", - "@vitest/spy": "5.0.4", + "@vitest/spy": "5.1.1", "estree-walker": "^3.0.3", - "magic-string": "^1.4.3" + "magic-string": "^1.4.5" }, "funding": { "url": "https://opencollective.com/vitest" @@ -1486,9 +1389,9 @@ } }, "node_modules/@vitest/spy": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-5.0.4.tgz", - "integrity": "sha512-MZKk/gSkm2q+ICobMxCpH1mA+cCAWm8WV7UhxlqGjq/sJ3AGc1BqFOs5CRVXxH78wQtme9q/NAAgBquj4AcyMw==", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-5.1.1.tgz", + "integrity": "sha512-6K8C6alQG1/Yc8/ZI22iJS7JEsxPdVzqtqDq+/xM4Z0mGVykemMVjLhqMy/q6/IHYG3kKD8hKSwRen/ZdyI9vQ==", "dev": true, "license": "MIT", "funding": { @@ -1623,28 +1526,45 @@ "node": "18 || 20 || >=22" } }, - "node_modules/bidi-js": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/bidi-js/-/bidi-js-1.1.0.tgz", - "integrity": "sha512-fX1Onk0tdVPC7obPWB5EbJ1z7NVhLq4m2xZLq2YXBkxzMXIGRpNMU88n0EPgWseKl12J7zXs7qrDxPK4sRs2fg==", + "node_modules/bcp-47": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/bcp-47/-/bcp-47-2.1.2.tgz", + "integrity": "sha512-wsv86UuNFuPnVieKLyECTT+CP1WSAHeoIg5P3xu2kA9Z+7fVPoKt7dxzSeEhtJel0AI+NW3fIW3KtTKQKUCngg==", "dev": true, "license": "MIT", "dependencies": { - "require-from-string": "^2.0.2" + "is-alphabetical": "^2.0.0", + "is-alphanumerical": "^2.0.0", + "is-decimal": "^2.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/bcp-47-match": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/bcp-47-match/-/bcp-47-match-2.0.3.tgz", + "integrity": "sha512-JtTezzbAibu8G0R9op9zb3vcWZd9JF6M0xOYGPn0fNCd7wOpRB1mU2mH9T8gaBGbAAyIIVgB2G7xG0GP98zMAQ==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" } }, "node_modules/bits-ui": { - "version": "2.19.5", - "resolved": "https://registry.npmjs.org/bits-ui/-/bits-ui-2.19.5.tgz", - "integrity": "sha512-TEwkLSYElE5SE0fIdcItiFPfyg9vrR67N1Mt6VvZCqZo24dwTA1MpGVV3WeyIg7rfVAaZ0So8a0/dcnPngCoew==", + "version": "2.22.0", + "resolved": "https://registry.npmjs.org/bits-ui/-/bits-ui-2.22.0.tgz", + "integrity": "sha512-NTQJBYKGdqd8QrnwZcOcGs90Ybt1aFe3xF+rrq7RXNAJPo01VCfTZctKQ27RVloDyb/pQhw4CvnEoce1JFZ8Mg==", "license": "MIT", "dependencies": { - "@floating-ui/core": "^1.7.1", - "@floating-ui/dom": "^1.7.1", - "esm-env": "^1.1.2", + "@floating-ui/core": "^1.8.0", + "@floating-ui/dom": "^1.8.0", + "esm-env": "^1.2.2", "runed": "^0.35.1", - "svelte-toolbelt": "^0.10.6", - "tabbable": "^6.2.0" + "svelte-toolbelt": "^0.10.7", + "tabbable": "^6.5.1" }, "engines": { "node": ">=20" @@ -1658,9 +1578,9 @@ } }, "node_modules/brace-expansion": { - "version": "5.0.12", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz", - "integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==", + "version": "5.0.13", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.13.tgz", + "integrity": "sha512-Vh3dmFbc4wZeox7M9I/0L9GfFd83Su4+yCck/OF9Gi/P/dAHn0RT7X4K9R7gMNMhDck3DvhR6QXsnQdjjgwNvQ==", "dev": true, "license": "MIT", "dependencies": { @@ -1748,20 +1668,6 @@ "node": ">= 8" } }, - "node_modules/css-tree": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-3.2.1.tgz", - "integrity": "sha512-X7sjQzceUhu1u7Y/ylrRZFU2FS6LRiFVp6rKLPg23y3x3c3DOKAwuXGDp+PAGjh6CSnCjYeAul8pcT8bAl+lSA==", - "dev": true, - "license": "MIT", - "dependencies": { - "mdn-data": "2.27.1", - "source-map-js": "^1.2.1" - }, - "engines": { - "node": "^10 || ^12.20.0 || ^14.13.0 || >=15.0.0" - } - }, "node_modules/css.escape": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/css.escape/-/css.escape-1.5.1.tgz", @@ -1769,19 +1675,6 @@ "dev": true, "license": "MIT" }, - "node_modules/cssesc": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/cssesc/-/cssesc-3.0.0.tgz", - "integrity": "sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==", - "dev": true, - "license": "MIT", - "bin": { - "cssesc": "bin/cssesc" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/data-urls": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-8.0.0.tgz", @@ -1871,18 +1764,18 @@ "license": "MIT" }, "node_modules/dompurify": { - "version": "3.4.17", - "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.4.17.tgz", - "integrity": "sha512-B/pSlYVHQ58kqISD/yDjuJ1yfzI34m1gF4lAod2bwSRhiN4K5Cl3H8Af7hqB2PmTL911tdEudnnXn5FnhRoz0w==", + "version": "3.4.18", + "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.4.18.tgz", + "integrity": "sha512-ofe3wI/uNm68HInABYFJYqQxRw1EaKAjNdrFVKqjUY+UZurvNd2L/HuQe097s/4RivWiZyP6tT7aoT8atjfhwg==", "license": "(MPL-2.0 OR Apache-2.0)", "optionalDependencies": { "@types/trusted-types": "^2.0.7" } }, "node_modules/entities": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-8.1.0.tgz", - "integrity": "sha512-kxL7msIffSuh9aaFAMD7rxAIuTRMAHMeBtgHW2yUdWw732ZNh4MehkF2gdjvtdmikkaIP9bFDDJOPlsvm7avrA==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-9.0.0.tgz", + "integrity": "sha512-oJFNDJg3kTPwAD1cNn2+WmUq4wFoo09npc3Ydf1D7ED4smRiWrsKnaLxykrTWgyGEcusc87P5dxlAleol9kpkg==", "dev": true, "license": "BSD-2-Clause", "engines": { @@ -1913,9 +1806,9 @@ } }, "node_modules/eslint": { - "version": "10.12.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-10.12.0.tgz", - "integrity": "sha512-npHjrHb2o4ehH3mE+YuxABR+0gyb0aVWCIolgJDArwCiHEIsonBm3ZKjel5b0U5+a+MbEvIyRCGCzD3eKKK2NA==", + "version": "10.15.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-10.15.0.tgz", + "integrity": "sha512-+5Wg4p+ze3sG1WErYgUO/3H1IQIfFBymVUA0Fo/XTeBOLS6UQIUekpSJ8sdRkn7O7wjh84b55w/roqavH2aScg==", "dev": true, "license": "MIT", "workspaces": [ @@ -1924,11 +1817,11 @@ "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.2", - "@eslint/config-array": "^0.23.5", + "@eslint/config-array": "^0.23.6", "@eslint/config-helpers": "^0.7.0", "@eslint/core": "^1.2.1", "@eslint/plugin-kit": "^0.7.3", - "@humanfs/node": "^0.16.6", + "@humanfs/node": "^0.16.8", "@humanwhocodes/module-importer": "^1.0.1", "@humanwhocodes/retry": "^0.4.2", "@types/estree": "^1.0.6", @@ -1949,7 +1842,7 @@ "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", "json-stable-stringify-without-jsonify": "^1.0.1", - "minimatch": "^10.2.5", + "minimatch": "^11.0.5", "natural-compare": "^1.4.0", "optionator": "^0.9.3" }, @@ -1988,9 +1881,9 @@ } }, "node_modules/eslint-plugin-svelte": { - "version": "3.23.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-svelte/-/eslint-plugin-svelte-3.23.1.tgz", - "integrity": "sha512-+w86Jlx4IRUuuvtqD6j4njql+akx+81JnpvbN5de3AV5iq2SexvST/Jr51CiTlKeY0i+vhoKjPO/ywFKIP75sA==", + "version": "3.24.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-svelte/-/eslint-plugin-svelte-3.24.1.tgz", + "integrity": "sha512-XYzp318u8UkDH4ZdRkdSomOYnwMTeJP2Zw9u6DuBj3mViFZD8zS+mhfTYq34plm3SH9eF7ZaiYJfQYq2xMhPHg==", "dev": true, "license": "MIT", "dependencies": { @@ -1999,11 +1892,11 @@ "esutils": "^2.0.3", "globals": "^16.0.0", "known-css-properties": "^0.37.0", - "postcss": "^8.4.49", + "postcss": "^8.5.10", "postcss-load-config": "^3.1.4", "postcss-safe-parser": "^7.0.0", "semver": "^7.6.3", - "svelte-eslint-parser": "^1.7.0" + "svelte-eslint-parser": "^1.10.1" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -2104,9 +1997,9 @@ } }, "node_modules/esrap": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/esrap/-/esrap-2.4.0.tgz", - "integrity": "sha512-CQPcneEHw/czj32uwQC52nYnax8H4SXt25FCM+LIwGZ49cMIxpOj3bP8wmzcI+Z0HIy5KkClaPhRLfCySzwHPA==", + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/esrap/-/esrap-2.4.2.tgz", + "integrity": "sha512-WpVZsWnSheHBy+fGrO/0duwnbe6ODZH1QyBbjupreSCJGojaBWRncrq+HVeIJ8eHQjEwSJg9hC4yPJyNVOrpqg==", "license": "MIT", "dependencies": { "@jridgewell/sourcemap-codec": "^1.4.15" @@ -2287,9 +2180,9 @@ } }, "node_modules/globals": { - "version": "17.13.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-17.13.0.tgz", - "integrity": "sha512-RwMTC61u7hrG3ZJMkZQOK4JLJrKS8QtoTii63EmWvFXHqycY9FObBJQCbsLxSO8kjKhWE5kV1GC+Vb1g3RI0Zg==", + "version": "17.14.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-17.14.0.tgz", + "integrity": "sha512-UtdkTVyAJePQv0J2M9Xe4L0ruNSDV314XiIJsADI2Zf40bcdAonE/D/OhAU8AT99oij9mhLByb+NvA3QWZYgCg==", "dev": true, "license": "MIT", "engines": { @@ -2395,6 +2288,43 @@ "integrity": "sha512-Nb2ctOyNR8DqQoR0OwRG95uNWIC0C1lCgf5Naz5H6Ji72KZ8OcFZLz2P5sNgwlyoJ8Yif11oMuYs5pBQa86csA==", "license": "MIT" }, + "node_modules/is-alphabetical": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-alphabetical/-/is-alphabetical-2.0.1.tgz", + "integrity": "sha512-FWyyY60MeTNyeSRpkM2Iry0G9hpr7/9kD40mD/cGQEuilcZYS4okz8SN2Q6rLCJ8gbCt6fN+rC+6tMGS99LaxQ==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/is-alphanumerical": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-alphanumerical/-/is-alphanumerical-2.0.1.tgz", + "integrity": "sha512-hmbYhX/9MUMF5uh7tOXyK/n0ZvWpad5caBA17GsC6vyuCqaWliRG5K1qS9inmUhEMaOBIW7/whAnSwveW/LtZw==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-alphabetical": "^2.0.0", + "is-decimal": "^2.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/is-decimal": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-decimal/-/is-decimal-2.0.1.tgz", + "integrity": "sha512-AAB9hiomQs5DXWcRB1rqsxGUstbRroFOPPVAomNk/3XHR5JyEZChOyTWe2oayKnsSsr/kcGqF+z6yuH6HHpN0A==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", @@ -2482,41 +2412,39 @@ } }, "node_modules/jsdom": { - "version": "30.1.2", - "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-30.1.2.tgz", - "integrity": "sha512-0FFE/jE1rppmVfUrJUgxqXjcwolZYIGtAgj1pTussMhNZxIxi7W/PvfWaMNroGi2B36X1IKHbexpZ9DhkoOPiQ==", + "version": "31.0.1", + "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-31.0.1.tgz", + "integrity": "sha512-CbhJL8ZQg3eKswxSZth4QO9tW0jPIhmR0vtSXQSbKSfWbwIT6hoRc17wdHIVTQ43KI0mdV5iTJr3281IDgVZ5g==", "dev": true, "license": "MIT", "dependencies": { - "@asamuzakjp/css-color": "^7.1.3", - "@asamuzakjp/dom-selector": "^9.2.4", - "@bramus/specificity": "^2.4.2", - "@csstools/css-syntax-patches-for-csstree": "^1.1.15", "@exodus/bytes": "^1.16.0", - "css-tree": "^3.2.1", + "bcp-47": "^2.1.2", + "bcp-47-match": "^2.0.3", "data-urls": "^8.0.0", "decimal.js": "^10.6.0", "html-encoding-sniffer": "^7.0.0", "is-potential-custom-element-name": "^1.0.1", "lru-cache": "^11.5.3", - "parse5": "^8.0.1", + "parse5": "^8.1.0", + "parse5-parser-stream": "^8.1.0", "saxes": "^6.0.0", "tough-cookie": "^6.0.2", - "undici": "^8.11.2", + "undici": "^8.12.3", "w3c-xmlserializer": "^6.0.0", "webidl-conversions": "^8.0.1", "whatwg-mimetype": "^5.0.0", - "whatwg-url": "^17.2.0", + "whatwg-url": "^17.3.0", "xml-name-validator": "^5.0.0" }, "engines": { "node": "^22.22.2 || ^24.15.0 || >=26.0.0" }, "peerDependencies": { - "canvas": "^3.2.3" + "@napi-rs/canvas": "^1.0.13" }, "peerDependenciesMeta": { - "canvas": { + "@napi-rs/canvas": { "optional": true } } @@ -2891,9 +2819,9 @@ } }, "node_modules/magic-string": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-1.4.3.tgz", - "integrity": "sha512-z12OxmaPGE0F4xlpGdjuAUckipLpQlTAuAmyGhNoD7ODpYUzvDfvtxUbjM/jwznyP178oju/KDdyi220wNJ0RQ==", + "version": "1.4.5", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-1.4.5.tgz", + "integrity": "sha512-oLLC2+YvQUfAa+vxoufE/yc1icb87M9iXIRqAoR/2EhE/8cb3SF/+Gi0c2By1B+5Vz2e2vQtUvHiu1+63Znh+w==", "dev": true, "license": "MIT", "dependencies": { @@ -2912,13 +2840,6 @@ "node": ">= 18" } }, - "node_modules/mdn-data": { - "version": "2.27.1", - "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.27.1.tgz", - "integrity": "sha512-9Yubnt3e8A0OKwxYSXyhLymGW4sCufcLG6VdiDdUGVkPhpqLxlvP5vl1983gQjJl3tqbrM731mjaZaP68AgosQ==", - "dev": true, - "license": "CC0-1.0" - }, "node_modules/min-indent": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.1.tgz", @@ -2930,17 +2851,17 @@ } }, "node_modules/minimatch": { - "version": "11.0.3", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-11.0.3.tgz", - "integrity": "sha512-iny/40PEGkNJQ5/Pv6z3nm6FbRAby32GeZRjCUJk2WnNDbgPSTcdI+DDvLqsgBdD4cD5sMtMheqPPnehCCa8Nw==", + "version": "11.0.9", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-11.0.9.tgz", + "integrity": "sha512-KCFkfyjqerNlSstjlhIGNXIKZGA/6O4V4RlhZ+Dsr621SPPw0mzlypE9D9ZOoPiVefHID+j7/XuMMlqfD/F60Q==", "dev": true, "license": "BlueOak-1.0.0", "dependencies": { - "@isaacs/nonrecursive-glob-match": "^1.0.3", + "@isaacs/nonrecursive-glob-match": "^1.1.0", "brace-expansion": "^5.0.12" }, "engines": { - "node": "18 || 20 || >=22" + "node": "20 || >=22" }, "funding": { "url": "https://github.com/sponsors/isaacs" @@ -3103,13 +3024,26 @@ } }, "node_modules/parse5": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/parse5/-/parse5-8.0.1.tgz", - "integrity": "sha512-z1e/HMG90obSGeidlli3hj7cbocou0/wa5HacvI3ASx34PecNjNQeaHNo5WIZpWofN9kgkqV1q5YvXe3F0FoPw==", + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-8.1.1.tgz", + "integrity": "sha512-EcR/6WDcU7b2N3vQSxKALCk9lXGtUMQxXio008OEMBE0kavu/7JLfBEeFPzi43nMqVDSbEn3QCK+BMCc9zO//w==", "dev": true, "license": "MIT", "dependencies": { - "entities": "^8.0.0" + "entities": "^9.0.0" + }, + "funding": { + "url": "https://github.com/inikulin/parse5?sponsor=1" + } + }, + "node_modules/parse5-parser-stream": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/parse5-parser-stream/-/parse5-parser-stream-8.1.1.tgz", + "integrity": "sha512-hMcVbbUJcQmP8rURWUdYrT1flRiBiBVjq/RYGguJpDUgIXSqdYKlE0CxthmdMWoSlBAuL5bUBa73g0pttSy7Hw==", + "dev": true, + "license": "MIT", + "dependencies": { + "parse5": "^8.1.1" }, "funding": { "url": "https://github.com/inikulin/parse5?sponsor=1" @@ -3156,13 +3090,13 @@ } }, "node_modules/playwright": { - "version": "1.64.0", - "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.64.0.tgz", - "integrity": "sha512-kVzTnYFYEyQ9RGzBjNCd2+yEqWmVbxl3AHPynv3qQ6JTjv4a+kwRcnqQwIpuP3NnrnIrE/Q6wWAIAvMfIE2/Yg==", + "version": "1.65.1", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.65.1.tgz", + "integrity": "sha512-vJ1FuoOrNwOKHUIVEvSt3jT1L+wjjDpwhwIstKtfvTh8XIG4FG4bIFuvNdMxi81LGfAhUgUZleVFaOLY4RIUUw==", "dev": true, "license": "Apache-2.0", "dependencies": { - "playwright-core": "1.64.0" + "playwright-core": "1.65.1" }, "bin": { "playwright": "cli.js" @@ -3172,9 +3106,9 @@ } }, "node_modules/playwright-core": { - "version": "1.64.0", - "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.64.0.tgz", - "integrity": "sha512-T9r+MZkTECl2+oUcZ26YgZzTrYidTsIhYYkJix+6iDOymOb1FB2RLLSOxRGnZGv5DStt+aduIVbt+E8WygXYpg==", + "version": "1.65.1", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.65.1.tgz", + "integrity": "sha512-hqPpz7blSMPxWVdoeE1yiBSzXsKiVOd2k+kjCvmUywD2GPO2Dd9HfcWnq9NN0GHbNZDFgZ9JfBFr+X5/BLo0qw==", "dev": true, "license": "Apache-2.0", "bin": { @@ -3195,9 +3129,9 @@ } }, "node_modules/postcss": { - "version": "8.5.29", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.29.tgz", - "integrity": "sha512-49cGhUbXj8Qenv0iTMxA1cFBzxXoctpC9Ujd77t1WcbJIr6nF/eI7g/8MgxrYldFRuAXvja7xQRwavoW7kgrxQ==", + "version": "8.5.33", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.33.tgz", + "integrity": "sha512-RVHEU9/Pp1Fnjr/MpAJsZoADukCKhfIi15OunEYiGktIkYLkPVvC1sioWolGDS7XByMTx9m/IGbro0Js13zhnQ==", "dev": true, "funding": [ { @@ -3215,7 +3149,7 @@ ], "license": "MIT", "dependencies": { - "nanoid": "^3.3.19", + "nanoid": "^3.3.20", "picocolors": "^1.1.1", "source-map-js": "^1.2.2" }, @@ -3318,13 +3252,12 @@ } }, "node_modules/postcss-selector-parser": { - "version": "7.1.6", - "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.6.tgz", - "integrity": "sha512-7qASPzhKF2l2KLboRZux8CCTRMdGiV08vWmyKzPz22qZ7ZjQBOeY7rNzNoCLSUiftJ7HUq0GERHmxw/t0dCdMw==", + "version": "7.2.1", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.2.1.tgz", + "integrity": "sha512-GwxlMgTTXwIom+ebC7an3k6RaJDwklRQQnfiXsLPGicu8FYV/k/+1/9YY2OU2+r938H2t4X0TDxoif+HP2rjzQ==", "dev": true, "license": "MIT", "dependencies": { - "cssesc": "^3.0.0", "util-deprecate": "^1.0.2" }, "engines": { @@ -3342,9 +3275,9 @@ } }, "node_modules/prettier": { - "version": "3.9.10", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.9.10.tgz", - "integrity": "sha512-skGHTH1Yb9QvaTC4hWnRTzEYtCpApF0UMBPz+t/0ZPzP8ihefo/btKd+QA7pUE0fEwA1SbS/NmhyEcstdXOIdA==", + "version": "3.10.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.10.1.tgz", + "integrity": "sha512-70vp3ZUYoPlFbF9uiTdXHUUCGEIp7d4+6p+8DYbkm2jP7x/3i/paXVF6dopSI3zd/CEitrZN1rc4i85xWmmXlg==", "dev": true, "license": "MIT", "bin": { @@ -3358,9 +3291,9 @@ } }, "node_modules/prettier-plugin-svelte": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/prettier-plugin-svelte/-/prettier-plugin-svelte-4.1.1.tgz", - "integrity": "sha512-wXvbXMjSvb4C9ENWTHXyd+ihakKCsJ6rJhLP6/8HFNj4GkZr48jqL9PoKsl2sk7SyCZRTnJ7O2TTowUpOxP/KA==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/prettier-plugin-svelte/-/prettier-plugin-svelte-4.2.0.tgz", + "integrity": "sha512-VgUFSR6+7/KLloVSIgKMwY/9OFxaixY/xsOBUCP95ZKaxSa6JBtLKzq6L1L/Tw6Jc1C7K+op7D1Yu5qD+YdPHA==", "dev": true, "license": "MIT", "engines": { @@ -3462,13 +3395,13 @@ } }, "node_modules/rolldown": { - "version": "1.2.13", - "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.13.tgz", - "integrity": "sha512-/5apOkwWxtACcQtZ5WlrAsKS4JwXVThQPJZ3RqIruRY9UG9M8e0VlXN068xum/JRKA4aIUoJ13ghe/kGCvidiQ==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.19.tgz", + "integrity": "sha512-QIiV1J9d0pzN4jeeTH4sjPy0AZ6cAy2cG0ExeoE1+U8Rvj+hR3gYkokx0YbeUNGlZqiQJJ2utcETe0oKXwzsuA==", "dev": true, "license": "MIT", "dependencies": { - "@oxc-project/types": "=0.153.0", + "@oxc-project/types": "=0.156.0", "@rolldown/pluginutils": "^1.0.0" }, "bin": { @@ -3478,21 +3411,22 @@ "node": "^20.19.0 || >=22.12.0" }, "optionalDependencies": { - "@rolldown/binding-android-arm-eabi": "1.2.13", - "@rolldown/binding-android-arm64": "1.2.13", - "@rolldown/binding-darwin-arm64": "1.2.13", - "@rolldown/binding-darwin-x64": "1.2.13", - "@rolldown/binding-freebsd-x64": "1.2.13", - "@rolldown/binding-linux-arm-gnueabihf": "1.2.13", - "@rolldown/binding-linux-arm64-gnu": "1.2.13", - "@rolldown/binding-linux-arm64-musl": "1.2.13", - "@rolldown/binding-linux-ppc64-gnu": "1.2.13", - "@rolldown/binding-linux-s390x-gnu": "1.2.13", - "@rolldown/binding-linux-x64-gnu": "1.2.13", - "@rolldown/binding-linux-x64-musl": "1.2.13", - "@rolldown/binding-openharmony-arm64": "1.2.13", - "@rolldown/binding-win32-arm64-msvc": "1.2.13", - "@rolldown/binding-win32-x64-msvc": "1.2.13" + "@rolldown/binding-android-arm-eabi": "1.2.19", + "@rolldown/binding-android-arm64": "1.2.19", + "@rolldown/binding-darwin-arm64": "1.2.19", + "@rolldown/binding-darwin-x64": "1.2.19", + "@rolldown/binding-freebsd-x64": "1.2.19", + "@rolldown/binding-linux-arm-gnueabihf": "1.2.19", + "@rolldown/binding-linux-arm64-gnu": "1.2.19", + "@rolldown/binding-linux-arm64-musl": "1.2.19", + "@rolldown/binding-linux-ppc64-gnu": "1.2.19", + "@rolldown/binding-linux-s390x-gnu": "1.2.19", + "@rolldown/binding-linux-x64-gnu": "1.2.19", + "@rolldown/binding-linux-x64-musl": "1.2.19", + "@rolldown/binding-openharmony-arm64": "1.2.19", + "@rolldown/binding-wasm32-wasi": "1.2.19", + "@rolldown/binding-win32-arm64-msvc": "1.2.19", + "@rolldown/binding-win32-x64-msvc": "1.2.19" } }, "node_modules/runed": { @@ -3546,9 +3480,9 @@ } }, "node_modules/semver": { - "version": "7.8.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz", - "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==", + "version": "7.8.6", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.6.tgz", + "integrity": "sha512-9lpSSU4Mly3mrtruwLs1eLK6+gzbzqeBFwRNjIjE+9LuDpWdYctrQlQ3ej1Ilgi7gknpsTRnPoLP8DpCHqHIJw==", "dev": true, "license": "ISC", "bin": { @@ -3582,13 +3516,13 @@ } }, "node_modules/source-map-js": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.2.tgz", - "integrity": "sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==", + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.4.tgz", + "integrity": "sha512-J7ZjMvHd9O1fcT/5V09QWaaSl2BbWx3F6O08spde82Namf9UB0GxRVIPiNbVsdKkoizHiSpTodo3vp2bAy91MA==", "dev": true, "license": "BSD-3-Clause", "engines": { - "node": ">=0.10.0" + "node": ">=6.0.0" } }, "node_modules/std-env": { @@ -3634,9 +3568,9 @@ } }, "node_modules/svelte": { - "version": "5.57.2", - "resolved": "https://registry.npmjs.org/svelte/-/svelte-5.57.2.tgz", - "integrity": "sha512-1YiPCAXT0Ct6g1vOMmSLa0Nsc3QRMvtDF32ihgglGVrugIuIK38RyDiFNXVDhtQ81TJjSO57NdMw6DyYLqSGDQ==", + "version": "5.59.1", + "resolved": "https://registry.npmjs.org/svelte/-/svelte-5.59.1.tgz", + "integrity": "sha512-ADG20W/jYSQut/79AavRRfbXQYebFKMVWT/xAbjVVZfZA4XzIoFfcpanEfYTyN+uWQUaPP+nstFx4qVKwEVnQQ==", "license": "MIT", "dependencies": { "@jridgewell/remapping": "^2.3.5", @@ -3649,7 +3583,7 @@ "clsx": "^2.1.1", "devalue": "^5.9.2", "esm-env": "^1.2.1", - "esrap": "^2.3.6", + "esrap": "^2.4.2", "is-reference": "^3.0.3", "locate-character": "^3.0.0", "magic-string": "^0.30.11", @@ -3660,9 +3594,9 @@ } }, "node_modules/svelte-check": { - "version": "4.7.6", - "resolved": "https://registry.npmjs.org/svelte-check/-/svelte-check-4.7.6.tgz", - "integrity": "sha512-t2scM//ZuVbSY/T2w6FSBw1v9s2NEmh/g+sy1lqtosW5ylBV5AF4wFb1Ts9Kf3MbfPDUDJDZ9L436YT0SPTdvw==", + "version": "4.7.8", + "resolved": "https://registry.npmjs.org/svelte-check/-/svelte-check-4.7.8.tgz", + "integrity": "sha512-laZ49GFHZ3b0z2PWinJWL0syehc/PTR8aHaUaTiBkWJ+4Y38nhxjmXsSz7CbGa3VdKopViVbrBH3bGNqIAI0bQ==", "dev": true, "license": "MIT", "dependencies": { @@ -3685,9 +3619,9 @@ } }, "node_modules/svelte-eslint-parser": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/svelte-eslint-parser/-/svelte-eslint-parser-1.9.0.tgz", - "integrity": "sha512-aKdKQAZP7MobfVcQNyy5Yk0QjlC9m5T1lTS0qA7+0EIsFzFX3WgbGHfb8267QK+4hI8Az9+2f+hk5sp39op8sg==", + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/svelte-eslint-parser/-/svelte-eslint-parser-1.10.1.tgz", + "integrity": "sha512-owYBhrNRp/m+hDaQCH0S683kc0TMFy2bB+qvsMQQZRsjSFD9xp/3FYgI8FZoOKA3xk62gwkUj1HpVek0p6WgNw==", "dev": true, "license": "MIT", "dependencies": { @@ -3764,37 +3698,18 @@ } }, "node_modules/svelte-sonner": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/svelte-sonner/-/svelte-sonner-1.2.1.tgz", - "integrity": "sha512-N00LOWb60fjKXULbpngku+7E9Krb16KpNq4/Eax5Vu7o1Dpbca55QpaLPsB+yp82JIEdFhfJuv5cVXLoe0ZtVA==", + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/svelte-sonner/-/svelte-sonner-1.2.3.tgz", + "integrity": "sha512-SjQaDI/k6L/ordD2w84XOkGv3kaZwyGRsJzR+lHW097/aJCaydvp63VblMTFsrakm58BxRjUSySK/BWH9jdY1Q==", "license": "MIT", - "dependencies": { - "runed": "^0.28.0" - }, "peerDependencies": { "svelte": "^5.0.0" } }, - "node_modules/svelte-sonner/node_modules/runed": { - "version": "0.28.0", - "resolved": "https://registry.npmjs.org/runed/-/runed-0.28.0.tgz", - "integrity": "sha512-k2xx7RuO9hWcdd9f+8JoBeqWtYrm5CALfgpkg2YDB80ds/QE4w0qqu34A7fqiAwiBBSBQOid7TLxwxVC27ymWQ==", - "funding": [ - "https://github.com/sponsors/huntabyte", - "https://github.com/sponsors/tglide" - ], - "license": "MIT", - "dependencies": { - "esm-env": "^1.0.0" - }, - "peerDependencies": { - "svelte": "^5.7.0" - } - }, "node_modules/svelte-toolbelt": { - "version": "0.10.6", - "resolved": "https://registry.npmjs.org/svelte-toolbelt/-/svelte-toolbelt-0.10.6.tgz", - "integrity": "sha512-YWuX+RE+CnWYx09yseAe4ZVMM7e7GRFZM6OYWpBKOb++s+SQ8RBIMMe+Bs/CznBMc0QPLjr+vDBxTAkozXsFXQ==", + "version": "0.10.7", + "resolved": "https://registry.npmjs.org/svelte-toolbelt/-/svelte-toolbelt-0.10.7.tgz", + "integrity": "sha512-gjuUVEEpo38UJCeI1ssE3NxG31tYENczPTcTGTXf4338qAQNdR9I1oAEbQY0KQFmbdUojNIhHuRNix7ThwFNxQ==", "funding": [ "https://github.com/sponsors/huntabyte" ], @@ -3830,15 +3745,15 @@ } }, "node_modules/tabbable": { - "version": "6.5.0", - "resolved": "https://registry.npmjs.org/tabbable/-/tabbable-6.5.0.tgz", - "integrity": "sha512-wieBHXygIm7OyQOu5hQlkk62/WyCFYGlWg7L6/ZCUZwx0o398Zkn4pVmMyfYhfMG8kGrj/Krt8eIk6UKC6VzwA==", + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/tabbable/-/tabbable-6.5.2.tgz", + "integrity": "sha512-XgdnB1nGU6KU4VgMnZPaZCx7M1hBrLyEiZYau2G2gq9UT0d7d4FUBlNX7vvPlm/B1vk1PjrzJBx9Lbv4fsqS9g==", "license": "MIT" }, "node_modules/tinybench": { - "version": "6.2.2", - "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-6.2.2.tgz", - "integrity": "sha512-nIZ2N2dFpjBsg2hgitKu7mA+FvsIJuGJOwysRngmVRRmWgR/UyPjwJj8c/fT/dhm8EkHnF5EOogRf+0Z2qrimA==", + "version": "6.2.4", + "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-6.2.4.tgz", + "integrity": "sha512-SQ52jEncXxbMCzJuY2A/jGIbbAu6NYsBWW7grz2pNE+EnzQdoGaoBfpk4qC/opE7qiUcGmGgaGIz5EoHdS1O9w==", "dev": true, "license": "MIT", "engines": { @@ -3873,29 +3788,29 @@ } }, "node_modules/tldts": { - "version": "7.4.18", - "resolved": "https://registry.npmjs.org/tldts/-/tldts-7.4.18.tgz", - "integrity": "sha512-somxA8xKAUzlAxl0TX/jMSYIbRNFIVGnI96pVGJPeMc5BsHmfVXn6mOJT6U++ELnl04eGfzpfcEuZe8WiASkXg==", + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/tldts/-/tldts-7.5.5.tgz", + "integrity": "sha512-Hy6IImaWALzJOgCIss4gIFi4G0M9lqk95pFKCUVxQPZw+biZ1Pv6f28JpYgahpJB+BufA0HYsIU/aP/WIx3KRg==", "dev": true, "license": "MIT", "dependencies": { - "tldts-core": "^7.4.18" + "tldts-core": "^7.5.5" }, "bin": { "tldts": "bin/cli.js" } }, "node_modules/tldts-core": { - "version": "7.4.18", - "resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-7.4.18.tgz", - "integrity": "sha512-KI2PKvCmvQI/xD6ypPqkU0i7oxNXR/O58RLRaHR4svsgVUQ2JE/XC8BtMbG6PSehD27I8sZJRcC1ASnCy6lp3g==", + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-7.5.5.tgz", + "integrity": "sha512-rEJz/8cJFY/bdF354gl14yxavbrIbvM+FcbkYVQ6CSCMQTJdUFUIm39TTWSiGPvcpQh7/F6qHrD3SkwwdgtDCw==", "dev": true, "license": "MIT" }, "node_modules/tough-cookie": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-6.0.2.tgz", - "integrity": "sha512-exgYmnmL/sJpR3upZfXG5PoatXQii55xAiXGXzY+sROLZ/Y+SLcp9PgJNI9Vz37HpQ74WvDcLT8eqm+kV3FzrA==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-6.1.0.tgz", + "integrity": "sha512-FTxc8u8Kl2tz0Lat1u8ksvcy8bwHRyEMawwTWybo51JqaC6O7SvfuhAKg+Ld6VqyIe2QRJBzY9HA7y2WyFRT2w==", "dev": true, "license": "BSD-3-Clause", "dependencies": { @@ -3932,11 +3847,12 @@ } }, "node_modules/tslib": { - "version": "2.8.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", - "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "version": "2.9.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.9.1.tgz", + "integrity": "sha512-a4Ux9VKuIMHsOS7ENbEq6hK2ZGYIT27Rtl0E4eD9KqwxhKiQeMZE/9xb3IdYwWaSOyIBQLExhQgXDTYoiCxnWA==", + "dev": true, "license": "0BSD", - "peer": true + "optional": true }, "node_modules/type-check": { "version": "0.4.0", @@ -3979,16 +3895,16 @@ } }, "node_modules/typescript-eslint": { - "version": "8.71.2", - "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.71.2.tgz", - "integrity": "sha512-Rz4effbMy2g9wnvOJZG6SbVavX313Lap1vNEbk1RUochzickvzP8P4HB+bkNg5e50eVz1hQGjh9K1omI1xB4Bw==", + "version": "8.73.0", + "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.73.0.tgz", + "integrity": "sha512-+EnKy9rkYPun4l+kG2bDuYWQ6y1tGVgdR/tY1U9AC6h21CjEwOoc7gsjwe0FXB8uWFzk4QiCFbuRWgX758PiAg==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/eslint-plugin": "8.71.2", - "@typescript-eslint/parser": "8.71.2", - "@typescript-eslint/typescript-estree": "8.71.2", - "@typescript-eslint/utils": "8.71.2" + "@typescript-eslint/eslint-plugin": "8.73.0", + "@typescript-eslint/parser": "8.73.0", + "@typescript-eslint/typescript-estree": "8.73.0", + "@typescript-eslint/utils": "8.73.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -4003,9 +3919,9 @@ } }, "node_modules/undici": { - "version": "8.12.3", - "resolved": "https://registry.npmjs.org/undici/-/undici-8.12.3.tgz", - "integrity": "sha512-+fdndUTwBP86cVjihTp21hZHo7d6oj1c/47XPA3lL8mM0XHs+C4EkcjmgRsFnFk2f/UONGDy9ItBItmXsLOQHw==", + "version": "8.13.1", + "resolved": "https://registry.npmjs.org/undici/-/undici-8.13.1.tgz", + "integrity": "sha512-Kt7EaPjh0s93lJH/PmW3d5rhkcpUa6fS3jqZ7+YGxNd9L7Xy/i827xe4C2uhhq+pJebM4tQOl5AgHmW11G5Skg==", "dev": true, "license": "MIT", "engines": { @@ -4030,9 +3946,9 @@ } }, "node_modules/uri-js-replace": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/uri-js-replace/-/uri-js-replace-1.0.1.tgz", - "integrity": "sha512-W+C9NWNLFOoBI2QWDp4UT9pv65r2w5Cx+3sTYFvtMdDBxkKt1syCqsUdSFAChbEe1uK5TfS04wt/nGwmaeIQ0g==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/uri-js-replace/-/uri-js-replace-1.0.3.tgz", + "integrity": "sha512-MMvVPvWo7I8nHX2Qn3+cji4YPAvEqBKjBoUqt7Z0RpE5hLdDpRLqaNfJtTwf56m40EQt2fJfptnrQdL2LXR99A==", "dev": true, "license": "MIT" }, @@ -4044,16 +3960,16 @@ "license": "MIT" }, "node_modules/vite": { - "version": "8.3.4", - "resolved": "https://registry.npmjs.org/vite/-/vite-8.3.4.tgz", - "integrity": "sha512-IftLE8phJhdNRIGNEV4JCCvfNScoZQVfcXaN8TQropWGJtOHcu+iAB9pHcuGvmEb/kddw0LBe/jS8ztdC6xdiQ==", + "version": "8.3.8", + "resolved": "https://registry.npmjs.org/vite/-/vite-8.3.8.tgz", + "integrity": "sha512-LzOn3h9rG/0vhLdXrV4yJ4QFA9eEoqCl+Yx+kGJd7aB9w6nfNgVHKSYwLPZUHrz4ZGa+t+kXjV9itvcHDLQouA==", "dev": true, "license": "MIT", "dependencies": { "lightningcss": "^1.33.0", "picomatch": "^4.0.7", - "postcss": "^8.5.29", - "rolldown": "~1.2.12", + "postcss": "^8.5.32", + "rolldown": "~1.2.18", "tinyglobby": "^0.2.17" }, "bin": { @@ -4070,7 +3986,7 @@ }, "peerDependencies": { "@types/node": "^20.19.0 || >=22.12.0", - "@vitejs/devtools": "^0.7.1", + "@vitejs/devtools": "^0.7.1 || ^0.8.0", "esbuild": "^0.27.0 || ^0.28.0", "jiti": ">=1.21.0", "less": "^4.0.0", @@ -4122,9 +4038,9 @@ } }, "node_modules/vitefu": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/vitefu/-/vitefu-1.1.3.tgz", - "integrity": "sha512-ub4okH7Z5KLjb6hDyjqrGXqWtWvoYdU3IGm/NorpgHncKoLTCfRIbvlhBm7r0YstIaQRYlp4yEbFqDcKSzXSSg==", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/vitefu/-/vitefu-1.1.4.tgz", + "integrity": "sha512-qbEIDswfXH3x3IYRMScl/bf1AVW0dn7Z8qkr7g7nohkusfuC7tcFa7t5EoTOz60AunosLM9sDrDjHxsX+Up+CQ==", "dev": true, "license": "MIT", "workspaces": [ @@ -4142,22 +4058,22 @@ } }, "node_modules/vitest": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/vitest/-/vitest-5.0.4.tgz", - "integrity": "sha512-z0WxZRV2Sg48wF0FSgMq3TFG8JS38/Qr96vZVZdX6+Em9raQTvnXQvdTFJe2m3rfyJnEHeHQ/snceIdi8D1pVg==", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-5.1.1.tgz", + "integrity": "sha512-trVmzUFOSraCZcI3uZIMD5FqBh4atFkC/XuJP/IU7qtyQay0FCs3Ia+0QiQ2JJwGyWG/xrcBoJNel2+O7kEZ0g==", "dev": true, "license": "MIT", "dependencies": { "@types/chai": "^5.2.2", - "@vitest/mocker": "5.0.4", + "@vitest/mocker": "5.1.1", "chai": "^6.3.0", "es-module-lexer": "^2.3.2", "expect-type": "^1.4.0", - "magic-string": "^1.4.3", + "magic-string": "^1.4.5", "obug": "^3.0.0", "picomatch": "^4.0.7", "std-env": "^4.3.0", - "tinybench": "^6.2.2", + "tinybench": "^6.2.3", "tinyexec": "^1.3.1", "tinyglobby": "^0.2.17", "why-is-node-running": "3.2.1" @@ -4175,12 +4091,12 @@ "@edge-runtime/vm": "*", "@opentelemetry/api": "^1.9.0", "@types/node": "^22.0.0 || >=24.0.0", - "@vitest/browser-playwright": "5.0.4", - "@vitest/browser-preview": "5.0.4", + "@vitest/browser-playwright": "5.1.1", + "@vitest/browser-preview": "5.1.1", "@vitest/browser-webdriverio": "^5.0.0-beta.5 || >=5.0.0", - "@vitest/coverage-istanbul": "5.0.4", - "@vitest/coverage-v8": "5.0.4", - "@vitest/ui": "5.0.4", + "@vitest/coverage-istanbul": "5.1.1", + "@vitest/coverage-v8": "5.1.1", + "@vitest/ui": "5.1.1", "happy-dom": "*", "jsdom": "*", "vite": "^6.4.0 || ^7.0.0 || ^8.0.0" @@ -4272,9 +4188,9 @@ } }, "node_modules/whatwg-url": { - "version": "17.2.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-17.2.0.tgz", - "integrity": "sha512-IhLIHNcBrzIixC5XXsbr4DxdjajyA5vQ5RwGZMtrUp+GbtE5Nrsge9QKau7jXrC0aTXLYGV0xiW7Tb4YS2aomw==", + "version": "17.3.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-17.3.0.tgz", + "integrity": "sha512-KwOAJrpf+GTgBvcBQJcP38sMF0DsQKdwtG+TxM2pW44P6E5k0hDbWrDmyuJDIF0Uef0aQq0ZoJs+5oI+k8ddhg==", "dev": true, "license": "MIT", "dependencies": { diff --git a/ui/package.json b/ui/package.json index 76338f5b7..45c6c4878 100644 --- a/ui/package.json +++ b/ui/package.json @@ -21,32 +21,32 @@ }, "devDependencies": { "@eslint/js": "^10.0.1", - "@playwright/test": "^1.64.0", + "@playwright/test": "^1.65.1", "@sveltejs/vite-plugin-svelte": "^7.3.1", - "@testing-library/jest-dom": "^7.0.1", + "@testing-library/jest-dom": "^8.0.0", "@testing-library/svelte": "^5.4.2", - "@tsconfig/svelte": "^5.0.8", + "@tsconfig/svelte": "^5.0.9", "@types/node": "^24.13.3", - "eslint": "^10.12.0", + "eslint": "^10.15.0", "eslint-config-prettier": "^10.1.8", - "eslint-plugin-svelte": "^3.23.1", - "globals": "^17.13.0", - "jsdom": "^30.1.2", + "eslint-plugin-svelte": "^3.24.1", + "globals": "^17.14.0", + "jsdom": "^31.0.1", "openapi-typescript": "^7.13.0", - "prettier": "^3.9.10", - "prettier-plugin-svelte": "^4.1.1", - "svelte": "^5.57.2", - "svelte-check": "^4.7.6", + "prettier": "^3.10.1", + "prettier-plugin-svelte": "^4.2.0", + "svelte": "^5.59.1", + "svelte-check": "^4.7.8", "typescript": "~6.0.2", - "typescript-eslint": "^8.71.2", - "vite": "^8.3.4", - "vitest": "^5.0.4" + "typescript-eslint": "^8.73.0", + "vite": "^8.3.8", + "vitest": "^5.1.1" }, "dependencies": { - "@lucide/svelte": "^1.55.0", - "bits-ui": "^2.19.5", + "@lucide/svelte": "^1.77.0", + "bits-ui": "^2.22.0", "monaco-editor": "^0.57.0", - "svelte-sonner": "^1.2.1" + "svelte-sonner": "^1.2.3" }, "allowScripts": { "fsevents@2.3.3": true, diff --git a/ui/src/lib/Breadcrumb.svelte b/ui/src/lib/Breadcrumb.svelte index d7f686c47..f796f839e 100644 --- a/ui/src/lib/Breadcrumb.svelte +++ b/ui/src/lib/Breadcrumb.svelte @@ -44,9 +44,10 @@ class="plain" href={crumb.href} in:fade={{ duration: prefersReducedMotion.current ? 0 : 150 }} - >{#if crumb.dot}<span class="dot" style:background={crumb.dot} - ></span>{/if}{crumb.label}</a > + {#if crumb.dot}<span class="dot" style:background={crumb.dot} + ></span>{/if}{crumb.label} + </a> {/key} {/each} </nav> diff --git a/ui/src/lib/BulkBar.svelte b/ui/src/lib/BulkBar.svelte index d42ba786d..c1e02d3bd 100644 --- a/ui/src/lib/BulkBar.svelte +++ b/ui/src/lib/BulkBar.svelte @@ -70,8 +70,10 @@ class="quiet" onclick={() => picks.clear()} disabled={busy} - title="deselect everything">Clear selection</button + title="deselect everything" > + Clear selection + </button> </div> {/if} @@ -80,8 +82,9 @@ class="quiet" onclick={() => picks.selectAll()} disabled={visible === 0} - >Select all{filterActive ? ' matching' : ''} ({visible})</button > + Select all{filterActive ? ' matching' : ''} ({visible}) + </button> </div> <style> diff --git a/ui/src/lib/CachesPanel.svelte b/ui/src/lib/CachesPanel.svelte index 5d546686e..004a7b8b2 100644 --- a/ui/src/lib/CachesPanel.svelte +++ b/ui/src/lib/CachesPanel.svelte @@ -144,9 +144,9 @@ class="disk" title="disk holding the {cache.name} cache" > - <span class="diskbar" - ><span style="width: {pct}%"></span></span - > + <span class="diskbar"> + <span style="width: {pct}%"></span> + </span> {gbFromBytes(cache.disk_free ?? 0)} / {gbFromBytes( cache.disk_total ?? 0, )} GB free @@ -236,9 +236,9 @@ : '—'} </td> <td> - <code title={entry.id} - >{entry.id.slice(0, 12)}</code - > + <code title={entry.id}> + {entry.id.slice(0, 12)} + </code> </td> <td> <button diff --git a/ui/src/lib/CardMemoryList.svelte b/ui/src/lib/CardMemoryList.svelte index bc6e284de..20ed0404f 100644 --- a/ui/src/lib/CardMemoryList.svelte +++ b/ui/src/lib/CardMemoryList.svelte @@ -13,13 +13,13 @@ <ul> {#each cards as c, i (c.device ?? i)} <li> - <span class="card" title={c.name ?? ''} - >{c.device ?? c.name ?? 'GPU'}</span - > + <span class="card" title={c.name ?? ''}> + {c.device ?? c.name ?? 'GPU'} + </span> {#if c.available} - <span class="num" - >{gb(c.allocatedMb)}{#if c.totalMb} / {gb(c.totalMb)}{/if} GB</span - > + <span class="num"> + {gb(c.allocatedMb)}{#if c.totalMb} / {gb(c.totalMb)}{/if} GB + </span> {#if c.freeMb != null} <span class="muted">{gb(c.freeMb)} GB free</span> {/if} @@ -30,9 +30,9 @@ <span class="muted">(this backend reports allocated only)</span> {/if} {#if !c.live && c.ageSeconds != null} - <span class="muted" title="the last reading; the card is busy" - >{Math.round(c.ageSeconds)}s ago</span - > + <span class="muted" title="the last reading; the card is busy"> + {Math.round(c.ageSeconds)}s ago + </span> {/if} {:else} <span class="muted">no reading yet</span> diff --git a/ui/src/lib/Sidebar.svelte b/ui/src/lib/Sidebar.svelte index 95191b77a..bb99d16e0 100644 --- a/ui/src/lib/Sidebar.svelte +++ b/ui/src/lib/Sidebar.svelte @@ -161,8 +161,9 @@ <span class="num muted size" title="{workspace.usage[name].files} files" - >{formatBytes(workspace.usage[name].bytes)}</span > + {formatBytes(workspace.usage[name].bytes)} + </span> {/if} </span> {/if} @@ -174,9 +175,9 @@ aria-current={wsSection === item.section ? 'page' : undefined} title={item.label} > - <item.icon size={15} />{#if !collapsed}<span class="label" - >{item.label}</span - >{/if} + <item.icon size={15} />{#if !collapsed}<span class="label"> + {item.label} + </span>{/if} </a> {/each} </div> @@ -192,9 +193,9 @@ <span class="dot"></span> <span class="name">{name}</span> {#if workspace.usage[name]} - <span class="num muted size" - >{formatBytes(workspace.usage[name].bytes)}</span - > + <span class="num muted size"> + {formatBytes(workspace.usage[name].bytes)} + </span> {/if} </a> {/if} @@ -254,8 +255,9 @@ class="bare muted hiddentoggle" aria-expanded={showHidden} onclick={() => (showHidden = !showHidden)} - ><Eye size={13} />{folded.hidden.length} hidden</button > + <Eye size={13} />{folded.hidden.length} hidden + </button> {#if showHidden} <div class="groupkids"> {#each folded.hidden as name (name)}{@render wsRow(name)}{/each} @@ -309,9 +311,9 @@ aria-current={sharedActive(item.section) ? 'page' : undefined} title={item.label} > - <item.icon size={15} />{#if !collapsed}<span class="label" - >{item.label}</span - >{/if} + <item.icon size={15} />{#if !collapsed}<span class="label"> + {item.label} + </span>{/if} </a> {/each} </div> @@ -326,9 +328,9 @@ aria-current={serverSection === item.section ? 'page' : undefined} title={item.label} > - <item.icon size={15} />{#if !collapsed}<span class="label" - >{item.label}</span - >{/if} + <item.icon size={15} />{#if !collapsed}<span class="label"> + {item.label} + </span>{/if} </a> {/each} </div> diff --git a/ui/src/lib/WorkerList.svelte b/ui/src/lib/WorkerList.svelte index fcad19bde..68532ac4e 100644 --- a/ui/src/lib/WorkerList.svelte +++ b/ui/src/lib/WorkerList.svelte @@ -25,14 +25,14 @@ <span class="muted">{w.vram_gb} GB</span> {/if} {#if w.host_memory_rss_mb != null} - <span class="muted" title="resident host memory of the worker process" - >{(w.host_memory_rss_mb / 1024).toFixed(1)} GB RSS</span - > + <span class="muted" title="resident host memory of the worker process"> + {(w.host_memory_rss_mb / 1024).toFixed(1)} GB RSS + </span> {/if} {#if w.current_job} - <a href={'#/jobs/' + w.current_job} onclick={() => onnavigate?.()} - >{w.current_job} →</a - > + <a href={'#/jobs/' + w.current_job} onclick={() => onnavigate?.()}> + {w.current_job} → + </a> {/if} </li> {/each} diff --git a/ui/src/lib/assets/AssetDetail.svelte b/ui/src/lib/assets/AssetDetail.svelte index 8dc824dd5..208c4bca6 100644 --- a/ui/src/lib/assets/AssetDetail.svelte +++ b/ui/src/lib/assets/AssetDetail.svelte @@ -60,17 +60,17 @@ href={asset.url} target="_blank" class="muted" - title="open the file itself in a new tab">open file</a - > - <span class="num muted" - >{asset.kind} · {formatBytes(asset.size)} · {formatMtime( - asset.mtime, - )}</span + title="open the file itself in a new tab" > + open file + </a> + <span class="num muted"> + {asset.kind} · {formatBytes(asset.size)} · {formatMtime(asset.mtime)} + </span> {#if asset.origin === 'examples'} - <span class="muted" title="read-only: an examples library brought it" - >read-only</span - > + <span class="muted" title="read-only: an examples library brought it"> + read-only + </span> {:else} <button class="quiet icon danger" @@ -87,8 +87,10 @@ class="quiet icon" onclick={onclose} title="close details" - aria-label="close details"><X size={14} /></button + aria-label="close details" > + <X size={14} /> + </button> </div> {#if keptFrom} <p class="usedby muted">{keptFrom}</p> @@ -98,8 +100,9 @@ used by {#each asset.used_by as name, i (name)}{i ? ', ' : ''}<a href={wsHref(workspace.current, 'workflows', ...name.split('/'))} - >{name}</a - >{/each} + > + {name} + </a>{/each} </p> {/if} <NoteEditor diff --git a/ui/src/lib/assets/LibraryRow.svelte b/ui/src/lib/assets/LibraryRow.svelte index d50507398..75f5f8e1c 100644 --- a/ui/src/lib/assets/LibraryRow.svelte +++ b/ui/src/lib/assets/LibraryRow.svelte @@ -34,9 +34,9 @@ <span class="path muted">{section.root}</span> <span class="flex"></span> {#if !section.writable} - <span class="muted" title="read-only: this server cannot write to it" - >read-only</span - > + <span class="muted" title="read-only: this server cannot write to it"> + read-only + </span> {:else if section.origin === 'common' && shared} <!-- Only on the Shared assets page: a workspace's page shows just the shared assets its workflows use, so an upload there would vanish diff --git a/ui/src/lib/assets/MediaPicker.svelte b/ui/src/lib/assets/MediaPicker.svelte index 751284bc9..bfb7b30ea 100644 --- a/ui/src/lib/assets/MediaPicker.svelte +++ b/ui/src/lib/assets/MediaPicker.svelte @@ -164,14 +164,18 @@ class="quiet" class:on={tab === 'assets'} aria-pressed={tab === 'assets'} - onclick={() => (tab = 'assets')}>Assets</button + onclick={() => (tab = 'assets')} > + Assets + </button> <button class="quiet" class:on={tab === 'outputs'} aria-pressed={tab === 'outputs'} - onclick={() => (tab = 'outputs')}>Earlier runs</button + onclick={() => (tab = 'outputs')} > + Earlier runs + </button> </div> <input class="search" diff --git a/ui/src/lib/assets/ShadowedAssets.svelte b/ui/src/lib/assets/ShadowedAssets.svelte index 036ca3a89..65ae3d0d1 100644 --- a/ui/src/lib/assets/ShadowedAssets.svelte +++ b/ui/src/lib/assets/ShadowedAssets.svelte @@ -22,9 +22,9 @@ not serve these, so a tile is a dimmed label rather than a picture, and nothing bulk can reach it --> <div class="grouprow"> - <span class="group" - >shadowed/ <span class="muted">({entries.length})</span></span - > + <span class="group"> + shadowed/ <span class="muted">({entries.length})</span> + </span> </div> <div class="grid"> {#each entries as entry (entry.name)} diff --git a/ui/src/lib/editor/ArgumentsEditor.svelte b/ui/src/lib/editor/ArgumentsEditor.svelte index e0e9917cf..5eeac4b31 100644 --- a/ui/src/lib/editor/ArgumentsEditor.svelte +++ b/ui/src/lib/editor/ArgumentsEditor.svelte @@ -200,9 +200,9 @@ > <Plus size={14} /> </button> - <span class="availname" - >{parameter.name}{parameter.required ? ' *' : ''}</span - > + <span class="availname"> + {parameter.name}{parameter.required ? ' *' : ''} + </span> {#if parameter.description} <div class="muted availdesc"> <ClampedText text={parameter.description} lines={2} /> diff --git a/ui/src/lib/editor/EnhancePanel.svelte b/ui/src/lib/editor/EnhancePanel.svelte index b8aaf7ead..ab43f01be 100644 --- a/ui/src/lib/editor/EnhancePanel.svelte +++ b/ui/src/lib/editor/EnhancePanel.svelte @@ -41,13 +41,13 @@ /> {#if enhancer.model} {#if enhancer.modelCached} - <span class="chip good" title="already in the local model cache" - >cached</span - > + <span class="chip good" title="already in the local model cache"> + cached + </span> {:else if enhancer.downloading} - <span class="chip" title="downloading to the local model cache" - >downloading…</span - > + <span class="chip" title="downloading to the local model cache"> + downloading… + </span> {:else} <button class="quiet withicon" @@ -93,9 +93,9 @@ <a class="muted joblink" href={'#/jobs/' + enhancer.jobId}>watch job</a> {/if} {#if enhancer.status} - <span class="muted enhancestatus" - ><span class="pulse-dot"></span>{enhancer.status}</span - > + <span class="muted enhancestatus"> + <span class="pulse-dot"></span>{enhancer.status} + </span> {/if} </div> {#if enhancer.error}<p class="error">{enhancer.error}</p>{/if} diff --git a/ui/src/lib/editor/FlowSegments.svelte b/ui/src/lib/editor/FlowSegments.svelte index f571d8614..eb1517ff1 100644 --- a/ui/src/lib/editor/FlowSegments.svelte +++ b/ui/src/lib/editor/FlowSegments.svelte @@ -68,22 +68,22 @@ <text x="15" y={y + 11} class="chiplabel">segment {i + 1}</text> {#if i === 0 && node.chain?.anchor} <g> - <title - >segment 1's latents anchor every later segment's (chain anchor: - segment_1) - anchor + + segment 1's latents anchor every later segment's (chain anchor: + segment_1) + + + anchor + {/if} {#if i < chips - 1 && node.chain} - {#if `↓ ${node.chain.seam}`.length > SEAM_CHARS}{node.chain.seam}{/if}{fit(`↓ ${node.chain.seam}`, SEAM_CHARS, 'head')} + + {#if `↓ ${node.chain.seam}`.length > SEAM_CHARS} + {node.chain.seam} + {/if}{fit(`↓ ${node.chain.seam}`, SEAM_CHARS, 'head')} + {/if} {/each} diff --git a/ui/src/lib/editor/FlowView.svelte b/ui/src/lib/editor/FlowView.svelte index d399bf465..9a2c407bf 100644 --- a/ui/src/lib/editor/FlowView.svelte +++ b/ui/src/lib/editor/FlowView.svelte @@ -237,10 +237,11 @@ crosses it rather than the line striking the label through --> {#each layout.edgeLines ?? [] as edge, i (i)} {#if edge} - {#if edge.label !== edge.title}{edge.title}{/if}{edge.label} + + {#if edge.label !== edge.title} + {edge.title} + {/if}{edge.label} + {/if} {/each} @@ -269,28 +270,28 @@ {overflowTitle(node)} {/if} - {fit( + + {fit( node.name, node.isEntryPoint ? NAME_CHARS_WITH_TAG : NAME_CHARS, 'head', - )} + )} + {kindLabel(node.kind)} {#if stateOf(node.name) === 'done' && nodeTimes[node.name] !== undefined} - {formatDuration(nodeTimes[node.name])} + + {formatDuration(nodeTimes[node.name])} + {/if} {#if node.detail} - {fit(node.detail, DETAIL_CHARS, 'tail')} + + {fit(node.detail, DETAIL_CHARS, 'tail')} + {/if} {#if node.isEntryPoint} - + {/if} {#if node.members?.length} - + : `copy of ${origin.startFrom}`} + {/if} {#each exampleGroups as [group, names] (group)} - {#each names as example (example)}{/each} + {#each names as example (example)}{/each} {/each} diff --git a/ui/src/lib/gallery/GalleryDetail.svelte b/ui/src/lib/gallery/GalleryDetail.svelte index fe1625d1f..5407063a0 100644 --- a/ui/src/lib/gallery/GalleryDetail.svelte +++ b/ui/src/lib/gallery/GalleryDetail.svelte @@ -228,20 +228,22 @@ href={file.url} target="_blank" class="muted" - title="open the file itself in a new tab">open file + open file + {#if file.version} - version {file.version} · {file.run_id} + + version {file.version} · {file.run_id} + {/if} - {formatBytes(file.size)} · {formatMtime(file.mtime)} + + {formatBytes(file.size)} · {formatMtime(file.mtime)} + + + + +
{#if file.kind === 'image'} @@ -288,9 +293,9 @@ label="Run note" onsaved={() => onnotesaved?.('run')} /> - + {:else} {inputName(input)} + {inputName(input)} + {input.kind} diff --git a/ui/src/lib/gallery/RequestFilter.svelte b/ui/src/lib/gallery/RequestFilter.svelte index 36c869c79..32a3326d8 100644 --- a/ui/src/lib/gallery/RequestFilter.svelte +++ b/ui/src/lib/gallery/RequestFilter.svelte @@ -52,10 +52,11 @@ class="plain" href={wsHref(workspace.current, 'requests', request)} title={title ? `${title} - open this request` : 'open this request'} - >{#if item}{request} › {item}{:else}request {request}{/if} + {#if item}{request} › {item}{:else}request + {request} + {/if} + + + {:else if requests.length} @@ -446,13 +433,15 @@ {' '}{/if}{#if file.starred} + aria-label="Has a note" + > + + {/if}{#if file.starred} - {' '}{/if} + {' '} + + {/if} +
{/snippet} diff --git a/ui/src/lib/pages/JobPage.svelte b/ui/src/lib/pages/JobPage.svelte index 07cd18de8..1b1636d3a 100644 --- a/ui/src/lib/pages/JobPage.svelte +++ b/ui/src/lib/pages/JobPage.svelte @@ -340,8 +340,9 @@ title={realized ? 'this is the realized copy the run itself wrote - every mutable input pinned to the value it used' : 'this is the definition as submitted - no realized copy of this run is on file'} - >{realized ? 'realized' : 'as submitted'} + {realized ? 'realized' : 'as submitted'} + {requestLabel(requestScope)} + {requestLabel(requestScope)} + + + {/if} @@ -266,15 +270,16 @@ {#each banners as banner (banner.batch)}
- {`${banner.count} ${banner.count === 1 ? 'job was' : 'jobs were'} cancelled by a server restart`} + + {`${banner.count} ${banner.count === 1 ? 'job was' : 'jobs were'} cancelled by a server restart`} + + Rerun… +
{/each} @@ -308,13 +313,14 @@ v{job.run_version} + v{job.run_version} + {/if} {#if job.rerun_of} - rerun + + rerun + {/if} {#if job.request} {requestLabel({ + > + {requestLabel({ request: job.request, item: job.item ?? '', - })} + })} + {/if} {#if scope === 'all' && (workspace.names?.length ?? 0) > 1} - {job.workspace} + + {job.workspace} + {/if} {#if job.device} - {job.device} + + {job.device} + {/if} {#if job.acknowledged === 'bound'} acknowledged + acknowledged + {/if} {#if job.queue_position !== undefined} - #{job.queue_position + 1} + + #{job.queue_position + 1} + {#if queueSize > 1} {#if job.queue_position > 0} @@ -393,22 +402,23 @@ title={job.created_at ? `queued ${formatExact(job.created_at)} - time spent waiting for a card` : 'time spent waiting for a card'} - >waiting {wait === null ? '' : formatDuration(wait)} + waiting {wait === null ? '' : formatDuration(wait)} + {#if job.waiting_for} {@const kind = holdKind(job.waiting_for)} - · {kind === 'host_ram' + + · {kind === 'host_ram' ? 'host RAM' : kind === 'cards_busy' ? 'cards busy' - : 'held'} + : 'held'} + {/if} {:else} - {when(job.started_at)} + + {when(job.started_at)} + {/if} {duration(job)} {job.id} diff --git a/ui/src/lib/pages/OverviewPage.svelte b/ui/src/lib/pages/OverviewPage.svelte index c1469fd18..caf82b34a 100644 --- a/ui/src/lib/pages/OverviewPage.svelte +++ b/ui/src/lib/pages/OverviewPage.svelte @@ -181,19 +181,19 @@

- Recent outputs + + Recent outputs +

{#if recentError}

Could not load recent outputs: {recentError}

{:else if recent === null} {:else if recent.length === 0} - {#snippet icon()}{/snippet}Nothing - generated yet — run a workflow. + + {#snippet icon()}{/snippet}Nothing + generated yet — run a workflow. + {:else}
{#each recent as file (file.name)} @@ -211,9 +211,9 @@ src={api.galleryThumbnailUrl(file.name)} alt={file.label} loading="lazy" - /> + /> {:else}{file.label}{/if} {/each} @@ -224,22 +224,22 @@ {#if openRequests.length}

- Requests + + Requests + all requests

    {#each openRequests as req (req.id)}
  • - {req.title} + + {req.title} + {attention(req).text} - {doneFigure(req)} + + {doneFigure(req)} +
  • {/each}
@@ -254,19 +254,19 @@ {:else if recentJobs === null} {:else if recentJobs.length === 0 && !running} - {#snippet icon()}{/snippet}No jobs - yet. + + {#snippet icon()}{/snippet}No jobs + yet. + {:else}
    {#if running}
  • running {running.workflow} - {running.id} + + {running.id} +
  • {/if} {#each recentJobs as job (job.id)} @@ -282,27 +282,29 @@

    - Workflows + + Workflows + {#if workflows}{workflows.length}{/if} + +

    {#if workflowsError}

    Could not load workflows: {workflowsError}

    {:else if workflows === null} {:else if workflows.length === 0} - {#snippet icon()}{/snippet}No - workflows yet — create one in the editor, or run an example. + + {#snippet icon()}{/snippet}No + workflows yet — create one in the editor, or run an example. + {:else}
    {#each featured as wf (wf)} @@ -321,9 +323,9 @@ src={api.galleryThumbnailUrl(proofs[wf].name)} alt="" loading="lazy" - />{/if} + />{/if} {/if} {leaf(wf)} diff --git a/ui/src/lib/pages/PromptEditorPage.svelte b/ui/src/lib/pages/PromptEditorPage.svelte index a1c1cf1db..1a50c4a0d 100644 --- a/ui/src/lib/pages/PromptEditorPage.svelte +++ b/ui/src/lib/pages/PromptEditorPage.svelte @@ -281,9 +281,9 @@ .json in {promptDir} {#if shell.savePath()} - prompt:{shell.savePath()} + + prompt:{shell.savePath()} + (shell.doc.text = e.currentTarget.value)} > - + + {#if refs.length || extra} +
    + About + {#if refs.length} + {@render chips()} + {:else} + {about} + {/if} + {@render extra?.()} +
    + {/if} + {#if wordless && refs.length} +

    {NEEDS_WORDS}

    + {/if}

    {listening ? LISTENING_LINE : NOT_LISTENING_LINE} {#if draft.length > COUNT_FROM} @@ -234,27 +248,29 @@

    - + {saving ? 'Saving…' : listening ? 'Send to agent' : 'Save note'} + +
    {:else} + {#if note}

    {note.text}

    - {@render chips()} + {#if refs.length} +
    + About + {@render chips()} +
    + {/if} {#if line}

    {line.text}

    {/if} - {:else} - {@render chips()} {/if} {#if kept}

    You have an unsaved draft.

    {/if} {#if editable} @@ -265,19 +281,22 @@ bind:this={opener} onclick={edit} disabled={saving} - >{kept + > + {kept ? 'Continue the draft' : note ? 'Edit note' - : 'Add a note for the agent'} + : 'Add a note for the agent'} + {#if note && ondelete} + Delete note + {/if}
    {/if} @@ -286,9 +305,9 @@ {/if} @@ -308,12 +327,26 @@ font-size: var(--t-sm); margin: var(--space-1) 0 0; } + .about { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: var(--space-1) var(--space-2); + margin: var(--space-1) 0; + font-size: var(--t-sm); + } + .aboutlabel { + color: var(--muted); + font-size: var(--t-xs); + text-transform: uppercase; + letter-spacing: 0.04em; + } .refs { list-style: none; display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-2); - margin: var(--space-1) 0; + margin: 0; padding: 0; } .refs li { @@ -325,6 +358,13 @@ padding: 0.1rem; color: var(--muted); } + /* Outlined like every button but the page's one filled one, and at full + strength once there is something to send, so ready and not-yet differ + by more than the disabled fade */ + .send:not(:disabled) { + color: var(--ink); + border-color: var(--muted); + } .actions { display: flex; gap: var(--space-2); diff --git a/ui/src/lib/request/ItemNote.test.ts b/ui/src/lib/request/ItemNote.test.ts index fe1d1e499..2d935cc0e 100644 --- a/ui/src/lib/request/ItemNote.test.ts +++ b/ui/src/lib/request/ItemNote.test.ts @@ -7,6 +7,7 @@ import { } from '@testing-library/svelte' import { afterEach, beforeEach, expect, it, vi } from 'vitest' import ItemNote from './ItemNote.svelte' +import { NEEDS_WORDS } from './noteState' import { ApiError } from '../apiErrors' const confirmDialog = vi.hoisted(() => vi.fn()) @@ -80,7 +81,7 @@ it('says Send to agent while a session is listening, and saves either way', asyn await waitFor(() => expect(given.onsave).toHaveBeenCalledWith('cooler')) }) -it('a new note shows what it is about, and a reference comes off before it is saved', async () => { +it('a new note shows what it is about under About, below its words, and a reference comes off before it is saved', async () => { const { createRawSnippet } = await import('svelte') const onremoveref = vi.fn() const take = { item: 's3', job: 'j2', output: 'run/s3.mp4' } @@ -90,6 +91,16 @@ it('a new note shows what it is about, and a reference comes off before it is sa render: () => `${ref().job ?? ref().item}`, })), }) + // closed: no chip, so nothing reads as a note already sent + expect(document.querySelectorAll('.chip')).toHaveLength(0) + await fireEvent.click( + screen.getByRole('button', { name: 'Add a note for the agent' }), + ) + // the words come first; what the note is about follows, labelled + const about = screen.getByText('About') + expect( + box().compareDocumentPosition(about) & Node.DOCUMENT_POSITION_FOLLOWING, + ).toBeTruthy() expect( [...document.querySelectorAll('.chip')].map((c) => c.textContent), ).toEqual(['j2', 's5']) @@ -106,7 +117,7 @@ it('shows a saved note with the line about where it stands', () => { expect(screen.getByRole('button', { name: 'Delete note' })).toBeTruthy() }) -it('saves the draft; a saved note emptied is deleted, an empty new one not sent', async () => { +it('saves the draft; a saved note emptied is deleted', async () => { const given = await draft('needs more red') given.onsave.mockResolvedValue(undefined) await fireEvent.click(screen.getByRole('button', { name: 'Save note' })) @@ -119,11 +130,47 @@ it('saves the draft; a saved note emptied is deleted, an empty new one not sent' await fireEvent.click(screen.getByRole('button', { name: 'Save note' })) await waitFor(() => expect(cleared.ondelete).toHaveBeenCalledTimes(1)) expect(cleared.onsave).not.toHaveBeenCalled() - cleanup() +}) + +it('a new note cannot be sent without words: the button waits, Ctrl+Enter does nothing, the box stays open', async () => { const empty = await draft(' ') - await fireEvent.click(screen.getByRole('button', { name: 'Save note' })) - await noBox() + const send = screen.getByRole('button', { + name: 'Save note', + }) as HTMLButtonElement + expect(send.disabled).toBe(true) + await fireEvent.keyDown(box(), { key: 'Enter', ctrlKey: true }) + expect(box()).toBeTruthy() expect(empty.onsave).not.toHaveBeenCalled() + await fireEvent.input(box(), { target: { value: 'warmer' } }) + expect(send.disabled).toBe(false) +}) + +it('a reference with no words says the note needs words, until it has some', async () => { + render(ItemNote, props(null, { refs: [{ item: 's5' }] })) + await fireEvent.click( + screen.getByRole('button', { name: 'Add a note for the agent' }), + ) + expect(screen.getByText(NEEDS_WORDS)).toBeTruthy() + await fireEvent.input(box(), { target: { value: 'lower the camera' } }) + expect(screen.queryByText(NEEDS_WORDS)).toBeNull() +}) + +it('a new note with no reference and no picker shows no About line', async () => { + await draft('') + expect(screen.queryByText('About')).toBeNull() + expect(screen.queryByText(NEEDS_WORDS)).toBeNull() +}) + +it('a saved note lists what it is about under About', async () => { + const { createRawSnippet } = await import('svelte') + render(ItemNote, { + ...props('warmer', { refs: [{ item: 's5' }] }), + chip: createRawSnippet((ref: () => { item: string }) => ({ + render: () => `${ref().item}`, + })), + }) + expect(screen.getByText('About')).toBeTruthy() + expect(document.querySelector('.chip')?.textContent).toBe('s5') }) it('Ctrl+Enter saves', async () => { diff --git a/ui/src/lib/request/ItemProof.svelte b/ui/src/lib/request/ItemProof.svelte index 5c7cd77d4..db348c67a 100644 --- a/ui/src/lib/request/ItemProof.svelte +++ b/ui/src/lib/request/ItemProof.svelte @@ -69,8 +69,9 @@ role={alt ? 'img' : undefined} aria-label={alt || undefined} aria-hidden={alt ? undefined : 'true'} - >{output.kind === 'text' ? '¶' : '♪'} + {output.kind === 'text' ? '¶' : '♪'} + {:else if shown === 'running'} {:else} @@ -85,15 +86,19 @@ class:slot={!output} class:picked {href} - title="open the job">{@render inside()} + {@render inside()} + {:else} {@render inside()} + {@render inside()} + {/if} diff --git a/ui/src/lib/request/NoteList.test.ts b/ui/src/lib/request/NoteList.test.ts index f7cceef68..271e67d0a 100644 --- a/ui/src/lib/request/NoteList.test.ts +++ b/ui/src/lib/request/NoteList.test.ts @@ -150,19 +150,24 @@ it("the request's box picks any live item, once each, as a reference", async () await fireEvent.click( screen.getByRole('button', { name: 'Add a note for the agent' }), ) - const picker = screen.getByLabelText( - 'Add an item to the note', - ) as HTMLSelectElement - expect([...picker.options].map((o) => o.textContent)).toEqual([ - 'About an item…', - 'Shot 3', - 'Shot 5', + const picker = () => + screen.getByLabelText('Add an item this note is about') as HTMLSelectElement + // keyed, so an item reads as a reference and not as a suggested note + expect([...picker().options].map((o) => o.textContent)).toEqual([ + '+ Add an item', + 's3 · Shot 3', + 's5 · Shot 5', ]) - for (const key of ['s5', 's3', 's5']) { - picker.value = key - await fireEvent.change(picker) - } - expect(picker.value).toBe('') + picker().value = 's5' + await fireEvent.change(picker()) + expect(picker().value).toBe('') + // a picked item is not offered again + expect([...picker().options].map((o) => o.value)).toEqual(['', 's3']) + picker().value = 's3' + await fireEvent.change(picker()) + // every item picked: the control goes, the About line stays + expect(screen.queryByLabelText('Add an item this note is about')).toBeNull() + expect(screen.getByText('About')).toBeTruthy() const chips = screen .getByRole('list', { name: 'What the note is about' }) .querySelectorAll('.ref') diff --git a/ui/src/lib/request/NoteRef.svelte b/ui/src/lib/request/NoteRef.svelte index 28b70baad..a90459ed5 100644 --- a/ui/src/lib/request/NoteRef.svelte +++ b/ui/src/lib/request/NoteRef.svelte @@ -34,9 +34,9 @@ {#if ref.gone} {label} {:else if !ref.job && ongo} - + {:else if ref.output} {label} {:else} diff --git a/ui/src/lib/request/PlanChanges.svelte b/ui/src/lib/request/PlanChanges.svelte index 90fbcbdac..bd0fc6df1 100644 --- a/ui/src/lib/request/PlanChanges.svelte +++ b/ui/src/lib/request/PlanChanges.svelte @@ -33,9 +33,9 @@

    r{entry.revision} - {formatMtime(seconds(entry.at))} + + {formatMtime(seconds(entry.at))} + {who(entry)} {#if turned}{turned}{/if}

    @@ -71,8 +71,9 @@ (opened = opened.includes(id) ? opened.filter((r) => r !== id) : [...opened, id])} - >{opened.includes(id) ? 'hide' : 'show'} + {opened.includes(id) ? 'hide' : 'show'} +

    {#if opened.includes(id)}
    @@ -91,8 +92,9 @@ class="bare fold" aria-expanded={all} onclick={() => (all = !all)} - >{all ? 'show fewer' : `show all ${changes.length}`} + {all ? 'show fewer' : `show all ${changes.length}`} + {/if}
    diff --git a/ui/src/lib/request/PlanItems.svelte b/ui/src/lib/request/PlanItems.svelte index e6a7ff88a..d07a35c0a 100644 --- a/ui/src/lib/request/PlanItems.svelte +++ b/ui/src/lib/request/PlanItems.svelte @@ -21,6 +21,7 @@ import { handleId, Reorder } from './reorder.svelte' import { moveTarget, type Direction, type Move } from './reorderMath' import RequestItem from './RequestItem.svelte' + import type { ReviewCountdown } from './review.svelte' // The plan as a list the user can edit: each row with its handle, its // menu and its one action, and - where an edit met the agent's - what @@ -36,6 +37,7 @@ onsay, onsee, onrun, + countdown, }: { store: PlanStore /** The request as the page shows it: the store's view */ @@ -53,6 +55,8 @@ onsee: (revision: number) => void /** Open the priced run dialog for one item; none, and no row offers it */ onrun?: (key: string) => void + /** The page's review countdowns, for a held row's chip */ + countdown?: ReviewCountdown } = $props() let list = $state() @@ -201,13 +205,24 @@ {#snippet action(row: ItemState)} {#if row.item.dropped} - + {:else if onrun && row.runnable} - onrun(row.item.key)}> + {row.display === 'ready' ? 'Run…' : 'Run again…'} + + {:else if onrun && row.canRetake} + + {/if} {/snippet} @@ -246,6 +261,7 @@ {menu} {notice} onaccept={(take, job) => accept(row, take, job)} + {countdown} /> {/snippet} diff --git a/ui/src/lib/request/RequestHeader.svelte b/ui/src/lib/request/RequestHeader.svelte index 2a844c2b4..28ed1f98b 100644 --- a/ui/src/lib/request/RequestHeader.svelte +++ b/ui/src/lib/request/RequestHeader.svelte @@ -4,9 +4,12 @@ import RequestProgress from './RequestProgress.svelte' import StateTag from './StateTag.svelte' import { CHIP, type PlanState } from './itemState' + import { listening } from './listening.svelte' import { notesWaiting } from './noteState' - import { standing } from './standing' - import { formatMinutes, formatSpent } from '../format' + import type { ReviewCountdown } from './review.svelte' + import { bannerText, holdGroup, runNowKeys } from './reviewText' + import { agentSaid, standing } from './standing' + import { formatMinutes, formatMtime, formatSpent } from '../format' import { requestQuery } from '../requestFilter' import { wsHref } from '../routes' import type { LedgerRequest } from '../types' @@ -22,6 +25,8 @@ onreload, actions, menu, + countdown, + onrunheld, }: { request: LedgerRequest plan: PlanState @@ -33,9 +38,16 @@ actions?: Snippet /** Beside the state: the request's own menu */ menu?: Snippet + /** The page's review countdowns, anchored to its reads */ + countdown?: ReviewCountdown + /** Open the run dialog for these held items: "Run now…" */ + onrunheld?: (keys: string[]) => void } = $props() const stand = $derived(standing(request, plan)) + // The agent's latest word: where an answer to a note, or "ready, not + // run", is said, so the page does not hide it in Plan changes + const said = $derived(agentSaid(request)) const waiting = $derived(notesWaiting(request)) const segments = $derived( plan.live.map((state) => ({ @@ -46,6 +58,29 @@ })), ) const open = $derived(request.state === 'open') + + // The review banner: one for the request, worded by its most urgent + // hold and by whether a session listens. Its digits tick, so it is not a + // live region: the page announces a change of its state once + const channel = $derived(listening(workspace)) + const hold = $derived(holdGroup(plan.held)) + const counting = $derived( + plan.held.some((r) => r.review?.state === 'holding'), + ) + $effect(() => { + if (counting && countdown) return countdown.hold() + }) + const left = $derived( + hold + ? (countdown?.left(hold.first.item.key) ?? + hold.first.review?.seconds_left ?? + 0) + : 0, + ) + const banner = $derived( + hold ? bannerText(hold, channel.listening, left) : null, + ) + const runNow = $derived(hold ? runNowKeys(hold, channel.listening) : [])
    @@ -58,6 +93,14 @@

    {stand.sentence}

    {#if stand.needs}

    {stand.needs}

    {/if} + {#if said} +

    + + The agent, r{said.revision} · {formatMtime(Date.parse(said.at) / 1000)}: + + {said.why} +

    + {/if} {#if segments.length} {/if} @@ -75,15 +118,29 @@ {#if actions}
    {@render actions()}
    {/if} its jobs + its jobs + its outputs + its outputs +
+ {#if banner} +
+

{banner}

+ {#if runNow.length && onrunheld} + + {/if} +
+ {/if} + + screen.getByLabelText('Add an item this note is about') as HTMLSelectElement + picker().value = 'a' + await fireEvent.change(picker()) + picker().value = 'b' + await fireEvent.change(picker()) // an item's chip goes to its row await fireEvent.click(screen.getByRole('button', { name: 'Shot 5' })) expect(given.onselect).toHaveBeenCalledWith('b') @@ -227,3 +226,94 @@ it('has no filled button of its own, and a place for the one a page hands it', ( 'Run 1 ready…', ) }) + +const UNTIL = '2026-11-21T15:30:00+00:00' +const held = ( + key: string, + state: 'holding' | 'redirected' | 'due', + over: Partial = {}, +) => + item(key, { + title: `Shot ${key}`, + review: { until: UNTIL, state, seconds_left: 125 }, + ...over, + }) +const banner = (container: HTMLElement) => + container.querySelector('.hold p')?.textContent + +it('shows one hold banner, worded by its most urgent state, with Run now for the ready rows', async () => { + const onrunheld = vi.fn() + const { container } = render(RequestHeader, { + ...props([ + held('a', 'holding', { ready: true }), + held('b', 'holding'), + held('c', 'redirected'), + ]), + onrunheld, + }) + await waitFor(() => + expect(banner(container)).toMatch( + /^2 items held for your review\. No session is listening, so nothing will run at .+\. Run them here, or leave a note\.$/, + ), + ) + expect(container.querySelectorAll('.hold')).toHaveLength(1) + // not a live region: its digits would be read out every second + expect(container.querySelector('.hold')?.closest('[aria-live]')).toBeNull() + await fireEvent.click(screen.getByRole('button', { name: 'Run now…' })) + expect(onrunheld).toHaveBeenCalledWith(['a']) +}) + +it('has no Run now when no held row is ready, and no banner with nothing held', () => { + const { container, unmount } = render(RequestHeader, { + ...props([held('b', 'holding')]), + onrunheld: vi.fn(), + }) + expect(banner(container)).toMatch(/^1 item held for your review\./) + expect(screen.queryByRole('button', { name: 'Run now…' })).toBeNull() + unmount() + const free = render(RequestHeader, props([item('a', { ready: true })])) + expect(free.container.querySelector('.hold')).toBeNull() +}) + +it('counts down while a session listens, and says a redirect without a button', async () => { + api.notesChannel.mockResolvedValue({ listening: true, last_seen: null }) + const { container, unmount } = render(RequestHeader, { + ...props([held('a', 'holding', { ready: true, estimate_minutes: 3 })]), + onrunheld: vi.fn(), + }) + await waitFor(() => + expect(banner(container)).toMatch( + /^1 item held for your review \(about 3 min by the agent's estimate\)\. A session is listening: at .+ \(in 02:05\) it is told to run it, unless you leave a note\.$/, + ), + ) + expect(screen.getByRole('button', { name: 'Run now…' })).toBeTruthy() + unmount() + const redirected = render(RequestHeader, { + ...props([held('a', 'redirected', { ready: true })]), + onrunheld: vi.fn(), + }) + expect(banner(redirected.container)).toBe( + 'You left a note after these were held: the agent will revise before running.', + ) + expect(screen.queryByRole('button', { name: 'Run now…' })).toBeNull() + redirected.unmount() + api.notesChannel.mockResolvedValue({ listening: false, last_seen: null }) +}) + +it("says the agent's latest word under what needs the user, and nothing of it once closed", () => { + const history = [ + entry(1, 'agent', 'opened'), + entry(2, 'user', 'note added'), + entry(3, 'agent', 'board-01 now blue; awaiting go-ahead to draw'), + ] + const view = render(RequestHeader, props([item('a')], { history })) + const said = view.container.querySelector('.said') as HTMLElement + expect(said.textContent).toContain('The agent, r3') + expect(said.textContent).toContain('awaiting go-ahead to draw') + cleanup() + const closed = render( + RequestHeader, + props([item('a')], { history, state: 'done' }), + ) + expect(closed.container.querySelector('.said')).toBeNull() +}) diff --git a/ui/src/lib/request/RequestItem.svelte b/ui/src/lib/request/RequestItem.svelte index bd75ccede..56b608e35 100644 --- a/ui/src/lib/request/RequestItem.svelte +++ b/ui/src/lib/request/RequestItem.svelte @@ -22,6 +22,8 @@ type Take, } from './itemState' import { noteWaiting } from './noteState' + import type { ReviewCountdown } from './review.svelte' + import { chipText } from './reviewText' import { addRef } from './noteRefs' import { displayValue } from '../editor' import { wsHref } from '../routes' @@ -42,6 +44,7 @@ menu, notice, onaccept, + countdown, }: { row: ItemState request: LedgerRequest @@ -61,6 +64,8 @@ notice?: Snippet<[ItemState]> /** Accept a take as the result (null clears the choice) */ onaccept?: (take: Take, job: string | null) => void + /** The page's review countdowns: what a held row's chip counts down */ + countdown?: ReviewCountdown } = $props() /** What a row's menu can ask of it */ @@ -76,6 +81,9 @@ let chosen = $state(null) const open = $derived(chosen ?? opensByDefault(row, waitingNote)) + const held = $derived( + row.review ? chipText(row.review, countdown?.left(item.key) ?? null) : null, + ) const figure = $derived(figureOf(row)) const takes = $derived(takesLine(row)) const mark = $derived(row.display === 'done' ? resultMark(item) : null) @@ -117,10 +125,12 @@ {i ? ', ' : ''}{` (${CHIP[dep.display].word})`} ongo(dep.key)} > + {dep.title} + + {` (${CHIP[dep.display].word})`} + {/each} {/snippet} @@ -143,6 +153,7 @@ {item.title} {item.key} + {#if held}{held}{/if} {#if row.display === 'waiting'}

waits on {@render refs(row.blockers)}

@@ -155,9 +166,9 @@

{takes} {#if item.attempts.length > 1 && mark === 'accepted'} - + + {:else if item.attempts.length > 1 && mark === 'latest'} latest, none accepted {/if} @@ -173,7 +184,13 @@

{/if} - + + 0} + > - {chip.word} + + {chip.word} + {figure} {#if job || action} {#if job} - Open job + Open job + {/if} {@render action?.(row)} {/if} - {#if menu}{@render menu(row, { note: openNote })}{/if} + {#if menu} + {@render menu(row, { note: openNote })} + {/if} {#if notice}{@render notice(row)}{/if} @@ -210,7 +231,6 @@ @@ -221,21 +241,6 @@ {#if row.neededBy.length}

needed by: {@render refs(row.neededBy)}

{/if} - {#if item.workflow && args.length} -
- Runs {item.workflow} with {args.length} - {args.length === 1 ? 'argument' : 'arguments'} -
    - {#each args as [name, value] (name)} -
  • {name} = {displayValue(value)}
  • - {/each} -
-
- {:else if item.workflow} -

Runs {item.workflow} with no arguments

- {/if} + + {#if item.workflow && args.length} +
+ + Runs {item.workflow} with {args.length} + {args.length === 1 ? 'argument' : 'arguments'} + +
    + {#each args as [name, value] (name)} +
  • {name} = {displayValue(value)}
  • + {/each} +
+
+ {:else if item.workflow} +

Runs {item.workflow} with no arguments

+ {/if} @@ -291,6 +313,9 @@ .handle { grid-area: handle; } + .proofcell.under { + visibility: hidden; + } .proofcell { grid-area: proof; display: flex; @@ -361,6 +386,9 @@ .key { font-size: var(--t-xs); } + .held { + white-space: nowrap; + } .dropped { opacity: 0.72; } diff --git a/ui/src/lib/request/RequestItem.test.ts b/ui/src/lib/request/RequestItem.test.ts index 7b778c455..4589a4e68 100644 --- a/ui/src/lib/request/RequestItem.test.ts +++ b/ui/src/lib/request/RequestItem.test.ts @@ -193,7 +193,7 @@ it('with several takes and none accepted, opens and marks the latest as the resu 'take 3', ]) expect(takes[2].querySelector('.mark')?.textContent?.trim()).toBe( - 'shown as the result (latest)', + 'result (latest)', ) expect(takes[0].querySelector('.mark')).toBeNull() // a take that made nothing is a slot with its status in words @@ -205,11 +205,6 @@ it('with several takes and none accepted, opens and marks the latest as the resu ) // read-only: there is nothing to accept with yet expect(screen.queryByRole('button', { name: /accept/i })).toBeNull() - expect( - screen - .getByRole('link', { name: 'open these in the gallery' }) - .getAttribute('href'), - ).toBe('#/ws/studio/gallery?req=r1%2Fa') }) it('marks the accepted take, and stays closed', async () => { @@ -327,14 +322,13 @@ it('opened, says what it follows, what needs it and what it would run', async () expect(given.ongo).toHaveBeenCalledWith('cut') }) -it("links an item's jobs through the req filter", async () => { +it('an open item shows its takes once: the row picture steps aside, and the jobs and outputs links are in its menu', async () => { const { container } = render(RequestItem, props([withOutput('a', image)])) await fireEvent.click(title('Opening shot')) - expect( - within(container.querySelector('.more') as HTMLElement) - .getByRole('link', { name: 'its jobs' }) - .getAttribute('href'), - ).toBe('#/ws/studio/jobs?req=r1%2Fa') + expect(container.querySelector('.proofcell')?.classList).toContain('under') + const more = within(container.querySelector('.more') as HTMLElement) + expect(more.queryByRole('link', { name: 'its jobs' })).toBeNull() + expect(more.queryByRole('link', { name: /gallery/ })).toBeNull() }) const noted = (at: string) => @@ -562,3 +556,22 @@ it('a dropped item offers no "Note this take"', async () => { await fireEvent.click(title('Shot 3')) expect(screen.queryByRole('button', { name: /^Note take/ })).toBeNull() }) + +it('marks a held row with a chip: its countdown, a note left, or time up', () => { + const hold = (state: 'holding' | 'redirected' | 'due') => + item('a', { + ready: true, + review: { until: '2026-11-21T12:00:00+00:00', state, seconds_left: 125 }, + }) + const chip = (state: 'holding' | 'redirected' | 'due') => { + const { container, unmount } = render(RequestItem, props([hold(state)])) + const text = container.querySelector('.chip.held')?.textContent + unmount() + return text + } + expect(chip('holding')).toBe('held · 02:05') + expect(chip('redirected')).toBe('held · note left') + expect(chip('due')).toBe('review time up') + const { container } = render(RequestItem, props([item('a')])) + expect(container.querySelector('.chip.held')).toBeNull() +}) diff --git a/ui/src/lib/request/RunDialog.svelte b/ui/src/lib/request/RunDialog.svelte index 5520ab1a8..ef6fbf8a0 100644 --- a/ui/src/lib/request/RunDialog.svelte +++ b/ui/src/lib/request/RunDialog.svelte @@ -8,7 +8,14 @@ import Modal from '../ui/Modal.svelte' import Skeleton from '../ui/Skeleton.svelte' import type { PlanState } from './itemState' - import { afterwardsLine, planNotes, planSaid, type RunPlan } from './runPlan' + import { listening } from './listening.svelte' + import { + afterwardsLine, + heldLine, + planNotes, + planSaid, + type RunPlan, + } from './runPlan' import { RunQueue, type RunRow } from './runQueue.svelte' // The one way this page spends GPU time: every item priced before the @@ -92,6 +99,15 @@ ) const n = $derived(queue.chosen.length) + // A held item says that running it is the go-ahead, read off the plan + // as it is now: its review may end while the dialog is open + const channel = $derived(listening(workspace)) + const held = (key: string) => + heldLine( + plan.live.find((state) => state.item.key === key)?.review ?? null, + channel.listening, + ) + const quote = (row: RunRow) => describeEstimate(row.plan?.estimate ?? null) const said = (row: RunRow) => planSaid(row.candidate.planMinutes, row.plan?.estimate.minutes) @@ -118,6 +134,7 @@
    {#each rows as row (row.candidate.key)} {@const item = row.candidate} + {@const hold = held(item.key)}
  • {#if !run.single} @@ -134,6 +151,15 @@ {item.key} {item.workflow}
    + {#if hold} +

    + {#if hold.tone === 'warn'}

    + {/if}
    {#if row.state === 'pricing'} @@ -175,8 +201,9 @@ class="quiet" disabled={queue.busy} onclick={() => queue.accept(item.key)} - >Run at this price + Run at this price +

    {:else if row.state === 'failed'} @@ -210,14 +237,16 @@ class="bare" bind:this={cancel} onclick={() => (open = false)} - >{queue.queued.length ? 'Close' : 'Cancel'} + {queue.queued.length ? 'Close' : 'Cancel'} + + {queue.busy ? 'Queuing…' : `Run ${n}`} +
    @@ -293,9 +322,15 @@ align-items: center; gap: var(--space-1) var(--space-2); } - .quote :global(svg) { + .quote :global(svg), + .held :global(svg) { flex: none; } + .held { + display: flex; + align-items: center; + gap: var(--space-1) var(--space-2); + } .quote span { min-width: 0; flex: 1; diff --git a/ui/src/lib/request/RunDialog.test.ts b/ui/src/lib/request/RunDialog.test.ts index af2a64049..0341add63 100644 --- a/ui/src/lib/request/RunDialog.test.ts +++ b/ui/src/lib/request/RunDialog.test.ts @@ -10,8 +10,10 @@ import { afterEach, beforeEach, expect, it, vi } from 'vitest' import RunDialog from './RunDialog.svelte' import { attempt, doneItem, item, request } from './fixtures' import { planState } from './itemState' -import { ALL_CACHED, itemPlan, readyPlan } from './runPlan' -import type { Plan } from '../types' +import { listening } from './listening.svelte' +import { clockTime } from './reviewText' +import { ALL_CACHED, heldPlan, itemPlan, readyPlan } from './runPlan' +import type { LedgerReview, Plan } from '../types' const world = vi.hoisted(() => ({ validate: vi.fn(), @@ -341,3 +343,56 @@ it('cancelling queues nothing and drops the pricing still out', async () => { expect(signal?.aborted).toBe(true) expect(world.submitJob).not.toHaveBeenCalled() }) + +const UNTIL = '2026-11-21T15:30:00+00:00' +function openHeld(state: LedgerReview['state'], listens: boolean) { + listening('studio').listening = listens + const held = planState( + request([ + item('title', { + title: 'Title card', + ready: true, + workflow: 'card', + review: { until: UNTIL, state, seconds_left: 0 }, + }), + item('s4', { title: 'Shot 4', ready: true, workflow: 'shot' }), + ]), + ) + render(RunDialog, { + run: heldPlan(held, ['title']), + plan: held, + workspace: 'studio', + requestId: 'r1', + onclose: vi.fn(), + }) +} + +it('says on a held row that running it now is the go-ahead', async () => { + openHeld('holding', true) + await screen.findByRole('dialog', { name: 'Run what is ready' }) + const line = runRow('title').querySelector('.held') as HTMLElement + expect(line.textContent?.trim()).toBe( + `Held for review until ${clockTime(UNTIL)}. Running it now is your go-ahead.`, + ) + expect(line.classList.contains('warn')).toBe(false) + // only the held row is in this run + expect(runRow('s4')).toBeNull() + listening('studio').listening = false +}) + +it('warns on a held row whose review is up while a session listens', async () => { + openHeld('due', true) + await screen.findByRole('dialog', { name: 'Run what is ready' }) + const line = runRow('title').querySelector('.held') as HTMLElement + expect(line.textContent?.trim()).toBe( + 'Review time is up and a session is listening: it may be starting this now.', + ) + expect(line.classList.contains('warn')).toBe(true) + listening('studio').listening = false +}) + +it('has no held line on a row that is not held', async () => { + open() + await screen.findByRole('dialog', { name: 'Run what is ready' }) + expect(runRow('s4').querySelector('.held')).toBeNull() +}) diff --git a/ui/src/lib/request/announce.test.ts b/ui/src/lib/request/announce.test.ts index 9a8842b43..5121a02b7 100644 --- a/ui/src/lib/request/announce.test.ts +++ b/ui/src/lib/request/announce.test.ts @@ -77,3 +77,24 @@ it('counts the changes past three instead of reading them all out', () => { 'A is now ready to run. B is now ready to run. C is now ready to run. And 2 more changes.', ) }) + +it('says the review banner changed state once, and nothing as it ticks', () => { + const held = (state: 'holding' | 'redirected' | 'due', seconds_left = 60) => + request([ + item('a', { + title: 'Title card', + review: { until: '2026-11-21T12:00:00+00:00', state, seconds_left }, + }), + ]) + const free = request([item('a', { title: 'Title card' })]) + expect(announce(free, held('holding'))).toBe('1 item held for your review.') + // the same state with fewer seconds left: nothing to say + expect(announce(held('holding', 60), held('holding', 30))).toBe('') + expect(announce(held('holding'), held('redirected'))).toBe( + 'You left a note after these were held: the agent will revise before running.', + ) + expect(announce(held('holding'), held('due', 0))).toBe( + 'Review time is up for the held items.', + ) + expect(announce(held('due', 0), free)).toBe('') +}) diff --git a/ui/src/lib/request/announce.ts b/ui/src/lib/request/announce.ts index 11a1d94d1..e15a11383 100644 --- a/ui/src/lib/request/announce.ts +++ b/ui/src/lib/request/announce.ts @@ -3,6 +3,7 @@ // first read says nothing - there is no change to announce. import type { LedgerRequest } from '../types' import { planState, type ItemDisplay, type ItemState } from './itemState' +import { holdGroup, holdNews } from './reviewText' /** More changes than this in one refresh are counted, not listed */ const MAX_SENTENCES = 3 @@ -46,12 +47,18 @@ export function announce( next: LedgerRequest, ): string { if (!previous || previous.id !== next.id) return '' - const before = new Map( - planState(previous).items.map((state) => [state.item.key, state]), - ) - const said = planState(next) - .items.map((state) => itemChange(before.get(state.item.key), state)) + const was = planState(previous) + const now = planState(next) + const before = new Map(was.items.map((state) => [state.item.key, state])) + const said = now.items + .map((state) => itemChange(before.get(state.item.key), state)) .filter((sentence): sentence is string => sentence !== null) + // The review banner's state, said once when it changes (ahead of the + // item changes, so a busy refresh does not count it away); its + // countdown ticks on the page, never here + const hold = holdGroup(now.held) + if (hold && hold.state !== holdGroup(was.held)?.state) + said.unshift(holdNews(hold)) if (previous.state !== next.state) said.unshift(STATE[next.state]) if (said.length <= MAX_SENTENCES) return said.join(' ') const more = said.length - MAX_SENTENCES diff --git a/ui/src/lib/request/fixtures.ts b/ui/src/lib/request/fixtures.ts index 32365bc7a..545bbd627 100644 --- a/ui/src/lib/request/fixtures.ts +++ b/ui/src/lib/request/fixtures.ts @@ -32,6 +32,8 @@ export const item = ( attempts: [], result: null, spent_minutes: 0, + review_until: null, + review_set_at: null, ...over, }) diff --git a/ui/src/lib/request/intents.test.ts b/ui/src/lib/request/intents.test.ts index 7e7f52cd5..53fc48e55 100644 --- a/ui/src/lib/request/intents.test.ts +++ b/ui/src/lib/request/intents.test.ts @@ -258,3 +258,72 @@ it('shows an item the server deleted after a drop until the page forgets it', () // still in the plan: nothing to add expect(withGhosts(before, memory)).toBe(before) }) + +const HELD = '2030-01-01T00:00:00Z' +const heldPlan = (): LedgerRequest => + request([ + item('a', { review_until: HELD, review_set_at: '2029-12-31T00:00:00Z' }), + item('b', { ready: true }), + item('c', { ready: true }), + ]) + +it('an item restored from what the page remembers comes back unheld', () => { + const before = heldPlan() + const without = { ...before, items: before.items.slice(1) } + const sent = body( + { + kind: 'restore', + key: 'a', + memory: { item: before.items[0], before: null, dependents: [] }, + }, + without, + ) + expect(sent.items.find((i) => i.key === 'a')?.review_until).toBeNull() +}) + +it('an item restored from the stored dropped copy keeps its hold as read', () => { + const before = heldPlan() + const stored = { + ...before, + items: before.items.map((i) => + i.key === 'a' ? { ...i, dropped: true, status: 'dropped' as const } : i, + ), + } + const sent = body( + { + kind: 'restore', + key: 'a', + memory: { item: before.items[0], before: null, dependents: [] }, + }, + stored, + ) + expect(sent.items.find((i) => i.key === 'a')?.review_until).toBe(HELD) +}) + +it('every page write sends a held item hold back exactly as read', () => { + const intents: Intent[] = [ + { kind: 'move', key: 'c', before: 'a' }, + { kind: 'drop', key: 'b' }, + { kind: 'state', state: 'done' }, + { kind: 'state', state: 'abandoned' }, + ] + for (const intent of intents) { + const sent = body(intent, heldPlan()) + const a = sent.items.find((i) => i.key === 'a') + expect(a?.review_until, intent.kind).toBe(HELD) + expect(a?.review_set_at, intent.kind).toBe('2029-12-31T00:00:00Z') + } + const done = heldPlan() + done.items[0] = { + ...done.items[0], + status: 'done', + attempts: [attempt('j1')], + } + const accepted = body({ kind: 'accept', key: 'a', job: 'j1' }, done) + expect(accepted.items[0].review_until).toBe(HELD) + const reopened = body( + { kind: 'state', state: 'open' }, + { ...heldPlan(), state: 'done' }, + ) + expect(reopened.items[0].review_until).toBe(HELD) +}) diff --git a/ui/src/lib/request/intents.ts b/ui/src/lib/request/intents.ts index 6337f8cb4..afdd65cc0 100644 --- a/ui/src/lib/request/intents.ts +++ b/ui/src/lib/request/intents.ts @@ -186,8 +186,13 @@ function restore( if (find(request, key) && !stored.dropped) return no('no_change') const others = request.items.filter((item) => item.key !== key) const live = new Set(others.filter((i) => !i.dropped).map((i) => i.key)) + // An item the server deleted comes back as a new one: a held deadline + // would be restamped (re-arming a hold a note redirected) or refused as + // too soon, so it returns unheld. The stored dropped copy rides as read. + const fromMemory = !find(request, key) const item: LedgerItem = { ...stored, + ...(fromMemory ? { review_until: null } : {}), dropped: false, status: statusOf(stored), depends_on: stored.depends_on.filter((dep) => live.has(dep)), diff --git a/ui/src/lib/request/itemState.test.ts b/ui/src/lib/request/itemState.test.ts index 8a0bbbc9c..8cb4da14b 100644 --- a/ui/src/lib/request/itemState.test.ts +++ b/ui/src/lib/request/itemState.test.ts @@ -255,3 +255,26 @@ it('bands a plan by status, leaving dropped items out', () => { { tone: 'rest', count: 4, label: '4 not started' }, ]) }) + +it("exposes each live row's review hold, and the held rows, as the server says", () => { + const hold = (state: 'holding' | 'redirected' | 'due') => ({ + until: '2026-11-21T12:00:00+00:00', + state, + seconds_left: 30, + }) + const plan = planState( + request([ + item('a', { review: hold('holding') }), + item('b'), + item('c', { review: hold('due') }), + item('d', { dropped: true, status: 'dropped', review: hold('holding') }), + ]), + ) + expect(plan.items.map((s) => s.review?.state ?? null)).toEqual([ + 'holding', + null, + 'due', + null, + ]) + expect(plan.held.map((s) => s.item.key)).toEqual(['a', 'c']) +}) diff --git a/ui/src/lib/request/itemState.ts b/ui/src/lib/request/itemState.ts index 729982c04..2fd6cb859 100644 --- a/ui/src/lib/request/itemState.ts +++ b/ui/src/lib/request/itemState.ts @@ -3,7 +3,12 @@ // is read off one LedgerRequest: what a planned item waits on, whether a // failure was a cancel, which items want the user, which take is the result. import { formatMinutes, formatSpent } from '../format' -import type { LedgerAttempt, LedgerItem, LedgerRequest } from '../types' +import type { + LedgerAttempt, + LedgerItem, + LedgerRequest, + LedgerReview, +} from '../types' export type ItemDisplay = | 'ready' @@ -42,6 +47,9 @@ export type ItemState = { /** Done, and another take could be queued (from its menu only) */ canRetake: boolean needs: NeedsReason[] + /** The server's review hold on it, while one applies; null otherwise. + * Its `state` is the one shown: the page never derives its own */ + review: LedgerReview | null } export type PlanState = { @@ -50,6 +58,8 @@ export type PlanState = { dropped: ItemState[] counts: Record needs: Record + /** The live items held for the user's review, in plan order */ + held: ItemState[] } /** The chip's word, and the `.chip` class in app.css that colours it */ @@ -161,11 +171,13 @@ export function planState(request: LedgerRequest): PlanState { runnable: runnableNow(item, display, depsDone(item), open), canRetake: display === 'done' && open && item.workflow !== null, needs: needsOf(item, display, open), + review: (!item.dropped && item.review) || null, } }) const live = items.filter((state) => !state.item.dropped) const dropped = items.filter((state) => state.item.dropped) - return { items, live, dropped, ...tally(live, dropped.length) } + const held = live.filter((state) => state.review !== null) + return { items, live, dropped, held, ...tally(live, dropped.length) } } /** Whether a row starts expanded: something is happening to it, it went diff --git a/ui/src/lib/request/noteRefs.test.ts b/ui/src/lib/request/noteRefs.test.ts index 88c2ade94..2b68a6e5f 100644 --- a/ui/src/lib/request/noteRefs.test.ts +++ b/ui/src/lib/request/noteRefs.test.ts @@ -1,5 +1,11 @@ import { expect, it } from 'vitest' -import { addRef, refAttempt, refLabel, writtenRefs } from './noteRefs' +import { + addRef, + collapseRefs, + refAttempt, + refLabel, + writtenRefs, +} from './noteRefs' import { attempt, item, request } from './fixtures' const req = request([ @@ -14,8 +20,34 @@ it('adds a reference once: the same item, job and file are one', () => { const one = addRef([], take) expect(one).toEqual([take]) expect(addRef(one, { ...take, kind: 'video' as const })).toBe(one) - expect(addRef(one, { item: 's3', job: 'j2' })).toHaveLength(2) - expect(addRef(one, { item: 's3' })).toHaveLength(2) + // a take's file already says the take and the item: nothing to add + expect(addRef(one, { item: 's3', job: 'j2' })).toBe(one) + expect(addRef(one, { item: 's3' })).toBe(one) + // another take of the same item is its own reference + expect(addRef(one, { item: 's3', job: 'j1' })).toHaveLength(2) +}) + +it('a more specific reference takes the place of what it covers', () => { + const item3 = { item: 's3' } + const take2 = { item: 's3', job: 'j2' } + const file2 = { item: 's3', job: 'j2', output: 'run/s3.mp4' } + expect(addRef([item3], take2)).toEqual([take2]) + expect(addRef([item3, take2, { item: 's5' }], file2)).toEqual([ + file2, + { item: 's5' }, + ]) +}) + +it('shows one chip for a take and its file, and for an item and its take', () => { + const file2 = { item: 's3', job: 'j2', output: 'run/s3.mp4', attempt: 2 } + expect( + collapseRefs([ + { item: 's3', job: 'j2', attempt: 2 }, + file2, + { item: 's3' }, + ]), + ).toEqual([file2]) + expect(collapseRefs([{ item: 's5' }, { item: 's3' }])).toHaveLength(2) }) it('numbers a take by its place among the item’s attempts', () => { diff --git a/ui/src/lib/request/noteRefs.ts b/ui/src/lib/request/noteRefs.ts index 45e8a706e..364559764 100644 --- a/ui/src/lib/request/noteRefs.ts +++ b/ui/src/lib/request/noteRefs.ts @@ -8,10 +8,33 @@ const same = (a: LedgerNoteRef, b: LedgerNoteRef) => (a.job ?? null) === (b.job ?? null) && (a.output ?? null) === (b.output ?? null) -/** `refs` with `ref` added at the end, unless it names the same item, job - * and file as one already there: then `refs` as it was */ -export const addRef = (refs: LedgerNoteRef[], ref: LedgerNoteRef) => - refs.some((r) => same(r, ref)) ? refs : [...refs, ref] +/** Whether `wide` says no more than `narrow` does: the same item, and the + * same take where it names one, and the same file where it names one. A + * take's file covers the take, and a take covers its item */ +const covers = (narrow: LedgerNoteRef, wide: LedgerNoteRef) => + narrow.item === wide.item && + (!wide.job || narrow.job === wide.job) && + (!wide.output || narrow.output === wide.output) + +/** `refs` with `ref` added, unless one already there says as much or more + * (then `refs` as it was). What the new one covers - its item alone, its + * take without the file - goes, and it takes the first such place */ +export function addRef(refs: LedgerNoteRef[], ref: LedgerNoteRef) { + if (refs.some((r) => same(r, ref) || covers(r, ref))) return refs + const at = refs.findIndex((r) => covers(ref, r)) + const kept = refs.filter((r) => !covers(ref, r)) + if (at < 0) return [...kept, ref] + const place = refs.slice(0, at).filter((r) => !covers(ref, r)).length + return [...kept.slice(0, place), ref, ...kept.slice(place)] +} + +/** A saved note's references as chips: one for a take and its file, one + * for an item and its take, in the order written */ +export const collapseRefs = (refs: LedgerNoteRef[]) => + refs.filter( + (r, i) => + !refs.some((other, j) => j !== i && !same(other, r) && covers(other, r)), + ) /** The 1-based take a reference names: the server's `attempt`, or the * job's place among the item's attempts; null for an item alone or a job diff --git a/ui/src/lib/request/noteState.test.ts b/ui/src/lib/request/noteState.test.ts index 9665ce938..7fc82b805 100644 --- a/ui/src/lib/request/noteState.test.ts +++ b/ui/src/lib/request/noteState.test.ts @@ -69,7 +69,7 @@ it('says the agent has written since, never that it read the note', () => { }) const line = noteLine(note, req) expect(line.text).toBe( - `Saved ${shown(5)}. The agent has updated the plan 2 times since (latest r14, ${shown(14)}: “retook shot 3 warmer”).`, + `Saved ${shown(5)}. The agent has updated the plan 2 times since (latest r14, ${shown(14)}).`, ) expect(line.text).not.toMatch(/\bread\b/) expect(line.answered).toBe(true) diff --git a/ui/src/lib/request/noteState.ts b/ui/src/lib/request/noteState.ts index 7d8def18a..01c8d39cf 100644 --- a/ui/src/lib/request/noteState.ts +++ b/ui/src/lib/request/noteState.ts @@ -59,6 +59,11 @@ export const LISTENING_LINE = export const NOT_LISTENING_LINE = 'No agent session is listening. It reads this the next time it updates the plan.' +/** A new note that has references but no words yet: the references say + * what it is about, never what to change */ +export const NEEDS_WORDS = + 'Add a few words: the items under About say what the note is about, not what to change.' + /** Where a note is on the request page, for a link to it */ export const noteAnchor = (id: string) => `request-note-${id}` @@ -93,12 +98,14 @@ export function noteLine( text: `${saved} The agent has updated the plan since (${formatMtime(seconds(request.agent_wrote_at as string), now)}).`, answered, } + // What it said is the header's and Plan changes' to show: here, only + // that it has answered, and where to look const latest = since[since.length - 1] const times = since.length === 1 ? 'once' : `${since.length} times` return { text: `${saved} The agent has updated the plan ${times} since ` + - `(latest r${latest.revision}, ${formatMtime(seconds(latest.at), now)}: “${latest.why}”).`, + `(latest r${latest.revision}, ${formatMtime(seconds(latest.at), now)}).`, answered, } } diff --git a/ui/src/lib/request/review.svelte.test.ts b/ui/src/lib/request/review.svelte.test.ts new file mode 100644 index 000000000..0b09d94d2 --- /dev/null +++ b/ui/src/lib/request/review.svelte.test.ts @@ -0,0 +1,115 @@ +import { afterEach, beforeEach, expect, it, vi } from 'vitest' +import { item, request } from './fixtures' +import { ReviewCountdown, TICK_MS, Ticker } from './review.svelte' +import type { LedgerReview } from '../types' + +let hidden = false +beforeEach(() => { + vi.useFakeTimers() + vi.setSystemTime(new Date('2026-11-21T12:00:00Z')) + hidden = false + vi.spyOn(document, 'visibilityState', 'get').mockImplementation(() => + hidden ? 'hidden' : 'visible', + ) +}) +afterEach(() => { + vi.useRealTimers() + vi.restoreAllMocks() +}) + +// The server's deadline is a day off the browser's clock on purpose: the +// countdown must come from seconds_left, never from comparing with `until` +const review = ( + seconds_left: number, + state: LedgerReview['state'] = 'holding', +): LedgerReview => ({ until: '2026-11-22T12:00:00+00:00', state, seconds_left }) +const held = (seconds_left: number, state?: LedgerReview['state']) => + request([item('a', { review: review(seconds_left, state) }), item('b')]) + +it('counts down from the read plus seconds_left, not the deadline', async () => { + const clock = new Ticker() + const countdown = new ReviewCountdown(vi.fn(), clock) + countdown.read(held(90)) + const release = countdown.hold() + expect(countdown.left('a')).toBe(90) + expect(countdown.left('b')).toBeNull() + await vi.advanceTimersByTimeAsync(TICK_MS * 30) + expect(countdown.left('a')).toBe(60) + // a newer read re-anchors it + countdown.read(held(45)) + expect(countdown.left('a')).toBe(45) + release() +}) + +it('re-reads the request once when a countdown reaches zero', async () => { + const refresh = vi.fn() + const clock = new Ticker() + const countdown = new ReviewCountdown(refresh, clock) + countdown.read(held(3)) + const release = countdown.hold() + await vi.advanceTimersByTimeAsync(TICK_MS * 2) + expect(refresh).not.toHaveBeenCalled() + await vi.advanceTimersByTimeAsync(TICK_MS) + expect(countdown.left('a')).toBe(0) + expect(refresh).toHaveBeenCalledTimes(1) + // the re-read still says holding (the server's clock is a second behind): + // the page does not ask again for the same deadline + countdown.read(held(1)) + await vi.advanceTimersByTimeAsync(TICK_MS * 10) + expect(refresh).toHaveBeenCalledTimes(1) + release() +}) + +it('only counts down a holding row: a redirected or due one has no digits', () => { + const countdown = new ReviewCountdown(vi.fn(), new Ticker()) + countdown.read(held(30, 'redirected')) + expect(countdown.left('a')).toBeNull() + countdown.read(held(0, 'due')) + expect(countdown.left('a')).toBeNull() +}) + +it('ticks once a second while held, and stops when the last holder lets go', async () => { + const clock = new Ticker() + const first = clock.hold() + const second = clock.hold() + expect(clock.running).toBe(true) + const start = clock.now + await vi.advanceTimersByTimeAsync(TICK_MS * 2) + expect(clock.now - start).toBe(TICK_MS * 2) + first() + first() // a second release of the same hold counts once + expect(clock.running).toBe(true) + second() + expect(clock.running).toBe(false) + const stopped = clock.now + await vi.advanceTimersByTimeAsync(TICK_MS * 5) + expect(clock.now).toBe(stopped) +}) + +it('stops while the tab is hidden and catches up when it is shown', async () => { + const refresh = vi.fn() + const clock = new Ticker() + const countdown = new ReviewCountdown(refresh, clock) + countdown.read(held(10)) + const release = countdown.hold() + hidden = true + document.dispatchEvent(new Event('visibilitychange')) + expect(clock.running).toBe(false) + await vi.advanceTimersByTimeAsync(TICK_MS * 20) + expect(refresh).not.toHaveBeenCalled() + hidden = false + document.dispatchEvent(new Event('visibilitychange')) + expect(clock.running).toBe(true) + // shown again past the deadline: the countdown is at zero and asks once + expect(countdown.left('a')).toBe(0) + expect(refresh).toHaveBeenCalledTimes(1) + release() +}) + +it('does not start while the tab is hidden', () => { + hidden = true + const clock = new Ticker() + const release = clock.hold() + expect(clock.running).toBe(false) + release() +}) diff --git a/ui/src/lib/request/review.svelte.ts b/ui/src/lib/request/review.svelte.ts new file mode 100644 index 000000000..5db786e52 --- /dev/null +++ b/ui/src/lib/request/review.svelte.ts @@ -0,0 +1,127 @@ +// The countdowns of items held for review. One shared one-second ticker, +// running only while a hold is on screen and the tab is visible (the +// hold() pattern of NotesChannel, listening.svelte.ts). A countdown is +// anchored to the moment the request was read plus the server's +// `seconds_left`: the browser's clock is never compared with +// `review.until`, so a skewed clock cannot make an item look due early. +// When a countdown reaches zero the page reads the request once more, so +// the server's own `due` replaces the local guess. +import type { LedgerRequest } from '../types' + +export const TICK_MS = 1000 + +const visible = () => + typeof document === 'undefined' || document.visibilityState !== 'hidden' + +type Listener = (now: number) => void + +export class Ticker { + /** Date.now() at the last tick */ + now = $state(Date.now()) + #holds: { listener?: Listener }[] = [] + #timer: ReturnType | null = null + + get running() { + return this.#timer !== null + } + + /** Something on screen counts down: tick, calling `listener` each time, + * until the returned function says it has gone. Written to be returned + * from an $effect */ + hold(listener?: Listener): () => void { + const hold = { listener } + this.#holds.push(hold) + if (this.#holds.length === 1) { + document.addEventListener('visibilitychange', this.#onVisibility) + this.#start() + } else if (this.running) listener?.(this.now) + return () => { + const at = this.#holds.indexOf(hold) + if (at < 0) return + this.#holds.splice(at, 1) + if (this.#holds.length) return + this.#stop() + document.removeEventListener('visibilitychange', this.#onVisibility) + } + } + + #tick = () => { + this.now = Date.now() + for (const hold of [...this.#holds]) hold.listener?.(this.now) + } + + #start() { + if (this.#timer !== null || !visible()) return + this.#tick() + this.#timer = setInterval(this.#tick, TICK_MS) + } + + #stop() { + if (this.#timer !== null) clearInterval(this.#timer) + this.#timer = null + } + + #onVisibility = () => (visible() ? this.#start() : this.#stop()) +} + +/** The one ticker every countdown on the page shares */ +export const ticker = new Ticker() + +type Anchor = { deadline: number; until: string } + +/** One request's countdowns: `read` with every read the page keeps, `left` + * for a row's seconds, `hold` while one is on screen */ +export class ReviewCountdown { + #anchors = $state>({}) + #readAt = $state(0) + /** The deadlines already re-read for, as `key@until` */ + #asked: Record = {} + #refresh: () => void + #clock: Ticker + + /** `refresh` re-reads the request through the page's own path */ + constructor(refresh: () => void, clock: Ticker = ticker) { + this.#refresh = refresh + this.#clock = clock + } + + /** A read of the request the page now holds, made at `at` (ms). Only a + * holding row counts down; a redirected or due one has no digits */ + read(request: LedgerRequest, at = Date.now()) { + const anchors: Record = {} + for (const { key, review } of request.items) + if (review?.state === 'holding') + anchors[key] = { + deadline: at + review.seconds_left * 1000, + until: review.until, + } + this.#anchors = anchors + this.#readAt = at + } + + /** Whole seconds left on `key`'s countdown, null when it has none */ + left(key: string): number | null { + const anchor = this.#anchors[key] + if (!anchor) return null + // a tick older than the read counts as the read + const now = Math.max(this.#clock.now, this.#readAt) + return Math.max(0, Math.ceil((anchor.deadline - now) / 1000)) + } + + /** A countdown is on screen: tick until the returned function is called */ + hold(): () => void { + return this.#clock.hold((now) => this.#check(now)) + } + + /** A countdown reached zero: read the request again, once per deadline */ + #check(now: number) { + let due = false + for (const [key, anchor] of Object.entries(this.#anchors)) { + const asked = `${key}@${anchor.until}` + if (now < anchor.deadline || this.#asked[asked]) continue + this.#asked[asked] = true + due = true + } + if (due) this.#refresh() + } +} diff --git a/ui/src/lib/request/reviewText.test.ts b/ui/src/lib/request/reviewText.test.ts new file mode 100644 index 000000000..59290fb4a --- /dev/null +++ b/ui/src/lib/request/reviewText.test.ts @@ -0,0 +1,157 @@ +import { expect, it } from 'vitest' +import { item, request } from './fixtures' +import { planState } from './itemState' +import { + bannerText, + chipText, + clockTime, + countdown, + holdGroup, + holdNews, + runNowKeys, +} from './reviewText' +import type { LedgerItem, LedgerReview } from '../types' + +const UNTIL = '2026-11-21T15:30:00+00:00' +const LATER = '2026-11-21T16:00:00+00:00' +const review = ( + state: LedgerReview['state'], + until = UNTIL, + seconds_left = 125, +): LedgerReview => ({ until, state, seconds_left }) +const held = (items: LedgerItem[]) => planState(request(items)).held +const group = (items: LedgerItem[]) => { + const found = holdGroup(held(items)) + if (!found) throw new Error('no hold') + return found +} +const at = clockTime(UNTIL) + +it('counts down in MM:SS, and H:MM:SS past an hour', () => { + expect(countdown(0)).toBe('00:00') + expect(countdown(9)).toBe('00:09') + expect(countdown(125)).toBe('02:05') + expect(countdown(3599)).toBe('59:59') + expect(countdown(3600)).toBe('1:00:00') + expect(countdown(3600 * 23 + 61)).toBe('23:01:01') + expect(countdown(-5)).toBe('00:00') +}) + +it("gives the deadline in the browser's locale time", () => { + expect(at).toBe( + new Date(UNTIL).toLocaleTimeString(undefined, { + hour: '2-digit', + minute: '2-digit', + }), + ) +}) + +it('has no group when nothing is held', () => { + expect(holdGroup(held([item('a')]))).toBeNull() +}) + +it('words the banner by the most urgent state: due, then holding, then redirected', () => { + const all = [ + item('r', { review: review('redirected') }), + item('h', { review: review('holding') }), + item('d', { review: review('due') }), + ] + expect(group(all).state).toBe('due') + expect(group(all.slice(0, 2)).state).toBe('holding') + expect(group(all.slice(0, 1)).state).toBe('redirected') +}) + +it('says a hold with a session listening, plural and singular, with and without estimates', () => { + const two = group([ + item('a', { review: review('holding', LATER), estimate_minutes: 3 }), + item('b', { review: review('holding'), estimate_minutes: 1.6 }), + item('c', { review: review('redirected'), estimate_minutes: 50 }), + ]) + expect(two.rows).toHaveLength(2) + // the soonest deadline is the one named + expect(two.first.item.key).toBe('b') + expect(bannerText(two, true, 125)).toBe( + `2 items held for your review (about 5 min by the agent's estimate). A session is listening: at ${at} (in 02:05) it is told to run them, unless you leave a note.`, + ) + const one = group([item('a', { review: review('holding') })]) + expect(bannerText(one, true, 3725)).toBe( + `1 item held for your review. A session is listening: at ${at} (in 1:02:05) it is told to run it, unless you leave a note.`, + ) + const partly = group([ + item('a', { review: review('holding'), estimate_minutes: 2 }), + item('b', { review: review('holding') }), + ]) + expect(bannerText(partly, true, 60)).toBe( + `2 items held for your review (about 2 min by the agent's estimate). A session is listening: at ${at} (in 01:00) it is told to run them, unless you leave a note.`, + ) +}) + +it('says a hold with no session listening, plural and singular', () => { + const two = group([ + item('a', { review: review('holding'), estimate_minutes: 3 }), + item('b', { review: review('holding') }), + ]) + expect(bannerText(two, false, 125)).toBe( + `2 items held for your review. No session is listening, so nothing will run at ${at}. Run them here, or leave a note.`, + ) + const one = group([item('a', { review: review('holding') })]) + expect(bannerText(one, false, 125)).toBe( + `1 item held for your review. No session is listening, so nothing will run at ${at}. Run it here, or leave a note.`, + ) +}) + +it('says a redirected hold, and a due one with and without a session', () => { + const redirected = group([item('a', { review: review('redirected') })]) + for (const listening of [true, false]) + expect(bannerText(redirected, listening, 0)).toBe( + 'You left a note after these were held: the agent will revise before running.', + ) + const due = group([item('a', { review: review('due', UNTIL, 0) })]) + expect(bannerText(due, true, 0)).toBe( + 'Review time is up: the agent should be starting these.', + ) + expect(bannerText(due, false, 0)).toBe( + 'Review time passed with no session listening: nothing ran.', + ) +}) + +it('offers Run now for the ready rows of a hold, or of a due one nobody listens for', () => { + const holding = group([ + item('a', { review: review('holding'), ready: true }), + item('b', { review: review('holding') }), + ]) + expect(runNowKeys(holding, true)).toEqual(['a']) + expect(runNowKeys(holding, false)).toEqual(['a']) + const none = group([item('b', { review: review('holding') })]) + expect(runNowKeys(none, false)).toEqual([]) + const due = group([item('a', { review: review('due'), ready: true })]) + expect(runNowKeys(due, false)).toEqual(['a']) + expect(runNowKeys(due, true)).toEqual([]) + const redirected = group([ + item('a', { review: review('redirected'), ready: true }), + ]) + expect(runNowKeys(redirected, false)).toEqual([]) +}) + +it("words a held row's chip", () => { + expect(chipText(review('holding'), 125)).toBe('held · 02:05') + expect(chipText(review('holding'), 3600)).toBe('held · 1:00:00') + expect(chipText(review('redirected'), null)).toBe('held · note left') + expect(chipText(review('due'), null)).toBe('review time up') +}) + +it('has one sentence for each state, for the live region', () => { + const one = group([item('a', { review: review('holding') })]) + expect(holdNews(one)).toBe('1 item held for your review.') + const two = group([ + item('a', { review: review('holding') }), + item('b', { review: review('holding') }), + ]) + expect(holdNews(two)).toBe('2 items held for your review.') + expect(holdNews(group([item('a', { review: review('redirected') })]))).toBe( + 'You left a note after these were held: the agent will revise before running.', + ) + expect(holdNews(group([item('a', { review: review('due') })]))).toBe( + 'Review time is up for the held items.', + ) +}) diff --git a/ui/src/lib/request/reviewText.ts b/ui/src/lib/request/reviewText.ts new file mode 100644 index 000000000..992f9de82 --- /dev/null +++ b/ui/src/lib/request/reviewText.ts @@ -0,0 +1,110 @@ +// What the request page says about items held for the user's review: the +// header's banner, a held row's chip, and the live region's sentence. The +// state is always the server's `review.state`; the seconds left come from +// the page's countdown (review.svelte.ts), anchored to the read. +import type { ItemState } from './itemState' +import type { LedgerReview } from '../types' + +export type HoldState = LedgerReview['state'] + +/** The banner speaks of the most urgent state present */ +const URGENCY: HoldState[] = ['due', 'holding', 'redirected'] + +/** The rows the banner speaks of: those in its one state */ +export type HoldGroup = { + state: HoldState + rows: ItemState[] + /** The row whose deadline comes first: the time the banner names */ + first: ItemState + /** The agent's estimates summed, null when none of the rows has one */ + minutes: number | null +} + +const deadline = (row: ItemState) => Date.parse(row.review?.until ?? '') + +/** The group the banner speaks of, or null when nothing is held */ +export function holdGroup(held: readonly ItemState[]): HoldGroup | null { + for (const state of URGENCY) { + const rows = held.filter((row) => row.review?.state === state) + if (!rows.length) continue + const first = rows.reduce((a, b) => (deadline(b) < deadline(a) ? b : a)) + const estimates = rows + .map((row) => row.item.estimate_minutes) + .filter((m): m is number => m != null) + const minutes = estimates.length ? estimates.reduce((a, b) => a + b) : null + return { state, rows, first, minutes } + } + return null +} + +/** A deadline in the browser's locale time, hours and minutes */ +export const clockTime = (until: string) => + new Date(until).toLocaleTimeString(undefined, { + hour: '2-digit', + minute: '2-digit', + }) + +const pad = (n: number) => String(n).padStart(2, '0') + +/** Seconds as MM:SS, or H:MM:SS past an hour */ +export function countdown(seconds: number): string { + const total = Math.max(0, Math.floor(seconds)) + const hours = Math.floor(total / 3600) + const minutes = Math.floor((total % 3600) / 60) + const rest = `${pad(minutes)}:${pad(total % 60)}` + return hours ? `${hours}:${rest}` : rest +} + +const counted = (n: number) => (n === 1 ? '1 item' : `${n} items`) + +const REDIRECTED = + 'You left a note after these were held: the agent will revise before running.' + +/** The banner's words. `left` is the seconds to the first deadline */ +export function bannerText( + group: HoldGroup, + listening: boolean, + left: number, +): string { + const one = group.rows.length === 1 + const at = clockTime(group.first.review?.until ?? '') + if (group.state === 'redirected') return REDIRECTED + if (group.state === 'due') + return listening + ? 'Review time is up: the agent should be starting these.' + : 'Review time passed with no session listening: nothing ran.' + const lead = `${counted(group.rows.length)} held for your review` + if (!listening) + return `${lead}. No session is listening, so nothing will run at ${at}. Run ${one ? 'it' : 'them'} here, or leave a note.` + const estimate = + group.minutes == null + ? '' + : ` (about ${Math.max(1, Math.round(group.minutes))} min by the agent's estimate)` + return `${lead}${estimate}. A session is listening: at ${at} (in ${countdown(left)}) it is told to run ${one ? 'it' : 'them'}, unless you leave a note.` +} + +/** The rows "Run now…" would open the run dialog for: the ready ones of a + * hold, or of a due one with no session to run it. Empty: no button */ +export function runNowKeys(group: HoldGroup, listening: boolean): string[] { + const offered = + group.state === 'holding' || (group.state === 'due' && !listening) + if (!offered) return [] + return group.rows + .filter((row) => row.display === 'ready') + .map((row) => row.item.key) +} + +/** A held row's chip. `left` is its countdown's seconds (holding only) */ +export function chipText(review: LedgerReview, left: number | null): string { + if (review.state === 'redirected') return 'held · note left' + if (review.state === 'due') return 'review time up' + return `held · ${countdown(left ?? review.seconds_left)}` +} + +/** What the live region says when the banner's state changes: never the + * ticking digits */ +export function holdNews(group: HoldGroup): string { + if (group.state === 'redirected') return REDIRECTED + if (group.state === 'due') return 'Review time is up for the held items.' + return `${counted(group.rows.length)} held for your review.` +} diff --git a/ui/src/lib/request/runPlan.test.ts b/ui/src/lib/request/runPlan.test.ts index 847e007c8..2e3e8d052 100644 --- a/ui/src/lib/request/runPlan.test.ts +++ b/ui/src/lib/request/runPlan.test.ts @@ -2,10 +2,13 @@ import { expect, it } from 'vitest' import type { Plan } from '../types' import { attempt, doneItem, item, request } from './fixtures' import { planState } from './itemState' +import { clockTime } from './reviewText' import { afterwardsLine, ALL_CACHED, becomesReady, + heldLine, + heldPlan, itemPlan, planNotes, planSaid, @@ -191,3 +194,39 @@ it('warns that a run with every step cached makes nothing new', () => { { text: ALL_CACHED, tone: 'warn' }, ]) }) + +const UNTIL = '2026-11-21T15:30:00+00:00' +const hold = (state: 'holding' | 'redirected' | 'due') => ({ + until: UNTIL, + state, + seconds_left: state === 'due' ? 0 : 600, +}) + +it('runs the held rows named that are ready, and none that is not', () => { + const held = planState( + request([ + item('a', { title: 'A', ready: true, review: hold('holding') }), + item('b', { title: 'B', review: hold('holding') }), + item('c', { title: 'C', ready: true }), + ]), + ) + const run = heldPlan(held, ['a', 'b']) + expect(run.candidates.map((c) => c.key)).toEqual(['a']) + expect(run.single).toBe(false) + expect(heldPlan(held, ['b']).candidates).toEqual([]) +}) + +it("gives a held item's dialog row its line, warning when a session may be starting it", () => { + const go = { + text: `Held for review until ${clockTime(UNTIL)}. Running it now is your go-ahead.`, + tone: 'plain', + } + expect(heldLine(null, true)).toBeNull() + expect(heldLine(hold('holding'), true)).toEqual(go) + expect(heldLine(hold('redirected'), false)).toEqual(go) + expect(heldLine(hold('due'), false)).toEqual(go) + expect(heldLine(hold('due'), true)).toEqual({ + text: 'Review time is up and a session is listening: it may be starting this now.', + tone: 'warn', + }) +}) diff --git a/ui/src/lib/request/runPlan.ts b/ui/src/lib/request/runPlan.ts index 64f925cc0..38c82ddc1 100644 --- a/ui/src/lib/request/runPlan.ts +++ b/ui/src/lib/request/runPlan.ts @@ -3,8 +3,9 @@ // ready once those finish; and what a plan's quote adds to a row. import { formatMinutes } from '../format' import { describePlan, type PlanLine } from '../plan' -import type { Plan } from '../types' +import type { LedgerReview, Plan } from '../types' import { CHIP, takesOf, type ItemState, type PlanState } from './itemState' +import { clockTime } from './reviewText' /** An item a job would be queued for, with what the job would run */ export type Candidate = { @@ -69,6 +70,39 @@ export function readyPlan(plan: PlanState): RunPlan { } } +/** The banner's "Run now…": the held rows named that are ready, in plan + * order, ticked as a run of what is ready is */ +export function heldPlan(plan: PlanState, keys: readonly string[]): RunPlan { + const rows = plan.live.filter( + (row) => keys.includes(row.item.key) && row.display === 'ready', + ) + return { + candidates: rows.map(candidate), + skipped: [], + single: false, + retake: null, + } +} + +/** The line a held item's row carries in the dialog: running it is the + * user's go-ahead, or, with the review over and a session listening, the + * agent may be starting it already */ +export function heldLine( + review: LedgerReview | null, + listening: boolean, +): PlanLine | null { + if (!review) return null + if (review.state === 'due' && listening) + return { + text: 'Review time is up and a session is listening: it may be starting this now.', + tone: 'warn', + } + return { + text: `Held for review until ${clockTime(review.until)}. Running it now is your go-ahead.`, + tone: 'plain', + } +} + /** What stands as a done item's result while another take is made */ export function retakeLine(row: ItemState): string | null { if (row.display !== 'done') return null diff --git a/ui/src/lib/request/standing.test.ts b/ui/src/lib/request/standing.test.ts index c9cb2f2ac..054163ed3 100644 --- a/ui/src/lib/request/standing.test.ts +++ b/ui/src/lib/request/standing.test.ts @@ -1,7 +1,7 @@ import { expect, it } from 'vitest' import { formatDay } from '../format' import { planState } from './itemState' -import { needsLine, standing } from './standing' +import { agentSaid, needsLine, standing } from './standing' import { attempt, doneItem, entry, item, request } from './fixtures' import type { LedgerItem, LedgerRequest } from '../types' @@ -138,3 +138,26 @@ it('lists every reason the user is needed, in one line', () => { needsLine({ ready: 0, failed: 0, choose: 0, accepted_missing: 0 }), ).toBeNull() }) + +it("gives the agent's latest word on an open request, and none on a closed one", () => { + const req = (over: Partial) => + request([item('a')], { + history: [ + entry(1, 'agent', 'opened'), + entry(2, 'user', 'note added'), + entry(3, 'agent', 'board-01 now blue; awaiting go-ahead to draw'), + entry(4, 'user', 'note added'), + ], + ...over, + }) + const said = agentSaid(req({})) + expect(said).toEqual({ + revision: 3, + why: 'board-01 now blue; awaiting go-ahead to draw', + at: '2026-01-01T00:03:00+00:00', + }) + expect(agentSaid(req({ state: 'done' }))).toBeNull() + expect( + agentSaid(req({ history: [entry(1, 'user', 'made by hand')] })), + ).toBeNull() +}) diff --git a/ui/src/lib/request/standing.ts b/ui/src/lib/request/standing.ts index 7ceb0db35..54fba7ab6 100644 --- a/ui/src/lib/request/standing.ts +++ b/ui/src/lib/request/standing.ts @@ -101,3 +101,21 @@ export function standing( needs: needsLine(plan.needs), } } + +export type AgentSaid = { revision: number; why: string; at: string } + +/** What the agent last wrote on an open request: its newest history entry, + * whose `why` is how it answers - "ready for take 2, not run", "awaiting + * go-ahead". Null on a closed request, or one the agent never wrote */ +export function agentSaid(request: LedgerRequest): AgentSaid | null { + if (request.state !== 'open') return null + const latest = request.history + .filter((e) => e.by === 'agent') + .reduce<(typeof request.history)[number] | null>( + (best, e) => (!best || e.revision > best.revision ? e : best), + null, + ) + return latest + ? { revision: latest.revision, why: latest.why, at: latest.at } + : null +} diff --git a/ui/src/lib/types.ts b/ui/src/lib/types.ts index a1b077199..36c4161f9 100644 --- a/ui/src/lib/types.ts +++ b/ui/src/lib/types.ts @@ -87,6 +87,7 @@ export type LedgerSummary = Schemas['LedgerSummary'] export type LedgerRequest = Schemas['LedgerRequest'] export type LedgerDeleted = Schemas['LedgerDeleted'] export type LedgerItem = Schemas['LedgerItem'] +export type LedgerReview = Schemas['LedgerReview'] export type LedgerAttempt = Schemas['LedgerAttempt'] export type LedgerOutput = Schemas['LedgerOutput'] export type LedgerNote = Schemas['LedgerNote'] diff --git a/ui/src/lib/ui/ClampedText.svelte b/ui/src/lib/ui/ClampedText.svelte index e12b953fe..de9f8878e 100644 --- a/ui/src/lib/ui/ClampedText.svelte +++ b/ui/src/lib/ui/ClampedText.svelte @@ -71,8 +71,10 @@ type="button" class="bare more" aria-expanded={expanded} - onclick={toggle}>{expanded ? 'Show less' : 'Show more'} + {expanded ? 'Show less' : 'Show more'} + {/if} diff --git a/ui/src/lib/ui/ConfirmDialog.svelte b/ui/src/lib/ui/ConfirmDialog.svelte index d02f02465..790f42578 100644 --- a/ui/src/lib/ui/ConfirmDialog.svelte +++ b/ui/src/lib/ui/ConfirmDialog.svelte @@ -28,9 +28,9 @@
    {#if !confirmState.alert} - {confirmState.cancelLabel} + + {confirmState.cancelLabel} + {/if} resolveConfirm(true)}> {confirmState.confirmLabel} diff --git a/ui/src/lib/ui/Markdown.svelte b/ui/src/lib/ui/Markdown.svelte index 31dffab6b..16ebc325a 100644 --- a/ui/src/lib/ui/Markdown.svelte +++ b/ui/src/lib/ui/Markdown.svelte @@ -12,13 +12,15 @@ {#snippet inline(nodes: Inline[])} {#each nodes as node, i (i)} {#if node.kind === 'text'}{node.text}{:else if node.kind === 'br'}
    {:else if node.kind === 'code'}{node.text}{:else if node.kind === 'strong'}{@render inline(node.children)}{:else if node.kind === 'em'}{@render inline(node.children)}{:else}{@render inline(node.children)}{/if} + />{:else if node.kind === 'code'} + {node.text} + {:else if node.kind === 'strong'} + {@render inline(node.children)} + {:else if node.kind === 'em'} + {@render inline(node.children)} + {:else} + {@render inline(node.children)} + {/if} {/each} {/snippet} diff --git a/ui/src/lib/ui/NoteEditor.svelte b/ui/src/lib/ui/NoteEditor.svelte index 206f16eb9..7dd319551 100644 --- a/ui/src/lib/ui/NoteEditor.svelte +++ b/ui/src/lib/ui/NoteEditor.svelte @@ -82,15 +82,17 @@ [link](https://…)

    - + + Cancel +
    {#if error}{/if} {:else} @@ -113,8 +115,10 @@ class="quiet icon" aria-label="Edit note" title="edit this note" - onclick={edit}> + +
    {/if}