Skip to content

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

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

fix(vscode): Fix Workflow save, token persistence#9406
bjbennet wants to merge 7 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(scope): prefix and descriptive.
  • Recommendation: No change needed.

Commit Type

  • Exactly one type selected: fix - Bug fix.
  • Matches the title prefix and the diff (bug fixes for token refresh, dirty-state, and parameter merge).

Risk Level

  • Exactly one box selected (Medium) and it matches the risk:medium label and my advised estimate. The diff touches extension distribution (apps/vs-code-designer), Redux state (DesignerSlice.ts), token handling, and shared serializers — moderate user impact with no security/breaking-API changes → medium is correct.

What & Why

  • Current: Detailed breakdown of Fix 1 (token expiration), Fix 2a/2b (data loss / parameter value loss), and Fix 3 (field mappings).
  • Issue: None — substantive and specific.
  • Recommendation: Consider cleaning up the vscode-file:// local links, but content is fully adequate.

⚠️ Impact of Change

  • Issue: All three sub-fields (Users/Developers/System) are left as empty template comments. This does not block merge but should be filled in.
  • Recommendation:
    • Users: Workflow saves no longer silently lose parameter values or field mappings; long editing sessions no longer fail to save due to expired tokens.
    • Developers: New HttpClient.updateAccessToken(), updateDesignerAccessToken reducer/message wiring, and parseWorkflowParameterValue now returns the raw value instead of undefined on parse failure.
    • System: Adds a 30s token-refresh interval in the local designer panel (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. Test requirement satisfied.

⚠️ Contributors

  • Section is blank. Nudge only — please credit any PMs, designers, or reviewers who contributed. Never blocks merge.

⚠️ Screenshots/Videos

  • Changes to libs/designer/src and libs/designer-v2/src are limited to serializer.ts (non-visual logic); other changes are extension host / state / test code. No visual UI change detected, so screenshots are not required — nudge only.

Summary Table

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

✅ PASS — All required checks pass. Please consider filling in the Impact of Change and Contributors sections before merge (non-blocking).


Powered by: Copilot CLI (claude-opus-4.8) | Last updated: Mon, 20 Jul 2026 16:22:34 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