feat: implement @file mention (#47) #56

Merged
ph merged 1 commit from feature-mention into master 2026-06-08 23:45:43 +00:00
Owner

Summary

Closes #47 — implements @file mention feature.

Changes

Backend (Go)

  • UserMessage → multi-part: Content stringParts []UserPart (UserTextPart + UserFileMentionPart), with backward-compatible JSON
  • new internal/mention package: parses @path/to/file mentions, reads file content, generates structured UserParts
  • hook in pool.Execute + EmbeddedService: both daemon and TUI paths parse @mentions before storing user message
  • GET /api/fs/tree?session_id=&search=: returns filtered file list using fd → find → Go WalkDir fallback chain

Frontend (TS/React)

  • Tiptap replaces textarea: rich text editor with Mention extension for @file autocomplete chips
  • 80ms debounced search: calls /api/fs/tree backend endpoint for fuzzy file matching
  • Inline mention chips: styled with background color, file icon, atomic deletion
  • User message rendering: file mention chips displayed in chat history
  • TypeScript types: hand-written UserPart discriminated union (same pattern as AssistantPart)

Prompt format

File contents injected as XML blocks after user text:

user text here

<file_content path="src/main.go">
package main
...
</file_content>

Files Changed

20 files, +1624/-65

Layer Files
Go mention.go, mention_test.go, types.go, session.go, pool.go, service.go, handler.go, router.go, gen-ts/main.go
TS composer.tsx (rewritten), mention-list.tsx (new), types.ts, message-types.ts, chat-store.ts, daemon.ts, message.tsx
Deps package.json + lock (Tiptap)
## Summary Closes #47 — implements @file mention feature. ## Changes ### Backend (Go) - **UserMessage → multi-part**: `Content string` → `Parts []UserPart` (UserTextPart + UserFileMentionPart), with backward-compatible JSON - **new `internal/mention` package**: parses `@path/to/file` mentions, reads file content, generates structured UserParts - **hook in pool.Execute + EmbeddedService**: both daemon and TUI paths parse @mentions before storing user message - **`GET /api/fs/tree?session_id=&search=`**: returns filtered file list using fd → find → Go WalkDir fallback chain ### Frontend (TS/React) - **Tiptap replaces textarea**: rich text editor with Mention extension for @file autocomplete chips - **80ms debounced search**: calls `/api/fs/tree` backend endpoint for fuzzy file matching - **Inline mention chips**: styled with background color, file icon, atomic deletion - **User message rendering**: file mention chips displayed in chat history - **TypeScript types**: hand-written UserPart discriminated union (same pattern as AssistantPart) ### Prompt format File contents injected as XML blocks after user text: ``` user text here <file_content path="src/main.go"> package main ... </file_content> ``` ## Files Changed 20 files, +1624/-65 | Layer | Files | |-------|-------| | Go | mention.go, mention_test.go, types.go, session.go, pool.go, service.go, handler.go, router.go, gen-ts/main.go | | TS | composer.tsx (rewritten), mention-list.tsx (new), types.ts, message-types.ts, chat-store.ts, daemon.ts, message.tsx | | Deps | package.json + lock (Tiptap)
- UserMessage refactored to multi-part (UserTextPart + UserFileMentionPart)
- New mention package: parses @mentions, reads files, injects XML into prompt
- GET /api/fs/tree endpoint with fd→find→WalkDir fallback file listing
- Tiptap replaces textarea: @mention autocomplete with 80ms debounce
- Mention chips with background styling, atomic deletion
- User message history renders file mention chips
- Backward compatible with legacy single-content UserMessage format
ph merged commit 5cd9f50bf9 into master 2026-06-08 23:45:43 +00:00
ph deleted branch feature-mention 2026-06-08 23:45:43 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ph/agentic!56
No description provided.