feat(agent): add nested agents.md support across backend and webui (#309)

* feat(agent): add nested agents.md support across backend and webui

* fix(webui): update agentsmd route paths and unnest folder agentsmd route

* fix(agent): flush agents.md autosave on close and address review feedback

- Flush pending debounced AGENTS.md autosave on close/unmount so edits
  made within 750ms of navigating away are no longer silently lost
- Serialize autosaves through a promise chain so an older in-flight
  request can never overwrite newer content on the server
- Internationalize the hardcoded "Failed to save" and
  "Loading AGENTS.md..." strings (en + zh)
- Validate that AGENTS.md is only stored on folder/root assets in
  AssetService, preventing bogus virtual paths for file assets
- Cap updateAgentsMd content at 100k chars via Zod validation
- Remove unused getAgentsMd/updateAgentsMd response DTO schemas
- Drop unused teamId prop from AgentsMdEditor
- Add tests: non-folder asset rejection, oversized content 400,
  and agent-chat workflow assetId passthrough

* refactor(db): isolate AGENTS.md content in dedicated 1:1 AssetAgentMd table

* style(webui): unify top bar button hover styles and add wand icon to agentsmd button

* style(webui): update agentsmd button state colors and remove presence dot

* fix(webui): fix close button overflow and stabilize debounced autosave in agentsmd editor

* fix(webui): update debounce to 1s and await pending save before closing agentsmd editor

* feat(webui): add terminal AGENTS.md breadcrumb on agentsmd editor page

* fix(webui): use ScrollArea for markdown editor scrolling
This commit is contained in:
Yiling-J
2026-08-15 10:25:46 +08:00
committed by GitHub
parent 3c3b6880e4
commit 1cee103b1c
56 changed files with 3529 additions and 242 deletions
@@ -24,6 +24,7 @@ import { AutoLinkNode, LinkNode } from '@lexical/link'
import { ToolbarPlugin } from './toolbar'
import { editorTheme } from './theme'
import { EDITOR_TRANSFORMERS } from './transformers'
import { ScrollArea } from '@/ui/components/ui/scroll-area'
import './markdown-editor.css'
function MarkdownSyncPlugin({
@@ -90,6 +91,7 @@ export interface MarkdownEditorProps {
autoFocus?: boolean
className?: string
hideToolbar?: boolean
rightToolbarContent?: React.ReactNode
}
export function MarkdownEditor({
@@ -101,6 +103,7 @@ export function MarkdownEditor({
autoFocus = false,
className = '',
hideToolbar = false,
rightToolbarContent,
}: MarkdownEditorProps) {
const initialConfig: InitialConfigType = {
namespace: 'ShumaiWysiwygMarkdownEditor',
@@ -126,13 +129,21 @@ export function MarkdownEditor({
return (
<div className={`shumai-editor-wrapper ${readOnly ? 'read-only' : ''} ${className}`}>
<LexicalComposer initialConfig={initialConfig}>
{!readOnly && !hideToolbar && <ToolbarPlugin />}
<div className="shumai-editor-content-area">
<RichTextPlugin
contentEditable={<ContentEditable className="editor-input" />}
placeholder={<div className="editor-placeholder">{placeholder}</div>}
ErrorBoundary={LexicalErrorBoundary}
/>
{!readOnly && !hideToolbar ? (
<ToolbarPlugin rightContent={rightToolbarContent} />
) : rightToolbarContent ? (
<div className="shumai-editor-toolbar flex items-center justify-end px-3 py-1.5 border-b">
{rightToolbarContent}
</div>
) : null}
<ScrollArea className="shumai-editor-content-area flex-1 min-h-0 w-full">
<div className="relative min-h-full">
<RichTextPlugin
contentEditable={<ContentEditable className="editor-input" />}
placeholder={<div className="editor-placeholder">{placeholder}</div>}
ErrorBoundary={LexicalErrorBoundary}
/>
</div>
<HistoryPlugin />
<ListPlugin />
<CheckListPlugin />
@@ -141,7 +152,7 @@ export function MarkdownEditor({
<MarkdownShortcutPlugin transformers={EDITOR_TRANSFORMERS} />
<MarkdownSyncPlugin value={value} initialContent={initialContent} onChange={onChange} />
{autoFocus && <AutoFocusPlugin />}
</div>
</ScrollArea>
</LexicalComposer>
</div>
)