fix: publish state

This commit is contained in:
Joel 2026-06-23 17:54:20 +08:00
parent 6e1b7d806d
commit bf01ad417c
2 changed files with 18 additions and 1 deletions

View File

@ -346,6 +346,20 @@ describe('AgentConfigurePublishBar', () => {
)
})
it('should show unpublished state for local edits when the active snapshot is not loaded', () => {
renderPublishBar({
activeConfigIsPublished: true,
activeConfigSnapshot: null,
prompt: 'Updated system prompt',
})
expect(screen.getByText('agentV2.agentDetail.configure.publishBar.unpublishedChanges')).toBeInTheDocument()
expect(screen.getByRole('button', { name: /agentV2\.agentDetail\.configure\.publishBar\.publishUpdate/ })).toBeInTheDocument()
expect(hotkeyRegistrations.get('Mod+Shift+P')?.options).toEqual(
expect.objectContaining({ enabled: true, ignoreInputs: false }),
)
})
it('should initialize unpublished state when active config is not published', async () => {
const { onPublish } = renderPublishBar({
activeConfigIsPublished: false,

View File

@ -55,10 +55,13 @@ function getPublishState({
if (isPublishing)
return 'publishing'
if (isDirty)
return 'unpublished'
if (!activeConfigSnapshot)
return activeConfigIsPublished ? 'published' : 'draft'
if (!activeConfigIsPublished || isDirty)
if (!activeConfigIsPublished)
return 'unpublished'
return 'published'