mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-01-31 06:42:03 +00:00
feat: Add auto-dismiss functionality for Init Script Indicator
This commit introduces an auto-dismiss feature for the Init Script Indicator, enhancing user experience by automatically hiding the indicator 5 seconds after the script completes. Key changes include: 1. **State Management**: Added `autoDismissInitScriptIndicatorByProject` to manage the auto-dismiss setting per project. 2. **UI Components**: Updated the WorktreesSection to include a toggle for enabling or disabling the auto-dismiss feature, allowing users to customize their experience. 3. **Indicator Logic**: Implemented logic in the SingleIndicator component to handle auto-dismiss based on the new setting. These enhancements provide users with more control over the visibility of the Init Script Indicator, streamlining project management workflows.
This commit is contained in:
@@ -13,9 +13,16 @@ interface SingleIndicatorProps {
|
||||
state: InitScriptState;
|
||||
onDismiss: (key: string) => void;
|
||||
isOnlyOne: boolean; // Whether this is the only indicator shown
|
||||
autoDismiss: boolean; // Whether to auto-dismiss after completion
|
||||
}
|
||||
|
||||
function SingleIndicator({ stateKey, state, onDismiss, isOnlyOne }: SingleIndicatorProps) {
|
||||
function SingleIndicator({
|
||||
stateKey,
|
||||
state,
|
||||
onDismiss,
|
||||
isOnlyOne,
|
||||
autoDismiss,
|
||||
}: SingleIndicatorProps) {
|
||||
const [showLogs, setShowLogs] = useState(false);
|
||||
const logsEndRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
@@ -35,6 +42,16 @@ function SingleIndicator({ stateKey, state, onDismiss, isOnlyOne }: SingleIndica
|
||||
}
|
||||
}, [status, isOnlyOne]);
|
||||
|
||||
// Auto-dismiss after completion (5 seconds)
|
||||
useEffect(() => {
|
||||
if (autoDismiss && (status === 'success' || status === 'failed')) {
|
||||
const timer = setTimeout(() => {
|
||||
onDismiss(stateKey);
|
||||
}, 5000);
|
||||
return () => clearTimeout(timer);
|
||||
}
|
||||
}, [status, autoDismiss, stateKey, onDismiss]);
|
||||
|
||||
if (status === 'idle') return null;
|
||||
|
||||
return (
|
||||
@@ -123,8 +140,12 @@ function SingleIndicator({ stateKey, state, onDismiss, isOnlyOne }: SingleIndica
|
||||
export function InitScriptIndicator({ projectPath }: InitScriptIndicatorProps) {
|
||||
const getInitScriptStatesForProject = useAppStore((s) => s.getInitScriptStatesForProject);
|
||||
const clearInitScriptState = useAppStore((s) => s.clearInitScriptState);
|
||||
const getAutoDismissInitScriptIndicator = useAppStore((s) => s.getAutoDismissInitScriptIndicator);
|
||||
const [dismissedKeys, setDismissedKeys] = useState<Set<string>>(new Set());
|
||||
|
||||
// Get auto-dismiss setting
|
||||
const autoDismiss = getAutoDismissInitScriptIndicator(projectPath);
|
||||
|
||||
// Get all init script states for this project
|
||||
const allStates = getInitScriptStatesForProject(projectPath);
|
||||
|
||||
@@ -180,6 +201,7 @@ export function InitScriptIndicator({ projectPath }: InitScriptIndicatorProps) {
|
||||
state={state}
|
||||
onDismiss={handleDismiss}
|
||||
isOnlyOne={activeStates.length === 1}
|
||||
autoDismiss={autoDismiss}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user