Major refactoring cleanup: - Add new controller architecture (class-controller-*.php) - Add new settings-v2 UI (views/settings-v2/) - Add new CSS architecture (agentic-sidebar.css, tokens) - Add esbuild build pipeline (scripts/build.js, package.json) - Add composer dependencies (vendor/) - Add frontend src directory (assets/js/src/index.jsx) - Add documentation files - Remove old/obsolete files (class-settings.php, old CSS) This commits all pending changes from previous refactoring efforts.
15 KiB
15 KiB
WP Agentic Writer Sidebar 1:1 Real Migration Tasklist
Source of truth: assets/js/sidebar.js
Audit ledger: SIDEBAR_1_TO_1_TASKLIST.md
Migration plan: SIDEBAR_1_TO_1_MIGRATION.md
Migration target: assets/js/src/index.jsx
This tasklist tracks real implementation progress only. Do not check an item because the behavior exists in sidebar.js; check it only after the migrated target, build pipeline, or runtime has actually been implemented and verified.
Current Status
- Preserve
SIDEBAR_1_TO_1_TASKLIST.mdas the Phase 0-14 parity/audit ledger. - Create monolithic migration target at
assets/js/src/index.jsx. - Convert all
wp.element.createElement/React.createElementrender calls in the monolith to JSX. - Complete Phase A manual JSX conversion verification.
- Preserve intentional
document.createElement("div")DOM usage. - Verify migrated JSX parses with
tsc --allowJs --checkJs false --jsx preserve --noEmit. - Verify migrated JSX still contains all 226 class inventory tokens.
- Verify endpoint inventory remains present after JSX conversion.
- Verify Gutenberg/browser side-effect inventory remains present after JSX conversion.
- Verify final plugin registration still renders
ConnectedSidebar. - Build pipeline is created and verified.
- Runtime parity smoke is complete with accepted exception for source-unreachable writing empty-state branch.
- Enqueue switch has been made to migrated built output.
- No extraction has been performed.
Real Migration Rules
- Keep
assets/js/sidebar.jsuntouched as the source of truth. - Keep
assets/js/src/index.jsxas the monolithic migration target. - Do not switch WordPress enqueue to migrated output until compiled output is verified.
- Do not extract helper files until monolith runtime parity is proven.
- Do not rename functions, state variables, refs, class names, endpoint strings, storage keys, or event names.
- Do not simplify JSX conditions, children order, callbacks, object shapes, SVG strings, or
dangerouslySetInnerHTML. - Record every real migration step here immediately after it is done.
Phase A - JSX Conversion Verification
- Convert plugin icon from
wp.element.createElement("img")to JSX. - Convert render surfaces from
wp.element.createElementto JSX. - Convert final main return tree to JSX.
- Preserve
RawHTMLusage as JSX component usage. - Preserve WordPress components:
PluginSidebarMoreMenuItem,PluginSidebar,Panel,TextareaControl,TextControl,CheckboxControl, andButton. - Preserve dynamic class expressions.
- Preserve
dangerouslySetInnerHTMLSVG/html strings. - Preserve stream/helper/runtime code outside render conversion.
- Manually audit converted JSX comments and expression containers for parser-safe, behavior-neutral output.
- Manually audit
renderRefineAllConfirmModalagainst source lines 6389-6455 after full conversion. - Manually audit
renderClarificationagainst source lines 8477-8829. - Manually audit conversation session actions against source lines 8830-9004.
- Fix JSX spread-child artifact in older session list:
...availableSessions.slice(1).map(...)is now{availableSessions.slice(1).map(...)}. - Manually audit
renderWelcomeScreenagainst source lines 9005-9184. - Manually audit
renderWritingEmptyStateagainst source lines 9185-9253. - Manually audit
renderFocusKeywordBaragainst source lines 9254-9459. - Manually audit
renderAgentWorkspaceCardagainst source lines 9460-9629. - Manually audit
renderContextualActionagainst source lines 9633-9996. - Manually audit
renderMessagesagainst source lines 9997-10917. - Manually audit
renderConfigTabagainst source lines 10918-11434. - Manually audit
renderGlobalStatusBaragainst source lines 11449-11585. - Manually audit
renderChatTabagainst source lines 11586-12020. - Manually audit
renderCostTabagainst source lines 12058-12306. - Manually audit main component return tree against source lines 12307-12346.
Phase B - Build Pipeline
- Audit current PHP enqueue path and dependencies before creating a build pipeline.
- Decide the minimal build tool needed for
assets/js/src/index.jsx: TypeScript CLI only, no React scaffold, no bundler. - Ensure JSX compiles to the same element factory expected by WordPress:
wp.element.createElement. - Ensure generated output keeps WordPress globals and does not introduce new runtime globals unless explicitly required.
- Add only the minimal package/build files needed for the monolith:
tsconfig.sidebar.json. - Generate a built file without changing the active enqueue.
- Verify built output contains expected plugin registration and no missing dependencies.
- Verify built output has no syntax errors.
- Record build command and output file path:
tsc -p tsconfig.sidebar.json->assets/js/dist/sidebar.js.
Phase C - Runtime Parity Smoke
- Load Gutenberg editor with the existing
assets/js/sidebar.jsruntime as baseline. - Load migrated built output without changing behavior.
- Verify baseline CDP smoke loads post
684, registerswp-agentic-writer, openswp-agentic-writer/wp-agentic-writer, and has no captured console errors. - Verify migrated CDP smoke serves
assets/js/dist/sidebar.jsthrough request interception without changing PHP enqueue;interceptedMigratedDist: true, SHA-2569685574363e7489935528340c071fbf0c32f6c85236d735b56d54050ca57a952. - Confirm sidebar menu item appears with the same icon and label.
- Verify baseline and migrated runtime plugin icon props:
alt: WP Agentic Writer,width: 20px,height: 20px,assets/img/icon.svg. - Verify baseline and migrated Gutenberg options menu contains
WP Agentic Writerunder Panels. - Confirm sidebar panel title/icon renders.
- Verify baseline and migrated sidebar title images include
alt: WP Agentic Writer,width: 24px,height: 24px,assets/img/icon.svg. - Confirm status bar buttons render and preserve active states.
- Confirm chat tab renders welcome, workspace, messages, command input, mentions, slash menu, and modal branches; empty-state is accepted as source-unreachable through normal runtime.
- Verify chat existing-session surface in baseline and migrated runtime: workspace card, messages list, command area, command input, and active Chat status button.
- Verify welcome/session surface in baseline and migrated runtime: Sessions status button, welcome prompt, continue session, explore/start outline/start writing actions.
- Accept chat empty-state branch as source-unreachable through normal runtime.
- Empty-state exception recorded: source guard requires
agentMode === "writing", nocurrentPlanRef.current, and zero editor blocks. Source tracing shows empty hydration resets tochat, plan hydration setsplanning, welcome/start UI sets onlychatorplanning, and the only naturalwritingpath isexecutePlanFromCard, which requirescurrentPlanRef.current; existing empty post593also hydrates an older conversation/plan, so no clean natural runtime fixture was available without mutating DB/session state or instrumenting React state. - Verify mention autocomplete branch.
- Verify baseline and migrated mention autocomplete: takeover enabled input,
.wpaw-mention-autocompleterendered, 61.wpaw-mention-optionentries including@this,@previous,@next,@all,@title, and block targets. - Verify slash menu branch.
- Verify baseline and migrated slash menu: textarea accepted
/,.wpaw-mention-autocompleterendered, 4 slash command options includingadd below,add above,append code block, andreformat. - Verify refine-all confirmation modal branch.
- Verify baseline and migrated refine-all confirmation modal:
@allrequest on post684resolved 35 text blocks,.wpaw-refine-confirm-overlayrenderedConfirm @all Refinement, block-count body text, checkbox,Cancel, andContinue;Cancelclosed the overlay; no console errors; no message-persist request fired before page close. - Confirm config tab renders every control and SEO section.
- Confirm cost tab renders cards, budget status, action summary, history, and settings link.
- Confirm no console syntax/runtime errors from migrated output.
- Confirm no endpoint URL, method, header, body shape, stream handling, or error handling changed.
- Verify static source/dist request inventory: 33 endpoint strings, 44
fetch(tokens, 2XMLHttpRequest, 2xhr.open, 40 nonce header values, 29 JSON content-type headers, 29 JSON body serializations, 8 GET, 28 POST, 2 DELETE, 9 stream readers/decoders, 23 thrown errors, 16 abort-error checks, and 28wpawLog.errorcalls. - Confirm editor locks, localStorage keys, beforeunload handlers, global listeners, abort handling, and stream reader lifecycle still work.
- Verify runtime session-lock branch in baseline and migrated smoke: session lock banner renders, takeover enables disabled command input.
- Verify static source/dist lifecycle inventory: session lock endpoints,
tab_id, forced takeover, heartbeat functions,keepalive, localStorage calls, beforeunload add/remove pairs,wpaw:insert-mentionlistener, abort/cancel calls, and stream reader assignments/read loops all match.
Phase D - Enqueue Switch
- Switch enqueue only after Phase A, Phase B, and Phase C are complete, with the recorded source-unreachable empty-state exception accepted.
- Keep rollback path to original
assets/js/sidebar.js. - Verify WordPress dependency handles match the migrated output: built globals
wp.blocks,wp.components,wp.data,wp.editPost,wp.element, andwp.pluginsmap to enqueued handleswp-blocks,wp-components,wp-data,wp-edit-post,wp-element, andwp-plugins; no missing handles. - Verify plugin loads in Gutenberg after enqueue switch: real enqueue loaded
assets/js/dist/sidebar.jsonce, did not loadassets/js/sidebar.js, registeredwp-agentic-writer, openedwp-agentic-writer/wp-agentic-writer, rendered sidebar menu/title/icon, status buttons, chat/config/cost/sessions surfaces, and had no captured console errors. - Verify
ConnectedSidebarstill receivespostId: real enqueue smoke on post684triggered post-specific REST calls including/post-config/684,/cost-tracking/684,/writing-state/684,/section-blocks/684, and/conversations/post/684. - Verify no duplicate sidebar/plugin registration occurs: real enqueue smoke found one
assets/js/dist/sidebar.jsresource, zeroassets/js/sidebar.jsresources, andpluginNameCount: 1forwp-agentic-writer.
Phase E - Post-Switch Cleanup
- Keep
assets/js/sidebar.jsuntil migrated runtime is proven stable. - Do not delete the monolith source target.
- Do not extract helpers until extraction has a separate source-range task.
- Commit only the real migration files intended for this step.
Post-Switch User Test Fixes
- Fix REST fatals from extracted controllers calling sidebar helper methods that were still private: exposed controller-used helper methods on
WP_Agentic_Writer_Gutenberg_Sidebar. - Fix
/generate-planfatal from missingWPAW_Rate_Limiter: loadincludes/class-rate-limiter.phpfrom the main plugin bootstrap. - Fix
/post-new.phpsession carry-over: migrated history loader now does not auto-hydrate any session whenpostIdis0, and the fallback only treatspost_id === 0as unassigned. - Restore welcome Start Writing 1:1 behavior:
handleWelcomeStartis synchronous, does not callstartNewConversation, sets the selected mode, hides welcome, and focuses the input likeassets/js/sidebar.js. - Fix start-new-session 500:
WP_Agentic_Writer_Conversation_Manager::generate_session_id()now returns 32-character hex IDs that fit the existingsession_id VARCHAR(32)table column and the REST route regex. - Fix blank chat response with local/9router streaming: local backend stream parser now accepts
choices[0].message.content, text-completion, Ollama-style, and simple content/response payloads in addition tochoices[0].delta.content. - Fix local/9router stream-empty edge case: when streaming returns HTTP 200 but no extractable content,
chat_stream()now falls back to non-streamingchat()and emits that response as a single assistant message. - Restore
/chatsource-of-truth backend path:handle_chat_request()andstream_chat_request()now run insideWP_Agentic_Writer_Gutenberg_Sidebaragain instead of delegating to the extracted chat controller. - Verify restored
/chatroute-level streaming smoke on post717emitsconversational_stream, finalconversational, andcomplete, and stores both user and assistant messages. - Verify restored
/chatroute-level streaming smoke on post717with the saved_wpaw_post_configandweb_searchenabled also emits assistant content and stores both user and assistant messages. - Fix silent empty provider completion on the active restored
/chatpath: local backend retries once when the non-streaming fallback returns empty content, and the active in-class stream handler emits an error instead of completing silently if content is still empty. - Verify post
719browser-equivalent route smoke with saved_wpaw_post_configandweb_searchenabled stores both user and assistant messages after the retry/empty guard patch. - Fix Zed refactor defect report: reverted migrated
handleWelcomeStartandstartNewConversationsignatures/side effects to matchassets/js/sidebar.js, then rebuiltassets/js/dist/sidebar.js. - Restore Sessions tab listing on
/post-new.php: prior sessions are listed for manual navigation while the history loader still prevents automatic continuation. - Rebuild migrated output with
tsc -p tsconfig.sidebar.json. - Verify PHP syntax for changed bootstrap/sidebar/controller files.
- Verify migrated
assets/js/dist/sidebar.jssyntax withnode --check. - Verify REST smoke checks:
post-config/684GET200,post-config/684update200,check-clarityJSON request200with no AI call, andgenerate-planempty-topic JSON request returns expected400 no_topicinstead of a PHP fatal. - Re-run authenticated
/wp-admin/post-new.phpbrowser probe after browser auth is available; current headless probe is blocked atwp-login.php?reauth=1because generated WP auth cookies are rejected by the web server even though they validate in WP CLI.
Optional Phase F - Extraction Later
- Extract only one helper group at a time.
- Record source range and destination file before extraction.
- Move code without renaming public/internal symbols.
- Re-run the same parity checks for the moved range.
- Do not delete the monolith source range until the moved range is checked line-by-line.