-
Notifications
You must be signed in to change notification settings - Fork 376
Prevent terminal hydration drift and improve settings semantics #1237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -371,7 +371,7 @@ export function AutomationForm({ mode, initialValues, onSubmit, submitting }: Au | |
| {/* Trigger Type */} | ||
| {mode === "create" ? ( | ||
| <div> | ||
| <label className="block text-sm font-medium text-foreground mb-1.5">Trigger Type</label> | ||
| <div className="block text-sm font-medium text-foreground mb-1.5">Trigger Type</div> | ||
| <FieldDescription className="my-1"> | ||
| Scheduled automations run on a repeating timer. Other types run when the connected | ||
| service sends an event (for example a GitHub webhook or Sentry alert). | ||
|
|
@@ -420,12 +420,16 @@ export function AutomationForm({ mode, initialValues, onSubmit, submitting }: Au | |
|
|
||
| {/* Repository Configuration */} | ||
| <div> | ||
| <label className="block text-sm font-medium text-foreground mb-1.5"> | ||
| <label | ||
| htmlFor="automation-repository-configuration" | ||
| className="block text-sm font-medium text-foreground mb-1.5" | ||
| > | ||
| Repository Configuration | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [deep review] The new |
||
| </label> | ||
| <Popover open={repoDropdownOpen} onOpenChange={setRepoDropdownOpen}> | ||
| <PopoverTrigger asChild> | ||
| <button | ||
| id="automation-repository-configuration" | ||
| type="button" | ||
| className="flex w-full items-center gap-2 rounded-sm border border-border bg-input px-3 py-2 text-sm text-foreground transition hover:border-foreground/20 focus-visible:border-ring focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40" | ||
| aria-label="Repository selection" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,9 +44,14 @@ export function useSessionAttachments() { | |
| const attachmentsRef = useRef<PendingAttachment[]>([]); | ||
| const attachmentsRevisionRef = useRef(0); | ||
| const activeUploadRef = useRef<AbortController | null>(null); | ||
| const uploadedByIdRef = useRef( | ||
| new Map<string, { sessionId: string; attachment: SessionAttachmentReference }>() | ||
| ); | ||
| const uploadedByIdRef = useRef<Map< | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [deep review] This behavior-neutral rewrite adds nullable state, render-time mutation, an alias, and callback dependencies merely to hold a stable |
||
| string, | ||
| { sessionId: string; attachment: SessionAttachmentReference } | ||
| > | null>(null); | ||
| if (uploadedByIdRef.current === null) { | ||
| uploadedByIdRef.current = new Map(); | ||
| } | ||
| const uploadedById = uploadedByIdRef.current; | ||
|
|
||
| useEffect(() => { | ||
| attachmentsRef.current = attachments; | ||
|
|
@@ -107,32 +112,35 @@ export function useSessionAttachments() { | |
| } | ||
| }, []); | ||
|
|
||
| const removeAttachment = useCallback((id: string) => { | ||
| setAttachmentError(null); | ||
| const current = attachmentsRef.current; | ||
| const removed = current.find((attachment) => attachment.id === id); | ||
| if (!removed) return; | ||
| const removeAttachment = useCallback( | ||
| (id: string) => { | ||
| setAttachmentError(null); | ||
| const current = attachmentsRef.current; | ||
| const removed = current.find((attachment) => attachment.id === id); | ||
| if (!removed) return; | ||
|
|
||
| URL.revokeObjectURL(removed.previewUrl); | ||
| uploadedByIdRef.current.delete(removed.id); | ||
| attachmentsRevisionRef.current += 1; | ||
| activeUploadRef.current?.abort(); | ||
| const next = current.filter((attachment) => attachment.id !== id); | ||
| attachmentsRef.current = next; | ||
| setAttachments(next); | ||
| }, []); | ||
| URL.revokeObjectURL(removed.previewUrl); | ||
| uploadedById.delete(removed.id); | ||
| attachmentsRevisionRef.current += 1; | ||
| activeUploadRef.current?.abort(); | ||
| const next = current.filter((attachment) => attachment.id !== id); | ||
| attachmentsRef.current = next; | ||
| setAttachments(next); | ||
| }, | ||
| [uploadedById] | ||
| ); | ||
|
|
||
| const clearAttachments = useCallback(() => { | ||
| const current = attachmentsRef.current; | ||
| for (const attachment of current) { | ||
| URL.revokeObjectURL(attachment.previewUrl); | ||
| } | ||
| uploadedByIdRef.current.clear(); | ||
| uploadedById.clear(); | ||
| attachmentsRevisionRef.current += 1; | ||
| activeUploadRef.current?.abort(); | ||
| attachmentsRef.current = []; | ||
| setAttachments([]); | ||
| }, []); | ||
| }, [uploadedById]); | ||
|
|
||
| /** | ||
| * Upload all pending attachments and return the references to send with the | ||
|
|
@@ -170,7 +178,7 @@ export function useSessionAttachments() { | |
| for (const pendingAttachment of pending) { | ||
| const fileName = pendingAttachment.file.name; | ||
| assertCurrent(); | ||
| const cached = uploadedByIdRef.current.get(pendingAttachment.id); | ||
| const cached = uploadedById.get(pendingAttachment.id); | ||
| if (cached?.sessionId === sessionId) { | ||
| uploaded.push(cached.attachment); | ||
| continue; | ||
|
|
@@ -204,7 +212,7 @@ export function useSessionAttachments() { | |
| name: fileName || "image-attachment", | ||
| attachmentId, | ||
| }; | ||
| uploadedByIdRef.current.set(pendingAttachment.id, { sessionId, attachment }); | ||
| uploadedById.set(pendingAttachment.id, { sessionId, attachment }); | ||
| uploaded.push(attachment); | ||
| } | ||
| assertCurrent(); | ||
|
|
@@ -228,7 +236,7 @@ export function useSessionAttachments() { | |
| setIsUploading(false); | ||
| } | ||
| }, | ||
| [] | ||
| [uploadedById] | ||
| ); | ||
|
|
||
| return { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[deep review] This removes the invalid standalone label, but it leaves the mutually exclusive choices semantically unnamed and ungrouped:
TriggerTypeSelectorstill renders plain buttons with no selected-state semantics. Please make this a real field boundary (fieldset/legendwith native radios, or a namedradiogroupwitharia-checked) so the structure expresses the model instead of only changing the heading element.