From dad5d8d61008dbd7c18610bbbcdf065940093f0b Mon Sep 17 00:00:00 2001 From: Seongmin Lee Date: Tue, 11 Aug 2026 19:01:12 +0900 Subject: [PATCH] web: PR title & body edit Signed-off-by: Seongmin Lee --- web/src/lib/api/pull.ts | 31 +++++++ .../components/repo/issues/IssueForm.svelte | 10 ++- .../components/repo/pulls/PullCompose.svelte | 5 ++ .../components/repo/pulls/PullInfoBar.svelte | 11 ++- .../[aturi]/[version]/[[range]]/+page.svelte | 86 ++++++++++++++++--- 5 files changed, 126 insertions(+), 17 deletions(-) diff --git a/web/src/lib/api/pull.ts b/web/src/lib/api/pull.ts index cf847fc01..7db0e8843 100644 --- a/web/src/lib/api/pull.ts +++ b/web/src/lib/api/pull.ts @@ -1,6 +1,7 @@ import { ok } from "@atcute/client"; import { mainSchema as putRecordSchema } from "@atcute/atproto/types/repo/putRecord"; import { mainSchema as deleteRecordSchema } from "@atcute/atproto/types/repo/deleteRecord"; +import { mainSchema as getRecordSchema } from "@atcute/atproto/types/repo/getRecord"; import type { Nsid, RecordKey } from "@atcute/lexicons/syntax"; import type { OAuthUserAgent } from "@atcute/oauth-browser-client"; import { now as tidNow } from "@atcute/tid"; @@ -30,6 +31,36 @@ export const putPull = async ( return { uri, cid, value: record }; }; +export const editPull = async ( + agent: OAuthUserAgent, + rkey: string, + patch: { title: string; body: string } +): Promise> => { + const rpc = createClient(agent); + const existing = await ok( + rpc.call(getRecordSchema, { + params: { + repo: agent.sub, + collection: PULL_COLLECTION, + rkey: rkey as RecordKey + } + }) + ); + const record = { ...(existing.value as PullRecord), ...patch }; + const { uri, cid } = await ok( + rpc.call(putRecordSchema, { + input: { + repo: agent.sub, + collection: PULL_COLLECTION, + rkey: rkey as RecordKey, + swapRecord: existing.cid, + record + } + }) + ); + return { uri, cid, value: record }; +}; + export const deletePull = async (agent: OAuthUserAgent, rkey: string): Promise => { const rpc = createClient(agent); await ok( diff --git a/web/src/lib/components/repo/issues/IssueForm.svelte b/web/src/lib/components/repo/issues/IssueForm.svelte index a9e950f45..ca80f9914 100644 --- a/web/src/lib/components/repo/issues/IssueForm.svelte +++ b/web/src/lib/components/repo/issues/IssueForm.svelte @@ -26,7 +26,8 @@ body?: string; submitLabel?: string; bodyPlaceholder?: string; - onsaved: (saved: RecordView) => void; + submit?: (input: { title: string; body: string }) => Promise; + onsaved?: (saved: RecordView) => void; oncancel: () => void; } @@ -40,6 +41,7 @@ body: initialBody = "", submitLabel, bodyPlaceholder = "Describe your issue. Markdown is supported.", + submit, onsaved, oncancel }: Props = $props(); @@ -55,6 +57,10 @@ event.preventDefault(); const agent = auth.agent; if (!agent || title.trim() === "") return; + if (submit) { + await submit({ title, body }); + return; + } const targetRkey = rkey ?? tidNow(); const record: IssueRecord = { $type: "sh.tangled.repo.issue", @@ -64,7 +70,7 @@ createdAt: createdAt ?? new Date().toISOString() }; const saved = await putIssue(agent, targetRkey, record); - onsaved(saved); + onsaved?.(saved); }); const canSubmit = $derived(title.trim() !== "" && !save.loading); diff --git a/web/src/lib/components/repo/pulls/PullCompose.svelte b/web/src/lib/components/repo/pulls/PullCompose.svelte index da8abc142..233987b40 100644 --- a/web/src/lib/components/repo/pulls/PullCompose.svelte +++ b/web/src/lib/components/repo/pulls/PullCompose.svelte @@ -176,6 +176,11 @@ ]); // pin before the record lands, so gc can't drop the head in between + console.log("keepCommit", { + repo: compose.sourceRepoDid, + oid: head.hash, + record: uri + }); await keepCommit(agent, compose.sourceKnot, { repo: compose.sourceRepoDid, oid: head.hash, diff --git a/web/src/lib/components/repo/pulls/PullInfoBar.svelte b/web/src/lib/components/repo/pulls/PullInfoBar.svelte index e94d18ea6..481809647 100644 --- a/web/src/lib/components/repo/pulls/PullInfoBar.svelte +++ b/web/src/lib/components/repo/pulls/PullInfoBar.svelte @@ -1,4 +1,5 @@