Skip to content

feat: Active Knowledge Collection — structured AI-guided data gathering#1

Draft
jakobengdahl wants to merge 4 commits into
stockholmsprintfrom
claude/active-knowledge-collection-aeiq5c
Draft

feat: Active Knowledge Collection — structured AI-guided data gathering#1
jakobengdahl wants to merge 4 commits into
stockholmsprintfrom
claude/active-knowledge-collection-aeiq5c

Conversation

@jakobengdahl

Copy link
Copy Markdown

Summary

Introduces the Active Knowledge Collection feature: a mechanism for setting up structured, AI-guided data collection sessions that reuse the graph's full CRUD capabilities through a custom AI prompt and a dedicated kiosk UI.

What's new

  • ActiveKnowledgeCollection node type — new system node (amber #F59E0B, FunnelFill icon) stored in the schema alongside Agent and EventSubscription. Key metadata fields:

    • short_name — unique URL slug (e.g. q1-partner-feedback)
    • introduction_text — shown to the user before the chat starts
    • prompt — custom system prompt injected into the AI assistant
    • node_type_permissions — per-type create/update/delete flags
  • Create/Edit dialog (CreateActiveKnowledgeCollectionDialog) — 4-section form:

    1. Basic info (name, auto-slugged short name, description)
    2. Collection configuration (intro text, AI prompt with placeholder guidance)
    3. Node-type permissions table (checkboxes per type × operation)
    4. Two copyable shareable URLs with contextual notes
  • Kiosk UI (CollectKioskView) — full-screen AI chat at /collect/<shortName>:

    • No graph, no toolbar — focused data-collection experience
    • Loading → intro overlay (shows introduction_text) → chat
    • AI receives prompt + formatted permissions as system prefix
    • Amber dark theme matching the node type colour
  • ?akc=<shortName> full-app mode — regular graph UI with:

    • Intro dialog overlay showing the collection's introduction text
    • ChatPanel pre-loaded with the collection's AI prompt as systemPromptPrefix
  • Backend:

    • GET /api/collect/{short_name} — looks up AKC config by slug
    • GET /collect/{short_name} — server-side redirect to /web/?collect=…
    • system_prompt_prefix field added to the chat API (ChatRequestChatServiceChatProcessor), prepended to the base system prompt for every LLM call including tool-use follow-ups

Test plan

  • Create an ActiveKnowledgeCollection node via the toolbar or canvas drop — dialog opens with all 4 sections
  • Short name auto-generates from the name; URLs update live
  • Copy-to-clipboard works for both kiosk and full-app URLs
  • Visit /collect/<shortName> → spinner → intro overlay → chat; AI uses the custom prompt
  • Visit /web/?akc=<shortName> → intro dialog → graph + ChatPanel uses the custom prompt
  • Visit /web/?collect=<shortName> → server redirects to kiosk view
  • Double-click an ActiveKnowledgeCollection node → edit dialog opens with pre-filled data
  • Node-type permissions table is populated from the loaded schema

🤖 Generated with Claude Code

https://claude.ai/code/session_014Xo4bjR6ro2p6umTF4eyyQ


Generated by Claude Code

@jakobengdahl jakobengdahl force-pushed the claude/active-knowledge-collection-aeiq5c branch from 874ae5c to 4834778 Compare June 18, 2026 07:45
@jakobengdahl jakobengdahl changed the base branch from main to stockholmsprint June 18, 2026 07:45
claude added 4 commits June 18, 2026 07:58
- Add ActiveKnowledgeCollection system node type to schema (amber #F59E0B, FunnelFill icon)
- Add system_prompt_prefix support to chat API (ChatRequest, ChatService, ChatProcessor)
- Pass effective_system_prompt through tool_use chain in ChatProcessor
- Add FunnelFill icon to FloatingToolbar registry and AKC special handling
- Add getCollectConfig() and sendCollectChatMessage() to api.js client
- Update sendChatMessage() to support systemPromptPrefix option

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014Xo4bjR6ro2p6umTF4eyyQ
- Add GET /collect/{short_name} redirect to /web/?collect={short_name}
- Add GET /api/collect/{short_name} endpoint to look up AKC config by short_name
- Search graph for ActiveKnowledgeCollection nodes and match by metadata.short_name

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014Xo4bjR6ro2p6umTF4eyyQ
- App.jsx: add AKC handlers (create, save, edit), kiosk routing via
  AppRoot, AKC intro overlay for ?akc= mode, systemPromptPrefix prop
  passed to ChatPanel when AKC config is active
- ChatPanel.jsx: accept systemPromptPrefix prop and thread it through
  all four sendChatMessage calls to support ?akc= collection mode
- FloatingToolbar.jsx: register FunnelFill icon and AKC node type
- CreateActiveKnowledgeCollectionDialog.jsx: new dialog with basic info,
  intro text, AI prompt, per-type permissions table, and copyable URLs
- CollectKioskView.jsx: full-screen kiosk chat UI for /collect/ route
- CollectKioskView.css: dark-themed styles for the kiosk view
- backend/chat_logic.py: system_prompt_prefix support in process_message

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014Xo4bjR6ro2p6umTF4eyyQ
Security (blockers):
- Validate short_name path param with regex [a-z0-9-] + URL-encode in
  redirect to prevent path-traversal and query-string injection
- Move AI prompt resolution server-side: chat endpoint now accepts
  collection_short_name; server looks up the AKC node and builds the
  system prompt prefix — prompt never leaves the server
- Add max_length=8000 to system_prompt_prefix as defence-in-depth
- Remove prompt field from GET /api/collect/{short_name} response
- Raise AKC node scan limit from 200 to 500 to avoid silent truncation

Feature correctness:
- ?akc= full-app mode now passes collection_short_name to ChatPanel
  (previously only passed the raw prompt, silently dropping permissions)
- CollectKioskView uses collectionShortName option to sendChatMessage
  instead of building and transmitting the full prompt text client-side

React/code quality:
- Wrap CollectKioskView.handleSend in useCallback; capture conversation
  history synchronously before state updates to fix stale-closure bug
- Replace deprecated onKeyPress with onKeyDown in CollectKioskView
- Use crypto.randomUUID() message keys instead of array index
- Move EXCLUDED_TYPES constant to module scope in CreateAKCDialog
- Remove dead sendCollectChatMessage duplicate from api.js

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014Xo4bjR6ro2p6umTF4eyyQ
@jakobengdahl jakobengdahl force-pushed the claude/active-knowledge-collection-aeiq5c branch from 4834778 to c0d261c Compare June 18, 2026 08:00
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