Skip to content

Make buffer size limits configurable via environment variables #48

@tenfourty

Description

@tenfourty

Feature Request

The buffer size limits in src/config/buffer-limits.ts are hardcoded constants. It would be great if these could be overridden via environment variables for users who want to tune memory usage for their specific setup.

Current behavior

Buffer limits are fixed at compile time:

  • MAX_TERMINAL_BUFFER_SIZE = 2MB
  • TRIM_TERMINAL_TO = 1.5MB
  • MAX_TEXT_OUTPUT_SIZE = 1MB
  • TRIM_TEXT_TO = 768KB
  • MAX_MESSAGES = 1000

Proposed behavior

Allow overriding via environment variables, falling back to the current defaults:

export const MAX_TERMINAL_BUFFER_SIZE = parseInt(process.env.CODEMAN_MAX_TERMINAL_BUFFER || '') || 2 * 1024 * 1024;
export const TRIM_TERMINAL_TO = parseInt(process.env.CODEMAN_TRIM_TERMINAL_TO || '') || 1.5 * 1024 * 1024;
export const MAX_TEXT_OUTPUT_SIZE = parseInt(process.env.CODEMAN_MAX_TEXT_OUTPUT || '') || 1 * 1024 * 1024;
export const TRIM_TEXT_TO = parseInt(process.env.CODEMAN_TRIM_TEXT_TO || '') || 768 * 1024;
export const MAX_MESSAGES = parseInt(process.env.CODEMAN_MAX_MESSAGES || '') || 1000;

Use case

Running Codeman as a single-user server (e.g., behind a reverse proxy with SSO) where memory headroom is plentiful but scrollback feels limited. Being able to set CODEMAN_MAX_TERMINAL_BUFFER=8388608 in the systemd unit would be much cleaner than patching the source.

The existing memory budget rationale (80MB for 20 sessions) is sensible as a default, but users with fewer sessions or more RAM should be able to opt into larger buffers without modifying source.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions