import type { Thread } from '@wovin/core/thread' import { A } from '@solidjs/router' import { dateNowIso, EntityID_LENGTH, tsNearlySame } from '@wovin/core/applog' import { tryJsonParse } from '@wovin/utils/conversion' import { Logger } from 'besonders-logger' import { Collapse } from 'solid-collapse' import { createMemo, createSignal, For, Match, Show, Switch } from 'solid-js' import { tiptapToPlaintext } from '../data/note3-utils-nodeps' import { useRawThread } from '../ui/reactive' import { copyOnClick, devMode, explorerUrl, setDevMode } from '../ui/utils-ui' import { DynamicColored, HighlightSameOnHover } from './mini-components' const { WARN, LOG, DEBUG, VERBOSE, ERROR } = Logger.setup(Logger.DEBUG) // eslint-disable-line unused-imports/no-unused-vars const MAX_BEFORE_TOGGLE = -50 export function ApplogView({ thread, alwaysOpen }: { thread?: Thread alwaysOpen?: boolean } = {}) { DEBUG(``, { thread, alwaysOpen }) if (!thread) thread = useRawThread() const [showAll, setShowAll] = createSignal(false) const reversed = createMemo(() => thread.applogs .slice(showAll() ? undefined : MAX_BEFORE_TOGGLE) // TODO: make it a virtual container - e.g. https://github.com/minht11/solid-virtual-container .reverse(), ) return (
{ /* No Applogs
}> {(item, index) =>
{JSON.stringify(item)}
} */ }
setDevMode(!devMode())} > {thread.size} Applogs  –  {thread.name}
{/* cellspacing='0' cellpadding='0' */} )} > {(item, index) => { const clumpingClass = createMemo(() => reversed()[index() + 1]?.ts && tsNearlySame(reversed()[index() + 1]?.ts, item.ts) ? '' : 'pb-2', ) let valueToDisplay = item.vl const valueParsed = typeof item.vl === 'string' ? tryJsonParse(item.vl) : undefined if (valueParsed?.type === 'doc') { valueToDisplay = tiptapToPlaintext(valueParsed) } return ( ) }}
Time Agent Entity Attribute Value CID,Prev
No Applogs
{ item.ts .replace(dateNowIso().slice(0, 11), '') // remove date if it's today .slice(0, -5) // remove ms } {item.at} {/* HACK: heuristic to check for EntityID */} {typeof valueToDisplay === 'string' && valueToDisplay ? valueToDisplay : JSON.stringify(valueToDisplay)} , null
setShowAll(!showAll())} > Show {showAll() ? 'fewer' : 'all'}
) }