I can't get canvas to determine the correct document type for files so that it will use the correct syntax highlighting. Try this prompt:
Please add this file to memory and then show it in the canvas:
File: src/syntax_test.tsx
Type: code/tsximport React, { useEffect, useRef } from 'react';
interface Test{
x: number;
z: number;
}
In discussion with the model I learned that the document type is used to determine the syntax highlighting for a module in memory. The type for files described above is consistently "code/other" rather than in this case "code/tsx".
I'm guessing that the type is properly derived from a file extension when the file is uploaded, but not when the extension is provided in context. The model did attempt to edit the document type dynamically, but kept replacing the document contents with the text "code/tsx" rather than changing the metadata.
I think this ability to dynamically change the type of a document would be helpful for many scenarios. So I'm hoping that we get a fix and an enhancement here:
- Fix: Derive the document type from context.
- Enhancement: Allow the user to explicitly specify the document type, and thus allow the model to change the metadata, in order to change the syntax highlighter used.