Skip to content

Fix: local lorebook update - #1042

Open
Nam-SW wants to merge 1 commit into
kwaroran:mainfrom
Nam-SW:fix/local-lorebook-update
Open

Nam-SW wants to merge 1 commit into
kwaroran:mainfrom
Nam-SW:fix/local-lorebook-update

Conversation

@Nam-SW

@Nam-SW Nam-SW commented Sep 11, 2025 •

Copy link
Copy Markdown

PR Checklist

  • Have you checked if it works normally in all models? Ignore this if it doesn't use models.
  • Have you checked if it works normally in all web, local, and node hosted versions? If it doesn't, have you blocked it in those versions?
  • Have you added type definitions?

Description

Fixes the issue where upsertLocalLoreBook function doesn't persist changes when called from onStart, onInput and onOutput events.

Changes Made

  • Modified upsertLocalLoreBook in scriptings.ts to use ScriptingEngineState.chat instead of char.chats[char.chatPage]
  • This ensures consistent behavior across all event types

Cause

The function was modifying a different chat object reference than the one being returned by the scripting engine, causing changes to be lost in onStart/onOutput contexts.

Testing

  • ✅ Verified upsertLocalLoreBook now works in onStart events
  • ✅ Verified upsertLocalLoreBook now works in onOutput events
  • ✅ Confirmed existing onButtonClick functionality remains intact
  • ✅ No breaking changes to other API functions
  • The only environment tested was Docker.

Files Changed

  • src/ts/process/scriptings.ts

Fixes #1041


(KR) 설명

onStart와 onInput, onOutput 이벤트에서 upsertLocalLoreBook 함수가 변경사항을 저장하지 않는 문제를 수정했습니다.

변경사항

  • scriptings.ts의 upsertLocalLoreBook을 char.chats[char.chatPage] 대신 ScriptingEngineState.chat을 사용하도록 수정
  • 모든 이벤트 타입에서 일관된 동작을 보장

원인

함수가 스크립팅 엔진에서 반환하는 채팅 객체와 다른 채팅 객체 참조를 수정하고 있어서, onStart/onOutput 컨텍스트에서 변경사항이 손실되었음.

테스트

  • ✅ upsertLocalLoreBook이 이제 onStart 이벤트에서 정상 작동하는 것을 확인
  • ✅ upsertLocalLoreBook이 이제 onOutput 이벤트에서 정상 작동하는 것을 확인
  • ✅ 기존 onButtonClick 기능이 그대로 유지되는 것을 확인
  • ✅ 다른 API 함수들에 대한 호환성 문제 없음
  • 노드리스 - 도커 환경에서만 테스트함

변경된 파일

  • src/ts/process/scriptings.ts

Fixes #1041

@Nam-SW
Nam-SW changed the base branch from dev to main September 17, 2025 11:45
@kwaroran

Copy link
Copy Markdown
Owner

Hold due to #998

@cubicj cubicj left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I traced why onButtonClick persisted while onStart and onOutput didn't. In the trigger path the engine works on a cloned chat, and that clone is what gets saved back afterwards, while the old code wrote to a separate clone of char that nothing reads again. So ScriptingEngineState.chat is the object that actually gets saved, and the #1041 cases hold up. pnpm check, pnpm test, and pnpm build pass locally with this applied on the current main.

The description also lists onInput, but that path saves only message from the returned chat, so an upsert from onInput is still lost. Could you check that case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] upsertLocalLoreBook not working in onStart and onOutput events

4 participants