Files
synapbus/specs/009-attachments-threads/plan.md
T
Algis DumbrisandClaude Opus 4.6 667b7a4c2e feat: file attachments and thread visibility (009-attachments-threads)
Web UI: paperclip button for file upload (images, PDFs, text), inline
attachment cards with file icon/name/size, image thumbnails with
fullscreen overlay, attachment display in thread panel.

Threads: always-visible reply count badges on messages, clickable to
open thread panel. reply_count and attachments enriched in all API
responses via batch queries.

MCP: attachments parameter on send_message tool, updated tool
descriptions for threading and attachment workflow guidance.

Backend: file type validation (allowlist), AttachmentLinker interface
to avoid circular deps, GetReplyCounts batch query, EnrichMessages
method on MessagingService.

Admin CLI: synapbus attachments backup/restore with tar.gz archives,
dedup-safe restore.

24 new test cases across 4 packages. All 24 test packages pass.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-17 16:36:21 +02:00

5.2 KiB

Implementation Plan: Attachments & Threads Enhancement

Branch: 009-attachments-threads | Date: 2026-03-17 | Spec: spec.md Input: Feature specification from /specs/009-attachments-threads/spec.md

Summary

Enhance SynapBus with web UI file attachment support (upload, thumbnail preview, fullscreen view, download), fix thread visibility (reply count badges, thread indicators), update MCP tools for agent attachment/thread workflows, and add admin CLI backup/restore for attachment files. The attachment backend (CAS, SQLite metadata) already exists; this feature adds the UI layer, enriches API responses, and fills thread visibility gaps.

Technical Context

Language/Version: Go 1.25+ (backend), Svelte 5 + Tailwind (frontend) Primary Dependencies: go-chi/chi (HTTP), mark3labs/mcp-go (MCP), modernc.org/sqlite (storage), spf13/cobra (CLI) Storage: SQLite (modernc.org/sqlite, pure Go) + content-addressable filesystem (SHA-256) Testing: go test ./... (backend), manual + curl (API), Chrome (UI) Target Platform: linux/amd64, darwin/arm64 (cross-compiled single binary) Project Type: Web service with embedded SPA Performance Goals: File uploads complete in <10s for files under 10MB; thumbnails render in <1s Constraints: Zero CGO, single binary, single --data directory Scale/Scope: LAN-scale (tens of agents, hundreds of messages/day)

Constitution Check

GATE: Must pass before Phase 0 research. Re-check after Phase 1 design.

Principle Status Notes
I. Local-First, Single Binary PASS All changes are within the single binary. No external dependencies added.
II. MCP-Native PASS Agent attachment/thread workflows use MCP tools. REST API changes are for Web UI only.
III. Pure Go, Zero CGO PASS No new CGO dependencies. Image thumbnails are CSS-only (client-side). Backup uses stdlib archive/tar + compress/gzip.
IV. Multi-Tenant with Ownership PASS Attachments track uploaded_by. Message ownership unchanged.
V. Embedded OAuth 2.1 N/A No auth changes.
VI. Semantic-Ready Storage N/A No search changes.
VII. Swarm Intelligence N/A No swarm pattern changes.
VIII. Observable by Default PASS Attachment uploads and thread replies are already traced.
IX. Progressive Complexity PASS Attachments are tier 3 (advanced). Thread fixes improve existing basic messaging.
X. Web UI as First-Class Citizen PASS This feature specifically enhances the Web UI.

Post-design re-check: All principles still satisfied. No violations.

Project Structure

Documentation (this feature)

specs/009-attachments-threads/
├── plan.md              # This file
├── spec.md              # Feature specification
├── research.md          # Research decisions
├── data-model.md        # Data model changes
├── quickstart.md        # Testing quickstart
├── contracts/           # API contract changes
│   └── rest-api.md
├── checklists/
│   └── requirements.md
└── tasks.md             # Task breakdown (generated by /speckit.tasks)

Source Code (repository root)

# Backend (Go)
internal/
├── attachments/
│   └── service.go           # Add file type validation
├── messaging/
│   ├── store.go             # Add reply_count to queries, attachment loading
│   ├── service.go           # Add attachment linking on send
│   └── types.go             # Add ReplyCount, Attachments fields to Message
├── api/
│   ├── messages_handler.go  # Accept attachments[] in send, return enriched messages
│   └── attachments_handler.go # (existing, minimal changes)
└── mcp/
    ├── tools_hybrid.go      # Add attachments param, update descriptions
    └── bridge.go            # Handle attachments in send flow

cmd/synapbus/
└── admin.go                 # Add backup/restore subcommands

# Frontend (Svelte)
web/src/lib/
├── components/
│   ├── ComposeForm.svelte   # Add attachment upload button + preview
│   ├── MessageList.svelte   # Add thread indicator badges
│   ├── MessageBody.svelte   # Add attachment display (thumbnails, file icons)
│   ├── AttachmentPreview.svelte  # NEW: thumbnail + fullscreen component
│   └── ThreadPanel.svelte   # Existing, minor fixes
├── stores/
│   └── thread.ts            # Existing, no changes
└── api/
    └── client.ts            # Add attachment upload method

# Tests
internal/attachments/service_test.go     # File type validation tests
internal/messaging/store_test.go         # Reply count query tests
internal/messaging/service_test.go       # Attachment linking tests
internal/api/messages_handler_test.go    # API enrichment tests
internal/mcp/tools_hybrid_test.go        # MCP attachment param tests
cmd/synapbus/admin_test.go               # Backup/restore tests

Structure Decision: Existing Go + Svelte project structure. No new packages needed — all changes extend existing packages. One new Svelte component (AttachmentPreview.svelte) for image thumbnail/fullscreen display.

Complexity Tracking

No constitution violations. No complexity justifications needed.