β¨ feat(task): support file & image attachments#15141
Conversation
|
Deployment failed with the following error: View Documentation: https://vercel.com/docs/accounts/team-members-and-roles |
There was a problem hiding this comment.
Sorry @sudongyuer, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
Codecov Reportβ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## canary #15141 +/- ##
===========================================
+ Coverage 65.91% 75.78% +9.86%
===========================================
Files 2976 120 -2856
Lines 262859 3866 -258993
Branches 31191 600 -30591
===========================================
- Hits 173275 2930 -170345
+ Misses 89423 923 -88500
+ Partials 161 13 -148
Flags with carried forward coverage won't be shown. Click here to find out more.
π New features to boost your workflow:
|
Codecov Reportβ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## canary #15141 +/- ##
==========================================
+ Coverage 82.45% 82.60% +0.14%
==========================================
Files 310 325 +15
Lines 23140 23880 +740
Branches 4500 4651 +151
==========================================
+ Hits 19080 19725 +645
- Misses 3955 4045 +90
- Partials 105 110 +5
Flags with carried forward coverage won't be shown. Click here to find out more.
π New features to boost your workflow:
|
There was a problem hiding this comment.
π‘ Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 88140c53c5
βΉοΈ 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".
| if (fileIds && task) { | ||
| await this.replaceTaskFilesIn(trx, id, fileIds); |
There was a problem hiding this comment.
Treat empty fileIds as a clear operation on update
update() only rewrites task-file relations when fileIds is truthy, so passing fileIds: [] (the natural way to remove all attachments) skips replaceTaskFilesIn and leaves old rows intact. The task editor now sends attachment ids on save, so removing every attachment produces [] and stale files remain attached to the task and keep showing up in later runs.
Useful? React with πΒ / π.
| if (!trimmed && attachments.fileIds.length === 0) return; | ||
| setSubmitting(true); | ||
| try { | ||
| await addComment(taskId, trimmed); | ||
| await addComment(taskId, trimmed, { | ||
| fileIds: attachments.fileIds.length > 0 ? attachments.fileIds : undefined, |
There was a problem hiding this comment.
Block attachment-only submits from sending empty comment text
This path allows submission when files are present, but still sends trimmed as comment content; when the user attaches files without typing text, trimmed is empty and the request fails because task.addComment still validates content with min(1). The UI therefore exposes a send path that deterministically errors for attachment-only comments (same pattern also appears in FeedbackInput).
Useful? React with πΒ / π.
2e98d13 to
f306ab1
Compare
Codecov Reportβ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## canary #15141 +/- ##
==========================================
- Coverage 71.13% 71.12% -0.01%
==========================================
Files 3182 3187 +5
Lines 318198 318597 +399
Branches 34725 28106 -6619
==========================================
+ Hits 226340 226601 +261
- Misses 91686 91824 +138
Partials 172 172
Flags with carried forward coverage won't be shown. Click here to find out more.
π New features to boost your workflow:
|
π Dependency: #15239 (DB schema)This PR's schema change has been split out into #15239 per the project's Split
Merge order
After rebase this PR will be purely application-layer changes (no Why this matters for reviewIf you're reviewing now, you can ignore the DB files in this PR β they belong to #15239 and will disappear post-rebase. Focus on:
cc reviewers |
π Dependency updated: #15239 β #15186The schema change has been merged into #15186 ( The Updated merge order
Everything else in my earlier comment still applies. |
Adds attachment / image upload to all four Task input surfaces (Create
Modal, Inline Entry, Task Instruction, Comment Input, Feedback Input)
plus comment edit. Attachments persist in `tasks.editor_data` /
`task_comments.editor_data` as part of the Lexical JSON state and flow
into agent runs via `execAgent.fileIds` β images as multimodal vision
content, documents through `documentService.parseFile` for text
extraction.
Server-side fileId resolution rides on the editor's
`extractMediaFromEditorState` (`@lobehub/editor/headless` 4.15.1), so
no junction tables are needed β editor_data is the single source of
truth. The /f/{fileId} proxy URL contract from the file router stays
the bridge between editor URLs and backend file lookup.
Five UI surfaces share `EditorCanvas` + `editorAttachments` for inline
attachment insertion. Comment display renders the Lexical state via
`@lobehub/editor/renderer`'s `LexicalRenderer` so image sizes round-
trip without the EditorCanvas hydration flash.
DB schema (`tasks.editor_data jsonb` column) landed separately via
#15280.
Fixes LOBE-8967
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
91631a0 to
f123a02
Compare
Real-world editor_data exposed two bugs in the regex-based extract:
1. `fileId` prefix was wrong β the regex looked for `fle_β¦` but
`idGenerator('files')` actually produces `file_β¦`, so every proxy
URL `/f/file_β¦` silently failed to match.
2. `@lobehub/editor`'s `extractMediaFromEditorState` requires
`status === 'uploaded'` strictly. Editor data from the cloud upload
path and from historical inserts omits the `status` field entirely,
so the upstream helper silently dropped everything. Walk the tree
ourselves and treat a missing `status` as uploaded.
Verified against real `tasks.editor_data` rows: T-6 (proxy URL form)
now extracts `file_β¦` correctly. T-8 (cloud R2 signed URL form) still
returns `[]` β that requires either aligning cloud's `createFile` to
return the proxy URL or adding a DB-fallback resolver, tracked as a
follow-up.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
β¦l lookup
Root cause: `fileService.getFileAccessUrl()` returns different URL forms
depending on the environment:
- prod / non-dev β `getFileProxyUrl(fileId)` = `${APP_URL}/f/{fileId}`
- dev β `getFullFileUrl(file.url)` = a pre-signed R2/S3 URL
The dev branch is intentional so remote model providers can fetch the
file directly (proxy URLs point to localhost and aren't reachable). But
the pre-signed URL doesn't contain the fileId anywhere, so our regex
extract silently returned [] for every local upload β agent never saw
any attached image.
Same shape happens for historical cloud data where the editor stored
pre-signed URLs.
Fix: make `extractFileIdsFromEditorData` async and take a `{ db, userId }`
context. Fast path stays the proxy-URL regex; URLs that don't match fall
back to a single batched `SELECT id FROM files WHERE user_id = ? AND url
IN (β¦)` keyed on the storage path extracted from each URL's pathname.
Verified against real local data:
T-6 (proxy URL form) β file_2vFD2sdzW9VO (regex fast path)
T-8 (pre-signed R2 URL) β file_cAQ4naT8G8r5 (DB fallback)
T-9 (pre-signed R2 URL Γ 2) β file_β¦, file_β¦ (DB fallback)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Same bytes re-uploaded by the same user produce multiple `files` rows with identical `url` + `file_hash`. The DB fallback in `extractFileIdsFromEditorData` was returning every matching row, so a task with one inline image but three historical upload attempts fed the agent three copies of the same image β wasteful multimodal tokens and noisy provider input. Group results by `files.url` and keep the first row per key. Verified against real local data: T-6 (1 img, 1 upload) β 1 fileId T-8 (1 img, 1 upload) β 1 fileId T-9 (1 img, 2 dup uploads) β 1 fileId (was 2) T-10 (1 img, 3 dup uploads) β 1 fileId (was 3) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The default @lobehub/editor `ReactFile` decorator paints file attachments as a tiny inline pill (icon + filename in monospace, inline-block with 0.4em padding), so a single PDF on its own line looked cramped and hugged the surrounding text. Override the upstream styling via the `className` prop the plugin already exposes: full-width flex row, 10px gap, 14px padding, `borderRadiusLG` corner, subtle hover, primary tint on `.selected`. Aligns the editor's file attachment row with the Linear attachment card look β and with the LexicalRenderer card the comment thread already uses, so the same file looks consistent across surfaces. The upstream component still only renders icon + name (no size), but the layout change is the main UX win. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Replace the upstream inline pill FileNode UI with a full-width card (icon + name + size + hover-revealed download button) wired in both the live editor and the read-only LexicalRenderer for saved comments. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
# π LobeHub Release (20260604) **Release Date:** June 4, 2026 **Since v2.2.1:** 88 merged PRs Β· 11 contributors > This week brings Execution Devices out of the lab β run agents and Claude Code on any configured local or remote machine β alongside Claude Opus 4.8, token-usage analytics, and Page sharing. --- ## β¨ Highlights - **Execution Devices** β Pick where an agent runs. Desktop and CLI devices auto-register with a stable machine ID, route through the gateway by channel, and surface a device switcher in the chat input. Run remote Claude Code on a configured device, with a recent-directory picker you can drag to reorder. (#15300, #15315, #15322, #15343, #15351, #15371) - **Claude Opus 4.8** β Day-one support for Anthropic's latest model. (#15314) - **Token-usage analytics** β A new token-usage mode on the activity heatmap, backed by a denormalized topic usage/cost rollup so totals stay accurate without recomputing from messages. (#15365, #15417, #15425) - **Page sharing** β Share a Page through a dedicated document share flow, plus new Workspace and Agent share tables. (#15309, #15439) - **Self-iteration agents** β Agent Signal's execAgent migration lands a server-runtime bridge, async memory writer, and a registered self-iteration tool package, with a CLI trigger command for testing. (#15360, #15364, #15392) - **Knowledge search** β BM25 search now extends to file-backed documents, and the portal ships an editable CodeMirror viewer for local files with document highlighting. (#15247, #15298) --- ## ποΈ Core Agent & Architecture ### Agent Signal & Runtime - **execAgent migration** β Server-runtime bridge, completion projection, async memory writer, and removal of the legacy `executeSelfIteration` path. (#15392) - Registered the self-iteration builtin tool package and restored the three mode-specific self-iteration agent slugs. (#15202, #15364) - Added a CLI trigger command with a golden-snapshot fixture for Agent Signal. (#15360) - **Skill priority** β Agent Builder now emits a skill-priority instruction with matching server runtime. (#15409) - Retry empty LLM completions instead of silently finishing the turn. (#15355) - Classify topic/agent/session foreign-key violations as `ConversationParentMissing` for clearer recovery. (#15408) - Persist canonical nested usage/performance on assistant messages, and re-link orphan tool messages at the raw bucket write boundary. (#15359, #15438) - Guard `createAgent` against LLM double-encoded array fields. (#15381) --- ## π₯οΈ Execution Devices & Gateway - Auto-register desktop and CLI devices with a stable machine ID, and add the `@lobechat/device-identity` package. (#15300, #15321) - New Devices settings page behind the Execution Device Switcher lab, with a device switcher shown for all agents in the chat input. (#15315, #15371) - `connectionId` + channel routing across the gateway client and device list; preset the local device on the first LLM request for the ζ¬ζΊ target. (#15322, #15435) - Run remote Claude Code on a configured device, with drag-to-reorder recent-directory management and client renders for device tool results. (#15343, #15351, #15437) - Preserve content and state across gateway tool calls, and prevent duplicate streaming from stale reconnects. (#15114, #15354) --- ## π₯οΈ CLI & Desktop - Preserve content/state for connect local file and shell tools; render the `runCommand` tool result card. (#15441, #15442) - New `lh topic view` command; CLI now auto-registers its device on login, matching desktop. (#15340, #15377) - Resolve CLI tools from the shell `PATH`, and clarify local command session handling. (#15368, #15389) - Relocate visual-ref helpers to `@lobechat/const` to fix a renderer crash; upload `.blockmap` files to S3 for differential updates. (#15326, #15369) - Fix a market OAuth expiry that triggered the wrong re-login modal, and kill dev child processes on parent shutdown. (#15246, #15290) --- ## ποΈ Pages, Library & Knowledge - Document share flow with business slot stubs, plus Workspace and Agent share tables. (#15309, #15439) - Export Agent profiles as Markdown, preserving an empty agent prompt on export. (#15312, #15316) - Editable CodeMirror viewer for local files with document highlighting; BM25 search extended to file-backed documents. (#15247, #15298) - Default new Agent-doc files to `.md` and preserve IME composition; refresh folder data on slug switch and dedupe breadcrumb fetches. (#15335, #15427) --- ## π¬ Chat & User Experience - Group-by-status mode for the Topic sidebar; dropped the legacy sessionβagentId compatibility path from Topic queries. (#15366, #15378) - Restore editor focus after the file picker closes, and close the skill dropdown before navigating to settings. (#15391, #15394) - Strip markdown tokens from fallback Topic titles; keep an open ActionBar popup when hovering another message. (#15303, #15372) - Stabilize home starter loading and stop transliterating model names in the home starter; show artifact source while streaming. (#15310, #15324, #15386) - Group the sidebar spacer with recents and agents. (#15373) --- ## π Analytics, Tasks & Notifications - Token-usage mode on the activity heatmap, backed by a denormalized topic usage/cost rollup. (#15365, #15417, #15425) - Push: new `PushChannel`, receipt cron, and `pushToken` tRPC API. (#15233) - Tasks now support file and image attachments. (#15141) --- ## π§© Models & Providers - Support Claude Opus 4.8 and configurable model routing with starters. (#15314, #15384) - MiniMax M3: new model entry and an Anthropic video runtime. (#15380, #15403) - Add `intern-s2-preview` with `thinking_mode`, and `step-3.7-flash` support. (#15308, #15317) - Block disabling the official provider; fix default provider setup in business mode. (#15379, #15382) --- ## π¨ UI & Modals - Migrate modals to `@lobehub/ui/base-ui` (LOBE-9711 + eval batch), including the create-custom-model and feedback/changelog modals. (#15401, #15416) - Restructure confirmModal title and content across deletion flows; polish the service-model form and migrate its Switch to base-ui. (#15426, #15440) - Wrap the BlueBubbles bridge config into a connection card; update `@lobehub/ui` to v5.15.5. (#15325, #15342) --- ## π Reliability - Replace hardcoded `session_context` values with template variables in credentials. (#15352) - Point `CHANGELOG_URL` to `/changelog`. (#15428) --- ## π₯ Contributors Huge thanks to **11 contributors** who shipped **88 merged PRs** this cycle. @hezhijie0327 Β· @qybaihe Β· @sxjeru Β· @arvinxx Β· @Innei Β· @tjx666 Β· @lijian Β· @sudongyuer Β· @cy948 Β· @rivertwilight Β· @AmAzing129 Plus @lobehubbot and renovate[bot] for maintenance. --- **Full Changelog**: v2.2.1...release/weekly-20260604
π» Change Type
π Related Issue
@lobehub/editor@4.10.6; CI picks up via existing^4.9.3constraint)π Description of Change
Adds the ability to attach files and images to Task surfaces and feeds them to the agent runtime as multimodal context.
Database
tasks_files+task_comments_files, mirroringmessages_filestasks.editor_data jsonbcolumn to round-trip Lexical state (preserves image sizes that markdown drops)0103_add_task_files_tables.sql+0104_add_tasks_editor_data.sqlServer
src/server/services/file/resolveAttachments.ts(resolveAttachmentsByFileIdsfor full +resolveAttachmentMetadatafor lightweight UI/prompt rendering)execAgent.fileIdsso the agent sees them as multimodal inputsTaskModel.create / update / addCommentwrap the parent insert + junction-table insert in a single transaction so a fileIds failure cannot leave an orphan task / commentfileIdsandeditorDataon create / update / addComment / getTaskDetailFront-end
src/features/AttachmentInput/β shared chip-style upload UI for the chat-style surfaces (CommentInput,FeedbackInput)src/features/EditorCanvas/β mountsReactFilePlugin, exposes a paperclip button that inserts attachments at the cursor, tracks aurl β fileIdregistry, and opens file cards in a new tab on click (workaround for vendor decorator with no built-in preview)CreateTaskContent,CreateTaskInlineEntry,TaskInstruction,CommentInput,FeedbackInputCommentCardrenders attached files via the existing chatFileListViewerπ§ͺ How to Test
Coverage:
setTaskFiles/setCommentFilesidempotency,create/addCommentwithfileIds, cascade delete on parent task / comment (72/72 task model tests pass)task/index.test.tsmocksresolveAttachmentMetadata+ new task-model methods (27/27 pass);execAgent.files.test.tsregression-tests the refactored file resolution (14/14 pass, including caller-order preservation)heterogeneous-agentsissues remain)Manual E2E (
dev:spa):CreateTaskModal, inline create,TaskInstruction,CommentInput,FeedbackInput)documentService.parseFileπΈ Screenshots / Videos
N/A β UI is incremental (paperclip button + file chips/cards in existing layouts).
π Additional Information
@lobehub/editor(inconsistentdeltaXcoefficient betweenhandleResizeandhandleResizeEnd). Fixed upstream in4.10.6; tracked as LOBE-9277.ReactFiledecorator with a custom renderer.π€ Generated with Claude Code