feat(drill): work-zero method picker and redesigned status card - #713
Conversation
📝 WalkthroughWalkthroughДобавлен экран выбора одного из трёх методов Work Zero, вычисление доступности и состояния карточки, сессионное хранение привязки, обновлённая навигация инспектора и межоконное открытие редактора панели. ChangesWork Zero
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant DrillPlanInspector
participant WorkZeroMethodPicker
participant DrillZeroInspector
participant WorkZeroStore
DrillPlanInspector->>WorkZeroMethodPicker: передаёт доступность методов
WorkZeroMethodPicker->>DrillZeroInspector: запускает выбранный метод
DrillZeroInspector->>WorkZeroStore: сохраняет результат привязки
DrillZeroInspector->>DrillPlanInspector: завершает сценарий и возвращает plan
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@cuprum-ui/src/components/operations/DrillOperationEditor.tsx`:
- Around line 96-105: Replace currentPath-based tracking in the
workZeroProjectRef effect with a stable project identifier, using workingDir or
the project ID from snap. Compare and store that identifier so switching unsaved
projects clears Work Zero metadata, while saving the current project does not
clear it spuriously; keep the existing clearWorkZero behavior.
In `@cuprum-ui/src/locales/en/drill.json`:
- Line 155: Update the noPoints translation in the drill locale to state that
the panel requires at least two alignment points, covering the pointCount < 2
case accurately instead of claiming no points exist.
🪄 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: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: fb903355-0049-4468-8567-a848613ad3b6
📒 Files selected for processing (14)
cuprum-ui/src/components/drill/DrillPlanInspector.tsxcuprum-ui/src/components/drill/DrillZeroInspector.tsxcuprum-ui/src/components/drill/WorkZeroMethodPicker.tsxcuprum-ui/src/components/drill/WorkZeroStatusCard.tsxcuprum-ui/src/components/operations/DrillOperationEditor.tsxcuprum-ui/src/hooks/useDrillBridge.tscuprum-ui/src/lib/api.tscuprum-ui/src/lib/workZeroMethods.test.tscuprum-ui/src/lib/workZeroMethods.tscuprum-ui/src/locales/en/drill.jsoncuprum-ui/src/locales/ru/drill.jsoncuprum-ui/src/navigationStore.tscuprum-ui/src/pages/ProjectPage.tsxcuprum-ui/src/workZeroMethodStore.ts
| // The work-zero method metadata (RMS/angle chip) is solved against one panel's | ||
| // alignment points; a project switch with the drill window open keeps the | ||
| // physical G54 offset but invalidates that metadata — drop it so the status | ||
| // card doesn't claim a registration that was never measured for this board. | ||
| const workZeroProjectRef = useRef(snap.currentPath); | ||
| useEffect(() => { | ||
| if (workZeroProjectRef.current === snap.currentPath) return; | ||
| workZeroProjectRef.current = snap.currentPath; | ||
| useWorkZeroMethod.getState().clearWorkZero(); | ||
| }, [snap.currentPath]); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Не используйте currentPath как идентификатор проекта.
Для несохранённых проектов currentPath остаётся null, поэтому переключение между ними сохраняет чужие Work Zero metadata. И наоборот, первое сохранение того же проекта меняет null на путь и ошибочно очищает metadata. Отслеживайте стабильный workingDir или project ID.
Предлагаемое исправление
- const workZeroProjectRef = useRef(snap.currentPath);
+ const workZeroProjectRef = useRef(snap.workingDir);
useEffect(() => {
- if (workZeroProjectRef.current === snap.currentPath) return;
- workZeroProjectRef.current = snap.currentPath;
+ if (workZeroProjectRef.current === snap.workingDir) return;
+ workZeroProjectRef.current = snap.workingDir;
useWorkZeroMethod.getState().clearWorkZero();
- }, [snap.currentPath]);
+ }, [snap.workingDir]);📝 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.
| // The work-zero method metadata (RMS/angle chip) is solved against one panel's | |
| // alignment points; a project switch with the drill window open keeps the | |
| // physical G54 offset but invalidates that metadata — drop it so the status | |
| // card doesn't claim a registration that was never measured for this board. | |
| const workZeroProjectRef = useRef(snap.currentPath); | |
| useEffect(() => { | |
| if (workZeroProjectRef.current === snap.currentPath) return; | |
| workZeroProjectRef.current = snap.currentPath; | |
| useWorkZeroMethod.getState().clearWorkZero(); | |
| }, [snap.currentPath]); | |
| // The work-zero method metadata (RMS/angle chip) is solved against one panel's | |
| // alignment points; a project switch with the drill window open keeps the | |
| // physical G54 offset but invalidates that metadata — drop it so the status | |
| // card doesn't claim a registration that was never measured for this board. | |
| const workZeroProjectRef = useRef(snap.workingDir); | |
| useEffect(() => { | |
| if (workZeroProjectRef.current === snap.workingDir) return; | |
| workZeroProjectRef.current = snap.workingDir; | |
| useWorkZeroMethod.getState().clearWorkZero(); | |
| }, [snap.workingDir]); |
🤖 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 `@cuprum-ui/src/components/operations/DrillOperationEditor.tsx` around lines 96
- 105, Replace currentPath-based tracking in the workZeroProjectRef effect with
a stable project identifier, using workingDir or the project ID from snap.
Compare and store that identifier so switching unsaved projects clears Work Zero
metadata, while saving the current project does not clear it spuriously; keep
the existing clearWorkZero behavior.
| "holes_other": "holes: {{count}}" | ||
| }, | ||
| "unavailable": { | ||
| "noPoints": "the panel has no alignment points", |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Исправьте причину недоступности для одной точки.
noPoints используется при pointCount < 2, поэтому при одной точке сообщение ошибочно утверждает, что точек нет. Укажите требование минимум двух точек.
Предлагаемое исправление
- "noPoints": "the panel has no alignment points",
+ "noPoints": "add at least 2 alignment points",📝 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.
| "noPoints": "the panel has no alignment points", | |
| "noPoints": "add at least 2 alignment points", |
🤖 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 `@cuprum-ui/src/locales/en/drill.json` at line 155, Update the noPoints
translation in the drill locale to state that the panel requires at least two
alignment points, covering the pointCount < 2 case accurately instead of
claiming no points exist.
Refs #708 (эпик #705). Фаза B: карточка «Рабочий ноль» + экран выбора метода + ре-компоновка метода 1 (по хэндоффу дизайнера).
panelMode: "method"): три карточки с чипами-фактов; недоступность с причинами — «нет точек центровки» + кнопка «Открыть редактор» (переход в редактор панели main-окна), «мастер в разработке» (метод 2 при наличии точек — мастер едет следующей фазой), «щуп не настроен» (метод 3); при отключённом станке заблокированы все.workZeroMethodStore.lib/workZeroMethods.ts+ тесты по карте состояний дизайнера.Проверки: pnpm build (tsc + i18n-check) чисто, vitest 890 ok. Визуальная проверка — за пользователем.
Summary by CodeRabbit
Новые возможности
Локализация
Тесты