Skip to content

Commit ddaae09

Browse files
wtheisenclaude
andcommitted
Restore auto-switch view on phase changes without locking
When the game phase changes, the view now auto-switches to the appropriate panel (e.g., plot view for swap/requisition, jobs view for assignment). However, the player can still manually switch to a different view - they're not locked into the auto-selected view. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 8645474 commit ddaae09

File tree

4 files changed

+68
-56
lines changed

4 files changed

+68
-56
lines changed

docs/assets/index-BC9uJLD-.js

Lines changed: 55 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/assets/index-Bmm_wMxU.js

Lines changed: 0 additions & 55 deletions
This file was deleted.

docs/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
height: 100dvh;
3838
}
3939
</style>
40-
<script type="module" crossorigin src="/assets/index-Bmm_wMxU.js"></script>
40+
<script type="module" crossorigin src="/assets/index-BC9uJLD-.js"></script>
4141
<link rel="stylesheet" crossorigin href="/assets/index-DwErYavY.css">
4242
</head>
4343
<body>

src/client/Board.jsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ export function Board({ G, ctx, moves, playerID, onNewGame }) {
1717
const [activePanel, setActivePanel] = useState(null);
1818
const togglePanel = (panel) => setActivePanel(activePanel === panel ? 'game' : panel);
1919

20+
// Track previous phase for auto-switch detection
21+
const prevPhaseRef = useRef(phase);
22+
2023
// Language toggle (persisted to localStorage)
2124
const [language, setLanguage] = useState(() => localStorage.getItem('kolkhoz-lang') || 'ru');
2225
const toggleLanguage = () => setLanguage(lang => {
@@ -101,6 +104,15 @@ export function Board({ G, ctx, moves, playerID, onNewGame }) {
101104
}
102105
}, [G.year]);
103106

107+
// Auto-switch view when phase changes, but don't lock the user there
108+
useEffect(() => {
109+
if (phase !== prevPhaseRef.current) {
110+
// Reset to auto mode so displayMode follows actionView
111+
setActivePanel(null);
112+
prevPhaseRef.current = phase;
113+
}
114+
}, [phase]);
115+
104116
// Requisition animation sequence - process job by job
105117
useEffect(() => {
106118
if (phase !== 'requisition' || !G.requisitionData) {

0 commit comments

Comments
 (0)