Skip to content

AI-native design editor. Open-source Figma alternative.

fix(storage): refresh the workspace when storage settings are saved (#989)

Danila Poyarkov2372e0872ac8
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1aa23e082..b4ad1487d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -128,6 +128,7 @@
### Fixed
+- List storage documents as soon as storage settings are saved. The home tab kept asking to configure storage until it next refreshed, which happened on window focus or up to a minute later.
- Keep a Figma file's exposed nested instances when it is saved from OpenPencil; their properties stopped showing on the outer component's instances in Figma.
- Offer only components that fit in an instance swap's list: one that would contain itself, such as the component the swapped layer sits in, is left out, and a variant is named with its set, as in `Badge / State=Info`.
- Undo a change to a property that drives several layers of an instance on all of them, and show an instance's value on a layer linked to that property after the instance was made.
diff --git a/src/app/integrations/storage/settings/use.ts b/src/app/integrations/storage/settings/use.ts
index 63fe061c9..7e671a3f7 100644
--- a/src/app/integrations/storage/settings/use.ts
+++ b/src/app/integrations/storage/settings/use.ts
@@ -13,6 +13,7 @@ import { appCredentialServices } from '@/app/settings/credentials/app'
import { credentialRef } from '@/app/settings/credentials/reference'
import type { CredentialStatus } from '@/app/settings/credentials/types'
import { resumeStorageSync } from '@/app/storage/sync'
+import { emitStorageWorkspaceEvent } from '@/app/storage/workspace/events'
import { testStorageDraft } from './draft'
@@ -22,9 +23,12 @@ const storageSettingsServices = {
statuses: storageCredentialStatuses,
manager: appCredentialServices.manager,
test: testStorageDraft,
- resume: resumeStorageSync
+ resume: resumeStorageSync,
+ changed: (providerId: StorageProviderID) =>
+ emitStorageWorkspaceEvent({ providerId, kind: 'changed' })
}
+import type { StorageProviderID } from '@/app/integrations/storage/types'
import type { SettingsSaveResult } from '@/app/settings/save-result'
export function useStorageSettings(
@@ -154,6 +158,8 @@ export function useStorageSettings(
return result
} finally {
operation.value = null
+ // The home workspace stays mounted and lists storage only when told to.
+ if (persisted) services.changed(target.id)
}
}
diff --git a/tests/e2e/storage/workspace.spec.ts b/tests/e2e/storage/workspace.spec.ts
index 4428fd3a5..386464f78 100644
--- a/tests/e2e/storage/workspace.spec.ts
+++ b/tests/e2e/storage/workspace.spec.ts
@@ -96,7 +96,6 @@ test('configured storage lists previews through ranges before opening the docume
await page.getByTestId('settings-storage-open-workspace').click()
await expect(page.getByTestId('recent-files-home')).toBeVisible()
- await page.getByRole('button', { name: 'Refresh', exact: true }).click()
const entry = page.getByRole('button', { name: /Remote design/ })
await expect(entry).toBeVisible()
const preview = entry.locator('img')
diff --git a/tests/engine/app/settings/storage-workflow.test.ts b/tests/engine/app/settings/storage-workflow.test.ts
index 8dbb54917..2e34c65c6 100644
--- a/tests/engine/app/settings/storage-workflow.test.ts
+++ b/tests/engine/app/settings/storage-workflow.test.ts
@@ -13,6 +13,7 @@ function fixture() {
})
const writes: string[] = []
const tests: Record<string, string>[] = []
+ const changed: string[] = []
const manager: CredentialManager = {
backend: 'memory',
availability: async () => 'available',
@@ -28,6 +29,7 @@ function fixture() {
preferences,
writes,
tests,
+ changed,
services: {
readPreferences: () => ({ ...preferences.value }),
writePreference: (_provider: string, field: string, value: string) => {
@@ -43,7 +45,10 @@ function fixture() {
tests.push(values)
return { ok: true, message: 'Connected' }
},
- resume: async () => undefined
+ resume: async () => undefined,
+ changed: (provider: string) => {
+ changed.push(provider)
+ }
}
}
}
@@ -61,6 +66,7 @@ test('testing storage drafts and cancelling never persist settings', async () =>
expect(await state.testConnection()).toEqual({ ok: true, message: 'Connected' })
expect(f.tests[0]?.endpoint).toBe('https://draft.example.com')
expect(f.writes).toEqual([])
+ expect(f.changed).toEqual([])
expect(f.preferences.value.endpoint).toBe('https://old.example.com')
state.cancel()
expect(state.dirty.value).toBe(false)
@@ -82,6 +88,7 @@ test('credential clearing is staged until Save', async () => {
expect(state.dirty.value).toBe(true)
expect(await state.save()).toBe('saved')
expect(f.writes).toContain('clear:secret-access-key')
+ expect(f.changed).toEqual(['s3-compatible'])
expect(state.dirty.value).toBe(false)
} finally {
scope.stop()
@@ -100,6 +107,7 @@ test('failure before any storage write is not reported as a partial save', async
expect(await state.save()).toBe('failed')
expect(state.saveResult.value).toBe('failed')
expect(f.writes).toEqual([])
+ expect(f.changed).toEqual([])
} finally {
scope.stop()
}
@@ -119,6 +127,7 @@ test('failed storage saves retain replacement drafts and expose the failure', as
expect(await state.save()).toBe('partial')
expect(state.saveResult.value).toBe('partial')
expect(state.error.value).toBe('Credential store locked')
+ expect(f.changed).toEqual(['s3-compatible'])
expect(state.busy.value).toBe(false)
expect(credentials.value['secret-access-key']).toBe('test-only-replacement')
scope.stop()