Skip to content

fix: database config not read from config.yaml, Handlebars dynamic import breaks subsession spawn #648

@mattwwarren

Description

@mattwwarren

Problem

1. Database config.yaml settings ignored

getDatabaseUrl() and getDatabaseDialect() in @agor/core/db only read from environment variables (AGOR_DB_DIALECT, DATABASE_URL, AGOR_DB_PATH). The database section in ~/.agor/config.yaml is completely ignored, even though AgorDatabaseSettings types are fully defined.

This means users who configure postgres via config.yaml still get SQLite, leading to confusing SQLITE_BUSY errors.

2. Handlebars dynamic import breaks in bundled UI

SessionPanel.tsx uses await import('handlebars') which returns a module namespace object in ESM/Vite, not the Handlebars object. This causes TypeError: Me.registerHelper is not a function when spawning subsessions.

Fix

Database config

  • Wire getDatabaseDialect() to read database.dialect from config.yaml (after env vars)
  • Wire getDatabaseUrl() to read database.postgresql.url / database.sqlite.path from config.yaml
  • Support building PostgreSQL URL from individual host/port/user/password/database fields
  • Env vars still take priority over config.yaml

Handlebars

  • Replace dynamic await import('handlebars') with static import Handlebars from 'handlebars'
  • Pre-compile template at module load, matching ForkSpawnModal pattern

Config.yaml example

database:
  dialect: postgresql
  postgresql:
    url: postgresql://agor:agor@localhost:55432/agor

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions