Skip to content

Commit 1b1840f

Browse files
authored
standalone: tweak ui (#32)
* fix: bump to v1 * feat: download extension from remote release * Revert "fix: bump to v1" This reverts commit 7f23e38. * style: tune style * Revert "feat: download extension from remote release" This reverts commit 5cd7c4c. * fix: aria fix * doc: document future todo when signign is available * feat: tweak database card * chore: update copy
1 parent 9e8d4a6 commit 1b1840f

6 files changed

Lines changed: 121 additions & 41 deletions

File tree

standalone/src-tauri/capabilities/default.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,16 @@
88
"permissions": [
99
"core:default",
1010
"opener:default",
11+
{
12+
"identifier": "opener:allow-open-path",
13+
"allow": [
14+
{
15+
"path": "$APPLOCALDATA"
16+
}
17+
]
18+
},
1119
"shell:default",
1220
"log:default",
1321
"fs:default"
1422
]
15-
}
23+
}

standalone/src-tauri/capabilities/desktop.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
"cli:default",
1313
"fs:default"
1414
]
15-
}
15+
}

standalone/src-tauri/src/db.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ fn resolve_extension_path(app_handle: &AppHandle) -> Option<PathBuf> {
140140
}
141141
}
142142

143+
// FIXME: in MacOS bundle, we should reference the library from Frameworks folder
144+
// instead of Resources. However, either way require code signing setup, which is not
145+
// yet done.
143146
match app_handle.path().resource_dir() {
144147
Ok(resource_dir) => {
145148
let resource_path = resource_dir.join("resources").join(&lib_name);

standalone/src/lib/components/JsonBlock.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
};
4242
</script>
4343

44-
<div class="rounded-md border border-black/10">
44+
<div class="rounded-md border border-black/10 overflow-hidden">
4545
<div class="flex items-center justify-between border-b border-black/10 bg-slate-50 px-3 py-2 text-xs text-slate-500">
4646
<span>{title}</span>
4747
<Button type="button" class="hover:text-slate-700" onclick={handleCopy}>

standalone/src/routes/settings/+page.svelte

Lines changed: 51 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
type WorkerStatus,
1111
} from "$lib/providers/absurdData";
1212
import { invoke } from "@tauri-apps/api/core";
13+
import { revealItemInDir } from "@tauri-apps/plugin-opener";
1314
1415
const provider = getAbsurdProvider();
1516
const defaults: SettingsInfo = {
@@ -54,6 +55,7 @@
5455
const canCopyPath = $derived(
5556
data.dbPath !== "--" && data.dbPath.trim().length > 0,
5657
);
58+
const canOpenFolder = $derived(canCopyPath && isTauriRuntime());
5759
let copyStatus = $state<"idle" | "copied" | "error">("idle");
5860
const showDevApi = $derived(isTauriRuntime());
5961
const normalizedWorkerPath = $derived(workerPathDraft.trim());
@@ -174,6 +176,27 @@
174176
}, 2000);
175177
};
176178
179+
const resolveFolderPath = (path: string) => {
180+
if (!path || path === "--") return "";
181+
const normalized = path.replace(/\\/g, "/");
182+
const lastSlash = normalized.lastIndexOf("/");
183+
if (lastSlash <= 0) return path;
184+
const dir = normalized.slice(0, lastSlash);
185+
return path.includes("\\") ? dir.replaceAll("/", "\\") : dir;
186+
};
187+
188+
const handleOpenFolder = async () => {
189+
if (!canOpenFolder) {
190+
return;
191+
}
192+
193+
try {
194+
await revealItemInDir(data.dbPath);
195+
} catch (error) {
196+
console.error("Failed to open database folder", error);
197+
}
198+
};
199+
177200
const syncWorkerStatus = (status: WorkerStatus) => {
178201
workerStatus = status;
179202
if (!workerPathTouched) {
@@ -375,33 +398,35 @@
375398

376399
<article class="rounded-lg border border-black/10 bg-white p-6">
377400
<h2 class="text-lg font-semibold text-slate-900">Database</h2>
378-
<p class="mt-1 text-sm text-slate-500">Primary storage location for task data.</p>
401+
<p class="mt-1 text-sm text-slate-500">SQLite database information.</p>
379402
<dl class="mt-4 space-y-3 text-sm">
380-
<div class="space-y-2">
381-
<div class="flex flex-wrap items-center justify-between gap-3">
382-
<dt class="text-slate-500">File path</dt>
383-
<div class="flex items-center gap-2">
384-
<span
385-
class="rounded-full border border-slate-200 bg-slate-50 px-2.5 py-1 text-[11px] font-semibold uppercase tracking-wide text-slate-600"
386-
>
387-
{dbSizeLabel}
388-
</span>
389-
<Button
390-
type="button"
391-
class="rounded-md border border-black/10 bg-white px-3 py-1 text-xs font-medium text-slate-700 disabled:cursor-not-allowed disabled:opacity-60"
392-
disabled={!canCopyPath}
393-
onclick={handleCopyPath}
394-
>
395-
{copyStatus === "copied"
396-
? "Copied"
397-
: copyStatus === "error"
398-
? "Copy failed"
399-
: "Copy"}
400-
</Button>
401-
</div>
402-
</div>
403-
<dd class="break-all rounded-md border border-black/10 bg-slate-50 px-3 py-2 font-mono text-xs text-slate-700">
404-
{data.dbPath}
403+
<div class="flex flex-wrap items-center justify-between gap-3">
404+
<dt class="text-slate-500">Disk size</dt>
405+
<dd class="font-medium text-slate-700">{dbSizeLabel}</dd>
406+
</div>
407+
<div class="flex flex-wrap items-center justify-between gap-3">
408+
<dt class="text-slate-500">Actions</dt>
409+
<dd class="flex flex-wrap items-center gap-2">
410+
<Button
411+
type="button"
412+
class="rounded-md border border-black/10 bg-white px-3 py-1 text-xs font-medium text-slate-700 disabled:cursor-not-allowed disabled:opacity-60"
413+
disabled={!canCopyPath}
414+
onclick={handleCopyPath}
415+
>
416+
{copyStatus === "copied"
417+
? "Copied"
418+
: copyStatus === "error"
419+
? "Copy failed"
420+
: "Copy full path"}
421+
</Button>
422+
<Button
423+
type="button"
424+
class="rounded-md border border-black/10 bg-white px-3 py-1 text-xs font-medium text-slate-700 disabled:cursor-not-allowed disabled:opacity-60"
425+
disabled={!canOpenFolder}
426+
onclick={handleOpenFolder}
427+
>
428+
Open folder
429+
</Button>
405430
</dd>
406431
</div>
407432
</dl>

standalone/src/routes/tasks/+page.svelte

Lines changed: 56 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
let taskRuns = $state<TaskRun[]>([]);
3838
let totalCount = $state(0);
3939
let expandedId = $state<string | null>(null);
40+
let hoveredTaskId = $state<string | null>(null);
4041
let isReady = $state(false);
4142
let isLoading = $state(false);
4243
let limit = $state(defaultLimit);
@@ -51,6 +52,19 @@
5152
const toggleExpanded = (runId: string) => {
5253
expandedId = expandedId === runId ? null : runId;
5354
};
55+
const applyTaskNameFilter = (name: string) => {
56+
selectedTaskName = name;
57+
if (activeSearch || searchTerm) {
58+
activeSearch = "";
59+
searchTerm = "";
60+
updateQuery({ q: null });
61+
}
62+
};
63+
const applyTaskIdFilter = (taskId: string) => {
64+
searchTerm = taskId;
65+
activeSearch = taskId;
66+
updateQuery({ q: taskId });
67+
};
5468
const handleSearchInput = (event: Event) => {
5569
const target = event.currentTarget as HTMLInputElement | null;
5670
if (!target) return;
@@ -251,7 +265,7 @@
251265
{#if totalCount === 0}
252266
Showing 0 tasks
253267
{:else}
254-
Showing 1–{taskRuns.length} of {totalCount} tasks
268+
Showing 1–{taskRuns.length} of {totalCount} task runs
255269
{/if}
256270
</span>
257271
{#if isLoading}
@@ -269,12 +283,11 @@
269283
<table class="min-w-full border-collapse text-left text-sm">
270284
<thead class="bg-slate-100 text-xs font-semibold uppercase tracking-wide text-slate-600">
271285
<tr>
272-
<th class="px-4 py-3">Task ID</th>
286+
<th class="px-4 py-3">Task Run</th>
273287
<th class="px-4 py-3">Task Name</th>
274288
<th class="px-4 py-3">Queue</th>
275289
<th class="px-4 py-3">Status</th>
276290
<th class="px-4 py-3">Attempt</th>
277-
<th class="px-4 py-3">Run ID</th>
278291
<th class="px-4 py-3">Age</th>
279292
<th class="px-4 py-3"></th>
280293
</tr>
@@ -285,7 +298,28 @@
285298
class="border-t border-black/5 hover:bg-slate-50 hover:cursor-pointer"
286299
onclick={() => toggleExpanded(run.runId)}
287300
>
288-
<td class="px-4 py-3 font-mono text-xs text-slate-600">{run.id}</td>
301+
<td class="px-4 py-3">
302+
<div class="flex flex-col gap-1">
303+
<span class="font-mono text-xs text-slate-700">run: {run.runId}</span>
304+
<button
305+
type="button"
306+
aria-label="Highlight task id"
307+
class={`w-fit cursor-default text-left font-mono text-[10px] ${
308+
hoveredTaskId === run.id
309+
? "rounded bg-amber-50 px-1 text-amber-700"
310+
: "text-slate-500"
311+
}`}
312+
onmouseenter={() => {
313+
hoveredTaskId = run.id;
314+
}}
315+
onmouseleave={() => {
316+
hoveredTaskId = null;
317+
}}
318+
>
319+
task: {run.id}
320+
</button>
321+
</div>
322+
</td>
289323
<td class="px-4 py-3 text-slate-800">{run.name}</td>
290324
<td class="px-4 py-3 text-slate-600">{run.queue}</td>
291325
<td class="px-4 py-3">
@@ -296,13 +330,12 @@
296330
</span>
297331
</td>
298332
<td class="px-4 py-3 text-slate-600">{run.attempt}</td>
299-
<td class="px-4 py-3 font-mono text-xs text-slate-600">{run.runId}</td>
300333
<td class="px-4 py-3 text-slate-600">{run.age}</td>
301334
<td class="px-4 py-3 text-slate-600">{expandedId === run.runId ? "" : ""}</td>
302335
</tr>
303336
{#if expandedId === run.runId}
304337
<tr class="border-t border-black/10 bg-white">
305-
<td colspan="8" class="px-4 py-4">
338+
<td colspan="7" class="px-4 py-4">
306339
<div class="mt-4">
307340
<div class="flex items-center justify-between">
308341
<h3 class="text-sm font-semibold text-slate-800">Basic Information</h3>
@@ -329,9 +362,13 @@
329362
<div class="flex gap-2">
330363
<dt class="text-slate-500">Task Name:</dt>
331364
<dd>
332-
<a href={`/tasks/${run.id}`} class="text-slate-700 hover:underline">
365+
<button
366+
type="button"
367+
class="cursor-pointer text-left text-slate-700 hover:underline"
368+
onclick={() => applyTaskNameFilter(run.name)}
369+
>
333370
{run.name}
334-
</a>
371+
</button>
335372
</dd>
336373
</div>
337374
<div class="flex gap-2">
@@ -341,12 +378,19 @@
341378
<div class="flex gap-2">
342379
<dt class="text-slate-500">Task ID:</dt>
343380
<dd>
344-
<a
345-
href={`/tasks/${run.id}`}
346-
class="rounded bg-blue-50 px-1 py-0.5 font-mono text-xs text-blue-700 hover:underline"
381+
<button
382+
type="button"
383+
class="cursor-pointer rounded bg-blue-50 px-1 py-0.5 text-left font-mono text-xs text-blue-700 hover:underline"
384+
onclick={() => applyTaskIdFilter(run.id)}
385+
onmouseenter={() => {
386+
hoveredTaskId = run.id;
387+
}}
388+
onmouseleave={() => {
389+
hoveredTaskId = null;
390+
}}
347391
>
348392
{run.id}
349-
</a>
393+
</button>
350394
</dd>
351395
</div>
352396
<div class="flex gap-2">

0 commit comments

Comments
 (0)