π fix(agent-documents): render system docs in editor#15462
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
π‘ Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e39ad55bbc
βΉοΈ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with π.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const isEditorDocument = (document: DocumentRenderModeFields): boolean => { | ||
| if (document.category === 'document') return true; | ||
| if (document.fileType && EDITOR_DOCUMENT_FILE_TYPES.has(document.fileType)) return true; | ||
| return !!document.sourceType && EDITOR_DOCUMENT_SOURCE_TYPES.has(document.sourceType); |
There was a problem hiding this comment.
Don't force code agent files into the rich editor
When an agent/VFS caller writes an explicit code filename such as ./config.json, writeOrdinaryDocument preserves that extension but AgentDocumentModel.create still defaults sourceType to agent; this check returns editor mode before the filename language detection runs. In the portal path I inspected (DocumentBody calls getDocumentRenderMode(documentMeta)), those .json/.txt agent documents will no longer open in the highlight/code editor and saving can route them through the rich markdown editor instead.
Useful? React with πΒ / π.
| doc.fileType === DOCUMENT_FOLDER_TYPE | ||
| ? trimmedTitle | ||
| : trimmedTitle | ||
| ? ensureDefaultAgentDocumentExtension(buildDocumentFilename(trimmedTitle)) |
There was a problem hiding this comment.
Keep the stored title extensionless on rename
For a title-only rename like New title, this now passes New title.md into AgentDocumentModel.rename, but that model treats the argument as the human title as well as the source for the filename, so it persists documents.title = 'New title.md'. That regresses the existing create behavior, which stores title: 'New title' while using filename: 'New title.md', and causes UI/tool callers that compare against or display title to see an unexpected extension after revalidation.
Useful? React with πΒ / π.
|
|
||
| export type DocumentRenderMode = { mode: 'editor' } | { language: string; mode: 'highlight' }; | ||
|
|
||
| const EDITOR_DOCUMENT_FILE_TYPES = new Set([ |
There was a problem hiding this comment.
Is this hardcoded?
This comment was translated by Claude.
Original Content
θΏιζ―瑬ηΌη οΌ| } from './headlessEditor'; | ||
|
|
||
| const MAX_UNIQUE_FILENAME_ATTEMPTS = 1000; | ||
| const DEFAULT_AGENT_DOCUMENT_EXTENSION = '.md'; |
There was a problem hiding this comment.
Extracted it. This should be reusable with the file tree's new file creation constant.
This comment was translated by Claude.
Original Content
ζ½δΊ εΊθ―₯ε―δ»₯ε file treeηζ°ε»Ίζδ»Άε€η¨εΈΈι
|
|
||
| const LOBE_PATH = './lobe'; | ||
| const LOBE_SKILLS_PATH = './lobe/skills'; | ||
| const DEFAULT_AGENT_DOCUMENT_EXTENSION = '.md'; |
There was a problem hiding this comment.
Same here
This comment was translated by Claude.
Original Content
θΏιδΉζ―
| const title = newTitle.trim(); | ||
| const trimmedTitle = newTitle.trim(); | ||
| const title = | ||
| doc.fileType === DOCUMENT_FOLDER_TYPE |
There was a problem hiding this comment.
Don't use complex nested ternaries.
This comment was translated by Claude.
Original Content
δΈθ¦ε€ζε΅ε₯δΈε
Codecov Reportβ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## canary #15462 +/- ##
===========================================
- Coverage 86.75% 70.85% -15.91%
===========================================
Files 387 3255 +2868
Lines 41713 321430 +279717
Branches 6609 28427 +21818
===========================================
+ Hits 36189 227747 +191558
- Misses 5409 93501 +88092
- Partials 115 182 +67
Flags with carried forward coverage won't be shown. Click here to find out more.
π New features to boost your workflow:
|
e39ad55 to
bd5563b
Compare
| export const AGENT_DOCUMENT_CATEGORY = 'document'; | ||
|
|
||
| export const AGENT_DOCUMENT_FILE_TYPE = 'agent/document'; | ||
| export const AGENT_PLAN_FILE_TYPE = 'agent/plan'; | ||
| export const CUSTOM_DOCUMENT_FILE_TYPE = 'custom/document'; | ||
|
|
||
| export const MARKDOWN_DOCUMENT_FILE_TYPES = ['markdown', 'text/markdown', 'text/x-markdown']; | ||
|
|
||
| export const EDITOR_DOCUMENT_SOURCE_TYPES = ['agent', 'agent-signal', 'document']; | ||
|
|
There was a problem hiding this comment.
Where are these used? Need to replace other business-use constants.
This comment was translated by Claude.
Original Content
θΏδΊε¨εͺιδ½Ώη¨ηοΌ ιθ¦ζΏζ’ε Άδ»ηδΈε‘δ½Ώη¨εΈΈι
bd5563b to
7cffd94
Compare
7cffd94 to
edec04a
Compare
edec04a to
b3dc3ef
Compare
|
@codex review |
β¦flush Add debounced autosave to the non-markdown highlight editor and a StrictMode-safe unmount flush via queueMicrotask, plus a beforeunload guard against dirty buffers.
|
Codex Review: Didn't find any major issues. Can't wait for the next one! βΉοΈ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with π. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
a726641 to
0eb3f74
Compare
π» εζ΄η±»ε | Change Type
π εζ΄θ―΄ζ | Description of Change
.mdsuffix into the title or visible filename.agent/document/ system document entries with the rich Document Editor instead of the highlight/code editor..jsonand.txtso those files still open in highlight mode.@lobechat/constacross app, server, and database usage.π§ͺ ζ΅θ― | Testing
bunx vitest run --silent=passed-only src/server/services/agentDocuments/index.test.ts src/server/routers/lambda/__tests__/integration/agentDocumentVfs.integration.test.ts src/server/services/agentDocumentVfs/index.test.ts src/utils/__tests__/documentRenderMode.test.tsbunx vitest run --silent=passed-only src/features/AgentDocumentsExplorer/types.test.ts src/features/AgentDocumentsExplorer/utils/canDrop.test.ts src/features/AgentDocumentsExplorer/DocumentExplorerTree.test.tsx src/routes/(main)/agent/features/Conversation/WorkingSidebar/ResourcesSection/AgentDocumentsGroup.test.tsx src/store/file/slices/document/action.test.tscd packages/database && bunx vitest run --silent=passed-only src/models/agentDocuments/__tests__/agentDocument.test.ts src/models/agentDocuments/__tests__/deriveFields.test.tsgit diff --check