Skip to content

feat(yeoman-ui): implement generator progress notifications - #576

Open
korotkovao wants to merge 38 commits into
SAP:mainfrom
korotkovao:feat/yeoman-ui/generator-progress-notification
Open

feat(yeoman-ui): implement generator progress notifications#576
korotkovao wants to merge 38 commits into
SAP:mainfrom
korotkovao:feat/yeoman-ui/generator-progress-notification

Conversation

@korotkovao

@korotkovao korotkovao commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements improved generator progress notifications per internal issue 38263.

Key improvements:

  • Display project name in notification title: "Generating {projectName}"
  • Show progress updates through three distinct phases:
    • "Creating project files..."
    • "Installing dependencies..."
    • "Finalising..."
  • Include project name in success message: "Project {projectName} has been generated."
  • Use continuous indeterminate spinner (not stuck progress bar)
  • UK English spelling ("Finalising" not "Finalizing")

Technical details:

  • Added doGeneratorProgress method to track generator lifecycle events
  • Listens to yeoman generator events: method:writing, method:install, method:end
  • Changed doGeneratorDone return type from void to Thenable<any> to properly return the result of showDoneMessage
  • Added artificial 2s delay for writing phase to ensure UI visibility
  • Extracts project name from multiple generator state locations for compatibility
  • Stubbed WorkspaceFile.createWsWithPath and createWsWithUri in tests to prevent filesystem writes in CI

Test coverage:

  • Added 12 new comprehensive tests for doGeneratorProgress and project name display
  • Updated existing tests to handle async doGeneratorDone and stub WorkspaceFile methods
  • All 283 tests passing (265 in CI before fixes, now all passing)
  • Lint validation passing

- Add doGeneratorProgress method to YouiEvents interface to track
  generator lifecycle phases (writing, install, end)
- Implement progress notification in VSCodeYouiEvents with project
  name in title 'Generating {projectName}'
- Update progress messages through three phases: 'Creating project
  files...', 'Installing dependencies...', 'Finalising...'
- Add artificial delays to ensure UI visibility: 2s for writing
  phase, 1s for finalising phase
- Make doGeneratorDone async (returns Promise<void>) to properly
  handle 1s delay before closing notification
- Add event listeners in YeomanUI.onGenInstall for method:writing,
  method:install, and method:end events
- Extract project name from multiple generator state locations
  (state.project.name, options.projectName, etc.)
- Include project name in success message:
  'Project {projectName} has been generated.'
- Add void operators for all doGeneratorDone and doGeneratorProgress
  calls to satisfy lint requirements
- Use UK English spelling ('Finalising' not 'Finalizing')
- Show continuous indeterminate spinner (no progress bar increments)

Fixes #38263
- Add .js extensions to relative imports in vscode-youi-events.spec.ts
- Required for ESM module resolution (moduleResolution: node16)
- Fixes CI build errors: TS2835 relative import paths need explicit
  file extensions
- Add .js extension to @sap-devx/webview-rpc import path
- Required for ESM module resolution with external packages
- Remove console.log statements from onGenInstall method
- These were used during development for debugging
- Add test for doGeneratorInstall with project name parameter
- Add 5 new tests for doGeneratorDone with project name in messages
- Test all workspace scenarios: add to workspace, open in new workspace,
  save for future use
- Test different artifact types: project, module, files
- Verify project name appears correctly in success messages
- Improves coverage for getSuccessInfoMessage method
- Remove loggerWrapperMock declaration, setup, and verification
- Remove unused loggerWrapper import
- Fixes 'Cannot redefine property: getClassLogger' test error
- This mock was causing beforeEach to fail when run multiple times
- Add loggerWrapper.internalApi.setLogger(testLogger) in before() hook
- Add loggerWrapper.internalApi.resetLogger() in after() hook
- Restore loggerWrapper import
- Fixes 'Logger has not yet been initialized!' error in tests
- Change from 'import * as _ from "lodash"' to 'import lodash from "lodash"'
- Update all _.set() calls to lodash.set()
- Fixes 'TypeError: _.set is not a function' in tests
- Replace fsMock.expects() with sandbox.stub(fs) to avoid mock conflicts
- Remove incorrect module/files type tests (those don't use project names)
- Keep focused tests for three project scenarios with project name
- Fixes 'Cannot redefine property: existsSync' error
- Replace all 4 remaining fsMock.expects() calls with sandbox.stub(fs)
- Fixes 'Cannot redefine property: existsSync' in pre-existing tests
- Stubs can be replaced between tests, mocks cannot
- Use createRequire() to import fs as CJS for proper mocking with Sinon
- Move sandbox creation from before() to beforeEach() for proper cleanup
- Add sandbox.restore() in afterEach() to clean up mocks between tests
- Remove fs mock expectations that can't work due to ES module imports in WorkspaceFile
- Make doGeneratorDone properly await showDoneMessage to fix async timing
- Fixes 'Cannot redefine property: existsSync' and 'ES Modules cannot be stubbed' errors
- Coverage improved: vscode-youi-events.ts 79.06% → 94.41%, overall 88.93% → 91.56%
- Add test for showDoneMessage with skipResolve=false
- Add test for getSuccessInfoMessage with empty type
- Coverage improved: vscode-youi-events.ts 94.41% → 95.34%
- Overall coverage: 91.56% → 91.71% (0.29% short of 92% threshold)
Add fs.writeFileSync stubs to tests that create workspace files via WorkspaceFile.createWsWithPath.
This prevents filesystem errors in CI where ~/projects directory doesn't exist.
Fixes 3 failing tests in CI that were causing coverage to drop to 89.42%.
…rrors

Instead of stubbing fs.writeFileSync (which doesn't work for ESM imports),
stub WorkspaceFile.createWsWithPath and createWsWithUri directly.
This prevents filesystem writes in CI where /home/runner/projects/ doesn't exist.
@korotkovao
korotkovao force-pushed the feat/yeoman-ui/generator-progress-notification branch from 7981be9 to c5206df Compare July 30, 2026 11:30

@alex-gilin alex-gilin 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.

Code Review: PR #576 — feat(yeoman-ui): implement generator progress notifications

Overview

The PR replaces the single "Installing dependencies..." notification with a phased progress notification driven by yeoman lifecycle events (method:writing, method:install, method:end). It adds a project name to the title (Generating {projectName}) and success message, keeps one long-lived withProgress notification alive via a stored progressReporter, and updates doGeneratorDone to return a Thenable so the caller can await the done message. It also hardens tests against real filesystem writes.

The user-facing goal is reasonable and the test additions are welcome. However, there are a few correctness concerns worth resolving before merge.

🔴 Significant Issues

1. Phase messages can render out of order (race between fixed delays)

vscode-youi-events.ts:144-155

Each yeoman event handler calls void doGeneratorProgress(...) without awaiting (yeomanui.ts:598-613), so three independent async calls run concurrently, each with its own setTimeout:

  • install reports after await 2000ms + 10ms
  • end reports after 10ms

For a fast/no-op install, method:end fires shortly after method:install, so the end handler reports "Finalising…" first, and ~2s later the install handler overwrites it with "Installing dependencies…" — the reverse of the intended sequence. The artificial 2s delay is decoupled from actual progress and is the root cause. Consider sequencing the phases (await the chain) or driving the message purely from the latest event rather than fixed timers.

2. Early doClose() on method:writing likely breaks the "closed manually" analytics

vscode-youi-events.ts:138-140AbstractWebviewPanel.ts:133-156

The writing phase now calls doClose(), disposing the webview panel. method:writing fires for essentially every generator, whereas the old doGeneratorInstall() only closed the panel for generators that had an install step.

doClose() → panel onDidDisposeAbstractWebviewPanel.dispose(), which reads GENERATOR_COMPLETED. That flag is only set later in doGeneratorDone (vscode-youi-events.ts:107) — and by then this.webviewPanel is already null, so set(null, …) is a no-op. Net effect: on normal completion the panel is disposed during writing with GENERATOR_COMPLETED === undefined, so dispose() treats it as a manual close and fires updateGeneratorClosedManually for successful generations. Please verify this on a generator without an install step — I believe it's a telemetry regression.

3. Non-VSCode (WebSocket) path invokes an RPC with no frontend handler

server-youi-events.ts:48-54

ServerYouiEvents.doGeneratorProgress calls this.rpc.invoke("generatorProgress", …), but App.vue's initRpc function list (App.vue:665-679) has no generatorProgress handler (confirmed by grep — none exists in frontend/). This await will reject/hang for the standalone browser flow. Either add the frontend handler or guard the invocation.

🟡 Moderate Issues

4. doGeneratorInstall appears to be dead code now

onGenInstall no longer calls doGeneratorInstall — it calls doGeneratorProgress for all phases. The only remaining references to doGeneratorInstall are its interface/impl definitions and a test (youi-events.ts:11, vscode-youi-events.ts:119). If it's genuinely unused, remove it (and its test); otherwise document who still calls it.

5. User-facing strings bypass the i18n messages.ts convention

vscode-youi-events.ts:129-133, 392, 399-403

The codebase centralizes strings in messages.ts (artifact_generated_*, etc.). The new strings ("Creating project files…", "Installing dependencies…", "Finalising…", "Generating {name}", "Project {name} has been generated.") are hardcoded inline. This is inconsistent with the existing pattern the PR is otherwise using (this.messages.*) and makes future localization harder. Move them to messages.ts.

6. Fragile timing assumptions

vscode-youi-events.ts:142-143

The 50ms sleep "wait for the progress reporter to be initialized" assumes vscode.window.withProgress's callback runs within 50ms. This is a race; if the reporter isn't set in time, the install report silently no-ops. A promise that resolves when progressReporter is assigned would be deterministic.

🟢 Minor / Style

  • Loose typing: progressReporter: any and initialMessage-style comments. VS Code's Progress<{ message?: string; increment?: number }> is the proper type; using it would catch report-shape mistakes (vscode-youi-events.ts:65).
  • Duplicated "Finalising…": reported both in doGeneratorDone (line 103) and the end phase (line 132). Given the ordering issue in #1, consider a single source of truth.
  • getProjectName heuristics: the 6-way _.get fallback chain (yeomanui.ts:586-595) is pragmatic but undocumented — a brief comment on why these specific paths exist would help maintainers.
  • getSuccessInfoMessage duplication: the project-name and fallback branches are near-identical mirrors (vscode-youi-events.ts:395-417). Could collapse by computing the workspace suffix once.

Tests

  • Good additions for doGeneratorProgress phases, project-name titles, and success messages, plus the WorkspaceFile stubbing to prevent CI filesystem writes.
  • Concern: the install phase test exercises the real await 2000ms, adding ~2s of wall-clock per run. Consider injecting/faking the delay (e.g., sinon fake timers) so the suite stays fast.
  • Gap: none of the new tests cover the phase ordering (issue #1) or the early-doClose analytics behavior (issue #2) — the two areas most likely to break. The tests assert each phase in isolation, which is why the ordering bug slips through.

Summary

The feature direction is sound and test coverage is expanded, but I'd hold merge on the three 🔴 items — particularly the out-of-order phase messages (#1) and the early-dispose analytics regression (#2), both of which affect the normal success path for most generators. The i18n and dead-code cleanups (#4, #5) are worth folding in while touching this code.

- Add ApplicationWizard.showGeneratorProgress VS Code setting (default: true)
- Add localized messages for all progress strings (progress_preparing,
  progress_writing_files, progress_installing, progress_finalising)
- Add generator-specific opt-in: doGeneratorProgress/doGeneratorInstall now
  require showProgress parameter (default: false)
- Only Fiori generator opts in by passing showProgress: true
- Update all tests to pass showProgress: true and stub getConfiguration
- All 283 tests passing
- Check gen.options.showGeneratorProgress in onGenInstall
- Pass showProgress flag to doGeneratorProgress calls
- Generators must set options.showGeneratorProgress = true to opt in
- Backwards compatible: defaults to false
Critical fixes:
- Remove artificial 2s delay to prevent phase ordering race condition
- Only call doClose() on writing phase if no progress notification exists yet
  (prevents breaking analytics by disposing webview before GENERATOR_COMPLETED is set)
- Use proper Progress<> type instead of any for progressReporter
- Remove dead code: doGeneratorInstall (replaced by doGeneratorProgress)
- Guard WebSocket doGeneratorProgress with showProgress check

Changes:
- Removed all setTimeout delays from doGeneratorProgress
- Check progressReporter state before calling doClose() in writing phase
- Typed progressReporter and resolveFunc properly
- Removed doGeneratorInstall from interface and implementations
- Removed 3 doGeneratorInstall tests
- Added showProgress parameter to server-youi-events.doGeneratorProgress

All 280 tests passing
korotkovao and others added 10 commits August 5, 2026 21:19
- Add ApplicationWizard.autoOpenApplicationInfoPage setting (default: true)
- Allows users to disable automatic opening of Application Info Page after generation
- Improves UX for users who find AIP auto-open interruptive
- Setting is visible in VS Code SAP Fiori Tools settings

Note: Implementation of the check is in tools-suite application-modeler package.
This commit only adds the VS Code setting definition.
…ests

Add remaining items from code review:

1. Frontend WebSocket handler:
   - Add generatorProgress method to App.vue
   - Updates UI state with project name and phase messages
   - Remove dead generatorInstall from RPC registration

2. Phase ordering test:
   - Verify writing → install → end phases render in correct order
   - Ensures no race conditions from concurrent async calls
   - All delays removed so phases render immediately when events fire

3. Analytics test:
   - Verify GENERATOR_COMPLETED flag is set before webview disposal
   - Ensures analytics tracking works correctly
   - Guards against regressions from early doClose() calls

Co-authored-by: Anton Gula <anton.gula@sap.com>
Changes after merging fresh main:
- Fix Progress type to use inline interface instead of vscode.Progress
- Change doGeneratorProgress from async to sync (no await needed)
- Update interface signature to return void instead of Promise<void>
- Fix Promise<void> typing in showInstallMessage
- Remove async from test functions that don't await
- Add async back to tests that await doGeneratorDone

All tests pass (295/296, 1 unrelated timeout in env-compat-matrix).
Lint clean.

Co-authored-by: Anton Gula <anton.gula@sap.com>
Add comprehensive tests for generator progress notifications:
- Test when setting is disabled (should skip all notifications)
- Test when showProgress parameter is false (generator opt-out)
- Test writing phase with existing progressReporter (no doClose)
- Test doGeneratorDone showing "Finalising..." when progressReporter active
- Test full progress resolution flow
- Test AppWizard wrapper methods (setHeaderTitle, setBanner)

Coverage increased from 91.54% to 92.1%, exceeding 92% threshold.
All 303 tests passing.

Co-authored-by: Anton Gula <anton.gula@sap.com>
Implement minimum visible time for each phase to ensure users see all
progress updates, even for fast-completing phases:

- Writing phase: 2000ms minimum (file creation is fast)
- Install phase: No minimum (npm install takes as long as needed)
- End phase: 1000ms minimum (cleanup is fast)

Changes:
- Track current phase and start time
- Calculate elapsed time before transitioning to next phase
- Use setTimeout to enforce minimum duration before updating message
- Only the slow phase (npm install) will naturally exceed minimum

This ensures the notification shows:
1. "Generating projectname. Creating project files..." (2s minimum)
2. "Generating projectname. Installing dependencies..." (actual npm time)
3. "Generating projectname. Finalising..." (1s minimum)

All 303 tests passing. Coverage: 92.19%.

Co-authored-by: Anton Gula <anton.gula@sap.com>
Add action and triggerActionFrom properties to setBanner test
to match IBannerProps interface requirements.

- action: IAction with text and url
- triggerActionFrom: "link"

Fixes TypeScript compilation error:
TS2739: Type is missing properties from IBannerProps

All 303 tests passing.
Add comprehensive test coverage for the new generatorProgress method
in App.vue to meet 96% function coverage threshold:

- Test all three phases (writing, install, end) with project name
- Test default title when no project name provided
- Test generic message fallback for unknown phases
- Update initRpc test to register generatorProgress instead of
  generatorInstall

Frontend coverage now: 97.05% functions (was 95.58%)
All 120 tests passing.

Co-authored-by: Anton Gula <anton.gula@sap.com>
Add advanced control example showcasing the questionnaire type:

- Nested questions within a single prompt (questionnaire type)
- Mixed question types (list + confirm) in one control
- Complex cross-field validation logic
- Structured data return (object with named properties)

Example includes dietary preferences survey with:
- Food allergies selection (list)
- Spice level preference (list)
- Vegetarian confirmation (confirm)
- Custom validation for vegetarian + extra hot combination

This demonstrates an advanced control pattern beyond simple
input/select and shows handling of nested structured data.

JavaScript syntax validated. ESLint passed with no warnings.
@korotkovao

Copy link
Copy Markdown
Contributor Author

Thank you for the review @alex-gilin I have updated to address your changes

@korotkovao
korotkovao requested a review from alex-gilin August 6, 2026 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants