diff --git a/src/state/__tests__/runtime.test.ts b/src/state/__tests__/runtime.test.ts index 7c22589..008c3cb 100644 --- a/src/state/__tests__/runtime.test.ts +++ b/src/state/__tests__/runtime.test.ts @@ -48,7 +48,6 @@ describe('GameRuntime', () => { // Setup clean store useGameStore.setState({ log: [], - storyPanelOpen: false, storyHasUnread: false, storyLog: [], prefs: getPrefs(), @@ -160,7 +159,6 @@ describe('GameRuntime', () => { // Force play panel and closed/no unread story store.setActivePanel('play'); - store.setStoryPanelOpen(false); store.setStoryHasUnread(false); runtime.continueStory(); @@ -169,7 +167,7 @@ describe('GameRuntime', () => { // Verifies it advances to fork_choice expect(updated.storyLog.some((entry) => entry.nodeId === 'fork_choice')).toBe(true); // Verifies it opens panel and does not set unread (since it's open) - expect(updated.storyPanelOpen).toBe(true); + expect(updated.activePanel).toBe('story'); expect(updated.storyHasUnread).toBe(false); }); @@ -179,7 +177,6 @@ describe('GameRuntime', () => { // Force play panel and closed/no unread story store.setActivePanel('play'); - store.setStoryPanelOpen(false); store.setStoryHasUnread(false); runtime.continueStory(); @@ -188,7 +185,7 @@ describe('GameRuntime', () => { // Verifies it advances to fork_choice expect(updated.storyLog.some((entry) => entry.nodeId === 'fork_choice')).toBe(true); // Verifies it does NOT open panel and sets unread flag to true - expect(updated.storyPanelOpen).toBe(false); + expect(updated.activePanel).toBe('play'); expect(updated.storyHasUnread).toBe(true); }); @@ -249,18 +246,6 @@ describe('GameRuntime', () => { } }); - it('delegates openStoryPanel and closeStoryPanel to setActivePanel', () => { - // Force activePanel back to play first - runtime.setActivePanel('play'); - expect(useGameStore.getState().activePanel).toBe('play'); - - runtime.openStoryPanel(); - expect(useGameStore.getState().activePanel).toBe('story'); - - runtime.closeStoryPanel(); - expect(useGameStore.getState().activePanel).toBe('play'); - }); - it('registers lifecycle listeners on boot and removes them on stop', () => { const addSpyDoc = vi.spyOn(document, 'addEventListener'); const removeSpyDoc = vi.spyOn(document, 'removeEventListener'); diff --git a/src/state/runtime.ts b/src/state/runtime.ts index aae47e6..015dcb8 100644 --- a/src/state/runtime.ts +++ b/src/state/runtime.ts @@ -159,7 +159,6 @@ export class GameRuntime { for (const entry of entries) store.appendStoryLog(entry); const choiceLabel = entries.at(-1)?.choiceLabel; if (choiceLabel) store.appendLog(`Story: ${choiceLabel}`); - store.setStoryPanelOpen(false); this.runPublishTriggers(); this.publish(); } catch (err) { @@ -180,14 +179,6 @@ export class GameRuntime { } } - openStoryPanel(): void { - this.setActivePanel('story'); - } - - closeStoryPanel(): void { - this.setActivePanel('play'); - } - continueStory(): void { const state = this.state; if (!state) return; @@ -203,16 +194,14 @@ export class GameRuntime { } const prefs = store.prefs; if (shouldAutoNavigateToStory(prefs, 'fork_choice', content)) { - store.setStoryPanelOpen(true); - store.setStoryHasUnread(false); + this.setActivePanel('story'); } else { store.setStoryHasUnread(true); - store.setStoryPanelOpen(false); } this.publish(); return; } - this.closeStoryPanel(); + this.setActivePanel('play'); this.publish(); } @@ -229,7 +218,6 @@ export class GameRuntime { } else { store.setStoryHasUnread(true); } - store.setStoryPanelOpen(true); } else if (effect.enteredNodeIds.length > 0) { store.setStoryHasUnread(true); } diff --git a/src/state/store.ts b/src/state/store.ts index 297d2c0..850ad63 100644 --- a/src/state/store.ts +++ b/src/state/store.ts @@ -20,20 +20,16 @@ export type ActivePanel = 'play' | 'story' | 'settings' | 'about'; export interface GameStoreState extends GameView { log: string[]; - storyPanelOpen: boolean; storyHasUnread: boolean; storyLog: StoryLogEntry[]; prefs: GamePrefs; - settingsOpen: boolean; activePanel: ActivePanel; selectedStoryNodeId: string | null; setView: (view: GameView) => void; appendLog: (line: string) => void; appendStoryLog: (entry: StoryLogEntry) => void; - setStoryPanelOpen: (open: boolean) => void; setStoryHasUnread: (unread: boolean) => void; setPrefs: (partial: Partial) => void; - setSettingsOpen: (open: boolean) => void; setActivePanel: (panel: ActivePanel) => void; setSelectedStoryNodeId: (id: string | null) => void; toggleActionGroupCollapsed: (groupKey: string) => void; @@ -50,23 +46,19 @@ export const useGameStore = create((set, get) => ({ story: { currentProse: null, choices: [], tree: [] }, actionColumns: [], log: [], - storyPanelOpen: false, storyHasUnread: false, storyLog: [], prefs: getPrefs(), - settingsOpen: false, activePanel: 'play', selectedStoryNodeId: null, setView: (view) => set((state) => ({ ...state, ...view })), appendLog: (line) => set((state) => ({ log: [...state.log, line].slice(-MAX_LOG_LINES) })), appendStoryLog: (entry) => set((state) => ({ storyLog: [...state.storyLog, entry] })), - setStoryPanelOpen: (open) => set({ storyPanelOpen: open }), setStoryHasUnread: (unread) => set({ storyHasUnread: unread }), setPrefs: (partial) => { const prefs = persistPrefs(partial); set({ prefs }); }, - setSettingsOpen: (open) => set({ settingsOpen: open }), setActivePanel: (panel) => set({ activePanel: panel }), setSelectedStoryNodeId: (id) => set({ selectedStoryNodeId: id }), toggleActionGroupCollapsed: (groupKey) => {