Skip to content

Commit cbcc31c

Browse files
committed
Default undeclared .html back to plain text/html
A file is a Sim page only when the model declares it at creation or the first written content proves it — never by extension alone.
1 parent 1beca2c commit cbcc31c

1 file changed

Lines changed: 5 additions & 15 deletions

File tree

‎apps/sim/lib/copilot/tools/server/files/create-file.ts‎

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
createWorkspaceFileByPath,
1414
updateWorkspaceFileContentByPath,
1515
} from '@/lib/workspace-files/application/write-workspace-file-by-path'
16-
import { SIM_PAGE_CONTENT_TYPE } from '@/lib/workspace-files/page-compile'
1716

1817
const logger = createLogger('CreateFileServerTool')
1918
const CREATE_FILE_TOOL_ID = 'create_empty_file'
@@ -58,20 +57,11 @@ export const createFileServerTool: BaseServerTool<CreateFileArgs, CreateFileResu
5857
}
5958
const outputPath =
6059
outputFile?.path ?? (fileName.startsWith('files/') ? fileName : `files/${fileName}`)
61-
// A copilot-created .html file IS a Sim page unless the model says
62-
// otherwise: an explicit contentType (the skill declares
63-
// text/x-sim-page for pages and text/html for a bespoke raw page)
64-
// always wins; with no declaration the .html default is a page. Either
65-
// way the record advertises the file's nature from birth, so the viewer
66-
// renders (never raw code) from the very first streamed byte, and the
67-
// first apply_file_edit re-confirms from the actual content. User
68-
// uploads never pass through here and stay text/html.
69-
const declaredType = outputFile?.mimeType ?? explicitType
70-
const inferredType = inferContentType(outputPath, declaredType)
71-
const contentType =
72-
!declaredType && inferredType === 'text/html' && outputPath.toLowerCase().endsWith('.html')
73-
? SIM_PAGE_CONTENT_TYPE
74-
: inferredType
60+
// .html defaults to plain text/html; a file is a Sim page only when the
61+
// model DECLARES it (the skill passes contentType text/x-sim-page at
62+
// creation) — or when the first apply_file_edit finds actual page
63+
// source, which re-stamps the record from reality either way.
64+
const contentType = outputFile?.mimeType ?? inferContentType(outputPath, explicitType)
7565
assertServerToolNotAborted(context)
7666
const mode = outputFile?.mode ?? 'create'
7767
// An empty shell provably contains no secrets; recording that keeps the

0 commit comments

Comments
 (0)