@hearsay-tools/squawk 0.18.0-dev.6646 → 0.18.0-dev.6703
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-config/seed.js +1 -6
- package/dist/agent-config/seed.js.map +1 -1
- package/dist/autosave-git.js +3 -4
- package/dist/autosave-git.js.map +1 -1
- package/dist/ci-wait/controller.d.ts +37 -37
- package/dist/ci-wait/tool-catalog.js +1 -1
- package/dist/ci-wait/tool-catalog.js.map +1 -1
- package/dist/contract/attention.d.ts +8 -0
- package/dist/contract/index.js +14 -0
- package/dist/contract/runs.d.ts +15 -0
- package/dist/core/backend-detect.js +2 -1
- package/dist/core/backend-detect.js.map +1 -1
- package/dist/core/codex-hook-mapper.js +2 -1
- package/dist/core/codex-hook-mapper.js.map +1 -1
- package/dist/core/codex-ui-mapper.js +2 -2
- package/dist/core/codex-ui-mapper.js.map +1 -1
- package/dist/core/cursor-print-runner.js +2 -1
- package/dist/core/cursor-print-runner.js.map +1 -1
- package/dist/core/omp-runner.js +4 -5
- package/dist/core/omp-runner.js.map +1 -1
- package/dist/core/omp-subagent-rows.js +2 -1
- package/dist/core/omp-subagent-rows.js.map +1 -1
- package/dist/core/opencode-ui-mapper.js +2 -2
- package/dist/core/opencode-ui-mapper.js.map +1 -1
- package/dist/core/own-lookup.d.ts +5 -0
- package/dist/core/own-lookup.js +8 -0
- package/dist/core/own-lookup.js.map +1 -0
- package/dist/data-gitignore.js +2 -2
- package/dist/data-gitignore.js.map +1 -1
- package/dist/delegation/cli.js +2 -2
- package/dist/delegation/cli.js.map +1 -1
- package/dist/delegation/context.js +7 -11
- package/dist/delegation/context.js.map +1 -1
- package/dist/delegation/conversations.d.ts +4 -2
- package/dist/delegation/park-notice.d.ts +5 -1
- package/dist/delegation/park-notice.js +7 -0
- package/dist/delegation/park-notice.js.map +1 -1
- package/dist/delegation/results.js +2 -2
- package/dist/delegation/results.js.map +1 -1
- package/dist/delegation/routes.d.ts +11 -11
- package/dist/delegation/scratch-cleanup.js +6 -3
- package/dist/delegation/scratch-cleanup.js.map +1 -1
- package/dist/delegation/service.js +2 -4
- package/dist/delegation/service.js.map +1 -1
- package/dist/delegation/transport.d.ts +77 -77
- package/dist/git-command.d.ts +29 -0
- package/dist/git-command.js +27 -1
- package/dist/git-command.js.map +1 -1
- package/dist/git-worktree-lock-helper.d.ts +2 -0
- package/dist/git-worktree-lock-helper.js +12 -14
- package/dist/git-worktree-lock-helper.js.map +1 -1
- package/dist/git-worktree-lock.js +3 -10
- package/dist/git-worktree-lock.js.map +1 -1
- package/dist/home/command.js +1 -1
- package/dist/home/command.js.map +1 -1
- package/dist/jobs/cli.js +4 -2
- package/dist/jobs/cli.js.map +1 -1
- package/dist/jobs/job.d.ts +7 -0
- package/dist/jobs/job.js +32 -3
- package/dist/jobs/job.js.map +1 -1
- package/dist/project-migration/containment.js +2 -4
- package/dist/project-migration/containment.js.map +1 -1
- package/dist/project-migration/plan.js +2 -4
- package/dist/project-migration/plan.js.map +1 -1
- package/dist/release/publication.js +2 -2
- package/dist/release/publication.js.map +1 -1
- package/dist/runs/agent-tmpdir.d.ts +3 -2
- package/dist/runs/agent-tmpdir.js +11 -4
- package/dist/runs/agent-tmpdir.js.map +1 -1
- package/dist/runs/automation-runs.js +4 -3
- package/dist/runs/automation-runs.js.map +1 -1
- package/dist/runs/conversation-members.js +3 -2
- package/dist/runs/conversation-members.js.map +1 -1
- package/dist/runs/guarded-json-sql.d.ts +8 -0
- package/dist/runs/guarded-json-sql.js +11 -0
- package/dist/runs/guarded-json-sql.js.map +1 -0
- package/dist/runs/run-database-peer-page.js +3 -4
- package/dist/runs/run-database-peer-page.js.map +1 -1
- package/dist/runs/run-database-version.d.ts +1 -1
- package/dist/runs/run-database-version.js +2 -1
- package/dist/runs/run-database-version.js.map +1 -1
- package/dist/runs/run-database.js +5 -4
- package/dist/runs/run-database.js.map +1 -1
- package/dist/runs/run-exits.d.ts +15 -6
- package/dist/runs/run-exits.js +13 -4
- package/dist/runs/run-exits.js.map +1 -1
- package/dist/runs/run-index.js +1 -2
- package/dist/runs/run-index.js.map +1 -1
- package/dist/runs/store.d.ts +11 -5
- package/dist/runs/store.js +21 -20
- package/dist/runs/store.js.map +1 -1
- package/dist/serve-boot.d.ts +1 -2
- package/dist/serve-command.js +25 -15
- package/dist/serve-command.js.map +1 -1
- package/dist/serve-stop.d.ts +41 -0
- package/dist/serve-stop.js +42 -0
- package/dist/serve-stop.js.map +1 -0
- package/dist/server/activity-routes.d.ts +23 -23
- package/dist/server/checkout.d.ts +1 -1
- package/dist/server/checkout.js +5 -5
- package/dist/server/checkout.js.map +1 -1
- package/dist/server/create-project.js +9 -10
- package/dist/server/create-project.js.map +1 -1
- package/dist/server/forge/draft-pr.js +17 -13
- package/dist/server/forge/draft-pr.js.map +1 -1
- package/dist/server/git.js +2 -4
- package/dist/server/git.js.map +1 -1
- package/dist/server/health-cache.d.ts +39 -0
- package/dist/server/health-cache.js +66 -0
- package/dist/server/health-cache.js.map +1 -0
- package/dist/server/repo-pull.js +3 -7
- package/dist/server/repo-pull.js.map +1 -1
- package/dist/server/server.d.ts +368 -341
- package/dist/server/server.js +39 -98
- package/dist/server/server.js.map +1 -1
- package/dist/server/workspace-live-routes.d.ts +6 -6
- package/dist/server-install/platforms/macosx-migration.js +1 -1
- package/dist/server-install/platforms/macosx-migration.js.map +1 -1
- package/dist/server-install/platforms/ubuntu-vps-migration.js +1 -1
- package/dist/server-install/platforms/ubuntu-vps-migration.js.map +1 -1
- package/dist/skills-remote.js +8 -12
- package/dist/skills-remote.js.map +1 -1
- package/dist/task-branch-head.js +2 -4
- package/dist/task-branch-head.js.map +1 -1
- package/dist/task-cli/discovery.js +2 -4
- package/dist/task-cli/discovery.js.map +1 -1
- package/dist/ui-state.d.ts +7 -6
- package/dist/ui-state.js +31 -6
- package/dist/ui-state.js.map +1 -1
- package/dist/workflows/continuation-admission.d.ts +2 -1
- package/dist/workflows/run/attachment-writer.d.ts +5 -4
- package/dist/workflows/run/attachment-writer.js +9 -7
- package/dist/workflows/run/attachment-writer.js.map +1 -1
- package/dist/workflows/run/compose.d.ts +4 -1
- package/dist/workflows/run/compose.js +14 -10
- package/dist/workflows/run/compose.js.map +1 -1
- package/dist/workflows/run/continuation-acceptance.d.ts +4 -1
- package/dist/workflows/run/continuation-acceptance.js +4 -1
- package/dist/workflows/run/continuation-acceptance.js.map +1 -1
- package/dist/workflows/run/family-reconciler.d.ts +4 -0
- package/dist/workflows/run/family-reconciler.js +4 -0
- package/dist/workflows/run/family-reconciler.js.map +1 -1
- package/dist/workflows/run/inbox-claims.d.ts +2 -0
- package/dist/workflows/run/inbox-claims.js +2 -0
- package/dist/workflows/run/inbox-claims.js.map +1 -1
- package/dist/workflows/run/maintenance-claims.d.ts +2 -0
- package/dist/workflows/run/maintenance-claims.js +2 -0
- package/dist/workflows/run/maintenance-claims.js.map +1 -1
- package/dist/workflows/run/memory-guard.d.ts +6 -6
- package/dist/workflows/run/memory-guard.js +8 -8
- package/dist/workflows/run/memory-guard.js.map +1 -1
- package/dist/workflows/run/prompts.js +1 -1
- package/dist/workflows/run/prompts.js.map +1 -1
- package/dist/workflows/run/queued-input.d.ts +12 -10
- package/dist/workflows/run/queued-input.js +17 -16
- package/dist/workflows/run/queued-input.js.map +1 -1
- package/dist/workflows/run/run-line.d.ts +5 -4
- package/dist/workflows/run/run-line.js +11 -6
- package/dist/workflows/run/run-line.js.map +1 -1
- package/dist/workflows/run/run-memory.d.ts +52 -0
- package/dist/workflows/run/run-memory.js +58 -0
- package/dist/workflows/run/run-memory.js.map +1 -0
- package/dist/workflows/run/run-settlement.d.ts +21 -4
- package/dist/workflows/run/run-settlement.js +60 -22
- package/dist/workflows/run/run-settlement.js.map +1 -1
- package/dist/workflows/run/session-events.d.ts +2 -0
- package/dist/workflows/run/session-events.js +2 -2
- package/dist/workflows/run/session-events.js.map +1 -1
- package/dist/workflows/run/step-loop.js +1 -1
- package/dist/workflows/run/step-loop.js.map +1 -1
- package/dist/workflows/run/turn-bookkeeping.d.ts +5 -5
- package/dist/workflows/run/turn-bookkeeping.js +7 -7
- package/dist/workflows/run/turn-bookkeeping.js.map +1 -1
- package/dist/workflows/run/turn-settler.d.ts +3 -0
- package/dist/workflows/run/turn-settler.js +7 -3
- package/dist/workflows/run/turn-settler.js.map +1 -1
- package/dist/workflows/run/wait-engine.d.ts +2 -1
- package/dist/workflows/run/wait-registry.d.ts +1 -0
- package/dist/workflows/run/wait-registry.js +1 -0
- package/dist/workflows/run/wait-registry.js.map +1 -1
- package/dist/workflows/run/wake-retries.d.ts +10 -6
- package/dist/workflows/run/wake-retries.js +14 -10
- package/dist/workflows/run/wake-retries.js.map +1 -1
- package/dist/workflows/run/worker-executions.d.ts +11 -2
- package/dist/workflows/run/worker-executions.js +15 -6
- package/dist/workflows/run/worker-executions.js.map +1 -1
- package/dist/workflows/run/worker-orphans.js +2 -0
- package/dist/workflows/run/worker-orphans.js.map +1 -1
- package/dist/workflows/run/worker-questions.d.ts +3 -2
- package/dist/workflows/run/worker-questions.js +6 -5
- package/dist/workflows/run/worker-questions.js.map +1 -1
- package/dist/workflows/run/worktree-autosave.d.ts +2 -1
- package/dist/workflows/run/worktree-autosave.js +2 -1
- package/dist/workflows/run/worktree-autosave.js.map +1 -1
- package/dist/workflows/run-states.js +3 -3
- package/dist/workflows/run-states.js.map +1 -1
- package/dist/workflows/run.d.ts +2 -0
- package/dist/workflows/run.js +12 -3
- package/dist/workflows/run.js.map +1 -1
- package/dist/workspace/projects.d.ts +2 -0
- package/dist/workspace/projects.js +3 -4
- package/dist/workspace/projects.js.map +1 -1
- package/dist/worktree-manifest.js +2 -4
- package/dist/worktree-manifest.js.map +1 -1
- package/package.json +4 -4
- package/scripts/measure-transcript-facts-health.mjs +13 -6
- package/scripts/mock-ask-answer.mjs +19 -0
- package/scripts/mock-codex-app-server.mjs +16 -4
- package/scripts/mock-opencode-questions.mjs +89 -0
- package/scripts/mock-opencode-serve.mjs +6 -72
- package/web/dist/assets/activity-motion-DhLXb8Pt.js +2 -0
- package/web/dist/assets/{activity-route--Qj4NT9h.js → activity-route-CpwAMYLn.js} +1 -1
- package/web/dist/assets/{agent-accounts-BxpWcFS3.js → agent-accounts-Bc0LJ4SB.js} +1 -1
- package/web/dist/assets/attention-BF8NA1XM.js +1 -0
- package/web/dist/assets/{commit-diff-panel-DOgakNKv.js → commit-diff-panel-B1KZl0GP.js} +1 -1
- package/web/dist/assets/{diff-MoyKcT8Q.js → diff-Ci-qd1lU.js} +2 -2
- package/web/dist/assets/{diff-view-BFQcOCEf.js → diff-view-CWZElKoD.js} +1 -1
- package/web/dist/assets/{file-preview-BancpZHA.js → file-preview-CoWRr13R.js} +1 -1
- package/web/dist/assets/{git-toolbar-ClMasBRM.js → git-toolbar-BYIni94R.js} +1 -1
- package/web/dist/assets/{github-BVZ01nJq.js → github-CAPNq5vY.js} +1 -1
- package/web/dist/assets/{global-activity-route-DTgywy--.js → global-activity-route-DLEwsMA7.js} +1 -1
- package/web/dist/assets/index-CpwAOct4.js +17 -0
- package/web/dist/assets/{preview-pane-connected-B5PCWA9a.js → preview-pane-connected-CGw_9VuF.js} +2 -2
- package/web/dist/assets/{project-router-CiB1O_5A.js → project-router-oKsNlPN6.js} +1 -1
- package/web/dist/assets/{project-scope-context-CSPQyWoO.js → project-scope-context-BBVJVcJp.js} +1 -1
- package/web/dist/assets/{prompt-template-menu-VwBcsbqE.js → prompt-template-menu-BZTz2mIG.js} +1 -1
- package/web/dist/assets/queries-Be8VyHam.js +1 -0
- package/web/dist/assets/{reference-chip-DT-_ninM.js → reference-chip-Ht4xX9-k.js} +1 -1
- package/web/dist/assets/{repo-git-7KuJaDRk.js → repo-git-CzVLCWig.js} +1 -1
- package/web/dist/assets/{report-reader-CgY75QM2.js → report-reader-iTBkUgg-.js} +1 -1
- package/web/dist/assets/reports-BJF1Cl3C.js +1 -0
- package/web/dist/assets/run-header-BxB6gyt1.js +2 -0
- package/web/dist/assets/{skills-Dnrta_-m.js → skills-DvgHKWgK.js} +1 -1
- package/web/dist/assets/{tab-link-BPBiho7-.js → tab-link-Buy1fRFO.js} +1 -1
- package/web/dist/assets/{task-changes-C6sDd3Le.js → task-changes-CStxhLFG.js} +1 -1
- package/web/dist/assets/{task-commits-CQHxnFJ5.js → task-commits-DhpOAdOf.js} +1 -1
- package/web/dist/assets/{task-files-DK8Demuc.js → task-files-COmKUUfN.js} +1 -1
- package/web/dist/assets/{task-github-item-DgmmFFtN.js → task-github-item-BNLeAz58.js} +1 -1
- package/web/dist/assets/{task-thread-Dg9VWJq6.js → task-thread-DjSFvEQe.js} +6 -6
- package/web/dist/assets/{thread-state-DIMUAyFk.js → thread-state-B5tTsVNm.js} +1 -1
- package/web/dist/assets/use-desktop-BPWIJ0Kw.js +1 -0
- package/web/dist/assets/{use-hand-to-agent-state-D-yaVRRx.js → use-hand-to-agent-state-Ce6QW2j_.js} +1 -1
- package/web/dist/assets/{useInfiniteQuery-Q8eFXz-L.js → useInfiniteQuery-Yn58_Fkn.js} +1 -1
- package/web/dist/assets/useQuery-C1xFF0nd.js +1 -0
- package/web/dist/assets/{workflows-W_uriBcj.js → workflows-CN8uKYnY.js} +1 -1
- package/web/dist/assets/{ws-B-tB133E.js → ws-DbXGHAke.js} +1 -1
- package/web/dist/index.html +12 -12
- package/web/dist/assets/activity-motion-CEnf2rDh.js +0 -2
- package/web/dist/assets/attention-BDa7opY9.js +0 -1
- package/web/dist/assets/index-CsOa03VW.js +0 -17
- package/web/dist/assets/queries-pj368bmB.js +0 -1
- package/web/dist/assets/reports-CxTUchWh.js +0 -1
- package/web/dist/assets/run-header-BcX23gw7.js +0 -2
- package/web/dist/assets/use-desktop-Bq_Qh5ur.js +0 -1
- package/web/dist/assets/useQuery-BoLjCS2U.js +0 -1
package/dist/server/server.js
CHANGED
|
@@ -110,6 +110,7 @@ import { worktreeDiff, worktreeSizeBytes } from '../git-worktree.js';
|
|
|
110
110
|
import { releaseThenRemoveWorktree } from '../git-worktree-release.js';
|
|
111
111
|
import { isReclaimable, reclaimWorktree, reclaimWorktrees, selectReclaimableWorktrees } from '../runs/retention.js';
|
|
112
112
|
import { getBranches, getCommit, getDiff, getLogWithParents, getRepoInfo, getStatus, getTracking } from './git.js';
|
|
113
|
+
import { createHealthCache, HEALTH_TTL_MS } from './health-cache.js';
|
|
113
114
|
import { createGithubBranchForge } from './repo-branch-forge.js';
|
|
114
115
|
import { attributeLog, classifyInputFor, deleteBranches, forgetRepoBranches, readRepoBranchCounts, readRepoBranches } from './repo-branches.js';
|
|
115
116
|
import { claimRepoGitMutation, localPullBranches, pullRepoCheckout } from './repo-pull.js';
|
|
@@ -133,7 +134,7 @@ import { mergeWriteWorkspaceUiState, readWorkspaceUiState } from '../workspace/u
|
|
|
133
134
|
import { checkoutRepo } from './checkout.js';
|
|
134
135
|
import { createProject, listGithubOwners } from './create-project.js';
|
|
135
136
|
import { createWorkspaceRunFeed } from './workspace-run-feed.js';
|
|
136
|
-
import {
|
|
137
|
+
import { mergeWriteProjectUiState, readUiState } from '../ui-state.js';
|
|
137
138
|
import { agentHomePaths, expandTilde } from '../paths.js';
|
|
138
139
|
import { isLoopbackHostHeader, normalizeHostname, resolveCapabilities } from './capabilities.js';
|
|
139
140
|
import { browseDirectory, isInsideBrowseRoot, isLexicallyInsideBrowseRoot, resolveBrowseRoot } from './fs-browse.js';
|
|
@@ -678,11 +679,9 @@ export function createApp(deps) {
|
|
|
678
679
|
.then((changed) => {
|
|
679
680
|
if (!changed)
|
|
680
681
|
return;
|
|
681
|
-
// Probe is settled;
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
await refreshHealth();
|
|
685
|
-
})().catch(() => { });
|
|
682
|
+
// Probe is settled; publish the new checks to both transports. Only availability changed:
|
|
683
|
+
// re-reading Git would spawn processes on this loop (hearsay-tools/squawk#3355).
|
|
684
|
+
void healthCache.patch((payload) => ({ ...payload, checks: backendChecks })).catch(() => { });
|
|
686
685
|
});
|
|
687
686
|
}
|
|
688
687
|
return backendChecks;
|
|
@@ -730,69 +729,24 @@ export function createApp(deps) {
|
|
|
730
729
|
bootProject: workspace.bootProject,
|
|
731
730
|
};
|
|
732
731
|
};
|
|
733
|
-
//
|
|
734
|
-
//
|
|
735
|
-
// probes have their own nonblocking cache above. Paying that on the browser's FIRST `GET /api/health` is
|
|
736
|
-
// exactly the few-seconds-blank the cockpit showed at load. So on the live
|
|
737
|
-
// server the snapshot is computed at the server's OWN pace: both the GET and
|
|
738
|
-
// the WS `health` topic serve the cached value immediately and revalidate
|
|
739
|
-
// behind the response, and the cache is pre-warmed at boot so that first
|
|
740
|
-
// request lands on a warm value instead of the cold compute.
|
|
741
|
-
const HEALTH_TTL_MS = 5_000;
|
|
742
|
-
// The staleness CEILING, which is a different job from the TTL above. The TTL
|
|
743
|
-
// decides how often a revalidation is kicked off; on its own it bounds nothing,
|
|
744
|
-
// because the revalidation is fire-and-forget. While a cockpit holds the
|
|
745
|
-
// `health` topic the publisher's interval keeps the cache warm and the two are
|
|
746
|
-
// the same number — but the normal state of a background `hsq serve` is NO
|
|
747
|
-
// subscriber, and then nothing refreshes the cache at all: the next `GET
|
|
748
|
-
// /api/health`, an hour later, would answer with the boot pre-warm's payload
|
|
749
|
-
// and only the request AFTER it would see the truth. `repo.branch` going stale there is
|
|
750
|
-
// literally #369, so past this age correctness beats the latency win and the
|
|
751
|
-
// read waits for the compute. `refreshHealth` dedupes, so waiting costs one.
|
|
752
|
-
const HEALTH_MAX_STALE_MS = 60_000;
|
|
753
|
-
let healthCache;
|
|
754
|
-
let healthInFlight;
|
|
755
|
-
// Set while the topic has a subscriber; a change a refresh detects is pushed
|
|
756
|
-
// here (a noop when nobody is listening).
|
|
732
|
+
// Stale-while-revalidate cache over the snapshot; see health-cache.ts.
|
|
733
|
+
// Set while the topic has a subscriber (a noop when nobody is listening).
|
|
757
734
|
let publishHealth = () => { };
|
|
758
|
-
const
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
const body = JSON.stringify(payload);
|
|
767
|
-
const changed = body !== healthCache?.body;
|
|
768
|
-
healthCache = { at: Date.now(), payload, body };
|
|
769
|
-
if (changed) {
|
|
770
|
-
publishHealth(payload);
|
|
771
|
-
workspaceEvents.emit('health', payload);
|
|
772
|
-
} // only a real change reaches either transport
|
|
773
|
-
return payload;
|
|
774
|
-
}
|
|
775
|
-
finally {
|
|
776
|
-
healthInFlight = undefined;
|
|
777
|
-
}
|
|
778
|
-
})();
|
|
779
|
-
return healthInFlight;
|
|
780
|
-
};
|
|
735
|
+
const healthCache = createHealthCache({
|
|
736
|
+
snapshot: healthSnapshot,
|
|
737
|
+
publish: (payload) => {
|
|
738
|
+
publishHealth(payload);
|
|
739
|
+
workspaceEvents.emit('health', payload);
|
|
740
|
+
},
|
|
741
|
+
});
|
|
742
|
+
const refreshHealth = () => healthCache.refresh();
|
|
781
743
|
// The read the GET and the topic snapshot share. On the live server (a hub is
|
|
782
|
-
// injected) it answers from cache
|
|
783
|
-
//
|
|
784
|
-
// keeping a cache coherent, so it computes fresh, exactly as before.
|
|
744
|
+
// injected) it answers from cache; without a hub — a bare app in tests — there is
|
|
745
|
+
// no refresher keeping a cache coherent, so it computes fresh, exactly as before.
|
|
785
746
|
const readHealth = async () => {
|
|
786
747
|
if (!deps.socketHub)
|
|
787
748
|
return healthSnapshot();
|
|
788
|
-
|
|
789
|
-
return refreshHealth(); // first ever: nothing to serve yet
|
|
790
|
-
const age = Date.now() - healthCache.at;
|
|
791
|
-
if (age > HEALTH_MAX_STALE_MS)
|
|
792
|
-
return refreshHealth(); // too old to serve — wait for the truth
|
|
793
|
-
if (age > HEALTH_TTL_MS)
|
|
794
|
-
void refreshHealth(); // stale: refresh, don't wait on it
|
|
795
|
-
return { ...healthCache.payload, capabilities: capabilities() }; // per request, like the gates (ADR 0055)
|
|
749
|
+
return healthCache.read((payload) => ({ ...payload, capabilities: capabilities() })); // per request, like the gates (ADR 0055)
|
|
796
750
|
};
|
|
797
751
|
// ---- chained family: health (workspace-level) ----------------------------
|
|
798
752
|
// Written as ONE chained expression rather than a loose `app.get(...)`
|
|
@@ -1624,6 +1578,12 @@ export function createApp(deps) {
|
|
|
1624
1578
|
const registered = await registerFolder(parsed.data.root, 'local');
|
|
1625
1579
|
if (registered.status !== 200)
|
|
1626
1580
|
return c.json(registered.body, registered.status);
|
|
1581
|
+
if (registered.existing) {
|
|
1582
|
+
// 409 with the EXISTING entry (spec): the dialog treats it as "you already have this one"
|
|
1583
|
+
// and navigates there rather than dead-ending.
|
|
1584
|
+
const { project } = registered.body;
|
|
1585
|
+
return c.json({ project, error: `already registered as ${project.id}` }, 409);
|
|
1586
|
+
}
|
|
1627
1587
|
return c.json(registered.body, 200);
|
|
1628
1588
|
})
|
|
1629
1589
|
.delete('/projects/:projectId', async (c) => {
|
|
@@ -1872,15 +1832,15 @@ export function createApp(deps) {
|
|
|
1872
1832
|
// `{ error, reason }` degradation, mirroring the GitHub pane.
|
|
1873
1833
|
return c.json('reason' in result ? { error: result.error, reason: result.reason } : { error: result.error }, result.status);
|
|
1874
1834
|
}
|
|
1835
|
+
// An existing entry for the same root (its folder had been deleted) is a success too: the
|
|
1836
|
+
// project the user asked for is there (hearsay-tools/squawk#1086).
|
|
1875
1837
|
const registered = await registerFolder(result.target, 'checkout');
|
|
1876
1838
|
if (registered.status !== 200) {
|
|
1877
1839
|
// The clone SUCCEEDED and its files are legitimately the user's, so this
|
|
1878
1840
|
// path deliberately does NOT clean up — an unregisterable checkout is a
|
|
1879
1841
|
// registry problem, not a reason to delete a repo we just fetched. Say
|
|
1880
1842
|
// where it is so they can register it by hand.
|
|
1881
|
-
|
|
1882
|
-
const error = 'error' in body && body.error ? body.error : 'could not register the checkout';
|
|
1883
|
-
return c.json({ error: `${error} (the clone is at ${result.target})` }, registered.status);
|
|
1843
|
+
return c.json({ error: `${registered.body.error} (the clone is at ${result.target})` }, registered.status);
|
|
1884
1844
|
}
|
|
1885
1845
|
return c.json(registered.body, 200);
|
|
1886
1846
|
})
|
|
@@ -1928,25 +1888,16 @@ export function createApp(deps) {
|
|
|
1928
1888
|
}
|
|
1929
1889
|
// GitHub-backed projects register as `checkout` (they have an origin the
|
|
1930
1890
|
// clone flow would also produce); a local-only repo is `local`.
|
|
1891
|
+
// A new entry, or the existing one for the same root — what creating a registered project
|
|
1892
|
+
// whose folder had been deleted produces. Both are a success.
|
|
1931
1893
|
const registered = await registerFolder(result.target, result.slug ? 'checkout' : 'local');
|
|
1932
|
-
|
|
1933
|
-
// creating a registered project whose folder had been deleted produces. The user asked for
|
|
1934
|
-
// that project and it is there, so both are a success. (An if/else chain, not a helper:
|
|
1935
|
-
// only narrowing `registered` keeps the error bodies out of the route's 200 type.)
|
|
1936
|
-
let project;
|
|
1937
|
-
if (registered.status === 200)
|
|
1938
|
-
project = registered.body.project;
|
|
1939
|
-
else if (registered.status === 409 && 'project' in registered.body)
|
|
1940
|
-
project = registered.body.project;
|
|
1941
|
-
else {
|
|
1894
|
+
if (registered.status !== 200) {
|
|
1942
1895
|
// As with a clone: the repository is the user's now, so it stays — and a GitHub warning
|
|
1943
1896
|
// rides along, since its finishing commands are the only record of what is left to do.
|
|
1944
|
-
const { body } = registered;
|
|
1945
|
-
const error = 'error' in body && body.error ? body.error : 'could not register the new project';
|
|
1946
1897
|
const warning = result.warning ? `\n${result.warning}` : '';
|
|
1947
|
-
return c.json({ error: `${error} (the project is at ${result.target})${warning}` }, registered.status);
|
|
1898
|
+
return c.json({ error: `${registered.body.error} (the project is at ${result.target})${warning}` }, registered.status);
|
|
1948
1899
|
}
|
|
1949
|
-
const body = { project, ...(result.warning ? { warning: result.warning } : {}) };
|
|
1900
|
+
const body = { project: registered.body.project, ...(result.warning ? { warning: result.warning } : {}) };
|
|
1950
1901
|
return c.json(body, 200);
|
|
1951
1902
|
});
|
|
1952
1903
|
/** Hosted containment for a path that may not exist yet: lexical for the
|
|
@@ -1973,7 +1924,8 @@ export function createApp(deps) {
|
|
|
1973
1924
|
* The register-a-folder half of `POST /api/projects`, factored out so the
|
|
1974
1925
|
* checkout route (step 4.3) commits its fresh clone through the SAME guards
|
|
1975
1926
|
* and the same `project-added` emission rather than a second copy of them.
|
|
1976
|
-
*
|
|
1927
|
+
* A root the registry already holds is a success with `existing: true`; each
|
|
1928
|
+
* route decides how to answer it.
|
|
1977
1929
|
*/
|
|
1978
1930
|
const registerFolder = async (spelled, source) => {
|
|
1979
1931
|
// `~` is expanded for the same reason `/api/fs/browse` expands it: the
|
|
@@ -2066,18 +2018,11 @@ export function createApp(deps) {
|
|
|
2066
2018
|
body: { error: err instanceof Error ? err.message : String(err) },
|
|
2067
2019
|
};
|
|
2068
2020
|
}
|
|
2069
|
-
if (known) {
|
|
2070
|
-
// 409 with the EXISTING entry (spec): the dialog treats it as "you
|
|
2071
|
-
// already have this one" and navigates there rather than dead-ending.
|
|
2072
|
-
return {
|
|
2073
|
-
status: 409,
|
|
2074
|
-
body: { project, error: `already registered as ${project.id}` },
|
|
2075
|
-
};
|
|
2076
|
-
}
|
|
2077
2021
|
// Only a genuinely new project is an event — a re-add is a no-op for every
|
|
2078
2022
|
// open cockpit's sidebar.
|
|
2079
|
-
|
|
2080
|
-
|
|
2023
|
+
if (!known)
|
|
2024
|
+
workspaceEvents.emit('project-added', { project });
|
|
2025
|
+
return { status: 200, body: { project }, existing: known };
|
|
2081
2026
|
};
|
|
2082
2027
|
// Deregister a project (multi-project spec, step 4.4 — Settings → Projects,
|
|
2083
2028
|
// the per-row "Remove"). READ THIS BEFORE TOUCHING THE HANDLER: the ONLY
|
|
@@ -2290,20 +2235,16 @@ export function createApp(deps) {
|
|
|
2290
2235
|
// On `use`, not inline on the route — see the workspace ui-state PUT above.
|
|
2291
2236
|
.use('/ui-state', bodyLimit({ maxSize: UI_STATE_BODY_LIMIT }))
|
|
2292
2237
|
.put('/ui-state', jsonZodValidator(uiStateBody), async (c) => {
|
|
2293
|
-
const { root: repoRoot, dataDir } = c.get('project');
|
|
2294
2238
|
// `.passthrough()` keeps unknown prefs, but a
|
|
2295
2239
|
// single request may not stuff an unbounded key set (#429) — the shared
|
|
2296
2240
|
// schema+cap half of both ui-state routes lives in `uiStateBody`.
|
|
2297
|
-
const
|
|
2298
|
-
const merged = { ...(await readProjectUiState(repoRoot)), ...parsed.data };
|
|
2241
|
+
const patch = c.req.valid('json');
|
|
2299
2242
|
try {
|
|
2300
|
-
await
|
|
2301
|
-
await writeProjectUiState(repoRoot, merged);
|
|
2243
|
+
return c.json(await mergeWriteProjectUiState(c.get('project').root, (current) => ({ ...current, ...patch })));
|
|
2302
2244
|
}
|
|
2303
2245
|
catch (err) {
|
|
2304
2246
|
return c.json({ error: err instanceof Error ? err.message : String(err) }, 500);
|
|
2305
2247
|
}
|
|
2306
|
-
return c.json(merged);
|
|
2307
2248
|
});
|
|
2308
2249
|
// ---- chained family: workflows (project-scoped) --------------------------
|
|
2309
2250
|
// One chained expression, mounted by `createApp` into BOTH the legacy `api`
|