Commit Graph

29 Commits

Author SHA1 Message Date
Arvin Xu f267232a19 ✨ feat: add dedicated project coordinator agent (#18054)
✨ feat: add project coordinator agent
2026-08-09 22:23:01 -07:00
Arvin Xu 4e1663f786 ⚡️ perf: batch recent-topic previews instead of per-topic subquery (#17928)
* ⚡️ perf: batch recent-topic previews instead of per-topic subquery

The lastAssistantMessage preview subquery lived in the topic arm's SELECT
list, below the union's ORDER BY/LIMIT, so Postgres evaluated it for every
topic the user owns before pruning to the final page. For heavy users
(~9k topics) the home Recents query took 30-83s (prod pg_stat_statements:
30k calls, mean 6.6s, max 215s). Fetch previews in a second DISTINCT ON
query scoped to the final page ids instead.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* ⚡️ perf: drop dead preview column from union arms and strip markdown from previews

All three union arms now emit a constant NULL for last_assistant_message
(previews come from the second batched query), so remove the column from
the SQL entirely. Also run previews through remove-markdown — they render
in plain-text rows, where raw markdown syntax shows up literally.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-05 15:54:14 +08:00
Arvin Xu 62689192ac ✨ feat(agent-quota): account-scoped quota data layer + capacity calibration (#17314)
* ✨ feat(agent-quota): quota accounts upper layer — models, service, tRPC, QuotaMenu DB-first UI

Squash of this branch's pre-split history: the DB schema/migration layer
was extracted and merged separately as #17378; this base commit carries
everything above it — models with credential encryption, AgentQuotaService
(ingest / windows / calibration / LB selection), the agentQuota tRPC
router, renderer service, and the DB-first QuotaMenu with the account
manager modal.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* ✨ feat(agent-quota): scope accounts, bindings and quota facts by workspace

Wire `workspaceId` end to end for the agent quota data layer: the tRPC
`quotaProcedure` now passes `ctx.workspaceId` into every model, the six
models filter through `buildWorkspaceWhere` and stamp inserts through
`buildWorkspacePayload`, and the account identity unique index is split
into the personal / workspace pair the rest of the repo uses — so the
same external account can be registered once per scope.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* 🐛 fix(agent-quota): drop NUL-byte bucket keys in recalibrate

Two raw NUL bytes had crept in as the map-key separator, which made git
treat the whole service file as binary (no diffs, no `git grep`). Key on
a JSON tuple and carry the (limitType, scopeKey) pair alongside instead
of re-splitting the key, so a scopeKey containing the separator can
neither merge two buckets nor be mis-parsed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* 🚧 chore(agent-quota): hide the account switcher entry until routing lands

Switching an account today only moves bindings — `selectForAgent` is not
wired into the spawn path yet, so the run still uses whatever credential
the local CLI is logged into. Keep the menu read-only until that lands.

Also refreshes QuotaMenu tests against the redesigned window row (bare
`NN%` + short duration instead of `left:`/`resetsIn:` sentences, exhausted
rows grey rather than warning) and the DB-first fetch: a rejected live
request now degrades to the unavailable state instead of surfacing a raw
transport error.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* 🌐 chore(agent-quota): sync en-US / zh-CN copy for the quota account keys

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* 🐛 fix(agent-quota): key the workspace account identity index by workspace only

The workspace-mode unique index carried userId, which let two members of
one workspace each hold a row for the same real provider account — and
the load balancer would then count that account's capacity twice. Drop
userId so the index matches what `upsertByIdentity` already does: the
workspace-scoped lookup ignores userId, so a teammate observing the same
login updates the existing row instead of adding a copy.

Covered by a new case in agentQuota.workspace.test.ts.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* 🐛 fix(agent-quota): open the account manager modal via createModal's own mount

`createModal()` mounts the modal as it is called and returns a ModalInstance
that has no `open()` — the extra call broke the type-check. Renamed the
factory to `openQuotaAccountManagerModal` to match the repo's other modal
call sites, so the "calling it opens it" contract is visible at the call site.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* 🐛 fix(agent-quota): calibrate on ingest, accept string epochs, prefer live over an empty panel

Three review findings:

- `recalibrate` had no caller, so the calibration table could never fill.
  Ingestion is the only moment new evidence arrives, so trigger it there.
  It stays self-guarding: without ledger spend every window reads as
  contaminated and no capacity row is written rather than a fabricated one.
- `parseResetsAt` passed every string to `Date.parse`, but the API types
  `resets_at` as `number | string`, so a quoted epoch parsed to NaN and the
  reading was dropped. Worse, a short digit string like "1784" was read as a
  year. Parse digit strings as epochs first.
- The live snapshot was only used as a fallback when no account existed. An
  account with zero persisted windows therefore rendered "unavailable" while
  a healthy live fetch sat unused. Prefer persisted data, else the live
  snapshot, else unavailable.

Adds a service-level test that drives the real ingest path end to end
(readings + ledger in → windows + calibrated capacity out) plus its inverse,
and QuotaMenu cases for both fallback routes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* 🗃️ chore(agent-quota): regenerate the workspace-identity migration as 0126

Canary took 0125 for the stats-activity indexes while this branch was in
flight, so the workspace identity-index migration is regenerated after the
rebase with the next free number, per the db-migrations convention.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* 🚚 refactor(agent-quota): gather the quota menu family into a QuotaMenu folder

Eight quota files were spread flat across HeterogeneousChatInput. Move the
generic menu, both provider menus, the account switcher + manager modal,
and the view model into QuotaMenu/, with index.ts exposing just the two
menus HeteroControlBar consumes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-22 10:00:49 +08:00
AmAzing- a6e57eaef4 🐛 fix(database): repair Zod 4 + drizzle-zod insert schema type inference (#17072)
* 🐛 fix(database): repair Zod 4 + drizzle-zod insert schema type inference

Align @lobechat/database drizzle-zod peer to ^0.8.3 and override text-enum
fields in createInsertSchema so inferred types match Drizzle row types.
Use createUpdateSchema for threads to avoid TS2589 on .partial().

* 🐛 fix(database): preserve insert/update optionality on Zod enum overrides

Bare z.enum refinements drop drizzle-zod's optional/nullish wrappers and
would require defaulted fields (or type/status on thread updates). Match
column nullability so runtime validation stays equivalent to pre-fix.

* ♻️ refactor(database): share enum tuples between column defs and zod overrides

Hand-written z.enum overrides re-duplicated enum lists already declared on
text(..., { enum }). Extract as-const single sources of truth so column
definitions and insert/update schemas stay in sync when values change.
2026-07-12 11:08:00 +08:00
Arvin Xu 20238b7b02 ⬆️ refactor: upgrade Zod to v4 (#16998)
* ⬆️ chore: upgrade Zod to v4

* ⬆️ chore: align drizzle-zod with Zod 4

* 🧰 chore(agent-testing): make verify runs lifecycle-safe

* ✅ test: align Zod 4 validation expectations

* ✅ test: use a valid tracing UUID
2026-07-11 15:09:20 +08:00
Arvin Xu ff3bad8c4d ✨ feat: Add Claude SDK streaming lab (#16927)
✨ feat: add Claude SDK streaming lab
2026-07-10 01:12:06 +08:00
YuTengjing be0255b746 🔨 chore: update dependency baseline (#16465)
* 🔨 chore: update dependency baseline

* 🔨 chore(cli): update dependency baseline

* 🔨 chore(desktop): update dependency baseline

* 🔨 chore: fix dependency baseline blockers

* 🔨 chore: update TypeScript and Next baseline
2026-06-30 23:18:08 +08:00
YuTengjing 0911c2a94c ♻️ refactor: load models through model bank slot (#14877)
* ♻️ refactor: load models through model bank slot

* ♻️ refactor: remove static LobeHub model cards

* ♻️ refactor: share OpenAI image parameters

* 🐛 fix: load async LobeHub model config in server paths

* 🐛 fix: repair model bank CI follow-ups

* 🐛 fix: avoid repeated model bank fallback loads

* 🐛 fix: resolve business model config import in browser

* 🐛 fix: align Nano Banana 2 resolution default

* ♻️ refactor: move model loader slot under client

* ✅ test: move model bank aiModels spec out of build entries

* 🐛 fix: use business model config for mixed provider parsing

* ♻️ refactor: consolidate model bank provider utilities

* 🐛 fix: preserve Nano Banana 2 raw resolution

* 🐛 fix: avoid generated locale sync for raw resolution

* 🌐 style: add Nano Banana 2 resolution locales

* 🌐 style: add online LobeHub model locales

* 🐛 fix: guard optional model provider loaders

* 🐛 fix: prevent sitemap build from hanging

* 🐛 fix: clear sitemap timeout after model load
2026-05-21 10:35:14 +08:00
Arvin Xu 4576059f4f ♻️ refactor: implement SkillResolver, BaseSystemRoleProvider, and agent document injection pipeline (#13315)
* ♻️ refactor: implement SkillResolver to replace ad-hoc skill assembly

Introduces a two-layer skill resolution architecture mirroring ToolsEngine + ToolResolver:

- SkillEngine (assembly layer): accepts raw skills + enableChecker, outputs OperationSkillSet
- SkillResolver (resolution layer): merges operation + step delta + accumulated activations

Key changes:
- Add SkillResolver, OperationSkillSet, StepSkillDelta, ActivatedStepSkill types
- Enhance SkillEngine with enableChecker and generate() method
- Wire SkillResolver into RuntimeExecutors call_llm
- Replace manual skillMetas assembly in aiAgent with SkillEngine.generate()
- Update client-side skillEngineering to use SkillEngine + enableChecker
- Add activatedStepSkills to AgentState for step-level skill accumulation

Fixes: agent-browser content injected into non-desktop scenarios (Discord bot)
due to missing filterBuiltinSkills call in aiAgent

LOBE-6410

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* ♻️ refactor: extract agent-templates to standalone package and inject documents server-side

- Create @lobechat/agent-templates package with types, templates, and registry
- Move DocumentLoadPosition, DocumentLoadFormat, DocumentLoadRule, etc. to new package
- Move claw templates (AGENTS, BOOTSTRAP, IDENTITY, SOUL) with .md file imports
- Add BOOTSTRAP.md as new onboarding template (priority 1, system-append)
- Fix template positions: AGENTS→before-system, IDENTITY/SOUL→system-append
- Update database package to re-export from @lobechat/agent-templates
- Migrate all consumers to import directly from @lobechat/agent-templates
- Add agent documents injection in server-side RuntimeExecutors (was missing)
- Support -p CLI flag in devStartupSequence for port configuration

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* 🐛 fix: correct import statement for non-type exports from agent-templates

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* 📦 build: add @lobechat/agent-templates to root dependencies

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* ♻️ refactor: remove template proxy files from database package

Stop re-exporting template/templates from database — consumers import
directly from @lobechat/agent-templates. Keep types.ts re-exports for
internal database code only.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* ♻️ refactor: create BaseSystemRoleProvider to unify system message append pattern

All providers that append to the system message now inherit from
BaseSystemRoleProvider and only implement buildSystemRoleContent().
The base class handles find-or-create and join logic.

Migrated providers:
- EvalContextSystemInjector
- BotPlatformContextInjector
- SystemDateProvider
- ToolSystemRoleProvider
- HistorySummaryProvider
- SkillContextProvider

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* 🐛 fix: restore metadata tracking in BaseSystemRoleProvider via onInjected hook

Add onInjected() callback to BaseSystemRoleProvider so subclasses can
update pipeline metadata after successful injection. Also add raw-md
plugin to context-engine vitest config for .md imports.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* ✨ feat: add enabled field to AgentDocumentInjector config

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* ♻️ refactor: add enabled field to all providers, remove spread conditionals in MessagesEngine

All providers now accept an `enabled` config field. MessagesEngine
pipeline is a flat array with no spread conditionals — each provider
is always instantiated and uses `enabled` to skip internally.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* 💄 style: clean up MessagesEngine pipeline comments

Remove numbered prefixes, keep descriptive comments for each provider.
Only phase headers use separator blocks.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* ♻️ refactor: reorganize MessagesEngine pipeline phases by injection target

Phase 1: History Truncation
Phase 2: System Message Assembly (all BaseSystemRoleProvider)
Phase 3: Context Injection (before first user message, BaseFirstUserContentProvider)
Phase 4: User Message Augmentation (last user message injections)
Phase 5: Message Transformation (flatten, template, variables)
Phase 6: Content Processing & Cleanup (multimodal, tool calls, cleanup)

Moved SkillContext, ToolSystemRole, HistorySummary from Phase 3 to
Phase 2 since they append to system message, not user context.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* 💄 style: split Phase 6 into Content Processing (6) and Cleanup (7)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* ♻️ refactor: split AgentDocumentInjector into three position-based injectors

- AgentDocumentSystemInjector (Phase 2): before-system, system-append, system-replace
- AgentDocumentContextInjector (Phase 3): before-first-user
- AgentDocumentMessageInjector (Phase 4): after-first-user, context-end

Shared utilities (filterByRules, formatDocument, sortByPriority) extracted
to AgentDocumentInjector/shared.ts. Old monolithic injector removed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* ♻️ refactor: split AgentDocumentSystemInjector into three separate injectors

- AgentDocumentBeforeSystemInjector: prepends as separate system message (before-system)
- AgentDocumentSystemAppendInjector: appends to system message (system-append)
- AgentDocumentSystemReplaceInjector: replaces entire system message (system-replace)

Each has distinct semantics and correct pipeline placement:
- BeforeSystem → before SystemRoleInjector
- SystemAppend → after HistorySummary (end of Phase 2)
- SystemReplace → last in Phase 2 (destructive)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* ✨ feat: auto-enable agent-documents tool when agent has documents

- Add AgentDocumentsManifest to defaultToolIds
- Add hasAgentDocuments rule in server createServerAgentToolsEngine
- Query agent documents in AiAgentService.execAgent to determine flag
- Pattern matches KnowledgeBase auto-enable via enableChecker rules

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* 🔨 chore: add agent documents status to execAgent operation log

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* update content

* fix tests

* 🐛 fix: add raw-md plugin to database vitest configs

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 10:10:06 +08:00
YuTengjing 57ec43cd00 🐛 fix(database): add drizzle-zod and zod as peer dependencies to fix type-check errors (#13132) 2026-03-19 21:24:41 +08:00
YuTengjing 37cb4983de 🐛 fix: filter out delisted lobehub provider models from DB residuals (#12896) 2026-03-11 10:22:51 +08:00
Arvin Xu 15941de63b ✅ test: add more test for db (#11830)
* add more test for db

* fix tests

* fix tests

* fix tests
2026-01-26 12:21:15 +08:00
Arvin Xu 09a00df38e ✨ feat: support history context auto compress (#11790)
* add compress implement

* push

* update

* update

* update

* fix auto scroll

* db schema update

* fix compress

* fix types

* fix lint

* update get compressedMessages

* update content

* update

* fix tests

* fix tests

* fix tests
2026-01-25 13:59:44 +08:00
Arvin Xu 0f889952dd 🐛 fix: fix model edit icon missing (#11105)
* 🐛 fix: fix model edit icon missing

* fix stats welcome

* refactor pglite db case

* fix e2e tests

* update docs
2026-01-02 20:12:19 +08:00
Arvin Xu 563927b55c 👷 build: fix deps not correct set in packages (#11001)
fix deps
2025-12-26 22:38:16 +08:00
Rdmclin2 8c42a934b3 ✨ feat: mobile native better auth support (#10871)
* feat: mobile native better auth support

* chore: add android assetlinks

* chore: add android assetlinks

* chore: add expo fingerpoint

* chore: add relation

* chore: add android origin hash

* chore: update passkey table

* chore: optimize version

* chore: remove as any

* fix: sql not exits problem

* fix: passkey statement

* fix:  passkey origin null

* chore: remove strict peer dependencies

* fix: test case

* chore: remove local passkey origin
2025-12-23 15:19:42 +08:00
renovate[bot] 4c3ac3bce7 Update dependency dayjs to >=1.11.19 (#10241)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-11-16 11:33:22 +08:00
renovate[bot] ee80f613df Update dependency nanoid to >=5.1.6 (#10243)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-11-16 11:24:48 +08:00
Arvin Xu 035994f1a8 ♻️ refactor: refactor chat message model to speed up (#10053)
* refactor new chat message

* ♻️ refactor: Unify message creation methods into single `internal_createMessage`

## Changes

### Method Consolidation
- Merged `internal_createMessage` and `internal_createNewMessage` into a single unified method
- All message creation now returns `{ id: string, messages: UIChatMessage[] }`
- Eliminated redundant API calls by always using `createNewMessage` backend endpoint

### Updated Call Sites (11 locations)
**Store Actions:**
- `addAIMessage` & `addUserMessage` - Added result validation

**AI Chat:**
- `generateAIChat.ts` - Extract `result.id` from response
- `generateAIChatV2.ts` - Renamed from `internal_createNewMessage` to `internal_createMessage`

**Group Chat:**
- `generateAIGroupChat.ts` - Extract `result.id` in 3 locations

**Thread & Tools:**
- `thread/action.ts` - Extract `result.id`
- `builtinTool/actions/search.ts` - Extract `result.id`
- `plugin/action.ts` - Extract `result.id`

### Test Updates
- Updated mocks to return `{ id, messages }` structure
- `thread/action.test.ts` - 4 mock updates
- `plugin/action.test.ts` - 2 mock updates

## Benefits
- **Performance**: All message creation now uses single-request pattern
- **Consistency**: Unified return type across all creation flows
- **Maintainability**: Single method to maintain instead of two similar ones

## Testing
- ✅ Type check: 0 errors
- ✅ Unit tests: 175/175 passed
  - message/action.test.ts: 33/33
  - plugin/action.test.ts: 26/26
  - thread/action.test.ts: 39/39
  - generateAIChat.test.ts: 41/41
  - generateAIChatV2.test.ts: 36/36

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* ♻️ refactor: optimize message update operations to reduce API calls

Optimized two message update operations to reduce network requests:

1. **updatePluginState**: Modified to return updated messages
   - Backend: `MessageModel.updatePluginState` now accepts options and returns `UpdateMessageResult`
   - Router: Added `sessionId`, `topicId`, and `useGroup` parameters
   - Frontend: Service layer passes lab preferences, store uses `replaceMessages` instead of `refreshMessages`
   - Reduction: 2 requests → 1 request

2. **message.update**: Added `groupAssistantMessages` support
   - Service: `updateMessage` now passes `useGroup` flag based on lab preferences
   - Backend model already had infrastructure for returning messages
   - Reduction: Ensures consistent 1-request pattern

Tests passing (26/26 plugin tests, 14/14 integration tests).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* ♻️ refactor: optimize all internal message methods to reduce API calls

Optimized 6 internal message methods and 3 error handling scenarios to reduce API calls from 2 requests (update + refresh) to 1 request (update with messages returned):

**Internal methods optimized:**
- internal_updateMessagePluginError
- internal_updateMessageRAG
- internal_deleteMessage
- internal_refreshToUpdateMessageTools
- internal_updatePluginError

**Error handling optimized:**
- internal_callPluginApi error scenarios (2 locations)
- invokeStandaloneTypePlugin invalid settings

**Changes:**
- Backend: Updated message routers to accept sessionId/topicId/useGroup and return messages
- Service: Added getUseGroupPreference() getter to simplify lab preference checks
- Service: Updated methods to use getter and return UpdateMessageResult
- Store: Changed from refreshMessages() to replaceMessages(result.messages)
- Tests: Updated 4 plugin tests to verify replaceMessages instead of refreshMessages

**Performance impact:**
Each optimized method now makes 1 request instead of 2, reducing network overhead and improving UI responsiveness.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* ♻️ refactor: optimize message deletion to reduce API calls and fix group message children deletion

**Problem 1 - Group message children not deleted:**
- When deleting a `role: 'group'` message, children messages (linked via `parentId`) were not deleted
- Tool result messages were also not included in deletion

**Problem 2 - Delete operations using refresh pattern:**
- `deleteMessage`, `clearMessage`, `clearAllMessages` all used refreshMessages after deletion
- This resulted in 2 requests: delete + refresh

**Solutions:**

1. **Enhanced deleteMessage in UI layer:**
   - Added logic to find all children messages via `parentId` for group role messages
   - Combined with existing tool message deletion logic
   - All related message IDs are collected and passed to backend in one call
   - Business logic stays in UI layer, model layer remains simple

2. **Optimized delete operations:**
   - Backend: `removeMessages` now accepts sessionId/topicId/useGroup and returns messages
   - Service: `removeMessages` updated to pass options and return UpdateMessageResult
   - Store: `deleteMessage` now uses replaceMessages with returned data (2 requests → 1 request)
   - Store: `clearMessage` and `clearAllMessages` directly replace with empty array

3. **Updated tests:**
   - Fixed 4 tests to verify replaceMessages instead of refreshMessages
   - Added mock for service to return messages in delete operations
   - All 33 message action tests passing
   - All 14 integration tests passing

**Performance impact:**
- deleteMessage: 2 requests → 1 request
- clearMessage/clearAllMessages: 1 delete + 1 refresh → 1 delete + direct clear

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* ✅ test: add comprehensive tests for group message deletion with children

Added 2 new test cases to verify group message deletion behavior:

1. **Basic group message with children deletion:**
   - Verifies that deleting a `role: 'group'` message also deletes all children (via `parentId`)
   - Tests that unrelated messages are preserved

2. **Group message with children that have tool calls:**
   - Verifies that deleting a group message also deletes:
     - The group message itself
     - All children messages (via `parentId`)
     - Tool result messages from children (via `tool_call_id`)
   - Ensures complete cleanup of the entire message tree

**Implementation enhancement:**
- Updated `deleteMessage` to also collect and delete tool results from children messages
- Ensures no orphaned tool result messages remain after group deletion

**Test results:**
- All 35 message action tests passing (2 new tests added)
- Verifies complete cascading deletion of group message trees

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-11-05 02:15:40 +08:00
Arvin Xu 2d4d70a66d ♻️ refactor: remove dalle builtin plugin (#9952)
* pre merge

* fix lint

* fix lint

* clean docker workflow

* fix tests

* fix docker

* fix tests

* fix tests

* fix tests

* fix docker

* update client db

* remove dalle

* fix tests

* fix tests

* improve tests

* fix tests
2025-11-02 13:31:01 +08:00
Arvin Xu d99a3a80f8 🐛 fix: pass threadId to messages in sendMessageInServer (#9808)
* fix dev hydration

* 🐛 fix: pass threadId to messages in sendMessageInServer

- Add threadId parameter to CreateMessageParams interface
- Pass threadId when creating user and assistant messages in aiChat router
- Add comprehensive tests for threadId handling and outputJSON method

This ensures thread context is properly maintained across message creation.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* ✅ test: add comprehensive tests for addUserMessage

- Test early return when activeId is undefined
- Test message creation with files
- Test threadId propagation when activeThreadId is set
- Test input message clearing after message creation
- Test handling messages without fileList

This ensures the addUserMessage action correctly handles all scenarios including thread context.

🤖 Generated with [Claude Code](https://claude.com/claude-code)



* fix thread fix

* move

* baseline

* ✅ test: fix and improve message integration tests

- Mock FileService to avoid S3 initialization issues
- Mock getServerDB to use test database instance
- Add test for threadId parameter in message creation
- Fix pagination test to handle variable message counts
- Fix batchCreate test to skip rowCount assertion (undefined in PGlite)
- Skip topicId validation test (not currently enforced)

All 15 integration tests now passing.

🤖 Generated with [Claude Code](https://claude.com/claude-code)


* refactor

* improve
2025-10-21 12:54:52 +08:00
Arvin Xu 2518d7eabf 🐛 fix: fix input cannot send markdown (#9674)
* fix claude json output

* refactor to remove langchain in file-loaders

* support deepseek tools calling

* use peer

* use peer

* move files

* fix test

* add local-system placeholder

* fix markdown editing

* fix markdown editing

* refactor doc parse
2025-10-12 16:11:02 +08:00
Arvin Xu af274190a8 🔨 chore: add group-messages database schema (#9543)
* add group messages

* update

* add migrations

* ♻️ refactor: refactor message group

* fix

* fix

* update schema
2025-10-05 23:49:27 +08:00
YuTengjing 1762dc9148 ♻️ chore: refactor router runtime (#9306) 2025-09-17 23:30:04 +08:00
Arvin Xu 2c677e597a 🐛 fix: fix open chat page with float link modal (#9235)
* refactor @lobechat/database

* move config/file and llm to envs

* move config/auth to envs

* refactor

* fix tests

* fix tests

* upgrade
2025-09-13 17:03:10 +08:00
Arvin Xu cf0272cc1b 🔨 chore: upgrade deps (#9228)
upgrade deps
2025-09-12 16:04:05 +08:00
YuTengjing 0efe28d122 ✨ feat(image): polish ai image (#8915) 2025-08-25 22:38:41 +08:00
Arvin Xu 8dedc2d3e1 ♻️ refactor: move utils to separate package (#8889)
* move utils

* move utils

* move utils

* update

* update

* update

* update

* update

* refactor to clean the tests

* fix release workflow

* fix tests

* fix tests

* fix tests

* fix tests

* fix tests

* fix tests

* try to fix client db migration issue

* fix tests
2025-08-22 14:05:01 +08:00
Arvin Xu af1f71572f ♻️ refactor: move database to packages (#8874)
* move db

* refactor db import

* refactor eval types

* fix tests

* fix tests

* fix tests

* fix db migration issues

* fix docker issue

* fix tests

* update alias

* fix tests

* update db test for client and server

* refactor db

* update codecov

* update codecov

* update codecov

* add docker pr comments
2025-08-22 11:09:03 +08:00