Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/features/editor/components/ClientEditorWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { ReadonlyEditor } from '@editor/components/Editor/ReadonlyEditor'
import { useViewStore } from '@editor/stores/viewStore'
import { isDefaultClientHome } from '@editor/utils/content'
import { isDefaultContent } from '@editor/utils/content'
import { useSettingsStore } from '@settings/providers/settings.provider'
import { useQuery } from '@tanstack/react-query'
import { ActionsCard } from '@/features/action-items/components/actions-card'
Expand All @@ -24,8 +24,6 @@ export const ClientEditorWrapper = () => {
const bannerPositionX = useSettingsStore((store) => store.bannerPositionX) ?? 50
const bannerPositionY = useSettingsStore((store) => store.bannerPositionY) ?? 50
const showGreeting = useSettingsStore((store) => store.showGreeting)
const createdAt = useSettingsStore((store) => store.createdAt)
const updatedAt = useSettingsStore((store) => store.updatedAt)

useQuery({
queryKey: ['tasks-app-id'],
Expand Down Expand Up @@ -63,7 +61,7 @@ export const ClientEditorWrapper = () => {
/>
)}

{!isDefaultClientHome({ content, createdAt, updatedAt }) && <ActionsCard readonly />}
{!isDefaultContent(content) && <ActionsCard readonly />}
<ReadonlyEditor content={content} />
</div>
</div>
Expand Down
6 changes: 2 additions & 4 deletions src/features/editor/components/EditorWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Heading } from '@editor/components/Heading'
import { Preview } from '@editor/components/Preview'
import { Subheading } from '@editor/components/Subheading'
import { useAppControls } from '@editor/hooks/useAppControls'
import { isDefaultClientHome } from '@editor/utils/content'
import { isDefaultContent } from '@editor/utils/content'
import { useBannerSettingsMutation } from '@settings/hooks/useBannerSettingsMutation'
import { useSegmentSettings } from '@settings/hooks/useSegmentSettings'
import { useSettingsStore } from '@settings/providers/settings.provider'
Expand Down Expand Up @@ -33,8 +33,6 @@ export function EditorWrapper({ className }: EditorWrapperProps) {
const bannerPositionX = useSettingsStore((store) => store.bannerPositionX) ?? 50
const bannerPositionY = useSettingsStore((store) => store.bannerPositionY) ?? 50
const showGreeting = useSettingsStore((store) => store.showGreeting)
const createdAt = useSettingsStore((store) => store.createdAt)
const updatedAt = useSettingsStore((store) => store.updatedAt)
const setSidebarView = useSidebarStore((store) => store.setSidebarView)
const bannerRepositioning = useSidebarStore((store) => store.bannerRepositioning)
const setBannerRepositioning = useSidebarStore((store) => store.setBannerRepositioning)
Expand Down Expand Up @@ -82,7 +80,7 @@ export function EditorWrapper({ className }: EditorWrapperProps) {
}
/>
)}
{!isDefaultClientHome({ content, createdAt, updatedAt }) && <ActionsCard />}
{!isDefaultContent(content) && <ActionsCard />}
<Editor content={content} />
</div>
</Activity>
Expand Down
6 changes: 2 additions & 4 deletions src/features/editor/components/Preview/Preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Loader } from '@common/components/Loader'
import { ReadonlyEditor } from '@editor/components/Editor/ReadonlyEditor'
import { PreviewTopBar } from '@editor/components/Preview/PreviewTopBar'
import { DisplayMode, useViewStore } from '@editor/stores/viewStore'
import { isDefaultClientHome } from '@editor/utils/content'
import { isDefaultContent } from '@editor/utils/content'
import { useSettingsStore } from '@settings/providers/settings.provider'
import { useUsersStore } from '@users/stores/usersStore'
import { ActionsCard } from '@/features/action-items/components/actions-card'
Expand All @@ -25,8 +25,6 @@ export function Preview({ content, backgroundColor, bannerUrl, bannerPositionX,
const displayMode = useViewStore((store) => store.displayMode)
const workspace = useViewStore((store) => store.workspace)
const showGreeting = useSettingsStore((store) => store.showGreeting)
const createdAt = useSettingsStore((store) => store.createdAt)
const updatedAt = useSettingsStore((store) => store.updatedAt)
const isDark = isDarkColor(backgroundColor)

const isInitialized = useUsersStore((store) => store.isInitialized)
Expand Down Expand Up @@ -66,7 +64,7 @@ export function Preview({ content, backgroundColor, bannerUrl, bannerPositionX,
{bannerUrl ? (
<Banner src={bannerUrl} alt="Workspace Banner" positionX={bannerPositionX} positionY={bannerPositionY} />
) : null}
{!isDefaultClientHome({ content, createdAt, updatedAt }) && <ActionsCard />}
{!isDefaultContent(content) && <ActionsCard />}
<ReadonlyEditor content={content} />
</div>
)}
Expand Down
13 changes: 0 additions & 13 deletions src/features/editor/utils/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,3 @@ export const isBlankContent = (html?: string): boolean => {

// True when the body still matches the seeded default copy.
export const isDefaultContent = (html?: string): boolean => html === defaultContent

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Historical defaults bypass the gate

When an existing workspace or segment still contains the previous untouched default HTML, isDefaultContent compares it only with the new default string and returns false, causing ActionsCard to appear on an untouched client home.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is intended. The change takes place only for newly created workspace.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, that makes sense. Existing workspaces with the old default HTML will show ActionsCard, and only newly created workspaces get the new gating behavior. Thanks for clarifying!

Tip: You can customize Greptile's behavior for this repo with .greptile/rules.md and .greptile/config.json.


// True when the row was never saved (createdAt and updatedAt match on insert).
export const isNeverSaved = (createdAt?: string | Date | null, updatedAt?: string | Date | null): boolean => {
if (!createdAt || !updatedAt) return false
return new Date(createdAt).getTime() === new Date(updatedAt).getTime()
}

// True while the client home is still the untouched default.
export const isDefaultClientHome = (params: {
content?: string
createdAt?: string | Date | null
updatedAt?: string | Date | null
}): boolean => isDefaultContent(params.content) || isNeverSaved(params.createdAt, params.updatedAt)
Loading