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
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
RESOURCE_TAB_ICON_BUTTON_CLASS,
RESOURCE_TAB_ICON_CLASS,
} from '@/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-tabs/resource-tab-controls'
import { hasRenderableFilePreviewContent } from '@/app/workspace/[workspaceId]/home/hooks/use-file-preview-sessions'
import type {
GenericResourceData,
MothershipResource,
Expand Down Expand Up @@ -116,13 +117,19 @@ export const ResourceContent = memo(function ResourceContent({
const disableStreamingAutoScroll = previewSession?.operation === 'patch'
const rawPreviewText = previewSession?.previewText
const streamingPreviewText =
typeof rawPreviewText === 'string' && rawPreviewText.length > 0 ? rawPreviewText : undefined
previewSession &&
typeof rawPreviewText === 'string' &&
hasRenderableFilePreviewContent(previewSession)
? rawPreviewText
: undefined
const pendingOrStreamingFilePreviewText =
previewSession?.fileId === resource.id && typeof rawPreviewText === 'string'
previewSession?.fileId === resource.id &&
typeof rawPreviewText === 'string' &&
hasRenderableFilePreviewContent(previewSession)
? rawPreviewText
: undefined

if (previewSession && resource.id === 'streaming-file') {
if (resource.id === 'streaming-file') {
return (
<div className='flex h-full flex-col overflow-hidden'>
{streamingPreviewText !== undefined ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { cn } from '@/lib/core/utils/cn'
import { getFileExtension } from '@/lib/uploads/utils/file-utils'
import type { PreviewMode } from '@/app/workspace/[workspaceId]/files/components/file-viewer'
import { RICH_PREVIEWABLE_EXTENSIONS } from '@/app/workspace/[workspaceId]/files/components/file-viewer'
import { hasRenderableFilePreviewContent } from '@/app/workspace/[workspaceId]/home/hooks/use-file-preview-sessions'
import type {
GenericResourceData,
MothershipResource,
Expand All @@ -23,7 +24,7 @@ const PREVIEW_CYCLE: Record<PreviewMode, PreviewMode> = {
/**
* Whether the active resource should show the in-progress file stream.
* The synthetic `streaming-file` tab always shows it; a real file tab only shows it
* when the streamed fileId matches that exact resource.
* after a preview content event has arrived for that exact resource.
*/
function shouldShowStreamingFilePanel(
previewSession: FilePreviewSession | null | undefined,
Expand All @@ -32,7 +33,9 @@ function shouldShowStreamingFilePanel(
if (!previewSession || previewSession.status === 'complete' || !active) return false
if (active.id === 'streaming-file') return true
if (active.type !== 'file') return false
if (active.id && previewSession.fileId === active.id) return true
if (active.id && previewSession.fileId === active.id) {
return hasRenderableFilePreviewContent(previewSession)
}
return false
}

Expand Down
Loading
Loading