feat(7833): each moment declares which kinds of record its search may consider, editable in Settings > Moments
CI & Build / Python lint (push) Successful in 3s
CI & Build / Plugin hooks (push) Successful in 15s
CI & Build / TypeScript typecheck (push) Successful in 34s
CI & Build / Python tests (push) Failing after 1m35s
CI & Build / integration (push) Successful in 1m58s
CI & Build / Build & push image (push) Skipped
CI & Build / Python lint (push) Successful in 3s
CI & Build / Plugin hooks (push) Successful in 15s
CI & Build / TypeScript typecheck (push) Successful in 34s
CI & Build / Python tests (push) Failing after 1m35s
CI & Build / integration (push) Successful in 1m58s
CI & Build / Build & push image (push) Skipped
The kind x moment table (services/record_kinds.py): - every record search fires at a door: the operator message, or a catalog moment (work.change for the write path); - each door considers a set of kinds (snippet, note, lesson, process, task:issue/work/spike/plan); a kind left out is never searched there; - the shipped defaults are today's behaviour; a user's change is stored per door, and putting a door back removes it. Both note arms read it, replacing their fixed kind lists, and a reserved slot whose kind is turned off is not reserved. The review re-run searches the same kinds. Settings > Moments shows and edits the table, with each cell's lines shown and opens from the record ledger. list_moments returns it as record_kinds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { apiGet, apiPost, apiDelete } from "@/api/client";
|
||||
import { apiGet, apiPost, apiPut, apiDelete } from "@/api/client";
|
||||
import type { RuleEnforcement, RuleSalience, RuleTrigger } from "@/api/rulebooks";
|
||||
|
||||
/**
|
||||
@@ -279,6 +279,37 @@ export interface AdherencePayload {
|
||||
by_moment: MomentAdherenceRow[];
|
||||
}
|
||||
|
||||
/** One door of the kind×moment table: where a record search fires, and
|
||||
* the kinds of record it may consider. */
|
||||
export interface RecordKindsDoor {
|
||||
/** A catalog moment, or `message` for the operator's message. */
|
||||
door: string;
|
||||
label: string;
|
||||
fires: string;
|
||||
kinds: string[];
|
||||
default: string[];
|
||||
/** The user changed this door; otherwise it follows the shipped default. */
|
||||
changed: boolean;
|
||||
/** Lines this door pushed of each kind, and how many were opened. */
|
||||
evidence: Record<string, WayCounts>;
|
||||
}
|
||||
|
||||
export interface RecordKindsTable {
|
||||
days: number;
|
||||
evidence_failed: boolean;
|
||||
kinds: { kind: string; label: string }[];
|
||||
doors: RecordKindsDoor[];
|
||||
}
|
||||
|
||||
export function getRecordKinds(days = 30): Promise<RecordKindsTable> {
|
||||
return apiGet(`/api/retrieval/record-kinds?days=${days}`);
|
||||
}
|
||||
|
||||
/** `kinds: null` puts the door back to its shipped default. */
|
||||
export function setRecordKinds(door: string, kinds: string[] | null): Promise<RecordKindsTable> {
|
||||
return apiPut("/api/retrieval/record-kinds", { door, kinds });
|
||||
}
|
||||
|
||||
/** How a record arrived in front of a session. */
|
||||
export type RecordWay = "pushed" | "asked" | "direct";
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import { useMomentsStore } from "@/stores/moments";
|
||||
import MomentProposals from "@/components/MomentProposals.vue";
|
||||
import MomentRuleUsage from "@/components/MomentRuleUsage.vue";
|
||||
import WeightProposals from "@/components/WeightProposals.vue";
|
||||
import RecordKinds from "@/components/RecordKinds.vue";
|
||||
import RecordReach from "@/components/RecordReach.vue";
|
||||
import RuleAdherence from "@/components/RuleAdherence.vue";
|
||||
import { getAdherence, getRecordReach } from "@/api/moments";
|
||||
@@ -172,6 +173,7 @@ onMounted(async () => {
|
||||
<WeightProposals />
|
||||
<RuleAdherence :data="adherence" :failed="adherenceFailed" @retry="loadAdherence" />
|
||||
<RecordReach :data="reach" :failed="reachFailed" @retry="loadReach" />
|
||||
<RecordKinds :days="days" />
|
||||
|
||||
<ul class="moment-list">
|
||||
<li v-for="m in catalog" :key="m.name" class="moment-row">
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from "vue";
|
||||
import { apiErrorMessage } from "@/api/client";
|
||||
import { getRecordKinds, setRecordKinds } 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.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
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
|
||||
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>
|
||||
<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" 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" />
|
||||
Reference in New Issue
Block a user