Skip to content

Feat: Rewrite wiki template with reui - #16797

Merged
wangq8 merged 2 commits into
infiniflow:mainfrom
cike8899:feat-structure-wiki
Jul 10, 2026
Merged

wangq8 merged 2 commits into
infiniflow:mainfrom
cike8899:feat-structure-wiki

Conversation

@cike8899

Copy link
Copy Markdown
Contributor

Summary

Feat: Rewrite wiki template with reui

@dosubot dosubot Bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Jul 10, 2026
@coderabbitai

coderabbitai Bot commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The PR adds reusable stepper components and integrates them into compilation-template creation. It also makes npm hook installation resilient, changes form validation timing, removes one translation entry, and updates Python proxy targets.

Changes

Compilation template stepper

Layer / File(s) Summary
Reusable stepper primitives
web/src/components/reui/stepper.tsx
Adds context-driven step state, controlled and uncontrolled activation, keyboard navigation, indicators, panels, content visibility, and exported component and hook APIs.
Compilation template step navigation
web/src/pages/user-setting/compilation-templates/create-next/components/template-stepper.tsx, web/src/pages/user-setting/compilation-templates/create-next/index.tsx
Adds localized template steps, conditionally includes blueprints, replaces CustomTimeline, and restricts navigation to earlier steps.

Web tooling and runtime configuration

Layer / File(s) Summary
Resilient Lefthook preparation
web/package.json, web/scripts/prepare.js
Runs a Node preparation script that conditionally installs Lefthook hooks and ignores installation failures.
Form, locale, and proxy behavior
web/src/pages/user-setting/compilation-templates/edit-template/hooks/use-compilation-template-group-form.ts, web/src/locales/en.ts, web/vite.config.ts
Enables on-change form updates, removes the entity translation, and changes Python proxy targets to port 9380.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant TemplateStepper
  participant CreateNextCompilationTemplate
  participant StepContent
  User->>TemplateStepper: select an available step
  TemplateStepper->>CreateNextCompilationTemplate: call onStepChange
  CreateNextCompilationTemplate->>CreateNextCompilationTemplate: accept earlier step
  CreateNextCompilationTemplate->>TemplateStepper: update activeStep
  TemplateStepper->>StepContent: render active content
Loading

Poem

I’m a rabbit hopping through each step,
With bright new hooks and tabs in prep.
Blueprints bloom, old timelines flee,
Forms change quickly—one, two, three!
Ports and labels neatly align,
I twitch my nose: the flow looks fine.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The description only repeats the title and lacks the required background/context. Add a short problem statement, background context, and the main goals of the template rewrite.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: rewriting the template with ReUI.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cike8899 cike8899 added the ci Continue Integration label Jul 10, 2026
@cike8899
cike8899 marked this pull request as draft July 10, 2026 03:12
@cike8899
cike8899 marked this pull request as ready for review July 10, 2026 03:12

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
web/scripts/prepare.js (1)

27-30: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider execFileSync with an argument array instead of string-based execSync.

Static analysis flags this as a dynamic command passed to execSync. While lefthookBin is derived deterministically from __dirname (not user-controlled), using execFileSync/spawnSync with an argument array is the recommended Node.js pattern and would satisfy the linter warnings. Note: on Windows you'd need shell: true (or spawnSync with shell: isWindows) to correctly invoke .cmd files.

♻️ Optional refactor
 import { execSync } from 'node:child_process';
+import { execFileSync } from 'node:child_process';
-  execSync(`"${lefthookBin}" install`, {
-    cwd: repoRoot,
-    stdio: 'inherit',
-  });
+  execFileSync(lefthookBin, ['install'], {
+    cwd: repoRoot,
+    stdio: 'inherit',
+    shell: isWindows,
+  });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/scripts/prepare.js` around lines 27 - 30, Replace string-based execSync
in the lefthook installation logic with execFileSync or spawnSync, passing
lefthookBin and arguments separately; configure Windows execution with shell:
true or an equivalent isWindows-based option so .cmd files continue to work.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@web/src/components/reui/stepper.tsx`:
- Around line 93-103: Trigger nodes are not removed when StepperTrigger
components unmount, and registerTrigger cannot remove a node when passed null.
Add an unregisterTrigger function to the Stepper context interface and
implementation that removes a specific HTMLButtonElement, expose it through
contextValue and dependencies, destructure it in StepperTrigger, and update the
registration effect to capture btnRef.current and return cleanup that
unregisters the captured node.
- Around line 148-155: Add indicators to the dependency array of the useMemo
containing the stepper context value, alongside currentStep and the other
dependencies, so changing indicators props updates StepperIndicator content.

---

Nitpick comments:
In `@web/scripts/prepare.js`:
- Around line 27-30: Replace string-based execSync in the lefthook installation
logic with execFileSync or spawnSync, passing lefthookBin and arguments
separately; configure Windows execution with shell: true or an equivalent
isWindows-based option so .cmd files continue to work.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ec952bc3-9303-456b-b5e1-a35f7787dd19

📥 Commits

Reviewing files that changed from the base of the PR and between 289ca28 and 2b83ca3.

📒 Files selected for processing (8)
  • web/package.json
  • web/scripts/prepare.js
  • web/src/components/reui/stepper.tsx
  • web/src/locales/en.ts
  • web/src/pages/user-setting/compilation-templates/create-next/components/template-stepper.tsx
  • web/src/pages/user-setting/compilation-templates/create-next/index.tsx
  • web/src/pages/user-setting/compilation-templates/edit-template/hooks/use-compilation-template-group-form.ts
  • web/vite.config.ts
💤 Files with no reviewable changes (1)
  • web/src/locales/en.ts

Comment on lines +93 to +103
const registerTrigger = useCallback((node: HTMLButtonElement | null) => {
setTriggerNodes((prev) => {
if (node && !prev.includes(node)) {
return [...prev, node];
} else if (!node && prev.includes(node!)) {
return prev.filter((n) => n !== node);
} else {
return prev;
}
});
}, []);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🔴 Critical | ⚡ Quick win

Trigger nodes are never cleaned up on unmount — keyboard navigation breaks when steps are conditionally removed.

StepperTrigger registers its DOM node via useEffect (line 251-255) but has no cleanup function. When a step is unmounted (e.g., the blueprints step disappears because isArtifacts flips to false), the stale button element remains in triggerNodes. This causes focusNext/focusPrev to attempt focusing detached DOM nodes and corrupts myIdx calculations.

Additionally, registerTrigger's removal path (line 97) is broken: when node is null, it checks prev.includes(null) which is always false for an array of HTMLButtonElement objects, so the filter branch never executes.

The fix requires both adding an unregisterTrigger function and calling it in the effect cleanup. The node must be captured in the effect closure because React nulls btnRef.current before cleanup runs.

🔧 Proposed fix: add unregisterTrigger and effect cleanup

Add unregisterTrigger to the context interface:

 interface StepperContextValue {
   activeStep: number;
   setActiveStep: (step: number) => void;
   stepsCount: number;
   orientation: StepperOrientation;
   registerTrigger: (node: HTMLButtonElement | null) => void;
+  unregisterTrigger: (node: HTMLButtonElement) => void;
   triggerNodes: HTMLButtonElement[];
   focusNext: (currentIdx: number) => void;
   focusPrev: (currentIdx: number) => void;
   focusFirst: () => void;
   focusLast: () => void;
   indicators: StepIndicators;
 }

Add the function in Stepper and wire it into the context:

   const registerTrigger = useCallback((node: HTMLButtonElement | null) => {
     setTriggerNodes((prev) => {
       if (node && !prev.includes(node)) {
         return [...prev, node];
       } else if (!node && prev.includes(node!)) {
         return prev.filter((n) => n !== node);
       } else {
         return prev;
       }
     });
   }, []);
+
+  const unregisterTrigger = useCallback((node: HTMLButtonElement) => {
+    setTriggerNodes((prev) => prev.filter((n) => n !== node));
+  }, []);

Add it to contextValue and its deps:

       orientation,
       registerTrigger,
+      unregisterTrigger,
       focusNext,
       focusPrev,
       focusFirst,
       focusLast,
       triggerNodes,
       indicators,
     }),
     [
       currentStep,
       handleSetActiveStep,
       children,
       orientation,
       registerTrigger,
+      unregisterTrigger,
       triggerNodes,
     ],

Destructure it in StepperTrigger:

   const {
     setActiveStep,
     activeStep,
     registerTrigger,
+    unregisterTrigger,
     triggerNodes,
     focusNext,
     focusPrev,
     focusFirst,
     focusLast,
   } = stepperCtx;

Add cleanup to the useEffect:

   useEffect(() => {
-    if (btnRef.current) {
-      registerTrigger(btnRef.current);
+    const node = btnRef.current;
+    if (node) {
+      registerTrigger(node);
     }
+    return () => {
+      if (node) {
+        unregisterTrigger(node);
+      }
+    };
   }, [btnRef.current]);

Also applies to: 250-255

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/src/components/reui/stepper.tsx` around lines 93 - 103, Trigger nodes are
not removed when StepperTrigger components unmount, and registerTrigger cannot
remove a node when passed null. Add an unregisterTrigger function to the Stepper
context interface and implementation that removes a specific HTMLButtonElement,
expose it through contextValue and dependencies, destructure it in
StepperTrigger, and update the registration effect to capture btnRef.current and
return cleanup that unregisters the captured node.

Comment on lines +148 to +155
[
currentStep,
handleSetActiveStep,
children,
orientation,
registerTrigger,
triggerNodes,
],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

indicators is missing from the useMemo dependency array.

indicators is used in the memoized context value (line 146) but absent from the deps array (lines 148-155). If a parent passes changing indicators props, StepperIndicator will render stale content. The file-level eslint-disable react-hooks/exhaustive-deps at line 1 suppresses the warning that would have caught this.

🔧 Proposed fix
     [
       currentStep,
       handleSetActiveStep,
       children,
       orientation,
       registerTrigger,
       triggerNodes,
+      indicators,
     ],
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
[
currentStep,
handleSetActiveStep,
children,
orientation,
registerTrigger,
triggerNodes,
],
[
currentStep,
handleSetActiveStep,
children,
orientation,
registerTrigger,
triggerNodes,
indicators,
],
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/src/components/reui/stepper.tsx` around lines 148 - 155, Add indicators
to the dependency array of the useMemo containing the stepper context value,
alongside currentStep and the other dependencies, so changing indicators props
updates StepperIndicator content.

@wangq8
wangq8 merged commit d317742 into infiniflow:main Jul 10, 2026
7 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants