Files
workutils/docs/superpowers/plans/2026-07-30-git-sync-refactor-phase-4.md
2026-07-30 22:06:04 +08:00

4.0 KiB

Git Sync Refactor Phase 4 Implementation Plan

For agentic workers: REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (- [ ]) syntax for tracking.

Goal: Stop exposing credential-bearing Git URLs, make large project lists searchable, and give repository synchronization one structured async state owner.

Architecture: Convert raw remote URLs to safe display values before they enter table rows. Add a filtered view over immutable project presentation rows. Wrap the existing blocking synchronization API behind a use case that translates callbacks into immutable progress and result records consumed by AsyncOperationController.

Tech Stack: Java 17, JavaFX, JUnit 5, Maven.

Global Constraints

  • Preserve Git command behavior and damaged-repository confirmation flow.
  • Never display username, password, or token-bearing URL text in the project table.
  • Do not add raw new Thread to GitSyncWindow.
  • Do not execute synchronization during UI verification.
  • Test first for every new production behavior.

Task 1: Remote URL safe display

Files:

  • Create: src/main/java/com/example/workutils/biz/git/presentation/RemoteUrlDisplay.java
  • Test: src/test/java/com/example/workutils/biz/git/presentation/RemoteUrlDisplayTest.java
  • Modify: src/main/java/com/example/workutils/biz/git/GitSyncWindow.java

Interfaces:

  • Produces RemoteUrlDisplay.safe(String rawUrl).

  • HTTPS credentials and SSH usernames are removed; host and repository path remain.

  • Test HTTPS credentials, SSH SCP syntax, plain host/path, and blank values.

  • Observe focused test failure.

  • Implement safe display.

  • Store only safe text in ProjectRow.

  • Confirm focused test passes.

Task 2: Project search and status filter

Files:

  • Create: src/main/java/com/example/workutils/biz/git/presentation/ProjectFilter.java
  • Test: src/test/java/com/example/workutils/biz/git/presentation/ProjectFilterTest.java
  • Modify: src/main/java/com/example/workutils/biz/git/GitSyncWindow.java

Interfaces:

  • Produces pure matches(name, path, status, query, requiredStatus).

  • Test case-insensitive name/path matching and status filtering.

  • Observe focused test failure.

  • Add search field, status combo, filtered list, and visible count.

  • Confirm focused test passes.

Task 3: Structured synchronization use case

Files:

  • Create: src/main/java/com/example/workutils/biz/git/application/GitSyncRequest.java
  • Create: src/main/java/com/example/workutils/biz/git/application/GitSyncProgress.java
  • Create: src/main/java/com/example/workutils/biz/git/application/RunGitSyncUseCase.java
  • Test: src/test/java/com/example/workutils/biz/git/application/RunGitSyncUseCaseTest.java

Interfaces:

  • Consumes Gateway.sync(branch, Listener).

  • Produces immutable Result(total, success, damaged, failed, elapsedSeconds, damagedRepos).

  • Reports progress through OperationContext.

  • Test request validation, progress translation, result construction, and missing completion failure.

  • Observe focused test failure.

  • Implement request, progress, gateway, listener, and result.

  • Confirm focused test passes.

Task 4: Migrate main sync action

Files:

  • Modify: src/main/java/com/example/workutils/biz/git/GitSyncWindow.java

Interfaces:

  • Consumes AsyncOperationController<RunGitSyncUseCase.Result>.

  • Uses LoadingButtonBinder and OperationStatusPane.

  • Replace manual button/progress state and window-level worker thread.

  • Keep cancellation wired to both operation state and plugin.cancelSync().

  • Render structured completion summary and damaged rows.

  • Confirm GitSyncWindow has no new Thread in synchronization flow.

Task 5: Verification

  • Run all tests and JDK 17 compilation.
  • Run git diff --check.
  • Inspect project list search/filter, masked remote values, and idle sync state.
  • Do not start synchronization or damaged-repository actions.