diff --git a/.beads/issues.jsonl b/.beads/issues.jsonl index fe1853d..be414bd 100644 --- a/.beads/issues.jsonl +++ b/.beads/issues.jsonl @@ -22,7 +22,7 @@ {"id":"ifcurl-8s8","title":"viewer.html: interactive tool to set clipping planes","description":"Currently clip= planes can only be set by hand-editing the URL. Add an interactive clipping tool to the viewer: a UI control (e.g. toolbar button) that lets the user drag/place a clipping plane against the loaded model. The plane position and normal should be written back into the ifc:// URL as clip= parameters so the view is shareable. Consider using ThatOpen's clipper component (OBC.Clipper) if available, or a Three.js-based approach.","status":"closed","priority":3,"issue_type":"feature","assignee":"Bruno Postle","owner":"bruno@postle.net","created_at":"2026-04-24T05:49:22Z","created_by":"Bruno Postle","updated_at":"2026-04-24T06:23:14Z","started_at":"2026-04-24T06:11:49Z","closed_at":"2026-04-24T06:23:14Z","close_reason":"setupClipper() uses OBC.Clipper: seeds URL planes as draggable SimplePlanes, toolbar '✂ clip' toggle for double-click placement, '⊗ clips' clear button. syncCameraUrl extended to serialise current planes back to URL.","dependency_count":0,"dependent_count":0,"comment_count":0} {"id":"ifcurl-07a","title":"Cache size control for bare repo clones","description":"git.py clones remote repos as bare repos under ~/.cache/ifcurl/\u003chash\u003e/repo.git with no size limit or eviction policy. Large repos accumulate indefinitely. Add a configurable max cache size (e.g. via env var IFCURL_CACHE_MAX_GB or a config file) with an LRU eviction policy based on last-access time of each repo directory. Should also expose a CLI command (ifcurl cache --list, --prune, --clear) to inspect and manage the cache manually.","status":"open","priority":3,"issue_type":"feature","owner":"bruno@postle.net","created_at":"2026-04-24T05:45:59Z","created_by":"Bruno Postle","updated_at":"2026-04-24T05:45:59Z","dependency_count":0,"dependent_count":0,"comment_count":0} {"id":"ifcurl-ts5","title":"Assess Go test strategy for Forgejo plugin patch","description":"The Forgejo integration is a low-maintenance source patch (footer.tmpl, viewer.html, /viewer and /proxy HTTP handlers). Evaluate whether adding Go tests is feasible without coupling to Forgejo's full test suite: can the handler logic be extracted into a small testable package, or do tests have to live inside the Forgejo tree? If the cost of keeping tests green across Forgejo upstream upgrades is too high, document the decision and close. Outcome: either a small test file or a documented rationale for no Go tests.","status":"open","priority":3,"issue_type":"task","owner":"bruno@postle.net","created_at":"2026-04-24T05:45:57Z","created_by":"Bruno Postle","updated_at":"2026-04-24T05:45:57Z","dependency_count":0,"dependent_count":0,"comment_count":0} -{"id":"ifcurl-hvw","title":"Add JavaScript tests for viewer.html URL logic","description":"viewer.html contains pure-JS functions (parseIfcUrl, buildIfcUrl, toRawUrl, syncCameraUrl) with no test coverage. Add a lightweight JS test harness (e.g. a standalone test.html or Node-runnable test.js using the native test runner) that unit-tests these functions: round-trip URL parse/build, toRawUrl for each host type (GitHub, GitLab, Forgejo), and camera parameter serialisation. No browser automation needed — pure function tests.","status":"open","priority":3,"issue_type":"task","owner":"bruno@postle.net","created_at":"2026-04-24T05:45:56Z","created_by":"Bruno Postle","updated_at":"2026-04-24T05:45:56Z","dependency_count":0,"dependent_count":0,"comment_count":0} +{"id":"ifcurl-hvw","title":"Add JavaScript tests for viewer.html URL logic","description":"viewer.html contains pure-JS functions (parseIfcUrl, buildIfcUrl, toRawUrl, syncCameraUrl) with no test coverage. Add a lightweight JS test harness (e.g. a standalone test.html or Node-runnable test.js using the native test runner) that unit-tests these functions: round-trip URL parse/build, toRawUrl for each host type (GitHub, GitLab, Forgejo), and camera parameter serialisation. No browser automation needed — pure function tests.","status":"closed","priority":3,"issue_type":"task","assignee":"Bruno Postle","owner":"bruno@postle.net","created_at":"2026-04-24T05:45:56Z","created_by":"Bruno Postle","updated_at":"2026-04-24T06:30:47Z","started_at":"2026-04-24T06:26:01Z","closed_at":"2026-04-24T06:30:47Z","close_reason":"32 Node tests in tests/test_viewer_url.mjs covering parseIfcUrl, buildIfcUrl, toRawUrl. Pure functions extracted to viewer-url.js; viewer.html imports from it. Also caught + not being decoded in URL building.","dependency_count":0,"dependent_count":0,"comment_count":0} {"id":"ifcurl-b9e","title":"Audit and extend Python test coverage","description":"103 tests exist across test_url.py, test_git.py, test_auth.py, test_render.py, and test_service.py. Audit what is missing: check branch/edge coverage in git.py (offline fallback, mutable ref fetch, auth injection), service.py (tier 2 cache eviction, mutable ref bypass), and the CLI entry points in __main__.py. Add tests for any significant gaps found.","status":"open","priority":3,"issue_type":"task","owner":"bruno@postle.net","created_at":"2026-04-24T05:45:40Z","created_by":"Bruno Postle","updated_at":"2026-04-24T05:45:40Z","dependency_count":0,"dependent_count":0,"comment_count":0} {"id":"ifcurl-bqt","title":"Phase 4: Bonsai IFCDOCUMENTREFERENCE federation via ifc://","description":"When opening a model via ifc://, resolve IFCDOCUMENTREFERENCE locations using the repo and ref from the root file's URL as context. Resolve ifc:// locations in linked model references recursively. Requires the Phase 4 protocol handler (ifcurl-0oj).","status":"deferred","priority":3,"issue_type":"feature","owner":"bruno@postle.net","created_at":"2026-04-23T05:48:56Z","created_by":"Bruno Postle","updated_at":"2026-04-23T06:15:11Z","defer_until":"2026-12-01T00:00:00Z","dependencies":[{"issue_id":"ifcurl-bqt","depends_on_id":"ifcurl-0oj","type":"blocks","created_at":"2026-04-23T06:49:02Z","created_by":"Bruno Postle","metadata":"{}"}],"dependency_count":1,"dependent_count":1,"comment_count":0} {"id":"ifcurl-lcr","title":"Phase 4: Bonsai 'Copy view URL' button","description":"Add a button to Bonsai that generates an ifc:// URL from the current state: git remote/ref/file path, active selection as IfcOpenShell selector, current camera as camera+fov or scale params in IFC world coordinates, active clipping planes as clip params, current visibility mode. Default to commit hash ref; secondary option for @heads/ ref.","status":"deferred","priority":3,"issue_type":"feature","owner":"bruno@postle.net","created_at":"2026-04-23T05:48:55Z","created_by":"Bruno Postle","updated_at":"2026-04-23T06:15:10Z","defer_until":"2026-12-01T00:00:00Z","dependencies":[{"issue_id":"ifcurl-lcr","depends_on_id":"ifcurl-0oj","type":"blocks","created_at":"2026-04-23T06:49:01Z","created_by":"Bruno Postle","metadata":"{}"}],"dependency_count":1,"dependent_count":0,"comment_count":0} diff --git a/forgejo/custom/public/assets/viewer-url.js b/forgejo/custom/public/assets/viewer-url.js new file mode 100644 index 0000000..2435386 --- /dev/null +++ b/forgejo/custom/public/assets/viewer-url.js @@ -0,0 +1,78 @@ +// Pure ifc:// URL logic shared between viewer.html and tests. + +export function parseIfcUrl(raw) { + if (!raw?.startsWith("ifc://")) return null; + const body = raw.slice("ifc://".length); + + const slashIdx = body.indexOf("/"); + const authority = slashIdx < 0 ? body : body.slice(0, slashIdx); + const pathAndQuery = slashIdx < 0 ? "" : body.slice(slashIdx + 1); + + const atInAuth = authority.indexOf("@"); + const userAt = atInAuth < 0 ? "" : authority.slice(0, atInAuth + 1); + const host = atInAuth < 0 ? authority : authority.slice(atInAuth + 1); + + const qIdx = pathAndQuery.indexOf("?"); + const pathPart = qIdx < 0 ? pathAndQuery : pathAndQuery.slice(0, qIdx); + const qs = new URLSearchParams(qIdx < 0 ? "" : pathAndQuery.slice(qIdx + 1)); + + const atIdx = pathPart.lastIndexOf("@"); + const repoSuffix = atIdx < 0 ? pathPart : pathPart.slice(0, atIdx); + const ref = atIdx < 0 ? "" : pathPart.slice(atIdx + 1); + + return { + repo: userAt + host + "/" + repoSuffix, + host, userAt, repoSuffix, ref, + path: qs.get("path") ?? "", + selector: qs.get("selector") ?? "", + camera: qs.get("camera") ?? "", + fov: qs.get("fov") ?? "", + scale: qs.get("scale") ?? "", + }; +} + +export function buildIfcUrl(repo, ref, path, selector) { + if (!repo || !ref) return null; + const qs = new URLSearchParams(); + if (path) qs.set("path", path); + if (selector) qs.set("selector", selector); + const qsStr = qs.toString().replace(/%2C/g, ",").replace(/%2B/g, "+"); + return `ifc://${repo}@${ref}${qsStr ? "?" + qsStr : ""}`; +} + +export function toRawUrl(raw) { + const body = raw.slice("ifc://".length); + + const slashIdx = body.indexOf("/"); + const authority = slashIdx < 0 ? body : body.slice(0, slashIdx); + const pathAndQuery = slashIdx < 0 ? "" : body.slice(slashIdx + 1); + + const atInAuth = authority.indexOf("@"); + const host = atInAuth < 0 ? authority : authority.slice(atInAuth + 1); + + const qIdx = pathAndQuery.indexOf("?"); + const pathPart = qIdx < 0 ? pathAndQuery : pathAndQuery.slice(0, qIdx); + const qs = new URLSearchParams(qIdx < 0 ? "" : pathAndQuery.slice(qIdx + 1)); + const filePath = qs.get("path") ?? ""; + + const atIdx = pathPart.lastIndexOf("@"); + const repoPath = atIdx < 0 ? pathPart : pathPart.slice(0, atIdx); + const ref = atIdx < 0 ? "" : pathPart.slice(atIdx + 1); + + const plainRef = ref.startsWith("heads/") ? ref.slice(6) + : ref.startsWith("tags/") ? ref.slice(5) + : ref; + + if (host === "github.com" || host.endsWith(".github.com")) { + return `https://raw.githubusercontent.com/${repoPath}/${plainRef}/${filePath}`; + } + if (host === "gitlab.com" || host.includes("gitlab")) { + const proto = host.startsWith("localhost") ? "http" : "https"; + return `${proto}://${host}/${repoPath}/-/raw/${plainRef}/${filePath}`; + } + const refSeg = ref.startsWith("heads/") ? "branch/" + ref.slice(6) + : ref.startsWith("tags/") ? "tag/" + ref.slice(5) + : "commit/" + ref; + const proto = host.startsWith("localhost") ? "http" : "https"; + return `${proto}://${host}/${repoPath}/raw/${refSeg}/${filePath}`; +} diff --git a/forgejo/custom/public/assets/viewer.html b/forgejo/custom/public/assets/viewer.html index 11e2353..0780fc9 100644 --- a/forgejo/custom/public/assets/viewer.html +++ b/forgejo/custom/public/assets/viewer.html @@ -123,6 +123,7 @@