Local projects: issues, asks and news. The open server's issues code runs in the client's process as the project's does, over issues.sqlite beside project.sqlite in the store; every call, issues ones too, holds the project file's lock, so local writers take one lock in one order. abso issue, issues, ask, answer, waiting, news and start --issue work with the network off. Attachments and news --stream don't yet. Version 294 of shared· pinch· Oct 16 (2026-10-16 03:33 UTC) · Not checked
Version 293 · Files at version 294
5 files, 72 lines added, 9 removed.
--- a/client/src/issues.ts
+++ b/client/src/issues.ts
@@ -28,6 +28,7 @@
28 28 import { ignoredHere } from "./fetch.ts"; 29 29 import { loadIgnore, relativeTo } from "./folder.ts"; 30 30 import type { AskReply } from "./issues-wire.ts"; 31 + import { isLocal, LOCAL_BASE } from "./local-store.ts"; 31 32 import { queuedLines, standing } from "./queue.ts"; 32 33 import { seenText, shortWhen } from "./times.ts"; @@ -36,6 +37,11 @@
36 37 /** The folder, with its Api pointed at the Issues Worker: the token goes only where tokenGoesTo allows, as for the avcs server. */ 37 38 export function openIssues(env: Env): { root: string; config: Config; api: Api } { 38 39 const { root, config, api } = open(env); 40 + // A local project's issues are in its store, where the open server keeps them: at /issues. 41 + if (isLocal(config.server)) { 42 + api.issuesServer = `${LOCAL_BASE}/issues`; 43 + return { root, config, api }; 39 45 // An explicit --server goes to that server's own Issues Worker: ABSO_ISSUES_SERVER doesn't redirect it. 41 47 (env.server === undefined ? fromEnv(env.env, "ISSUES_SERVER") : undefined) || --- a/client/src/local-server.d.mts
+++ b/client/src/local-server.d.mts
@@ -1,3 +1,5 @@
1 1 // The types of local-server.mjs: as much of the open server as the client calls. 2 2 export declare function handle(request: Request, env: unknown, ctx: unknown, issues: unknown): Promise<Response>; 3 3 export declare const ProjectObject: new (ctx: unknown, env: unknown) => object; 4 + export declare const IssueProject: new (ctx: unknown, env: unknown) => object; 5 + export declare function issuesFetch(request: Request, env: unknown, ctx: unknown, route: unknown): Promise<Response>; --- a/client/src/local-server.mjs
+++ b/client/src/local-server.mjs
@@ -1,6 +1,7 @@
1 − // The open server's router and project object, for local projects (local-store.ts). Plain JS, with its types in
2 − // local-server.d.mts, so the client's typecheck stops here: server/src is typechecked with the Workers' types
1 + // The open server's router, project object and issues, for local projects (local-store.ts). Plain JS, with its types 2 + // in local-server.d.mts, so the client's typecheck stops here: server/src is typechecked with the Workers' types 3 3 // (server/tsconfig.json). The build and Node follow these imports as usual. 5 + export { IssueProject, issuesFetch } from "../../server/src/issues-entry.ts"; 5 6 export { ProjectObject } from "../../server/src/project-object.ts"; 6 7 export { handle } from "../../server/src/router.ts"; --- a/client/src/local-store.ts
+++ b/client/src/local-store.ts
@@ -189,6 +189,8 @@
189 189 DatabaseSync: new (path: string) => Db; 190 190 handle: (request: Request, env: unknown, ctx: unknown, issues: unknown) => Promise<Response>; 191 191 ProjectObject: new (ctx: unknown, env: unknown) => object; 192 + IssueProject: new (ctx: unknown, env: unknown) => object; 193 + issuesFetch: (request: Request, env: unknown, ctx: unknown, route: unknown) => Promise<Response>; 193 195 let server: Promise<Server> | undefined; @@ -240,7 +242,13 @@
240 242 `local projects couldn't load the server's code: ${e instanceof Error ? e.message : String(e)}`, 243 − return { DatabaseSync: sqlite.DatabaseSync, handle: loaded.handle, ProjectObject: loaded.ProjectObject };
246 + DatabaseSync: sqlite.DatabaseSync, 247 + handle: loaded.handle, 248 + ProjectObject: loaded.ProjectObject, 249 + IssueProject: loaded.IssueProject, 250 + issuesFetch: loaded.issuesFetch, @@ -256,6 +264,10 @@
256 264 object: object | undefined; 257 265 /** PRAGMA data_version when this process last used the project: it changes when another process writes. */ 258 266 seen: number | undefined; 267 + /** The project's issues, asks and news: issues.sqlite beside it, opened when a call first reaches them. */ 268 + issues?: { db: Db; storage: ReturnType<typeof storageOver> }; 269 + /** The issues object for the call under way: made again for each call, as another process may have written. */ 270 + issueObject?: object; 261 273 /** Every store file this process has open: closed when its command ends (closeLocalStores). */ @@ -271,7 +283,8 @@
274 − const PROJECT_PATH = /^\/p\/([^/]+)\//;
286 + /** A project's calls, and its issues, asks and news, which the open server keeps at /issues/p/<project>/. */ 287 + const PROJECT_PATH = /^(?:\/issues)?\/p\/([^/]+)\//; 275 288 const NAME = /^[A-Za-z0-9._-]{1,100}$/; 276 289 const json = (status: number, body: unknown) => Response.json(body, { status }); @@ -312,8 +325,25 @@
315 − // Issues, asks and news aren't in local projects yet: a start note's issue hooks find nothing to call.
316 − ISSUES_DO: { idFromName: (n: string) => n, get: () => ({}) },
329 + idFromName: (n: string) => n, 330 + get: (n: string) => { 331 + const p = open.get(n); 332 + if (!p || n !== name) throw new LocalError(`no local project ${n}`); 333 + if (p.issues === undefined || !opened.has(p.issues.db)) { 334 + const db = new opening!.DatabaseSync(join(dir, name, "issues.sqlite")); 336 + db.exec("PRAGMA journal_mode = WAL; PRAGMA busy_timeout = 120000; PRAGMA synchronous = NORMAL"); 337 + p.issues = { db, storage: storageOver(db) }; 339 + // Its writes need no lock of their own: every call holds the project file's (see below). 340 + p.issueObject ??= new opening!.IssueProject( 341 + { id: { toString: () => n, name: n }, storage: p.issues.storage }, 344 + return p.issueObject; 318 348 return async (input, init = {}) => { 319 349 const s = await loadServer(); @@ -329,7 +359,10 @@
329 359 headers.set("authorization", `Bearer ${LOCAL_TOKEN}`); 330 360 const request = new Request(url, { ...init, headers }); 331 361 const waits: Promise<unknown>[] = []; 362 + // Every call, issues ones too, holds the project file's lock, so local writers of the project and of its 363 + // issues take one lock in one order. 332 364 p.db.exec("BEGIN IMMEDIATE"); 365 + p.issueObject = undefined; 334 367 const version = (p.db.prepare("PRAGMA data_version").get() as { data_version: number }).data_version; 335 368 if (p.seen !== undefined && version !== p.seen) p.object = undefined; @@ -337,7 +370,7 @@
339 372 { waitUntil: (w: Promise<unknown>) => waits.push(w) }, 340 − issuesNone,
342 375 await Promise.allSettled(waits); 343 376 // The answer is read whole before the write is kept, so a body that fails to arrive keeps nothing either. @@ -358,5 +391,3 @@
361 −
362 − const issuesNone = async () => json(404, { error: "issues, asks and news aren't in local projects yet" });
--- a/client/test/local.test.ts
+++ b/client/test/local.test.ts
@@ -104,6 +104,29 @@
104 104 assert.notEqual(held.exit, 0); 105 105 assert.match(held.out + held.err, /collision/); 108 + it("issues, asks and news work too, kept in issues.sqlite beside the project", async () => { 109 + const opened = await run(alice, "issue", "new", "Fix the parser", "--agent", "bob"); 110 + assert.equal(opened.exit, 0, opened.out + opened.err); 111 + assert.ok(existsSync(join(store, "demo", "issues.sqlite"))); 112 + const listed = await run(bob, "issues"); 113 + assert.equal(listed.exit, 0, listed.err); 114 + assert.match(listed.out, /Fix the parser/); 115 + const started = await run(bob, "start", "Parser fix", "--issue", "1"); 116 + assert.equal(started.exit, 0, started.out + started.err); 117 + const asked = await run(alice, "ask", "bob", "Which grammar?", "--issue", "1"); 118 + assert.equal(asked.exit, 0, asked.out + asked.err); 119 + const waiting = await run(bob, "waiting", "--mine"); 120 + assert.equal(waiting.exit, 0, waiting.err); 121 + assert.match(waiting.out, /Which grammar\?/); 122 + const answered = await run(bob, "answer", "1", "The new one"); 123 + assert.equal(answered.exit, 0, answered.out + answered.err); 124 + const news = await run(alice, "news"); 125 + assert.equal(news.exit, 0, news.err); 126 + assert.match(news.out, /The new one/); 127 + const issue = await run(alice, "issue", "1"); 128 + assert.match(issue.out, /In progress|bob/); 109 132 describe("where a local project's store is", () => {