mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #6164] [MERGED] Improve CJK token estimation and prompt token count display #7072
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#7072
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/6164
Author: @minikkeuen
Created: 9/13/2026
Status: ✅ Merged
Merged: 9/13/2026
Merged by: @SpicyMarinara
Base:
staging← Head:feature/cjk-token-estimation📝 Commits (8)
d97ed9dImprove lightweight token estimates for CJK text853e2c1Unify token counts for prompt and context inputs58ed50dPreserve aggregate token estimate roundingf16394fDocument token estimation and counter improvements5ef9bc7Merge branch 'staging' into feature/cjk-token-estimation81a582cfix(tokens): honor CJK budgets and harden prompt countersf1ea1actest(ui): provide valid locale metadata for token countersfdcf10efix(ui): refresh saved translations and loading token counts📊 Changes
49 files changed (+974 additions, -349 deletions)
View changed files
📝
CHANGELOG.md(+5 -0)📝
e2e/chat-sweep.e2e.ts(+13 -0)📝
e2e/core-flows.e2e.ts(+137 -3)📝
package.json(+2 -1)📝
packages/client/src/components/agents/AgentEditor.tsx(+20 -7)📝
packages/client/src/components/characters/CardLibraryPreview.tsx(+1 -1)📝
packages/client/src/components/characters/CharacterEditor.tsx(+37 -34)📝
packages/client/src/components/characters/CharacterLibraryView.tsx(+4 -4)📝
packages/client/src/components/chat/AgentSuiteModal.tsx(+7 -3)📝
packages/client/src/components/chat/ChatArea.tsx(+2 -5)📝
packages/client/src/components/chat/ChatRoleplayPanels.tsx(+22 -17)📝
packages/client/src/components/chat/ChatSettingsDrawer.tsx(+3 -3)📝
packages/client/src/components/chat/MariChatHistoryPicker.tsx(+3 -3)📝
packages/client/src/components/chat/PeekPromptModal.tsx(+2 -2)📝
packages/client/src/components/chat/SummariesEditorModal.tsx(+8 -2)📝
packages/client/src/components/chat/SummaryPopover.tsx(+2 -1)📝
packages/client/src/components/lorebooks/LorebookFormFields.tsx(+2 -1)📝
packages/client/src/components/panels/CharactersPanel.tsx(+2 -2)📝
packages/client/src/components/panels/PersonasPanel.tsx(+2 -2)📝
packages/client/src/components/panels/settings/PromptOverridesEditor.tsx(+3 -1)...and 29 more files
📄 Description
Linked issue
Closes #6161
Why this change
What changed
Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)UI evidence (if applicable)
Before
No token count was displayed for this prompt field.
After
The prompt field now displays an estimated token count.
Summary by CodeRabbit
New Features
Bug Fixes
Maintainer review fixes
The contributor's implementation and commits are preserved. The follow-up fixes malformed saved preset markers through the existing safe parser and uses the existing localized token label across counter callers. A shared Unicode-safe token-budget cutter keeps CJK recall, provider trimming, retrieval chunks, Game transcripts, and Advanced Memory preparation within the new estimates; short lorebook previews stop at their budget instead of scanning the full entry.
The counter also clears stale values while a prompt loads. Full CI exposed a delayed translation-save race when returning to a chat; message-cache updates now refresh saved translations, with a deterministic held-response browser regression. Two unrelated browser assertions now wait for smooth scrolling or measure both rectangles in one animation frame, preserving their original focus and non-overlap requirements.
The estimator and counter regressions, plus the new CJK budget regression, now receive TypeScript checking during
pnpm check. The lorebook fixture uses real schema defaults instead of an unchecked partial entry. No new dependency or storage migration is introduced.Maintainer automated validation:
pnpm check,pnpm regression:prompt, andpnpm version:checkpassed.pnpm checkpassed. The delayed-translation, editor-navigation, and category-header checks passed 9/9 across desktop Chromium, mobile Chromium, and mobile WebKit; final E2E type checking and formatting passed.fdcf10e57; all review threads are resolved.Original contributor checkboxes and manual verification notes above are unchanged. Physical-device and model-specific tokenizer calibration were not performed by this maintainer follow-up; these remain intentionally approximate token estimates.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.