Skip to content

Commit e524132

Browse files
committed
Simplify terminal boot
1 parent 84c6d56 commit e524132

3 files changed

Lines changed: 27 additions & 18 deletions

File tree

websiteBuilder/src/main/kotlin/com/linuxcommandlibrary/desktop/WebsiteBuilder.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class WebsiteBuilder(
119119
private val pastSponsors: List<Pair<String, String>> = emptyList(),
120120
) {
121121

122-
private val cacheVersion = 15
122+
private val cacheVersion = 16
123123

124124
private val preInstalledCommands: Set<String>
125125
private val installableCommands: Set<String>

websiteBuilder/src/main/resources/scripts/terminal.js

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,23 @@ function startTerminal() {
141141
var status = document.getElementById('terminal-status');
142142
if (status) status.textContent = 'Loading...';
143143

144+
// Replace placeholder with loading animation
145+
var tbody = document.getElementById('terminal-body');
146+
if (tbody) tbody.classList.add('loading');
144147
var ph = document.getElementById('terminal-placeholder');
145-
if (ph) ph.remove();
148+
if (ph) {
149+
ph.innerHTML =
150+
'<pre id="terminal-ascii">' +
151+
'<span id="terminal-spinner"></span>\n\n' +
152+
'<span class="tp-info">Loading Alpine Linux terminal...</span>\n' +
153+
'</pre>';
154+
var frames = ['|', '/', '-', '\\'];
155+
var fi = 0;
156+
var spinner = document.getElementById('terminal-spinner');
157+
var spinInterval = setInterval(function() {
158+
if (spinner) spinner.textContent = ' ' + frames[fi++ % 4];
159+
}, 150);
160+
}
146161

147162
var script = document.createElement('script');
148163
script.src = '/v86/libv86.js';
@@ -169,18 +184,8 @@ function startTerminal() {
169184
disable_mouse: true,
170185
};
171186

172-
fetch('/v86/vm_state.bin', { method: 'HEAD' }).then(function(r) {
173-
if (r.ok) {
174-
if (status) status.textContent = 'Restoring...';
175-
config.initial_state = { url: '/v86/vm_state.bin' };
176-
} else {
177-
if (status) status.textContent = 'Booting...';
178-
}
179-
bootEmulator(config, status);
180-
}).catch(function() {
181-
if (status) status.textContent = 'Booting...';
182-
bootEmulator(config, status);
183-
});
187+
if (status) status.textContent = 'Booting...';
188+
bootEmulator(config, status);
184189
};
185190
script.onerror = function() {
186191
if (status) status.textContent = 'Failed to load';
@@ -190,18 +195,19 @@ function startTerminal() {
190195
}
191196

192197
function bootEmulator(config, status) {
193-
var useSnapshot = !!config.initial_state;
194-
195198
emulator = new V86(config);
196199

197200
emulator.add_listener('emulator-ready', function() {
198201
if (status) status.textContent = '';
202+
var ph = document.getElementById('terminal-placeholder');
203+
if (ph) ph.remove();
204+
var tbody = document.getElementById('terminal-body');
205+
if (tbody) tbody.classList.remove('loading');
199206
v86Loading = false;
200207
updateTerminalSpacing();
201208

202209
if (pendingCommand) {
203-
var delay = useSnapshot ? 500 : 30000;
204-
setTimeout(typePendingCommand, delay);
210+
setTimeout(typePendingCommand, 30000);
205211
}
206212
});
207213
}

websiteBuilder/src/main/resources/stylesheets/terminal.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
background: #000;
4040
overflow: hidden;
4141
}
42+
#terminal-body.loading {
43+
height: 300px;
44+
}
4245
#terminal-placeholder {
4346
display: flex;
4447
align-items: center;

0 commit comments

Comments
 (0)