Skip to content

Conversation

@Disviel
Copy link
Contributor

@Disviel Disviel commented Jan 19, 2026

Close #139
Close #146
Close #148

This pull request introduces several improvements and refactorings across the EMA UI and core packages. The most significant changes include a refactor of the chat input schema, enhancements to the chat UI's scrolling behavior and accessibility, updates to the system prompt for more immersive character roleplay, and improvements to the event streaming and LLM client interfaces.

API and Schema Refactoring:

  • Refactored the chat input schema to use a more generic Content type with type and text fields, replacing the previous ActorInput structure with kind and content. This change affects the API contract and related documentation and example usage. [1] [2] [3] [4]

Chat UI/UX Improvements:

  • Enhanced the chat area with custom scrollbar styling and added auto-scroll-to-bottom functionality, which respects user scroll position and only auto-scrolls when appropriate. This includes new refs and logic in the chat component and new CSS rules for scrollbars and message end tracking. [1] [2] F4ca933dL4R1, [3] F4ca933dL120R120, [4]
  • Removed the loading state from the chat UI, simplifying the message submission and button disabling logic. [1] [2] [3] [4]

System Prompt and Character Roleplay:

  • Completely rewrote the system prompt to emphasize immersive, in-character roleplay, strict persona boundaries, and nuanced memory handling. The new prompt enforces never breaking character, prohibits meta/system talk, and provides detailed behavioral rules and memory segmentation.

Event Streaming and Typing:

  • Updated the actor SSE API and chat event handling to use the new ActorAgentEvent type instead of the previous ActorResponse/ActorEvent, and filtered for emaReplyReceived events only. [1] [2] F4ca933dL4R1)

Core Library and Miscellaneous:

  • Extended short-term memory entity kinds to include "week" granularity.
  • Added support for abort signals in LLM client interfaces for better request management and cancellation. [1] [2] [3]
  • Added dayjs as a dependency for date handling.
  • Removed the unused _run_actor.ts script, cleaning up the codebase.
  • Updated exports in the core package to re-export all actor types.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements chat interruption functionality and performs substantial refactoring of the agent and actor architecture. The main goal is to allow users to interrupt ongoing agent responses with new messages, enabling more natural conversational flow.

Changes:

  • Adds abort mechanism to Agent class using AbortController and AbortSignal to stop LLM calls mid-execution
  • Refactors Actor to use a queue-based processing model with state resumption after interruption
  • Introduces BufferMessage class for managing conversational history with timestamps and context metadata
  • Adds dayjs library for time formatting in memory buffer
  • Updates UI to allow message submission while agent is running (removes loading state from input controls)

Reviewed changes

Copilot reviewed 19 out of 20 changed files in this pull request and generated 19 comments.

Show a summary per file
File Description
pnpm-lock.yaml Adds dayjs@1.11.19 dependency and updates eslint resolver references
packages/ema/package.json Adds dayjs dependency
packages/ema/src/schema.ts Adds EmaMessage type to Message union for distinguishing EMA-originated messages
packages/ema/src/memory/memory.ts Adds BufferMessage class for managing timestamped conversation history and updates ActorState interface
packages/ema/src/db/base.ts Adds "week" granularity option to ShortTermMemoryEntity
packages/ema/src/agent.ts Major refactoring: removes token management/summarization logic, adds abort support, introduces AgentState and callback-based run model
packages/ema/src/actor.ts Implements queue-based processing with interruption support, adds buildSystemPrompt, and manages buffer writes
packages/ema/src/llm/base.ts Adds signal parameter to support abort operations
packages/ema/src/llm/client.ts Passes signal parameter through to underlying client
packages/ema/src/llm/openai_client.ts Implements abort signal support for OpenAI API calls
packages/ema/src/llm/google_client.ts Implements abort signal support for Google Gemini API calls
packages/ema/src/retry.ts Adds abort error detection to prevent retrying aborted requests
packages/ema/src/server.ts Passes userId to ActorWorker constructor
packages/ema/src/tools/ema_reply_tool.ts Removes pretty-printing from JSON output (removes null, 2 formatting)
packages/ema/src/tests/skills/memory.spec.ts Updates test to pass userId parameter to ActorWorker
packages/ema/config/system_prompt.md Complete rewrite with detailed role-playing instructions and memory buffer integration
packages/ema-ui/src/app/chat/page.tsx Removes loading state from input controls and adds auto-scroll to latest message
packages/ema-ui/src/app/chat/page.module.css Adds custom scrollbar styling and messagesEnd anchor
packages/ema-ui/src/app/api/actor/input/route.ts Updates API schema from ActorInput to Content type
packages/ema/src/_run_actor.ts Deleted - removes standalone actor runner script
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 19 out of 20 changed files in this pull request and generated 16 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (1)

packages/ema/src/retry.ts:139

  • The isAbortError function checks for the error message containing "aborted" using includes(), which might be too broad and could match unrelated errors. Consider making this check more specific to avoid false positives. For example, an error message like "The data was abbreviated" could incorrectly match this condition.
      }
      if (lastException) {
        throw lastException;
      }
      throw new Error("Unknown error");
    };
    return descriptor;

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 19 out of 20 changed files in this pull request and generated 16 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

@Disviel Disviel marked this pull request as ready for review January 20, 2026 07:39
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 23 out of 24 changed files in this pull request and generated 4 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 25 out of 26 changed files in this pull request and generated 9 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 26 out of 27 changed files in this pull request and generated 16 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

@Disviel Disviel merged commit 2432dac into EmaFanClub:main Jan 21, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants