Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(views): align revision-conflict actions with their previews (#7634)
Bohan Jiang6e8019ba20cd
diff --git a/packages/views/issues/components/comment-card.tsx b/packages/views/issues/components/comment-card.tsxindex ef69e57059..a2b8110889 100644--- a/packages/views/issues/components/comment-card.tsx+++ b/packages/views/issues/components/comment-card.tsx@@ -556,21 +556,26 @@ function CommentRevisionConflict({localLabel={t(($) => $.revision.local_version)}serverValue={serverContent}localValue={localContent}- actions={(- <div className="flex flex-wrap items-center gap-2">- <Button- type="button"- size="sm"- variant="outline"- disabled={saving}- onClick={onKeepLocal}- >- {t(($) => $.revision.keep_local)}- </Button>- <Button type="button" size="sm" variant="ghost" onClick={onUseServer}>- {t(($) => $.revision.use_server)}- </Button>- </div>+ serverAction={(+ <Button+ type="button"+ size="sm"+ variant="outline"+ onClick={onUseServer}+ >+ {t(($) => $.revision.use_server)}+ </Button>+ )}+ localAction={(+ <Button+ type="button"+ size="sm"+ variant="outline"+ disabled={saving}+ onClick={onKeepLocal}+ >+ {t(($) => $.revision.keep_local)}+ </Button>)}/>);diff --git a/packages/views/issues/components/issue-detail.tsx b/packages/views/issues/components/issue-detail.tsxindex fbff5ea8fa..18c79ba12d 100644--- a/packages/views/issues/components/issue-detail.tsx+++ b/packages/views/issues/components/issue-detail.tsx@@ -2950,44 +2950,44 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = trlocalLabel={t(($) => $.revision.local_version)}serverValue={issue.title}localValue={titleConflictDraft}- actions={(- <div className="flex flex-wrap items-center gap-2">- <Button- type="button"- size="sm"- variant="outline"- onClick={() => {- const draft = titleConflictDraft.trim();- if (!draft) return;- handleUpdateField(- { title: draft, title_base: issue.title },- {- onSuccess: (serverIssue) => {- setTitleConflictDraft(null);- titleBaseRef.current = serverIssue.title;- },+ serverAction={(+ <Button+ type="button"+ size="sm"+ variant="outline"+ onClick={() => {+ // Local-only: the server already holds this title, so+ // discarding writes nothing. The remount is what puts it+ // back into the editor (see titleResetToken).+ setTitleConflictDraft(null);+ titleBaseRef.current = issue.title;+ setTitleResetToken((token) => token + 1);+ }}+ >+ {t(($) => $.revision.use_server)}+ </Button>+ )}+ localAction={(+ <Button+ type="button"+ size="sm"+ variant="outline"+ onClick={() => {+ const draft = titleConflictDraft.trim();+ if (!draft) return;+ handleUpdateField(+ { title: draft, title_base: issue.title },+ {+ onSuccess: (serverIssue) => {+ setTitleConflictDraft(null);+ titleBaseRef.current = serverIssue.title;},- );- }}- >- {t(($) => $.revision.keep_local)}- </Button>- <Button- type="button"- size="sm"- variant="ghost"- onClick={() => {- // Local-only: the server already holds this title, so- // discarding writes nothing. The remount is what puts it- // back into the editor (see titleResetToken).- setTitleConflictDraft(null);- titleBaseRef.current = issue.title;- setTitleResetToken((token) => token + 1);- }}- >- {t(($) => $.revision.use_server)}- </Button>- </div>+ },+ );+ }}+ >+ {t(($) => $.revision.keep_local)}+ </Button>)}/>) : null}@@ -3102,52 +3102,52 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = trlocalLabel={t(($) => $.revision.local_version)}serverValue={issue.description || ""}localValue={descriptionConflictDraft}- actions={(- <div className="flex flex-wrap items-center gap-2">- <Button- type="button"- size="sm"- variant="outline"- onClick={() => {- handleUpdateField(- {- description: descriptionConflictDraft,- description_base: issue.description || "",- attachment_ids:- descriptionAttachmentIdsRef.current.length > 0- ? descriptionAttachmentIdsRef.current- : undefined,- },- {- onSuccess: () => {- setDescriptionConflictDraft(null);- },+ serverAction={(+ <Button+ type="button"+ size="sm"+ variant="outline"+ onClick={() => {+ // The editor is dirty — that is why this conflict+ // exists — so the `value` prop cannot land: ContentEditor+ // deliberately refuses to clobber unsaved bytes.+ // adoptContent is the explicit "take this content"+ // channel and applies without emitting an update, so+ // discarding never writes.+ descEditorRef.current?.adoptContent(issue.description || "");+ descriptionAttachmentIdsRef.current = [];+ pendingDescriptionSaveRef.current = null;+ setDescriptionConflictDraft(null);+ }}+ >+ {t(($) => $.revision.use_server)}+ </Button>+ )}+ localAction={(+ <Button+ type="button"+ size="sm"+ variant="outline"+ onClick={() => {+ handleUpdateField(+ {+ description: descriptionConflictDraft,+ description_base: issue.description || "",+ attachment_ids:+ descriptionAttachmentIdsRef.current.length > 0+ ? descriptionAttachmentIdsRef.current+ : undefined,+ },+ {+ onSuccess: () => {+ setDescriptionConflictDraft(null);},- );- }}- >- {t(($) => $.revision.keep_local)}- </Button>- <Button- type="button"- size="sm"- variant="ghost"- onClick={() => {- // The editor is dirty — that is why this conflict- // exists — so the `value` prop cannot land: ContentEditor- // deliberately refuses to clobber unsaved bytes.- // adoptContent is the explicit "take this content"- // channel and applies without emitting an update, so- // discarding never writes.- descEditorRef.current?.adoptContent(issue.description || "");- descriptionAttachmentIdsRef.current = [];- pendingDescriptionSaveRef.current = null;- setDescriptionConflictDraft(null);- }}- >- {t(($) => $.revision.use_server)}- </Button>- </div>+ },+ );+ }}+ >+ {t(($) => $.revision.keep_local)}+ </Button>)}/>) : null}diff --git a/packages/views/issues/components/revision-conflict-compare.test.tsx b/packages/views/issues/components/revision-conflict-compare.test.tsxindex 13e1910df5..003c70058a 100644--- a/packages/views/issues/components/revision-conflict-compare.test.tsx+++ b/packages/views/issues/components/revision-conflict-compare.test.tsx@@ -62,4 +62,32 @@ describe("RevisionConflictCompare", () => {);expect(container.querySelector("[class*='line-clamp']")).toBeNull();});++ it("puts each action in the column of the preview it applies to", () => {+ const { container } = render(+ <RevisionConflictCompare+ title="Compare both versions"+ serverLabel="Latest server version"+ localLabel="Your local version"+ serverValue="server"+ localValue="local"+ serverAction={<button type="button">Use the latest version</button>}+ localAction={<button type="button">Keep my version</button>}+ />,+ );++ // The mismatch reported in #7624 was "keep my version" sitting under the+ // server preview, so assert the side each action lands on — not just that+ // both rendered.+ const actions = container.querySelector(+ "[data-revision-conflict-actions]",+ );+ expect(actions).not.toBeNull();+ const [serverCell, localCell] = Array.from(actions!.children);+ expect(serverCell).toHaveTextContent("Use the latest version");+ expect(localCell).toHaveTextContent("Keep my version");+ // Same two-column grid as the labels and the diff rows, so the pairing+ // survives every window width.+ expect(actions).toHaveClass("grid", "grid-cols-2");+ });});diff --git a/packages/views/issues/components/revision-conflict-compare.tsx b/packages/views/issues/components/revision-conflict-compare.tsxindex 29f6b08a39..6d59a67b12 100644--- a/packages/views/issues/components/revision-conflict-compare.tsx+++ b/packages/views/issues/components/revision-conflict-compare.tsx@@ -9,7 +9,13 @@ interface RevisionConflictCompareProps {serverValue: string;localValue: string;footer?: ReactNode;- actions?: ReactNode;+ // One action per side, rendered in its own column of the same two-column+ // grid as the labels and the diff. A single shared action row read as+ // "keep my version" sitting under the SERVER preview it discards (#7624);+ // the column is what makes each action point at its own pane, and it holds+ // at every width because the diff itself never stacks.+ serverAction?: ReactNode;+ localAction?: ReactNode;className?: string;}@@ -101,7 +107,8 @@ export function RevisionConflictCompare({serverValue,localValue,footer,- actions,+ serverAction,+ localAction,className,}: RevisionConflictCompareProps) {const rows = revisionConflictRows(serverValue, localValue);@@ -135,11 +142,21 @@ export function RevisionConflictCompare({</div>))}</div>+ {serverAction || localAction ? (+ <div+ data-revision-conflict-actions+ className="grid grid-cols-2 border-t bg-muted/40"+ >+ {/* px-3 matches the label cells above, so each button's left+ edge lands on the same vertical line as its column header. */}+ <div className="min-w-0 px-3 py-2">{serverAction}</div>+ <div className="min-w-0 border-l px-3 py-2">{localAction}</div>+ </div>+ ) : null}</div>{footer ? (<div className="mt-2 text-muted-foreground">{footer}</div>) : null}- {actions ? <div className="mt-2">{actions}</div> : null}</div>);}