fix: add hash check to polling fallback and persist sidebar state
- Add content hash check to config watcher polling path to match fsnotify behavior, preventing unnecessary restarts when .env is touched but content unchanged (Related to #748) - Change settings sidebar to expanded by default and persist user preference using usePersistentSignal (Related to #764)
This commit is contained in:
parent
455c711185
commit
cb8c46cfb6
2 changed files with 12 additions and 2 deletions
|
|
@ -39,6 +39,7 @@ import { SettingsSectionNav } from './SettingsSectionNav';
|
||||||
import { SettingsAPI } from '@/api/settings';
|
import { SettingsAPI } from '@/api/settings';
|
||||||
import { NodesAPI } from '@/api/nodes';
|
import { NodesAPI } from '@/api/nodes';
|
||||||
import { UpdatesAPI } from '@/api/updates';
|
import { UpdatesAPI } from '@/api/updates';
|
||||||
|
import { usePersistentSignal } from '@/hooks/usePersistentSignal';
|
||||||
import { Card } from '@/components/shared/Card';
|
import { Card } from '@/components/shared/Card';
|
||||||
import { SectionHeader } from '@/components/shared/SectionHeader';
|
import { SectionHeader } from '@/components/shared/SectionHeader';
|
||||||
import { Toggle } from '@/components/shared/Toggle';
|
import { Toggle } from '@/components/shared/Toggle';
|
||||||
|
|
@ -596,7 +597,7 @@ const Settings: Component<SettingsProps> = (props) => {
|
||||||
);
|
);
|
||||||
|
|
||||||
const [hasUnsavedChanges, setHasUnsavedChanges] = createSignal(false);
|
const [hasUnsavedChanges, setHasUnsavedChanges] = createSignal(false);
|
||||||
const [sidebarCollapsed, setSidebarCollapsed] = createSignal(true);
|
const [sidebarCollapsed, setSidebarCollapsed] = usePersistentSignal('settings-sidebar-collapsed', false);
|
||||||
const [nodes, setNodes] = createSignal<NodeConfigWithStatus[]>([]);
|
const [nodes, setNodes] = createSignal<NodeConfigWithStatus[]>([]);
|
||||||
const [discoveredNodes, setDiscoveredNodes] = createSignal<DiscoveredServer[]>([]);
|
const [discoveredNodes, setDiscoveredNodes] = createSignal<DiscoveredServer[]>([]);
|
||||||
const [showNodeModal, setShowNodeModal] = createSignal(false);
|
const [showNodeModal, setShowNodeModal] = createSignal(false);
|
||||||
|
|
|
||||||
|
|
@ -265,8 +265,17 @@ func (cw *ConfigWatcher) pollForChanges() {
|
||||||
// Check .env
|
// Check .env
|
||||||
if stat, err := os.Stat(cw.envPath); err == nil {
|
if stat, err := os.Stat(cw.envPath); err == nil {
|
||||||
if stat.ModTime().After(cw.lastModTime) {
|
if stat.ModTime().After(cw.lastModTime) {
|
||||||
log.Info().Msg("Detected .env file change via polling")
|
|
||||||
cw.lastModTime = stat.ModTime()
|
cw.lastModTime = stat.ModTime()
|
||||||
|
// Check if content actually changed to prevent restart loops on touch
|
||||||
|
newHash, err := cw.calculateFileHash(cw.envPath)
|
||||||
|
if err == nil {
|
||||||
|
if newHash == cw.lastEnvHash {
|
||||||
|
log.Debug().Msg("Detected .env file touch but content unchanged (polling), skipping reload")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
cw.lastEnvHash = newHash
|
||||||
|
}
|
||||||
|
log.Info().Msg("Detected .env file change via polling")
|
||||||
cw.reloadConfig()
|
cw.reloadConfig()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue