Skip to content

[codex] Fix episode selection after script generation#27

Open
RaBBBBBIT wants to merge 2 commits into
xuanyustudio:mainfrom
RaBBBBBIT:codex/fix-episode-selection-after-script-generation
Open

[codex] Fix episode selection after script generation#27
RaBBBBBIT wants to merge 2 commits into
xuanyustudio:mainfrom
RaBBBBBIT:codex/fix-episode-selection-after-script-generation

Conversation

@RaBBBBBIT

Copy link
Copy Markdown

Summary

Fixes episode selection state in the film creation page when users add a new episode or generate scripts from the story prompt.

Issue

When a user adds a new episode and then works from the script generation panel, the UI can jump back to the first or previous episode. This makes it look like the newly added episode did not receive the generated or saved script.

Root cause

The add-episode path saved the new episode and reloaded the drama, but did not explicitly select the newly created episode after the reload. The story-generation path also reset savedCurrentEpisodeNumber to 1 and then selected the first episode after generation, regardless of which episode the user was editing.

Fix

  • After adding an episode, find the new episode by episode_number and select it explicitly.
  • During story generation, preserve the current episode number as the preferred target and reselect that episode after saving/reloading.

Validation

  • Ran npm run build in frontweb successfully.

Copilot AI review requested due to automatic review settings June 22, 2026 09:17

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 fixes episode-selection drift on the film creation page by explicitly re-selecting the intended episode after operations that reload the drama (adding an episode and generating story/scripts).

Changes:

  • After adding a new episode, re-select the newly created episode by matching episode_number after loadDrama().
  • During story generation, preserve the user’s current episode number as the preferred target and re-select it after save/reload (fallback to the first episode if missing).

Reviewed changes

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

File Description
frontweb/src/views/FilmCreate.vue After onAddEpisode() reloads the drama, finds the new episode by episode_number and selects it to avoid jumping back to an older episode.
frontweb/src/composables/useStoryGeneration.js Preserves a preferred episode number across generation/save/reload and selects that episode after loadDrama() instead of always selecting the first.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +100 to +104
const preferredEp = episodesAfterSave.find((ep) => Number(ep.episode_number) === Number(preferredEpisodeNumber))
|| episodesAfterSave[0]
if (preferredEp) {
selectedEpisodeId.value = preferredEp.id
onEpisodeSelect(preferredEp.id)
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.

3 participants