Skip to content

Fix dialogue extraction and reconstruction for menu titles#186

Merged
mikkisguy merged 2 commits into
mainfrom
some-fixes-yes
Jun 6, 2026
Merged

Fix dialogue extraction and reconstruction for menu titles#186
mikkisguy merged 2 commits into
mainfrom
some-fixes-yes

Conversation

@mikkisguy

@mikkisguy mikkisguy commented Jun 6, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • Bug Fixes

    • Menu titles are now correctly handled as editable dialogue entries.
    • Prevented duplicate menu titles and duplicate jump/call/return lines during file reconstruction.
    • Improved detection of menu block boundaries for accurate choice parsing.
  • Tests

    • Added tests for menu title extraction and reconstruction idempotency to prevent regressions.

@coderabbitai

coderabbitai Bot commented Jun 6, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a42344e4-43c3-4f60-889d-375ccaaf8b6a

📥 Commits

Reviewing files that changed from the base of the PR and between 288ef84 and 6ce0c84.

📒 Files selected for processing (1)
  • apps/backend/src/services/rpy-parser.service.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/backend/src/services/rpy-parser.service.ts

📝 Walkthrough

Walkthrough

Fixes menu boundary detection and adds nesting-aware reconstruction in the Ren'Py parser to prevent dialogue duplication inside menus; adds unit tests verifying menu title extraction, parsed label dialogue, and idempotent reconstruction of menu titles and jump statements.

Changes

Menu parsing and reconstruction fixes

Layer / File(s) Summary
Menu boundary detection in extractChoices
apps/backend/src/services/rpy-parser.service.ts
Menu-stack unwinding logic changes to treat a dedent to the menu: indentation level (including equality) as exiting the menu context, ensuring correct choice-body boundary detection.
Menu reconstruction with nesting tracking
apps/backend/src/services/rpy-parser.service.ts
reconstructRPYFile adds menuStack state to track menu nesting depth, revises label-end keyword handling to exclude menu, and gates remaining dialogue insertion to execute only outside menu blocks. Dialogue replacement logic distinguishes menu titles from menu choice bodies to avoid duplication.
Test coverage for menu extraction and reconstruction
apps/backend/src/services/__tests__/rpy-parser.service.unit.test.ts
Four unit tests validate menu title extraction as editable dialogue, menu title presence in parsed label output, and duplication-free reconstruction of menu titles and jump statements within menus.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 I nibble lines in menu groves,
Titles sing where choice-paths rove.
No duplicates left to chase,
Nesting kept in tidy place—
Tests clap paws and hop with glee.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main changes: fixes to dialogue extraction and reconstruction specifically for menu titles, which aligns with the core modifications in both the test suite and the service implementation.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch some-fixes-yes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown

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 adjusts Ren’Py (.rpy) parsing/reconstruction to treat menu titles as editable dialogue while preventing duplicated dialogue insertion when reconstructing files (especially around menu: blocks).

Changes:

  • Adjusted menu block boundary handling in extractChoices() to treat lines at the same indent as menu: as outside the menu.
  • Updated reconstructRPYFile() to track menu nesting so menu titles are replaced in-place and remaining-dialogue insertion doesn’t trigger inside menu choice bodies.
  • Added unit tests covering menu-title extraction and preventing reconstruction duplication.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
apps/backend/src/services/rpy-parser.service.ts Updates menu boundary logic and adds menu-nesting tracking during reconstruction to avoid duplicate insertions.
apps/backend/src/services/tests/rpy-parser.service.unit.test.ts Adds regression tests for extracting menu titles and preventing duplication during reconstruction.

Comment thread apps/backend/src/services/rpy-parser.service.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/backend/src/services/rpy-parser.service.ts`:
- Around line 457-463: In extractChoices, a dedent can exit multiple nested menu
blocks but the code only pops one level; replace the single pop with a loop that
unwinds menuStack fully while menuStack.length > 0 and trimmed is truthy and
lineIndent <= menuStack[menuStack.length - 1], so all deeper menu levels are
popped (use menuStack and the existing trimmed/lineIndent checks to drive the
while-loop).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c6cfa3ee-e700-456b-a16a-42a280d50c8f

📥 Commits

Reviewing files that changed from the base of the PR and between ea77c58 and 288ef84.

📒 Files selected for processing (2)
  • apps/backend/src/services/__tests__/rpy-parser.service.unit.test.ts
  • apps/backend/src/services/rpy-parser.service.ts

Comment thread apps/backend/src/services/rpy-parser.service.ts Outdated
@mikkisguy mikkisguy merged commit 68eaf21 into main Jun 6, 2026
5 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

Development

Successfully merging this pull request may close these issues.

2 participants