feat: better composer etc

This commit is contained in:
Brooklyn Nicholson
2026-05-04 22:19:16 -05:00
parent 42db075e10
commit fcce49db3f
50 changed files with 1299 additions and 668 deletions
+11 -2
View File
@@ -12,7 +12,9 @@ function asRecord(payload: unknown): Record<string, unknown> {
}
export function gatewayEventCompletedFileDiff(event: RpcEventLike): boolean {
if (event.type !== 'tool.complete') {return false}
if (event.type !== 'tool.complete') {
return false
}
const diff = asRecord(event.payload).inline_diff
return typeof diff === 'string' && diff.trim().length > 0
@@ -20,7 +22,14 @@ export function gatewayEventCompletedFileDiff(event: RpcEventLike): boolean {
export function buildGatewayLogItems(lines: readonly string[]): readonly StatusbarMenuItem[] {
if (lines.length === 0) {
return [{ className: 'text-muted-foreground', disabled: true, id: 'gateway-log-empty', label: 'No recent gateway log lines' }]
return [
{
className: 'text-muted-foreground',
disabled: true,
id: 'gateway-log-empty',
label: 'No recent gateway log lines'
}
]
}
return lines.slice(-LOG_TAIL).map((line, index) => ({
+2
View File
@@ -32,6 +32,7 @@ import {
IconGitBranch as GitBranch,
IconGitBranch as GitBranchIcon,
IconGlobe as Globe,
IconHash as Hash,
IconHelpCircle as HelpCircle,
IconPhoto as ImageIcon,
IconInfoCircle as Info,
@@ -120,6 +121,7 @@ export {
GitBranch,
GitBranchIcon,
Globe,
Hash,
HelpCircle,
ImageIcon,
Info,
+14 -4
View File
@@ -50,13 +50,18 @@ function extension(value: string) {
}
function joinPath(base: string, rel: string) {
if (!base) {return rel}
if (!base) {
return rel
}
return `${base.replace(/\/+$/, '')}/${rel.replace(/^\.?\//, '')}`
}
function pathToFileUrl(path: string) {
const encoded = path.split('/').map(part => encodeURIComponent(part)).join('/')
const encoded = path
.split('/')
.map(part => encodeURIComponent(part))
.join('/')
return `file://${encoded.startsWith('/') ? encoded : `/${encoded}`}`
}
@@ -64,7 +69,9 @@ function pathToFileUrl(path: string) {
export function localPreviewTarget(rawTarget: string, cwd?: string | null): PreviewTarget | null {
const raw = rawTarget.trim().replace(/^`|`$/g, '')
if (!raw) {return null}
if (!raw) {
return null
}
if (/^https?:\/\//i.test(raw)) {
return { kind: 'url', label: basename(raw), source: raw, url: raw }
@@ -100,7 +107,10 @@ export function localPreviewTarget(rawTarget: string, cwd?: string | null): Prev
}
}
export async function normalizeOrLocalPreviewTarget(rawTarget: string, cwd?: string | null): Promise<PreviewTarget | null> {
export async function normalizeOrLocalPreviewTarget(
rawTarget: string,
cwd?: string | null
): Promise<PreviewTarget | null> {
try {
const normalized = await window.hermesDesktop?.normalizePreviewTarget?.(rawTarget, cwd || undefined)
+1 -5
View File
@@ -1,10 +1,6 @@
import { describe, expect, it } from 'vitest'
import {
extractPreviewTargets,
previewTargetFromMarkdownHref,
stripPreviewTargets
} from './preview-targets'
import { extractPreviewTargets, previewTargetFromMarkdownHref, stripPreviewTargets } from './preview-targets'
describe('preview target detection', () => {
it('does not infer preview targets from raw paths or URLs', () => {
-1
View File
@@ -61,4 +61,3 @@ export function previewDisplayLabel(target: string): string {
return `Preview: ${escaped}`
}