Chế độ chỉnh sửa của Trình kiểm tra (ở phạm vi phiên)
Quy tắcThiết lập Chế độ chỉnh sửa của Trình kiểm tra có trạng thái, ở phạm vi phiên để đồng duy trì các thành phần React và trình kiểm tra phát triển tách biệt tương ứng mà không gây ô nhiễm giữa các phiên.
Đăng nhập để truy cập vào quy tắc này
Đăng nhập bằng Hồ sơ nhà phát triển của Google để xem và sao chép toàn bộ quy tắc được sử dụng trong loạt bài Build It! (Xây dựng).
Phải có Hồ sơ nhà phát triển
Bạn không đủ điều kiện để tạo hồ sơ nhà phát triển. Hãy thông báo cho quản trị viên Workspace của bạn để bật tính năng này.
Tạo hồ sơ nhà phát triển
Tạo Hồ sơ nhà phát triển của Google miễn phí để sử dụng tất cả kỹ năng, quy tắc, câu lệnh và cấu phần phần mềm của Build It!
Tham gia Builder Central để mở khoá
Chỉ cần nhấp một lần là bạn có thể nhận huy hiệu hội viên miễn phí của Build It! để mở khoá tất cả kỹ năng, quy tắc, câu lệnh và cấu phần phần mềm của Build It!.
Cách hoạt động của Chế độ chỉnh sửa trong Trình kiểm tra ở phạm vi phiên
Khi lặp lại các thành phần giao diện người dùng bằng Trình kiểm tra thành phần đang mở, bạn muốn các nội dung chỉnh sửa thành phần cập nhật chế độ xem trình kiểm tra phù hợp trong cùng một lượt mà không buộc phải chỉnh sửa trình kiểm tra vĩnh viễn trong các phiên sau này. Quy tắc này giải quyết vấn đề đó bằng cách sử dụng tệp đánh dấu trong phạm vi cuộc trò chuyện:
- TẮT theo mặc định cho mọi phiên mới: Các cuộc trò chuyện mới bắt đầu ở Chế độ thông thường để các nội dung chỉnh sửa thông thường chỉ ảnh hưởng đến đúng những tệp bạn yêu cầu.
- Vào Chế độ chỉnh sửa của trình kiểm tra: Nói "Vào chế độ chỉnh sửa của trình kiểm tra" (hoặc "Bật chế độ trình kiểm tra"). Tác nhân tạo tệp đánh dấu trong phạm vi phiên tại
<appDataDir>/brain/<conversation-id>/inspector-mode.active, đọcsrc/dev/registry.tsvà liệt kê mọi thành phần đã đăng ký được đề cập trong phiên này. - Tự động đồng bảo trì: Khi hoạt động, mọi thay đổi mà bạn yêu cầu đối với một thành phần đã đăng ký sẽ cập nhật thành phần đó trước, rồi đồng bộ hoá ngay
src/dev/inspectors/[ComponentName]Inspector.tsxphù hợp bằng quy trình Trình cập nhật Trình kiểm tra thành phần, chạynpx tsc --noEmitvà đóng dấu phản hồi bằng một khối xác nhận. - Thoát sạch bất cứ lúc nào: Nói "Thoát khỏi chế độ chỉnh sửa của trình kiểm tra" để xoá tệp đánh dấu và quay lại chế độ chỉnh sửa một mục tiêu thông thường. Việc bật chế độ này trong một phiên sẽ không ảnh hưởng đến các phiên song song hoặc phiên trong tương lai.
Cách cài đặt trong Google Antigravity
Đặt quy tắc này vào không gian làm việc Google Antigravity cùng với hai kỹ năng Trình kiểm tra thành phần trong Tập 9:
- Tạo thư mục
.agents/rules/trong không gian làm việc của dự án (hoặc mở Google Antigravity Customizations > Rules (Tuỳ chỉnh > Quy tắc) để thêm quy tắc không gian làm việc). - Lưu toàn bộ quy tắc Markdown bên dưới dưới dạng
inspector-editing-mode.mdbên trong.agents/rules/. - Cài đặt các kỹ năng đồng hành Component Inspector Generator và Component Inspector Updater để tác nhân của bạn có cả quy trình tạo khung và đồng bộ hoá được quy tắc này tham chiếu.
Định nghĩa quy tắc về chế độ chỉnh sửa của Công cụ kiểm tra
Sao chép toàn bộ định nghĩa quy tắc này vào không gian làm việc của bạn dưới dạng inspector-editing-mode.md.
# Inspector Editing Mode (Session-Scoped)
This rule establishes a stateful, session-scoped **Inspector Editing Mode** for co-maintaining React components and their corresponding isolated development inspectors (`src/dev/inspectors/[ComponentName]Inspector.tsx`).
---
## 1. Scope & Isolation Model
* **Session-Scoped**: The on/off state of this mode is strictly scoped to the current conversation session (`<conversation-id>`).
* **Default State**: Every new conversation session begins with Inspector Editing Mode **OFF** by default.
* **State Marker**:
- Activation is tracked at `<appDataDir>/brain/<conversation-id>/inspector-mode.active`.
- If this file exists for the active session's conversation ID, Inspector Editing Mode is **ON**.
- If this file does NOT exist, Inspector Editing Mode is **OFF**.
* **Zero Cross-Session Contamination**: Turning this mode on in one conversation has no effect on any other parallel or future conversation sessions.
---
## 2. Trigger Commands & State Transitions
### A. Entering Inspector Mode
* **Trigger Phrases**:
- *"Enter inspector editing mode"*
- *"Start inspector editing mode"*
- *"Turn on inspector mode"*
- *"Inspector mode on"*
* **Agent Action**:
1. Create the marker file at `<appDataDir>/brain/<conversation-id>/inspector-mode.active`.
2. Read `src/dev/registry.ts` to identify all currently registered components.
3. Respond confirming:
- Inspector Editing Mode is now **ACTIVE** for this session.
- Any subsequent changes to registered components will automatically update both the component and its dev inspector.
- List the currently registered components covered by this mode.
### B. Exiting Inspector Mode
* **Trigger Phrases**:
- *"Exit inspector editing mode"*
- *"Stop inspector editing mode"*
- *"Turn off inspector mode"*
- *"Inspector mode off"*
* **Agent Action**:
1. Remove the marker file at `<appDataDir>/brain/<conversation-id>/inspector-mode.active` if present.
2. Respond confirming that Inspector Editing Mode is now **DEACTIVATED** for this session and normal single-target editing has resumed.
### C. Status Query
* **Trigger Phrases**:
- *"Is inspector mode active?"*
- *"Inspector mode status"*
- *"What mode am I in?"*
* **Agent Action**:
- Check for the existence of `<appDataDir>/brain/<conversation-id>/inspector-mode.active`.
- Report whether the current session is in **Inspector Mode** or **Normal Mode**.
---
## 3. Co-Maintenance Behavior While Mode is ACTIVE
Whenever the user requests changes, fixes, or refactors to ANY component registered in `src/dev/registry.ts`:
1. **Step 1: Update the Core Component**
- Apply the requested code changes, props modifications, or behavioral logic in `src/components/.../[ComponentName].tsx` (or `src/views/.../[ComponentName].tsx`).
- Update any relevant unit tests in `scripts/` or `__tests__/`.
2. **Step 2: Automatically Synchronize the Dev Inspector**
- Locate the matching inspector at `src/dev/inspectors/[ComponentName]Inspector.tsx`.
- Apply the `component-inspector-updater` workflow:
- **Props & State**: Reconcile any new, altered, or deleted props into the *Editable State* or *Props State* categories.
- **Computed State**: Update derived `useMemo` metrics if underlying rules or formulas changed.
- **Test Verification Cards**: Synchronize the plain-English test fixtures at the bottom of the inspector with the new behavior, updating click handlers so `[Load Test Fixture]` accurately reflects the new state.
- **Preserve Custom Presets**: Keep all existing scenario presets (e.g. week overhauls, superset pairs, edge cases) intact, adapting their shapes to new prop signatures.
- **Advance Timestamp Chip**: Advance `const GENERATED_AT = 'YYYY-MM-DD HH:MM [TIMEZONE]';` to the current local timestamp.
- **No Auto-Scroll**: Ensure all internal scrolling is scoped strictly to element containers (`containerRef.current.scrollTop = containerRef.current.scrollHeight`) with zero page-level scrolling.
3. **Step 3: Verify Types**
- Run `npx tsc --noEmit` to ensure type alignment between the component and its inspector.
- **DO NOT** run raw `npm run build` while a local dev server is active to prevent wiping out `.next/` chunk manifests.
4. **Step 4: Badge Confirmation in Response**
- Include an explicit status chip in your response header or summary:
`[Inspector Mode: Synced <ComponentName> & Dev Inspector]`
---
## 4. Behavior While Mode is INACTIVE (Default)
* When the mode is OFF, the agent performs only the exact requested file modifications.
* Do NOT edit `src/dev/inspectors/` unless the user explicitly requests an inspector update or instructs the agent to create a brand new inspector route.