-
Notifications
You must be signed in to change notification settings - Fork 492
Feat: Persist all unsaved workflow tabs #6050
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
981801a
workflow caching cascade persistence
christian-byrne 19fd94c
remove unused export
christian-byrne 6b7de3d
fix: rebase main branch
Yourz 3de875c
fix: optimizing
Yourz 45a5d7a
fix: reload with default graph and e2e tests
Yourz 62c834e
fix: remove draft cache when workflow is closed:
Yourz 47dab54
fix: persist unsaved changes for saved workflows
Yourz 9d3bb5e
fix: update for reviews
Yourz 7d7fa44
fix: update for reviews
Yourz 24514f7
fix: update for reviews
Yourz 46b358e
fix: update for reviews
Yourz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| import { describe, expect, it } from 'vitest' | ||
|
|
||
| import { | ||
| MAX_DRAFTS, | ||
| createDraftCacheState, | ||
| mostRecentDraftPath, | ||
| moveDraft, | ||
| removeDraft, | ||
| touchEntry, | ||
| upsertDraft | ||
| } from './draftCache' | ||
| import type { WorkflowDraftSnapshot } from './draftCache' | ||
|
|
||
| function createSnapshot(name: string): WorkflowDraftSnapshot { | ||
| return { | ||
| data: JSON.stringify({ name }), | ||
| updatedAt: Date.now(), | ||
| name, | ||
| isTemporary: true | ||
| } | ||
| } | ||
|
|
||
| describe('draftCache helpers', () => { | ||
| it('touchEntry moves path to end', () => { | ||
| expect(touchEntry(['a', 'b'], 'a')).toEqual(['b', 'a']) | ||
| expect(touchEntry(['a', 'b'], 'c')).toEqual(['a', 'b', 'c']) | ||
| }) | ||
|
|
||
| it('upsertDraft stores snapshot and applies LRU', () => { | ||
| let state = createDraftCacheState() | ||
| for (let i = 0; i < MAX_DRAFTS; i++) { | ||
| const path = `workflows/Draft${i}.json` | ||
| state = upsertDraft(state, path, createSnapshot(String(i))) | ||
| } | ||
|
|
||
| expect(Object.keys(state.drafts).length).toBe(MAX_DRAFTS) | ||
|
|
||
| state = upsertDraft(state, 'workflows/New.json', createSnapshot('new')) | ||
| expect(Object.keys(state.drafts).length).toBe(MAX_DRAFTS) | ||
| expect(state.drafts).not.toHaveProperty('workflows/Draft0.json') | ||
| expect(state.order[state.order.length - 1]).toBe('workflows/New.json') | ||
| }) | ||
|
|
||
| it('removeDraft clears entry and order', () => { | ||
| const state = upsertDraft( | ||
| createDraftCacheState(), | ||
| 'workflows/test.json', | ||
| createSnapshot('test') | ||
| ) | ||
|
|
||
| const nextState = removeDraft(state, 'workflows/test.json') | ||
| expect(nextState.drafts).toEqual({}) | ||
| expect(nextState.order).toEqual([]) | ||
| }) | ||
|
|
||
| it('moveDraft renames entry and updates order', () => { | ||
| const state = upsertDraft( | ||
| createDraftCacheState(), | ||
| 'workflows/old.json', | ||
| createSnapshot('old') | ||
| ) | ||
|
|
||
| const nextState = moveDraft( | ||
| state, | ||
| 'workflows/old.json', | ||
| 'workflows/new.json', | ||
| 'new' | ||
| ) | ||
| expect(nextState.drafts).not.toHaveProperty('workflows/old.json') | ||
| expect(nextState.drafts['workflows/new.json']?.name).toBe('new') | ||
| expect(nextState.order).toEqual(['workflows/new.json']) | ||
| }) | ||
|
|
||
| it('mostRecentDraftPath returns last entry', () => { | ||
| const state = createDraftCacheState({}, ['a', 'b', 'c']) | ||
| expect(mostRecentDraftPath(state.order)).toBe('c') | ||
| expect(mostRecentDraftPath([])).toBeNull() | ||
| }) | ||
| }) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.