mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
feat: add multi-run fusion and session change walkthroughs
Fuse two to five completed multi-run entries into one synthesized session, and explain a session's diff as ordered walkthrough stops cached by diff hash. - Multi-run fusion service, persistence, routes and FuseRunDialog - Change walkthrough service, persistence, routes and ChangesWalkthroughDialog - Shared unified-diff parser plus bounded text generation, json-extract, text-truncate and service-error helpers
This commit is contained in:
1 parent
90c6ccf236
commit
b36d412ca2
66 files changed
+6228
-468
No files matched your search
@@ -0,0 +1,40 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { extractFirstJsonObject } from '../../src/utils/json-extract'
|
||||
|
||||
describe('extractFirstJsonObject', () => {
|
||||
it('returns a plain JSON object', () => {
|
||||
expect(extractFirstJsonObject('{"a":1}')).toBe('{"a":1}')
|
||||
})
|
||||
|
||||
it('returns the first object when several are present', () => {
|
||||
expect(extractFirstJsonObject('prefix {"a":1} middle {"b":2} suffix')).toBe('{"a":1}')
|
||||
})
|
||||
|
||||
it('ignores prose before and after the object', () => {
|
||||
expect(extractFirstJsonObject('Here you go:\n{"a":1}\nThanks')).toBe('{"a":1}')
|
||||
})
|
||||
|
||||
it('matches nested braces', () => {
|
||||
expect(extractFirstJsonObject('{"a":{"b":{"c":1}},"d":2}')).toBe('{"a":{"b":{"c":1}},"d":2}')
|
||||
})
|
||||
|
||||
it('ignores braces inside strings', () => {
|
||||
expect(extractFirstJsonObject('{"a":"}{","b":1}')).toBe('{"a":"}{","b":1}')
|
||||
})
|
||||
|
||||
it('handles escaped quotes inside strings', () => {
|
||||
expect(extractFirstJsonObject('{"a":"a \\" b","c":2}')).toBe('{"a":"a \\" b","c":2}')
|
||||
})
|
||||
|
||||
it('returns null when there is no object', () => {
|
||||
expect(extractFirstJsonObject('no object here')).toBeNull()
|
||||
})
|
||||
|
||||
it('returns null for an unterminated object', () => {
|
||||
expect(extractFirstJsonObject('{"a":1')).toBeNull()
|
||||
})
|
||||
|
||||
it('returns null when a string is left open', () => {
|
||||
expect(extractFirstJsonObject('{"a":"unterminated}')).toBeNull()
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,24 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { truncateText } from '../../src/utils/text-truncate'
|
||||
|
||||
describe('truncateText', () => {
|
||||
it('returns text unchanged when it is within the limit', () => {
|
||||
expect(truncateText('hello', 10, '[cut]')).toEqual({ text: 'hello', truncated: false })
|
||||
})
|
||||
|
||||
it('returns text unchanged when it is exactly at the limit', () => {
|
||||
expect(truncateText('hello', 5, '[cut]')).toEqual({ text: 'hello', truncated: false })
|
||||
})
|
||||
|
||||
it('slices to the limit, appends the marker and reports truncation', () => {
|
||||
expect(truncateText('hello world', 5, '…')).toEqual({ text: 'hello…', truncated: true })
|
||||
})
|
||||
|
||||
it('supports a zero limit', () => {
|
||||
expect(truncateText('hello', 0, '[cut]')).toEqual({ text: '[cut]', truncated: true })
|
||||
})
|
||||
|
||||
it('leaves empty text untouched', () => {
|
||||
expect(truncateText('', 5, '[cut]')).toEqual({ text: '', truncated: false })
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user