fix(gitlab): persist unposted inline comments + split browser-safe types#719
Merged
Conversation
…m browser-safe pr-types Closes #680. Two changes that landed together because the persistence fix exposed a hidden architectural constraint. 1. GitLab inline comments: when one or more discussion POSTs failed (e.g. transient `i/o timeout`), the failed comment bodies were lost. Now `submitGlMRReview` writes them to `~/.plannotator/failed-comments/{host}-{project}-mr{iid}-{ts}.json` in both the all-fail and partial-fail branches. The throw-vs-warn split is preserved deliberately: all-fail throws so the UI retries from a clean state, partial-fail warns so the UI doesn't resubmit already-posted content. 2. Split `packages/shared/pr-provider.ts` into `pr-types.ts` (browser-safe types + pure label/URL helpers) and `pr-provider.ts` (server-only dispatch that imports pr-github / pr-gitlab). The review-editor browser bundle previously dragged pr-gitlab.ts in as dead code via static imports, which silently constrained the file to never use Node built-ins. Adding `fs`/`os`/`path` for (1) broke the review build until we routed browser imports to pr-types and left server callers on the now server-only pr-provider facade. Server-only `pr-provider.ts` re-exports `pr-types` so existing server-side imports keep working unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #680.
submitGlMRReview(packages/shared/pr-gitlab.ts): when one or more inline discussion POSTs fail (e.g. transienti/o timeoutagainst GitLab), the failed comment bodies are now persisted to~/.plannotator/failed-comments/{host}-{project}-mr{iid}-{ts}.jsonso they can be recovered. The error message points the user at the file path.Why the diff is bigger than #680 alone
The persistence call needs
fs/os/path. The review-editor browser bundle was pullingpr-gitlab.tsin as dead code throughpr-provider.ts's static imports, which made the file silently constrained to "no Node-only imports." Addingfsbrokebun run --cwd apps/review build.So I split
pr-provider.tsalong its existing seam:pr-types.ts(new) — types, label helpers (getPlatformLabel,getMRLabel, ...),parsePRUrl. No imports ofpr-github/pr-gitlab. Browser-safe by construction.pr-provider.ts— server-only dispatch (submitPRReview,fetchPR, ...). Re-exportspr-typesso existing server-side imports keep working unchanged.packages/review-editor/*now imports frompr-types(~14 files, all type-only or pure-helper imports).Test plan
bun test packages/shared/— 272 pass, 0 failtsc --noEmitonpackages/shared,packages/ai,packages/server,packages/ui,apps/pi-extension— all cleanbun run --cwd apps/review build— review browser bundle no longer fails on__vite-browser-externalbun run build:hook— full hook build greenbun build apps/hook/server/index.ts --compile— single-file binary builds (107 MB output)vendor.shupdated to vendorpr-types.tsintoapps/pi-extension/generated/; Pi typecheck clean~/.plannotator/failed-comments/*.jsoncontains the unposted bodies, while already-posted comments are not duplicated on retry