Skip to content

Commit 07da09f

Browse files
committed
Welcomewrap shortened, terminal got help command
1 parent 83f30a1 commit 07da09f

File tree

6 files changed

+306
-179
lines changed

6 files changed

+306
-179
lines changed

src/webOS/components/WelcomeWrap/WelcomeWrap.jsx

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,40 @@
11
// =================================================================================
2-
// Chapter 1: Imports & Dependencies
2+
// Area 1: Constants, Imports & Dependencies
33
// =================================================================================
44

5+
// 1.1: Timing constants
6+
// how long each welcome message displays (in milliseconds)
7+
const MESSAGE_DISPLAY_MS = 1800;
8+
// delay before first message appears (in seconds)
9+
const INITIAL_DELAY_SEC = 1;
10+
511
import React, { useEffect, useState } from 'react';
612
import messages from './messages';
713
import './WelcomeWrap.css';
814
import { useStateManager } from '../../stores/StateManager/StateManager';
915

1016
// =================================================================================
11-
// Chapter 2: Component Definition & State Manager Setup
17+
// Area 2: Component Definition & State Setup
1218
// =================================================================================
1319

1420
const WelcomeWrap = () => {
15-
// Initialize state manager hooks
21+
// 2.1: State manager hooks
1622
const { state, editStateValue, refreshState } = useStateManager();
1723

18-
// Determine if welcome screen is enabled in global state
24+
// 2.2: Check if welcome screen is enabled
1925
const welcomeEnabledStr =
2026
state.groups.welcomeWrap && state.groups.welcomeWrap.welcomeEnabled;
2127
const welcomeEnabled = welcomeEnabledStr === "false" ? false : true;
2228
if (!welcomeEnabled) return null;
2329

24-
// Timing configuration for messages and animations
25-
const totalDuration = 10;
26-
const initialDelay = 1;
30+
// 2.3: Timing configuration
2731
const messageCount = messages.length;
28-
const messageDuration = (totalDuration - initialDelay) / messageCount;
32+
// 2.3.1: per-message duration in seconds
33+
const messageDuration = MESSAGE_DISPLAY_MS / 1000;
34+
// 2.3.2: total seconds until switching to loading
35+
const totalDuration = INITIAL_DELAY_SEC + messageCount * messageDuration;
2936

30-
// Local UI state
37+
// 2.4: Local UI state flags
3138
const [showWelcome, setShowWelcome] = useState(true);
3239
const [showLoading, setShowLoading] = useState(false);
3340
const [messageIndex, setMessageIndex] = useState(-1);
@@ -36,80 +43,79 @@ const WelcomeWrap = () => {
3643
const [fadeHello, setFadeHello] = useState(false);
3744

3845
// =================================================================================
39-
// Chapter 3: Mount Effect: Hide UI on Mount
46+
// Area 3: Mount Effect: Hide UI on Mount
4047
// =================================================================================
4148

4249
useEffect(() => {
43-
// Hide dock, desktop icons, and menubar immediately
50+
// 3.1: Hide dock, icons, menubar immediately
4451
editStateValue("dock", "dockVisible", "false");
4552
editStateValue("desktop", "iconVisible", "false");
4653
editStateValue("desktop", "menubarVisible", "false");
4754
refreshState();
4855
}, []);
4956

5057
// =================================================================================
51-
// Chapter 4: Effect: Show Loading and Fade Welcome
58+
// Area 4: Effect: Show Loading and Fade Welcome
5259
// =================================================================================
5360

5461
useEffect(() => {
55-
// After totalDuration seconds, transition to loading screen
62+
// 4.1: After totalDuration (sec), show loading and fade out welcome
5663
const t = setTimeout(() => {
5764
setShowLoading(true);
5865
setFadeWelcome(true);
59-
// Remove welcome screen after fade-out
66+
// remove welcome after fade completes (1s)
6067
setTimeout(() => setShowWelcome(false), 1000);
6168
}, totalDuration * 1000);
6269
return () => clearTimeout(t);
6370
}, [totalDuration]);
6471

6572
// =================================================================================
66-
// Chapter 5: Effect: Cycle Welcome Messages
73+
// Area 5: Effect: Cycle Welcome Messages
6774
// =================================================================================
6875

6976
useEffect(() => {
7077
if (!showWelcome) return;
71-
// Start cycling messages after initial delay
78+
// 5.1: first message after INITIAL_DELAY_SEC
7279
if (messageIndex === -1) {
73-
const t = setTimeout(() => setMessageIndex(0), initialDelay * 1000);
80+
const t = setTimeout(() => setMessageIndex(0), INITIAL_DELAY_SEC * 1000);
7481
return () => clearTimeout(t);
7582
}
76-
// Advance to next message until all shown
83+
// 5.2: advance until the last message
7784
if (messageIndex < messageCount - 1) {
7885
const t = setTimeout(
7986
() => setMessageIndex(i => i + 1),
8087
messageDuration * 1000
8188
);
8289
return () => clearTimeout(t);
8390
}
84-
}, [showWelcome, messageIndex, messageCount, messageDuration, initialDelay]);
91+
}, [showWelcome, messageIndex, messageCount, messageDuration]);
8592

8693
// =================================================================================
87-
// Chapter 6: Handler: Hello Animation End and Restore UI
94+
// Area 6: Handler: Hello Animation End and Restore UI
8895
// =================================================================================
8996

9097
const handleHelloAnimationEnd = () => {
91-
// Trigger fade-out of the SVG “hello”
9298
setFadeHello(true);
99+
// 6.1: wait 1s, restore UI, then fade loading
93100
setTimeout(() => {
94-
// Restore dock, desktop icons, and menubar
95101
editStateValue("dock", "dockVisible", "true");
96102
editStateValue("desktop", "iconVisible", "true");
97103
editStateValue("desktop", "menubarVisible", "true");
98-
// Disable further welcome screens
99-
editStateValue("welcomeWrap", "welcomeEnabled", "false");
100104
refreshState();
101-
102-
// Fade out loading screen and then hide it
103105
setFadeLoading(true);
104-
setTimeout(() => setShowLoading(false), 1000);
106+
// 6.2: after fade, hide loading & disable future welcomes
107+
setTimeout(() => {
108+
setShowLoading(false);
109+
editStateValue("welcomeWrap", "welcomeEnabled", "false");
110+
refreshState();
111+
}, 1000);
105112
}, 1000);
106113
};
107114

108-
// Prevent pointer-events during welcome/loading phases
109115
const isBlocking = showWelcome || showLoading;
110116

111117
// =================================================================================
112-
// Chapter 7: Rendering: Conditional Screens and Animations
118+
// Area 7: Rendering
113119
// =================================================================================
114120

115121
return (
@@ -127,12 +133,11 @@ const WelcomeWrap = () => {
127133
)}
128134
</div>
129135
)}
130-
131136
{showLoading && (
132137
<div className={`loading-screen ${fadeLoading ? 'fade-out' : ''}`}>
133138
<div className="loading-animation">
134139
<div className={`hello__div ${fadeHello ? 'fade-out' : ''}`}>
135-
<svg
140+
<svg
136141
className="hello__svg"
137142
viewBox="0 0 1230.94 414.57"
138143
onAnimationEnd={handleHelloAnimationEnd}

src/webOS/components/WelcomeWrap/messages.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
const messages = [
33
"Kia Ora",
44
"webOS is here",
5-
"developed by Nikita Mogilevskii",
6-
"Have fun!"
5+
"developed by Nikita Mogilevskii"
76
];
87

98
export default messages;
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// src/apps/Help/Help.jsx
2+
3+
/* ====================================================
4+
Area 1: Imports & Utilities
5+
==================================================== */
6+
7+
// 1.1: React imports for component, refs, and effects
8+
import React, { forwardRef, useImperativeHandle, useEffect } from "react";
9+
10+
// 1.2: Import the apps registry to list their commands/descriptions
11+
import { apps } from "../../components/AppsList";
12+
13+
/* ====================================================
14+
Area 2: Component Definition
15+
==================================================== */
16+
17+
const Help = forwardRef(({ output, setAutocompleteCommands }, ref) => {
18+
// 2.1: Helper to write a line to the terminal
19+
const writeln = (msg = "") => {
20+
if (output?.current?.writeln) {
21+
output.current.writeln(msg);
22+
}
23+
};
24+
25+
// 2.2: On mount, list all registered commands with descriptions
26+
useEffect(() => {
27+
writeln("");
28+
writeln("Available Commands:");
29+
writeln("-------------------");
30+
apps.forEach(({ commands, description }) => {
31+
const cmdList = Array.isArray(commands) ? commands.join(", ") : commands;
32+
writeln(` • ${cmdList}`);
33+
writeln(` ${description}`);
34+
});
35+
writeln("");
36+
}, []);
37+
38+
// 2.3: Stub for processing further input (no-op)
39+
const processInput = (input) => {
40+
// No additional commands beyond initial help listing
41+
};
42+
43+
// 2.4: Stub for autocomplete suggestions (none needed)
44+
const getAutocompleteSuggestions = () => {
45+
return [];
46+
};
47+
48+
// 2.5: Expose methods to the terminal host
49+
useImperativeHandle(ref, () => ({
50+
processInput,
51+
getAutocompleteSuggestions,
52+
}));
53+
54+
// 2.6: Render minimal placeholder UI
55+
return (
56+
<div className="help-app">
57+
<h3>Use CTRL + C to exit an app</h3>
58+
</div>
59+
);
60+
});
61+
62+
/* ====================================================
63+
Area 3: Export
64+
==================================================== */
65+
66+
// 3.1: Export the component as default
67+
export default Help;

src/webOS/initialapps/Noterminal/components/AppsList.jsx

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,42 @@
1-
// Wherever your AppsList is defined (e.g., src/configs/AppsList.jsx or similar),
2-
// add the Logger terminal entry. Example:
1+
// src/configs/AppsList.jsx
32

4-
import StateEditor from "../apps/StateEditor/StateEditor";
3+
/* ====================================================
4+
Area 1: Imports
5+
==================================================== */
6+
7+
// 1.1: Import application components
8+
import Help from "../apps/Help/Help.jsx";
59
import TerminalSettingsEditor from "../apps/TerminalSettingsEditor/TerminalSettingsEditor";
10+
import StateEditor from "../apps/StateEditor/StateEditor";
611
import LoggerTerminal from "../apps/Logger/LoggerTerminal";
712

13+
/* ====================================================
14+
Area 2: Apps Array
15+
==================================================== */
16+
817
export const apps = [
18+
// 2.1: Help app invoked by "help", lists all commands
19+
{
20+
name: "help",
21+
description: "List available commands with their descriptions.",
22+
commands: ["help"],
23+
component: Help,
24+
},
925
{
1026
name: "Terminal Settings Editor",
1127
description: "Edit terminal font, color, and design settings.",
12-
commands: ["terminal settings editor", "tse"],
28+
commands: ["tse"],
1329
component: TerminalSettingsEditor,
1430
},
1531
{
1632
name: "State Editor",
1733
description: "Edit states and state groups.",
18-
commands: ["state editor", "stedit"],
34+
commands: ["stedit"],
1935
component: StateEditor,
2036
},
2137
{
2238
name: "Logger",
23-
description: "Inspect and control the logger—view registered components/groups, mute/unmute, toggle global logging.",
39+
description: "Inspect and control the logs",
2440
commands: ["logger", "logapp"],
2541
component: LoggerTerminal,
2642
},

0 commit comments

Comments
 (0)