Fix: Finalize manual command interface and structured output handling

- Improved manual OS command input with better binding and extraction logic.
- Resolved '[object Object]' issue by correctly displaying stdout/stderr/error from structured return.
- Polished terminal output UI with better styling and clear functionality.
- Renamed section to 'Native OS Handlers & Folders' for better clarity.
This commit is contained in:
Scott Idem
2026-01-23 17:32:15 -05:00
parent f9f6d7f4f0
commit 10f7c1b776

View File

@@ -99,19 +99,42 @@
</button>
</div>
<div class="w-full border-t border-surface-500/30 pt-2 mt-2">
<button
onclick={async () => {
test_cmd_result = 'Running...';
const res = await native.run_cmd({ cmd: 'whoami && uptime', return_stdout: true });
test_cmd_result = res as string;
}}
class="btn btn-sm variant-soft-secondary w-full"
>
<span class="fas fa-terminal mr-2"></span> Test OS Command
</button>
<div class="w-full border-t border-surface-500/30 pt-2 mt-2 flex flex-col gap-2">
<div class="flex flex-col gap-1">
<label class="text-[10px] opacity-70 ml-1">Run Manual Command:</label>
<div class="flex gap-1">
<input
type="text"
bind:value={$events_sess.launcher.manual_cmd}
placeholder="e.g. ls -la or whoami"
class="input input-sm grow text-[10px] preset-tonal-surface"
/>
<button
onclick={async () => {
test_cmd_result = 'Running...';
const res = await native.run_cmd({ cmd: $events_sess.launcher.manual_cmd || 'whoami && uptime' });
if (res && typeof res === 'object') {
test_cmd_result = (res as any).stdout || (res as any).error || 'No Output';
if ((res as any).stderr) test_cmd_result += `\nStderr: ${(res as any).stderr}`;
} else {
test_cmd_result = String(res);
}
}}
class="btn btn-sm preset-filled-secondary hover:preset-filled-primary-500 text-[10px]"
>
Run
</button>
</div>
</div>
{#if test_cmd_result}
<pre class="text-[10px] bg-black text-green-500 p-1 mt-1 overflow-x-auto rounded w-full">{test_cmd_result}</pre>
<div class="relative">
<pre class="text-[9px] bg-black text-green-500 p-2 mt-1 overflow-x-auto rounded w-full border border-surface-500/50 min-h-12 max-h-32 shadow-inner">{test_cmd_result}</pre>
<button
onclick={() => test_cmd_result = ''}
class="absolute top-2 right-2 text-white/30 hover:text-white text-[8px]"
>Clear</button>
</div>
{/if}
</div>
</div>