Skip to content

Move uploaded files from workspace to DATA_DIR for consistency with history/memory #145

@dcellison

Description

@dcellison

Summary

_save_to_workspace() in bot.py saves user-uploaded files to workspace/files/ (the inner Claude working directory). Meanwhile, _apply_directories() in install.py creates an empty /var/lib/kai/files/ that nothing uses.

This is the same category of issue PR #144 fixed for history and MEMORY.md: runtime data living inside the install tree instead of DATA_DIR.

Current state

  • Where files are saved: pool.get_workspace(chat_id) / "files/" (resolves to /opt/kai/workspace/files/ in production)
  • Where _apply_directories creates a directory: DATA_DIR / "files" (resolves to /var/lib/kai/files/)
  • Result: /var/lib/kai/files/ exists but is always empty. Uploaded files live in the install tree.

Why it matters

Proposed fix

Follow the PR #144 pattern:

  1. Move file storage from workspace/files/ to DATA_DIR / "files" (which already exists)
  2. Update _save_to_workspace() to save to DATA_DIR / "files" instead of workspace / "files"
  3. Inject the absolute files path into context so the inner Claude knows where to find them
  4. Add a migration in _apply_migrate for any existing files at the old location
  5. Add "files" to .gitignore for the dev layout (if not already covered)

Priority

Low. The merge-based _copy_tree prevents data loss. This is a cleanup for architectural consistency with the history/memory fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions