Files
FabledGrimoire/frontend/src/components/RecordKinds.vue
T
bvandeusenandClaude Opus 5.5 30aa5cf1c6
CI & Build / TypeScript typecheck (push) Successful in 32s
CI & Build / Plugin hooks (push) Successful in 17s
CI & Build / Python lint (push) Successful in 3s
CI & Build / Python tests (push) Failing after 2m0s
CI & Build / Build & push image (push) Canceled after 0s
CI & Build / integration (push) Canceled after 2m7s
feat(8191): knowledge reaches a session from every project, ranked below its own and labelled
A per-kind reach beside the kind-by-moment table (setting record_reach,
default snippet/note/process/lesson) widens the passive note arms and their
slots to the user's other projects. A record from elsewhere gives up 0.05
before the floor and the ranking, and its line names the project. Work kinds
stay in their project, the visibility clause is unchanged, and an explicit
project search still means that project. Settings > Moments edits the reach.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-28 17:20:31 -05:00

186 lines
7.3 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup lang="ts">
import { onMounted, ref } from "vue";
import { apiErrorMessage } from "@/api/client";
import { getRecordKinds, setRecordKinds, setRecordKindsReach } from "@/api/moments";
import type { RecordKindsDoor, RecordKindsTable } from "@/api/moments";
/**
* The kind×moment table: for each point where a record search fires, which
* kinds of record it may consider. A kind left unticked is never pushed
* there; a session can still search for it. Each box shows the lines that
* door pushed of that kind and how many were opened, so a change is made
* against its own evidence. A change saves as soon as it is made.
*
* Above the doors: which kinds may also come from the user's other projects.
* Knowledge crosses by default and work stays in its project; a record from
* elsewhere ranks a little below this project's own and says where it is from.
*/
const props = defineProps<{ days: number }>();
const table = ref<RecordKindsTable | null>(null);
const failed = ref(false);
const saving = ref<string | null>(null);
const saveError = ref("");
async function load() {
try {
table.value = await getRecordKinds(props.days);
failed.value = false;
} catch {
failed.value = true;
}
}
async function save(door: string, kinds: string[] | null) {
saving.value = door;
saveError.value = "";
try {
table.value = await setRecordKinds(door, kinds);
} catch (e) {
saveError.value = apiErrorMessage(e, "The change could not be saved.");
} finally {
saving.value = null;
}
}
function toggle(row: RecordKindsDoor, kind: string, on: boolean) {
const next = on ? [...row.kinds, kind] : row.kinds.filter((k) => k !== kind);
void save(row.door, next);
}
const REACH = "reach";
async function saveReach(kinds: string[] | null) {
saving.value = REACH;
saveError.value = "";
try {
table.value = await setRecordKindsReach(kinds);
} catch (e) {
saveError.value = apiErrorMessage(e, "The change could not be saved.");
} finally {
saving.value = null;
}
}
function toggleReach(kind: string, on: boolean) {
if (!table.value) return;
const now = table.value.reach.kinds;
void saveReach(on ? [...now, kind] : now.filter((k) => k !== kind));
}
function evidenceText(row: RecordKindsDoor, kind: string): string {
const c = row.evidence[kind];
return c ? `${c.opened} of ${c.delivered} opened` : "none shown";
}
onMounted(load);
</script>
<template>
<section class="kinds" aria-labelledby="kinds-title">
<h3 id="kinds-title" class="sub-title">Which records each moment considers</h3>
<p v-if="failed" class="error-msg">
The table could not be loaded.
<button type="button" class="btn-text" @click="load">Try again</button>
</p>
<p v-else-if="!table" class="empty-msg">Loading the table…</p>
<template v-else>
<p class="field-hint">
A search for records runs at each point below. An unticked kind is never shown there;
a session can still search for it. Beside each kind: lines shown there over the last
{{ table.days }} days, and how many were opened.
</p>
<p v-if="table.evidence_failed" class="error-msg">
The counts could not be read, so they are missing below, not zero.
</p>
<p v-if="saveError" class="error-msg" role="alert">{{ saveError }}</p>
<fieldset class="door" :disabled="saving === REACH">
<legend class="door-head">
<span class="door-label">Also from your other projects</span>
<span class="door-fires">at every point below, while a session works in a project</span>
<span v-if="!table.reach.changed" class="door-default">shipped default</span>
</legend>
<p class="field-hint">
A ticked kind is offered from any project you can see, not only the one the session is in.
Such a record has to be a little closer to be shown, ranks below an equally close one from
the session's project, and its line names the project it came from. An unticked kind is
offered only from the session's own project. A search the session runs itself, for one
project, still means that project.
</p>
<ul class="kind-list">
<li v-for="k in table.kinds" :key="k.kind" class="kind-cell">
<label class="kind-label">
<input
type="checkbox" :checked="table.reach.kinds.includes(k.kind)"
@change="toggleReach(k.kind, ($event.target as HTMLInputElement).checked)"
/>
{{ k.label }}
</label>
</li>
</ul>
<button v-if="table.reach.changed" type="button" class="btn-text door-reset" @click="saveReach(null)">
Back to the shipped default
</button>
</fieldset>
<fieldset
v-for="row in table.doors" :key="row.door" class="door"
:disabled="saving === row.door"
>
<legend class="door-head">
<span class="door-label">{{ row.label }}</span>
<code class="moment-name">{{ row.door }}</code>
<span class="door-fires">{{ row.fires }}</span>
<span v-if="!row.changed" class="door-default">shipped default</span>
</legend>
<p v-if="!row.measured" class="door-default">
Named by id in the reply that sets a task in progress, so there are no counts for it.
</p>
<ul class="kind-list">
<li v-for="k in table.kinds" :key="k.kind" class="kind-cell">
<label class="kind-label">
<input
type="checkbox" :checked="row.kinds.includes(k.kind)"
@change="toggle(row, k.kind, ($event.target as HTMLInputElement).checked)"
/>
{{ k.label }}
</label>
<span v-if="!table.evidence_failed && row.measured" class="kind-evidence">{{ evidenceText(row, k.kind) }}</span>
</li>
</ul>
<button v-if="row.changed" type="button" class="btn-text door-reset" @click="save(row.door, null)">
Back to the shipped default
</button>
</fieldset>
</template>
</section>
</template>
<style scoped>
.kinds { display: flex; flex-direction: column; gap: var(--fs-space-2); }
.sub-title { margin: 0; font-size: 0.95rem; color: var(--fs-text-primary); }
.door {
border: 1px solid var(--fs-border-color);
border-radius: var(--fs-radius-md);
padding: var(--fs-space-2) var(--fs-space-3);
margin: 0;
display: flex; flex-direction: column; gap: var(--fs-space-2);
}
.door:disabled { opacity: var(--fs-disabled-opacity); }
.door-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--fs-space-2); padding: 0 var(--fs-space-1); }
.door-label { font-size: var(--fs-size-body-sm); color: var(--fs-text-primary); }
.door-fires,
.door-default,
.kind-evidence { font-size: var(--fs-size-tiny); color: var(--fs-text-secondary); font-variant-numeric: tabular-nums; }
.kind-list {
list-style: none; margin: 0; padding: 0;
display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
gap: var(--fs-space-1) var(--fs-space-3);
}
.kind-cell { display: flex; flex-direction: column; }
.kind-label { display: inline-flex; align-items: center; gap: var(--fs-space-1); font-size: var(--fs-size-body-sm); cursor: pointer; }
.kind-label input:focus-visible { outline: none; box-shadow: var(--fs-focus-ring); }
.door-reset { align-self: flex-start; }
</style>
<style src="@/assets/moments-shared.css" />