Skip to content

feat(local-chat): add local conversation with file attachment support#1149

Open
coder-zkl1988 wants to merge 2 commits intonexu-io:mainfrom
coder-zkl1988:feat/local-chat
Open

feat(local-chat): add local conversation with file attachment support#1149
coder-zkl1988 wants to merge 2 commits intonexu-io:mainfrom
coder-zkl1988:feat/local-chat

Conversation

@coder-zkl1988
Copy link
Copy Markdown

What

Add local conversation (local-chat) feature: auto-creates a local AI bot on first launch, supports file attachments (images + PDFs with text extraction), and improves session management UX.

Why

Users need a local AI chat experience without requiring external service setup. File attachment support (especially PDF text extraction) enables document-based conversations. Fixes session loading spinner and heartbeat session noise.

How

  • Auto-create local bot: New local-bot type in bot schema; controller creates it on first startup if no local bot exists
  • File attachment pipeline: New attachment-extractor service (pdf-parse for PDFs, native preview for images); attachment-store manages local file persistence
  • Chat routes & service: chat-routes.ts + chat-service.ts handle session CRUD and message streaming
  • Session UX fixes: Filter heartbeat sessions in list; replace alert() with toast; fix spinner timing

Affected areas

  • Desktop app (Electron shell)
  • Controller (backend / API)
  • Web dashboard (React UI)
  • OpenClaw runtime
  • Skills
  • Shared schemas / packages
  • Build / CI / Tooling

Checklist

  • pnpm typecheck passes
  • pnpm lint passes
  • pnpm test passes
  • pnpm generate-types run (API routes/schemas changed)
  • No credentials or tokens in code or logs
  • No any types introduced (use unknown with narrowing)

Screenshots / recordings

Notes for reviewers

  • apps/web/src/pages/local-chat.tsx is the primary UI page (~1550 lines)
  • apps/controller/src/services/attachment-extractor.ts uses pdf-parse for PDF text extraction
  • packages/shared/src/schemas/device-control.ts may be removed if device-control feature is deferred

- Auto-create local bot on first launch
- File attachment support (images, PDFs with text extraction)
- Session management with heartbeat filtering
- Spinner UX fix for session loading

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@lefarcen lefarcen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @zongkelong! πŸŽ‰ Wow, what an impressive PR for adding local conversation with file attachment supportβ€”thank you for this thoughtful contribution! πŸ™Œ The attachment pipeline (PDF extraction + image forwarding), auto-bot creation, and session UX fixes look solid overall.

A few quick thoughts:

  • Great use of OpenClaw's trusted agents/*/attachments/ root for persisted filesβ€”matches media tool policies perfectly.
  • Preview extraction (first 3 PDF pages) + pdf tool hint is smart context management.
  • Comprehensive session filtering (subagents/heartbeats/orphans) cleans up the list nicely.

This looks promising. We'll review promptly (target: 24h). Questions or updates? Push here!

Join communities:

Thanks for making Nexu better!
Nexu Team

@coder-zkl1988
Copy link
Copy Markdown
Author

image

@lefarcen
Copy link
Copy Markdown
Collaborator

Hey @zongkelong πŸ‘‹ Thanks for the screenshot! Looking great. πŸŽ‰

The local chat implementation looks solid:

βœ… Attachment handling: Smart split β€” images forward through OpenClaw's native attachment pipeline, PDFs/text extract server-side into <file path=\\"…\\">preview</file> blocks so the model can pdf(path) for deeper analysis without bloating main context.

βœ… Session UX: Filtering heartbeats/subagents/orphans keeps the list clean; getFullMainChatHistory spans compactions transparently.

βœ… API design: /chat/local + /chat/history endpoints are clean; controller handles the OpenClaw session.json indirection.

A few thoughts to polish:

  • Consider adding pdf-parse error boundaries (empty pages, corrupt PDFs) with a fallback [PDF: scanned/corrupt] marker.
  • History endpoint could include sessionCount metadata for the UI ("this conversation spans 3 compactions").

Ready for team review! πŸš€ Questions? Push more here.

Join communities:

Thanks! πŸ™Œ
Nexu Team

Replaces the raw OpenClaw error ("Agent failed before reply:
No API key found for provider…") with a friendly yellow warning card
that explains the issue in plain language and links directly to
/workspace/settings?tab=providers for easy configuration.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@lefarcen
Copy link
Copy Markdown
Collaborator

Hey @zongkelong! πŸ‘‹ Thanks for the push! πŸŽ‰

Great iteration β€” local chat looks production-ready:

βœ… Attachment pipeline: Images forward via OpenClaw attachments, PDFs/text extract cleanly to <file path="agents/.../attachments/...">preview</file> blocks + pdf(path) tool hint. Preview mode (first 3 pages) keeps main context lean.

βœ… Session UX: Orphaned/heartbeat/subagent filtering keeps the list clean; getFullMainChatHistory spans compactions transparently with sessionCount metadata.

βœ… API surface: /chat/local, /chat/session, /chat/history endpoints are crisp; OpenAPI docs generated.

Prior suggestions addressed:

  • pdf-parse error boundaries β†’ logged + fallback [PDF: scanned/corrupt]
  • History metadata β†’ sessionCount in response

Nit (P3):

  • attachment-store.ts: sanitizeFilename collapses whitespace β†’ multi word file name.pdf β†’ multi_word_file_name.pdf. Consider path.basename + path.sep stripping only.

We'll merge soon! πŸš€ Questions? Push here.

Join communities:

Thanks! πŸ™Œ
Nexu Team

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants