Skip to content

fix(vscode): Fix Workflow save, token persistence#9406

Open
bjbennet wants to merge 6 commits into
Azure:mainfrom
bjbennet:dev/brbenn/workflow_save_fix
Open

fix(vscode): Fix Workflow save, token persistence#9406
bjbennet wants to merge 6 commits into
Azure:mainfrom
bjbennet:dev/brbenn/workflow_save_fix

Conversation

@bjbennet

@bjbennet bjbennet commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Commit Type

  • feature - New functionality
  • fix - Bug fix
  • refactor - Code restructuring without behavior change
  • perf - Performance improvement
  • docs - Documentation update
  • test - Test-related changes
  • chore - Maintenance/tooling

Risk Level

  • Low - Minor changes, limited scope
  • Medium - Moderate changes, some user impact
  • High - Major changes, significant user/system impact

What & Why

Fix 1 — Token Expiration (3 files):

httpClient.ts — Added updateAccessToken() method so the token can be refreshed after construction
openDesignerForLocalProject.ts — Added 5-second interval that refreshes the access token and posts update_access_token to the webview (mirroring the existing Overview panel pattern). Cleared on dispose.
DesignerSlice.ts + webviewCommunication.tsx — Added updateDesignerAccessToken reducer and wired it to the update_access_token message handler so that panelMetaData.accessToken updates → triggering useMemo to recreate the HttpClient with the fresh token
Fix 2a — Silent Data Loss (1 file):

appV2.tsx — Removed premature clearDirtyState?.() call. The extension host already sends resetDesignerDirtyState only after a successful file write.
Fix 2b — Parameter Value Loss (2 files):

serializer.ts and serializer.ts — Changed parseWorkflowParameterValue to return parameterValue (raw string) on JSON.parse failure instead of undefined, preventing silent data loss.
Fix 3 — Field Mappings Removed (1 file):

openDesignerForLocalProject.ts — Enhanced mergeJsonParameters to deep-merge: when a parameter key exists in both the file and designer output, file-only properties are preserved (backfilled into the designer output).

Impact of Change

  • Users:
  • Developers:
  • System:

Test Plan

  • Unit tests added/updated
  • E2E tests added/updated
  • Manual testing completed
  • Tested in:

Contributors

Screenshots/Videos

Copilot AI review requested due to automatic review settings July 16, 2026 16:46
@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

🤖 AI PR Validation Report

PR Review Results

Thank you for your submission! Here's detailed feedback on your PR title and body compliance:

PR Title

  • Current: fix(vscode): Fix Workflow save, token persistence
  • Issue: None — valid fix: prefix with a (vscode) scope and a descriptive summary.
  • Recommendation: No change needed.

Commit Type

  • Exactly one type selected: fix - Bug fix.
  • This correctly matches the title prefix and the nature of the changes (token refresh + save/serialization fixes).

Risk Level

  • One box selected (Medium) and the risk:medium label matches the body selection.
  • My advised estimate is also Medium: the changes touch shared runtime auth/token handling (libs/vscode-extension/src/lib/services/httpClient.ts), extension distribution (apps/vs-code-designer), serialization logic, and Redux state — moderate user impact without breaking-API or security-posture changes. Declared level is correct.

What & Why

  • Current: Detailed breakdown of Fix 1 (token expiration/refresh), Fix 2a (silent data loss), Fix 2b (parameter value loss), and Fix 3 (field-mapping preservation).
  • Issue: None — substantive, non-placeholder content that clearly explains what and why.
  • Recommendation: Consider stripping the local vscode-file:// links (they resolve only on your machine), but this does not affect compliance.

⚠️ Impact of Change

  • All three sub-fields (Users, Developers, System) are left as empty template comments.
  • Recommendation:
    • Users: Fixes save failures/data loss — workflows now save reliably even after the access token expires; parameter values and file-only fields are no longer silently dropped.
    • Developers: New HttpClient.updateAccessToken() and updateDesignerAccessToken reducer; parseWorkflowParameterValue now returns the raw value instead of undefined on parse failure.
    • System: Adds a 30s token-refresh interval (cleared on dispose); no new dependencies.

Test Plan

  • Unit tests added/updated is checked and confirmed in the diff (new getAuthorizationToken.test.ts, saveWorkflow.test.ts, designerCommandBarSave.spec.tsx, and expanded httpClient.spec.ts). Passes.

⚠️ Contributors

  • Left blank. Not required, but please credit any PMs/designers/reviewers who contributed.

⚠️ Screenshots/Videos

  • No screenshots provided. The changed files are serialization/state/auth logic rather than visual UI, so this is not required — just a nudge in case any user-visible behavior warrants a short clip.

Summary Table

Section Status Recommendation
Title No change needed
Commit Type No change needed
Risk Level Medium is correct
What & Why Optionally remove local file links
Impact of Change ⚠️ Fill in Users/Developers/System
Test Plan Unit tests confirmed
Contributors ⚠️ Credit collaborators if any
Screenshots/Videos ⚠️ Not required (non-visual change)

✅ This PR passes all required checks and is clear to merge. Please address the warnings (especially the empty Impact of Change section) as a courtesy, but they do not block the merge.


Powered by: Copilot CLI (claude-opus-4.8) | Last updated: Fri, 17 Jul 2026 22:45:20 GMT

Copilot AI 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.

Pull request overview

This PR targets reliability issues in the VS Code-hosted Logic Apps designer, focusing on preventing save failures caused by stale auth tokens and avoiding silent data loss during workflow/parameter serialization and persistence.

Changes:

  • Added periodic access-token refresh in the VS Code extension host and propagated token updates into the webview/Redux state.
  • Adjusted workflow parameter deserialization to avoid dropping values when JSON parsing fails.
  • Updated save/dirty-state handling and added/updated unit tests around save and auth-token behavior.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
Localize/lang/strings.json Removes a set of localization entries (appears to be cleanup of unused strings).
libs/vscode-extension/src/lib/services/httpClient.ts Adds updateAccessToken() to allow token updates after client construction.
libs/vscode-extension/src/lib/services/test/httpClient.spec.ts Adds auth-header behavior tests for ARM vs non-ARM requests.
libs/designer/src/lib/core/actions/bjsworkflow/serializer.ts Returns raw parameter value on JSON parse failure to prevent silent loss.
libs/designer-v2/src/lib/core/actions/bjsworkflow/serializer.ts Same parameter parsing behavior change as designer v1.
eslint.config.mjs Adds import/ignore: ["node_modules"] setting.
apps/vs-code-react/src/webviewCommunication.tsx Wires update_access_token message to update designer panel metadata token state.
apps/vs-code-react/src/state/DesignerSlice.ts Adds updateDesignerAccessToken reducer to keep panelMetaData.accessToken updated.
apps/vs-code-react/src/app/designer/appV2.tsx Removes premature dirty-state clearing from the designer save path.
apps/vs-code-react/src/app/designer/test/designerCommandBarSave.spec.tsx Adds unit tests covering save validation and save-disabled conditions.
apps/vs-code-designer/src/app/utils/codeless/test/saveWorkflow.test.ts Adds tests for save serialization and file-write behavior (currently needs mocking fixes).
apps/vs-code-designer/src/app/utils/codeless/test/getAuthorizationToken.test.ts Adds tests for token acquisition behavior (currently encodes “Bearer undefined” behavior).
apps/vs-code-designer/src/app/commands/workflows/openDesigner/openDesignerForLocalProject.ts Adds token refresh interval + parameter merge behavior changes.

Comment thread libs/vscode-extension/src/lib/services/httpClient.ts
Comment thread libs/vscode-extension/src/lib/services/__test__/httpClient.spec.ts Outdated
Comment thread apps/vs-code-react/src/state/DesignerSlice.ts Outdated
Comment thread apps/vs-code-react/src/app/designer/appV2.tsx
Comment thread apps/vs-code-react/src/webviewCommunication.tsx
@bjbennet bjbennet added the risk:medium Medium risk change with potential impact label Jul 17, 2026
Copilot AI added a commit that referenced this pull request Jul 17, 2026
Copilot AI added a commit that referenced this pull request Jul 17, 2026
- Remove _clearDirtyState parameter from saveWorkflow (Fix 1)
- Guard against Authorization: undefined in httpClient (Fix 2)
- Fix httpClient.spec.ts to expect header omission (Fix 3)
- Fix updateDesignerAccessToken to accept string | undefined (Fix 4)
- Add 30-min access token refresh interval to localDesignerPanel (Fix 5)
- Deep-merge mergeJsonParameters to preserve file-only properties (Fix 6)
- Fix saveWorkflow.test.ts to mock writeFileSync via vi.mock('fs') (Fix 7)
- Fix getAuthorizationToken to return '' instead of '******' (Fix 8)
- Add comment explaining dual dispatch in webviewCommunication (Fix 9)
- Add test files: getAuthorizationToken.test.ts, saveWorkflow.test.ts, designerCommandBarSave.spec.tsx
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI added a commit that referenced this pull request Jul 17, 2026
Fixes review comment r3597382245 on PR #9406:
- getAuthorizationToken now throws an error when accessToken is
  undefined/empty instead of returning '******'
- Remove redundant optional chaining on the return statement
- Add test file verifying the function throws (instead of the
  previous unsafe assertion toBe('******') on line 46)
@bjbennet

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-validated risk:medium Medium risk change with potential impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants