Radish alpha
r
Radicle desktop app
Radicle
Git (anonymous pull)
Log in to clone via SSH
Fix CID compute hang and add OID autocomplete
Daniel Norman committed 7 days ago
commit aa91ec508fd65053a50865e34acc57101dd83910
parent cf005da3b89d9b70c92abb85dbcead93ef27edfb
1 file changed +33 -6
modified src/views/repo/NewRelease.svelte
@@ -8,8 +8,12 @@
  //   4. submit: create_or_open_release, then add_artifact per file,
  //      and seed_artifact if the auto-seed setting is on

+
  import type { PaginatedQuery } from "@bindings/cob/PaginatedQuery";
+
  import type { Commit } from "@bindings/repo/Commit";
  import type { RepoInfo } from "@bindings/repo/RepoInfo";

+
  import { onMount } from "svelte";
+

  import { invoke } from "@app/lib/invoke";
  import * as router from "@app/lib/router";

@@ -33,11 +37,25 @@
  let submitting = $state(false);
  let autoSeed = $state(true);
  let submitError: string | undefined = $state();
+
  // Recent commits offered as autocomplete suggestions for the OID input.
+
  let commits = $state<Commit[]>([]);

  void invoke<boolean>("get_auto_seed_artifacts").then(v => {
    autoSeed = v;
  });

+
  onMount(async () => {
+
    try {
+
      const result = await invoke<PaginatedQuery<Commit[]>>(
+
        "list_repo_commits",
+
        { rid: repo.rid, skip: 0, take: 50 },
+
      );
+
      commits = result.content;
+
    } catch (err) {
+
      console.error("list_repo_commits failed", err);
+
    }
+
  });
+

  async function pickFiles() {
    const picked = await invoke<string[]>("pick_artifact_files");
    for (const p of picked) {
@@ -52,18 +70,21 @@

  async function stageFile(path: string) {
    const baseName = path.split(/[\\/]/).filter(Boolean).pop() ?? path;
-
    const entry: StagedFile = {
+
    const idx = files.length;
+
    files.push({
      path,
      name: baseName,
      computing: true,
-
    };
-
    files.push(entry);
+
    });
+
    // After push, files[idx] returns Svelte 5's reactive proxy view of the
+
    // entry — write through that handle, not a local reference, otherwise
+
    // mutations don't trigger re-renders and the row spins forever.
    try {
-
      entry.cid = await invoke<string>("compute_artifact_cid", { path });
+
      files[idx].cid = await invoke<string>("compute_artifact_cid", { path });
    } catch (err) {
-
      entry.error = String(err);
+
      files[idx].error = String(err);
    } finally {
-
      entry.computing = false;
+
      files[idx].computing = false;
    }
  }

@@ -213,8 +234,14 @@
      id="release-oid"
      type="text"
      placeholder="e.g. ec49ecb..."
+
      list="release-oid-options"
      bind:value={oid}
      disabled={submitting} />
+
    <datalist id="release-oid-options">
+
      {#each commits as commit (commit.id)}
+
        <option value={commit.id} label={commit.summary}></option>
+
      {/each}
+
    </datalist>
  </div>

  <div class="field">