()
| 358 | |
| 359 | function Debug() { |
| 360 | const plugin = usePlugin(); |
| 361 | const ctx = useRunAsync( |
| 362 | async () => await plugin.widget.getWidgetContext<WidgetLocation.Popup>(), |
| 363 | [] |
| 364 | ); |
| 365 | const remId = ctx?.contextData?.remId; |
| 366 | const [refreshKey, setRefreshKey] = useState(0); |
| 367 | const [isEditingHistory, setIsEditingHistory] = useState(false); |
| 368 | const [historyDraft, setHistoryDraft] = useState(''); |
| 369 | const [historyError, setHistoryError] = useState<string | null>(null); |
| 370 | const [isSavingHistory, setIsSavingHistory] = useState(false); |
| 371 | |
| 372 | // Synced-storage key audit (RemNote caps plugins at 1000 synced keys). |
| 373 | const [keyAudit, setKeyAudit] = useState<AuditResult | null>(null); |
| 374 | const [keyAuditProgress, setKeyAuditProgress] = useState(''); |
| 375 | const [isAuditingKeys, setIsAuditingKeys] = useState(false); |
| 376 | const [capacityReport, setCapacityReport] = useState<CapacityReport | null>(null); |
| 377 | const [nullTestReport, setNullTestReport] = useState<NullFreesSlotReport | null>(null); |
| 378 | const [limitReport, setLimitReport] = useState<PerKeyLimitReport | null>(null); |
| 379 | // Per-key anatomy: which key's bytes to break down. Defaults to the largest key |
| 380 | // in the KB — the pre-shard `flashcardHistoryData` holds [] since it was drained |
| 381 | // into per-KB shards, so naming it would only ever report an empty array. |
| 382 | const [anatomyKey, setAnatomyKey] = useState(AUTHORITATIVE_AGGREGATES_KEY); |
| 383 | const [anatomy, setAnatomy] = useState<ArrayKeyAnatomy | null>(null); |
| 384 | // Shard names embed a 24-character kbId, so offer them as one click rather than |
| 385 | // asking for them to be typed. |
| 386 | const currentKbId = useTrackerPlugin( |
| 387 | async (rp) => (await rp.kb.getCurrentKnowledgeBaseData())?._id, |
| 388 | [] |
| 389 | ); |
| 390 | |
| 391 | const debugData = useTrackerPlugin( |
| 392 | async (rp) => { |
| 393 | const rem = await rp.rem.findOne(remId); |
| 394 | if (!rem) return null; |
| 395 | |
| 396 | const incrementalRem = await getIncrementalRemFromRem(rp, rem); |
| 397 | |
| 398 | // Lightweight diagnostic probe of the Incremental DATE slots. Reports whether each |
| 399 | // slot's Daily Doc reference round-trips back to a date — some daily-doc rems carry |
| 400 | // the DailyDocument powerup but an empty 'Date' property, which is why interval-0 |
| 401 | // (today-referenced) rems don't resolve from the reference and rely on the |
| 402 | // history `nextRepMs` fallback instead. |
| 403 | const probeDateSlot = async (slotCode: string) => { |
| 404 | try { |
| 405 | const richText = (await rem.getPowerupPropertyAsRichText( |
| 406 | powerupCode, |
| 407 | slotCode |
| 408 | )) as RichTextElementRemInterface[]; |
| 409 | const firstId = richText?.[0]?._id; |
| 410 | let dailyDocDate: string | null = null; |
| 411 | let refRemText: string | null = null; |
| 412 | if (firstId) { |
| 413 | const refRem = await rp.rem.findOne(firstId); |
| 414 | if (refRem) { |
| 415 | dailyDocDate = |
| 416 | (await refRem.getPowerupProperty<BuiltInPowerupCodes.DailyDocument>( |
| 417 | BuiltInPowerupCodes.DailyDocument, |
nothing calls this directly
no test coverage detected