Skip to content

Commit 3e8732f

Browse files
mzxchandraclaude
andcommitted
refactor(forks): render the fork-sync default with ChipSwitch
CLAUDE.md makes the chip family the canonical control chrome, and `ChipSwitch` is what the equivalent settings row already uses (`inbox-enable-toggle.tsx`). Two knock-on details, both forced by the control rather than chosen. `ChipSwitch` is a Radix radio group over a string, so the boolean inversion now runs through named values instead of `!`: `exclude` and `sync` map onto the stored `forkSyncNewWorkflowsExcluded`. And it takes no `id`, so the `Label` drops its `htmlFor` and the group carries its own `aria-label` - the same pairing `inbox-enable-toggle.tsx` uses. It also reads better here. This row's "off" means new workflows stop syncing across the whole lineage, which a thumb position leaves the reader to infer from the label; naming both outcomes puts it on screen. No behavior change beyond the control: the same mutation, the same error toast, the same placeholder-data gate. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 4ae7641 commit 3e8732f

1 file changed

Lines changed: 19 additions & 10 deletions

File tree

‎apps/sim/ee/workspace-forking/components/fork-sync-default-toggle/fork-sync-default-toggle.tsx‎

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
'use client'
22

3-
import { Label, Switch, toast } from '@sim/emcn'
3+
import { ChipSwitch, Label, toast } from '@sim/emcn'
44
import { getErrorMessage } from '@sim/utils/errors'
55
import { useUpdateForkSyncDefault } from '@/ee/workspace-forking/hooks/workspace-fork'
66

7+
/** Both outcomes named, so "off" does not have to be inferred from the label. */
8+
const FORK_SYNC_DEFAULT_OPTIONS = [
9+
{ value: 'sync', label: 'Sync' },
10+
{ value: 'exclude', label: "Don't sync" },
11+
] as const
12+
713
interface ForkSyncDefaultToggleProps {
814
workspaceId: string
915
/** The lineage's stored policy: true means new workflows start outside fork sync. */
@@ -40,26 +46,29 @@ export function ForkSyncDefaultToggle({
4046
const updateDefault = useUpdateForkSyncDefault()
4147

4248
// Render nothing until the lineage resolves, matching the workflow list below. A
43-
// placeholder would have to guess a value, and guessing `false` renders the switch ON -
44-
// the opposite of the truth for an opt-in lineage, which then visibly snaps once the
45-
// real value lands. Disabled-but-wrong is worse than absent for a cross-workspace policy.
49+
// placeholder would have to guess a value, and guessing `false` selects "Sync" - the
50+
// opposite of the truth for an opt-in lineage, which then visibly snaps once the real
51+
// value lands. Disabled-but-wrong is worse than absent for a cross-workspace policy.
4652
if (loading) return null
4753

4854
return (
4955
<div className='flex items-center justify-between'>
5056
<div className='flex flex-col gap-1'>
51-
<Label htmlFor='fork-sync-new-workflows'>Sync new workflows by default</Label>
57+
{/* No `htmlFor`: `ChipSwitch` is a radio group and takes no id, so the group
58+
carries its own `aria-label`. Matches `inbox-enable-toggle.tsx`. */}
59+
<Label>Sync new workflows by default</Label>
5260
<p className='text-[var(--text-muted)] text-caption'>
5361
Applies to every workspace in this fork lineage.
5462
</p>
5563
</div>
56-
<Switch
57-
id='fork-sync-new-workflows'
58-
checked={!excludeNewWorkflows}
64+
<ChipSwitch
65+
aria-label='Sync new workflows by default'
66+
options={FORK_SYNC_DEFAULT_OPTIONS}
67+
value={excludeNewWorkflows ? 'exclude' : 'sync'}
5968
disabled={updateDefault.isPending}
60-
onCheckedChange={(syncNewWorkflows) =>
69+
onChange={(value) =>
6170
updateDefault.mutate(
62-
{ workspaceId, body: { excludeNewWorkflows: !syncNewWorkflows } },
71+
{ workspaceId, body: { excludeNewWorkflows: value === 'exclude' } },
6372
{
6473
onError: (error) =>
6574
toast.error(getErrorMessage(error, 'Failed to update the fork sync default')),

0 commit comments

Comments
 (0)