Skip to content

Commit 71d3809

Browse files
committed
improvement(editor): convert new inline comments to concise TSDoc
Replaces the multi-line // comment blocks introduced by this PR (render-phase adjustment rationale, derived-in-render notes) with concise TSDoc, per the repo's TSDoc-only comment convention. Comment-only; no code changes.
1 parent 14add6d commit 71d3809

8 files changed

Lines changed: 29 additions & 30 deletions

File tree

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/user-input/hooks/use-mention-tokens.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export function useMentionTokens({
5757
// when multiple contexts share the same label
5858
const uniqueLabels = Array.from(new Set(labels))
5959

60-
// Precompute first-matching context per label for O(1) lookups in the loop
60+
/** First-matching context per label, for O(1) lookup while tokenizing. */
6161
const contextByLabel = new Map<string, (typeof selectedContexts)[number]>()
6262
for (const c of selectedContexts) {
6363
if (c.label && !contextByLabel.has(c.label)) contextByLabel.set(c.label, c)

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/document-tag-entry/document-tag-entry.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,7 @@ export function DocumentTagEntry({
192192
const tags: DocumentTag[] = parsedTags.length > 0 ? parsedTags : [createDefaultTag()]
193193
const isReadOnly = isPreview || disabled
194194

195-
// Get tag names already used (case-insensitive).
196-
// `tags` is rebuilt every render, so this is computed during render rather than memoized.
195+
/** Tag names already in use (case-insensitive); computed in render since `tags` is rebuilt each render. */
197196
const usedTagNames = (() => {
198197
const names = new Set<string>()
199198
for (const t of tags) {

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/file-upload/file-upload.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -632,8 +632,7 @@ export function FileUpload({
632632
[workspaceFiles, acceptedTypes]
633633
)
634634

635-
// Find the selected file's workspace ID for highlighting in single file mode.
636-
// `filesArray` is rebuilt every render, so this is computed during render rather than memoized.
635+
/** Selected file's workspace id for single-file highlighting; computed in render since `filesArray` is rebuilt each render. */
637636
const selectedFileId = (() => {
638637
if (!hasFiles || multiple) return ''
639638
const currentFile = filesArray[0]

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/long-input/long-input.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,10 @@ export function LongInput({
204204
? propValue
205205
: ctrl.valueString
206206

207-
// Sync local content with base value when not streaming by adjusting state
208-
// during render (no effect), so the wand's currentValue stays current without
209-
// an extra commit. localContent is only displayed while streaming.
207+
/**
208+
* Sync local content with the base value when not streaming, adjusted during render (no effect)
209+
* so the wand's currentValue never lags a commit. localContent is shown only while streaming.
210+
*/
210211
if (!wandHook.isStreaming) {
211212
const baseValueString = baseValue?.toString() ?? ''
212213
if (baseValueString !== localContent) {

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/hooks/use-sub-block-value.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,7 @@ export function useSubBlockValue<T = any>(
207207
? storeValue
208208
: initialValue
209209

210-
// Keep the ref in sync with the effective value so we always work with the latest value.
211-
// On first render valueRef starts as null, so this effect also performs the initial seed.
210+
/** Mirror the latest effective value into the ref; also seeds it on first render (ref starts null). */
212211
useEffect(() => {
213212
// Use deep comparison for objects to prevent unnecessary updates
214213
if (!isEqual(valueRef.current, effectiveValue)) {

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2621,11 +2621,11 @@ const WorkflowContent = React.memo(
26212621
syncPanelWithSelection(selectedNodeIds)
26222622
}, [selectedNodeIdsKey])
26232623

2624-
// Keep the most recently selected block on top even after deselection, so a
2625-
// dragged block doesn't suddenly drop behind other overlapping blocks. Adjust
2626-
// during render (not through an effect) so the latched id never lags a commit
2627-
// behind the selection it mirrors. It retains the previous value when the
2628-
// selection is cleared, so this is a latch rather than plain derived state.
2624+
/**
2625+
* Keep the most recently selected block on top even after deselection (so a dragged block
2626+
* doesn't drop behind overlapping blocks). Latched during render — retains the previous id
2627+
* when the selection clears, so it's a latch rather than plain derived state.
2628+
*/
26292629
const lastSelectedNodeId =
26302630
selectedNodeIds.length > 0 ? selectedNodeIds[selectedNodeIds.length - 1] : null
26312631
if (lastSelectedNodeId !== null && lastSelectedNodeId !== lastInteractedNodeId) {

apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/workspace-header/components/fork-workspace-modal/fork-workspace-modal.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,11 @@ export function ForkWorkspaceModal({
108108
const [forkedWorkspace, setForkedWorkspace] = useState<{ id: string; name: string } | null>(null)
109109
const [confirmRollbackOpen, setConfirmRollbackOpen] = useState(false)
110110

111-
// Reset the modal to a fresh state each time it opens (or the source name changes while
112-
// open). Adjusted during render via prev-value refs rather than a post-commit effect, so the
113-
// reopened modal never briefly commits the previous fork's name/selection before clearing it.
111+
/**
112+
* Reset the modal to a fresh state on open or when the source name changes while open.
113+
* Adjusted during render so the reopened modal never commits the previous fork's
114+
* name/selection before clearing it.
115+
*/
114116
const prevOpenRef = useRef(open)
115117
const prevSourceNameRef = useRef(sourceWorkspaceName)
116118
if (open && (prevOpenRef.current !== open || prevSourceNameRef.current !== sourceWorkspaceName)) {
@@ -125,9 +127,7 @@ export function ForkWorkspaceModal({
125127
prevOpenRef.current = open
126128
prevSourceNameRef.current = sourceWorkspaceName
127129

128-
// Seed the selection with everything the moment the resources query resolves (once per open,
129-
// guarded by `defaulted`). Adjusted during render for the same reason as the reset above:
130-
// routing it through an effect would commit an empty selection for a frame before the default.
130+
/** Seed the full selection once the resources query resolves (once per open, guarded by `defaulted`). */
131131
if (open && resources.data && !defaulted) {
132132
setDefaulted(true)
133133
setSelected(fullSelection(resources.data))

apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/workspace-header/components/promote-workspace-modal/promote-workspace-modal.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,11 @@ export function PromoteWorkspaceModal({
216216
const [confirmSyncOpen, setConfirmSyncOpen] = useState(false)
217217
const [submitting, setSubmitting] = useState(false)
218218

219-
// Seed the direction picker when the modal opens (or the parent edge changes while it's
220-
// open). Adjusted during render via a prev-value compare so the seeded value lands before
221-
// paint instead of a post-paint effect flashing the prior selection. `selectedKey` stays
222-
// editable (the dropdown sets it), so it isn't derived state.
219+
/**
220+
* Seed the direction picker when the modal opens or the parent edge changes while open.
221+
* Adjusted during render so the value lands before paint; `selectedKey` stays editable (the
222+
* dropdown sets it), so it isn't derived state.
223+
*/
223224
const prevOpenSeedRef = useRef(false)
224225
const prevEdgeOptionsRef = useRef(edgeOptions)
225226
const openSeedChanged = prevOpenSeedRef.current !== open
@@ -230,11 +231,11 @@ export function PromoteWorkspaceModal({
230231
setSelectedKey(edgeOptions[0]?.value ?? '')
231232
}
232233

233-
// Restart at the overview and drop in-session overrides whenever it (re)opens or the
234-
// direction changes - the mapping set, and therefore the steps, depend on the direction.
235-
// Adjusted during render (prev-value compare) so the reset lands before paint rather than
236-
// an effect flashing the prior edge's state. `copyDefaulted` stays state so its reset here
237-
// re-triggers the copy-default effect below (needed on a reopen with cached diff data).
234+
/**
235+
* Restart at the overview and drop in-session overrides on (re)open or direction change (the
236+
* mapping set, and therefore the steps, depend on direction). Adjusted during render;
237+
* `copyDefaulted` stays state so its reset here re-triggers the copy-default effect below.
238+
*/
238239
const prevOpenResetRef = useRef(false)
239240
const prevSelectedKeyRef = useRef(selectedKey)
240241
const openResetChanged = prevOpenResetRef.current !== open

0 commit comments

Comments
 (0)