mirror of
https://github.com/stablyai/orca.git
synced 2026-11-19 04:23:57 +00:00
* feat(plugins): orca plugin dev request; --template worker-panel - orca plugin dev request <dir|key> <name> [--data] [--panel] [--timeout-ms] calls a dev plugin's orca.panels.handle handler through the real panel bridge (plugins.devRequest) and prints the answer; handler errors become plugin_request_failed with the worker's code. - orca plugin create --template worker-panel scaffolds a build-less trusted-worker plugin: a components panel, src/worker.ts, a shared src/protocol.ts contract, and panel and worker tests that pass under orca plugin test and type-check with tsc. * feat(plugins): shot --act, shots in the plugin folder, quieter logs - orca plugin shot --act '<json>' presses, types, selects and toggles in the live components panel (the test kit's queries and acts, through Orca's own controls and onEvent) before the capture, waiting for each to settle. Only that plugin's panel, only with Orca's window hidden or minimized; html panels refused; acts are not user gestures. Results in actions[]. - shot run inside a plugin folder defaults to its .orca/shots, like dev watch --shot. - dev watch prints identical [frame] lines once per reload with a count; logged stacks drop <anonymous>/native frames; the floating workspace button hides during a capture. - Skill: worker-panel template in the decision table, dev request, shot --act, and a gotcha that a worker save drops its in-memory state.
38 lines
1.8 KiB
TypeScript
38 lines
1.8 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
||
import { formatPluginDevWatchEvent } from './plugin-dev-watch-events'
|
||
import { PluginFrameLogDedupe } from './plugin-frame-log-dedupe'
|
||
|
||
const line = (ts: number, text: string, level = 'warn') => ({ ts, level, line: text })
|
||
const KEY_WARNING = '[frame] Each child in a list should have a unique "key"'
|
||
|
||
describe('PluginFrameLogDedupe', () => {
|
||
it('prints a repeated panel line once per reload with its count, then the later copies', () => {
|
||
const dedupe = new PluginFrameLogDedupe()
|
||
expect(
|
||
dedupe.take([line(1, KEY_WARNING), line(2, 'worker tick', 'info'), line(3, KEY_WARNING)])
|
||
).toEqual([{ ...line(1, KEY_WARNING), count: 2 }, line(2, 'worker tick', 'info')])
|
||
// Worker lines are never folded; the panel line already printed this reload is only counted.
|
||
expect(
|
||
dedupe.take([line(4, KEY_WARNING), line(5, 'worker tick', 'info'), line(6, KEY_WARNING)])
|
||
).toEqual([line(5, 'worker tick', 'info')])
|
||
expect(dedupe.flush()).toEqual([{ ...line(6, KEY_WARNING), count: 2, repeat: true }])
|
||
// A new reload prints it again.
|
||
expect(dedupe.take([line(7, KEY_WARNING)])).toEqual([line(7, KEY_WARNING)])
|
||
expect(dedupe.flush()).toEqual([])
|
||
})
|
||
|
||
it('keeps the same text at another level apart', () => {
|
||
const dedupe = new PluginFrameLogDedupe()
|
||
expect(dedupe.take([line(1, '[frame] boom'), line(2, '[frame] boom', 'error')])).toHaveLength(2)
|
||
})
|
||
|
||
it('shows the count after the line', () => {
|
||
const base = { type: 'log' as const, pluginKey: 'acme.todos', ts: 0, level: 'warn', line: 'x' }
|
||
expect(formatPluginDevWatchEvent({ ...base, count: 3 })).toMatch(/warn {2}x ×3$/)
|
||
expect(formatPluginDevWatchEvent({ ...base, count: 4, repeat: true })).toMatch(
|
||
/warn {2}x \(×4 more\)$/
|
||
)
|
||
expect(formatPluginDevWatchEvent(base)).toMatch(/warn {2}x$/)
|
||
})
|
||
})
|