Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "codenomad-workspace",
"version": "0.7.0",
"version": "0.7.1",
"private": true,
"description": "CodeNomad monorepo workspace",
"workspaces": {
Expand Down
2 changes: 1 addition & 1 deletion packages/electron-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@neuralnomads/codenomad-electron-app",
"version": "0.7.0",
"version": "0.7.1",
"description": "CodeNomad - AI coding assistant",
"author": {
"name": "Neural Nomads",
Expand Down
2 changes: 1 addition & 1 deletion packages/opencode-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"version": "0.5.0",
"private": true,
"dependencies": {
"@opencode-ai/plugin": "1.1.12"
"@opencode-ai/plugin": "1.1.16"
}
}
4 changes: 2 additions & 2 deletions packages/server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@neuralnomads/codenomad",
"version": "0.7.0",
"version": "0.7.1",
"description": "CodeNomad Server",
"author": {
"name": "Neural Nomads",
Expand Down
2 changes: 1 addition & 1 deletion packages/tauri-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@codenomad/tauri-app",
"version": "0.7.0",
"version": "0.7.1",
"private": true,
"scripts": {
"dev": "tauri dev",
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@codenomad/ui",
"version": "0.7.0",
"version": "0.7.1",
"private": true,
"type": "module",
"scripts": {
Expand Down
16 changes: 14 additions & 2 deletions packages/ui/src/components/message-block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,20 @@ interface TaskSessionLocation {
parentId: string | null
}

function findTaskSessionLocation(sessionId: string): TaskSessionLocation | null {
function findTaskSessionLocation(sessionId: string, preferredInstanceId?: string): TaskSessionLocation | null {
if (!sessionId) return null

if (preferredInstanceId) {
const session = sessions().get(preferredInstanceId)?.get(sessionId)
if (session) {
return {
sessionId: session.id,
instanceId: preferredInstanceId,
parentId: session.parentId ?? null,
}
}
}

const allSessions = sessions()
for (const [instanceId, sessionMap] of allSessions) {
const session = sessionMap?.get(sessionId)
Expand Down Expand Up @@ -440,7 +452,7 @@ export default function MessageBlock(props: MessageBlockProps) {
const hasToolState =
Boolean(toolState) && (isToolStateRunning(toolState) || isToolStateCompleted(toolState) || isToolStateError(toolState))
const taskSessionId = hasToolState ? extractTaskSessionId(toolState) : ""
const taskLocation = taskSessionId ? findTaskSessionLocation(taskSessionId) : null
const taskLocation = taskSessionId ? findTaskSessionLocation(taskSessionId, props.instanceId) : null
const handleGoToTaskSession = (event: MouseEvent) => {
event.preventDefault()
event.stopPropagation()
Expand Down
11 changes: 9 additions & 2 deletions packages/ui/src/components/permission-approval-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
setActivePermissionIdForInstance,
setActiveQuestionIdForInstance,
} from "../stores/instances"
import { loadMessages, setActiveSession } from "../stores/sessions"
import { ensureSessionParentExpanded, loadMessages, sessions as sessionStateSessions, setActiveSessionFromList } from "../stores/sessions"
import { messageStoreBus } from "../stores/message-v2/bus"
import ToolCall from "./tool-call"

Expand Down Expand Up @@ -201,7 +201,14 @@ const PermissionApprovalModal: Component<PermissionApprovalModalProps> = (props)

function handleGoToSession(sessionId: string) {
if (!sessionId) return
setActiveSession(props.instanceId, sessionId)

const session = sessionStateSessions().get(props.instanceId)?.get(sessionId)
const parentId = session?.parentId ?? session?.id
if (parentId) {
ensureSessionParentExpanded(props.instanceId, parentId)
}

setActiveSessionFromList(props.instanceId, sessionId)
props.onClose()
}

Expand Down
86 changes: 78 additions & 8 deletions packages/ui/src/components/session/session-view.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Show, For, createMemo, createEffect, type Component } from "solid-js"
import { Expand } from "lucide-solid"
import type { Session } from "../../types/session"
import type { Attachment } from "../../types/attachment"
import type { ClientPart } from "../../types/message"
import MessageSection from "../message-section"
import { messageStoreBus } from "../../stores/message-v2/bus"
import PromptInput from "../prompt-input"
import AttachmentChip from "../attachment-chip"
import type { Attachment as PromptAttachment } from "../../types/attachment"
import { getAttachments, removeAttachment } from "../../stores/attachments"
import { instances } from "../../stores/instances"
import { loadMessages, sendMessage, forkSession, isSessionMessagesLoading, setActiveParentSession, setActiveSession, runShellCommand, abortSession } from "../../stores/sessions"
Expand Down Expand Up @@ -49,6 +50,54 @@ export const SessionView: Component<SessionViewProps> = (props) => {
})

const attachments = createMemo(() => getAttachments(props.instanceId, props.sessionId))

function handleExpandTextAttachment(attachment: PromptAttachment) {
if (attachment.source.type !== "text") return

const textarea = rootRef?.querySelector(".prompt-input") as HTMLTextAreaElement | null
const value = attachment.source.value
const match = attachment.display.match(/pasted #(\d+)/)
const placeholder = match ? `[pasted #${match[1]}]` : null

const currentText = textarea?.value ?? ""

let nextText = currentText
let selectionTarget: number | null = null

if (placeholder) {
const placeholderIndex = currentText.indexOf(placeholder)
if (placeholderIndex !== -1) {
nextText =
currentText.substring(0, placeholderIndex) +
value +
currentText.substring(placeholderIndex + placeholder.length)
selectionTarget = placeholderIndex + value.length
}
}

if (nextText === currentText) {
if (textarea) {
const start = textarea.selectionStart
const end = textarea.selectionEnd
nextText = currentText.substring(0, start) + value + currentText.substring(end)
selectionTarget = start + value.length
} else {
nextText = currentText + value
}
}

if (textarea) {
textarea.value = nextText
textarea.dispatchEvent(new Event("input", { bubbles: true }))
textarea.focus()
if (selectionTarget !== null) {
textarea.setSelectionRange(selectionTarget, selectionTarget)
}
}

removeAttachment(props.instanceId, props.sessionId, attachment.id)
}

let scrollToBottomHandle: (() => void) | undefined
let rootRef: HTMLDivElement | undefined
function scheduleScrollToBottom() {
Expand Down Expand Up @@ -235,14 +284,35 @@ export const SessionView: Component<SessionViewProps> = (props) => {


<Show when={attachments().length > 0}>
<div class="flex flex-wrap gap-1.5 border-t px-3 py-2" style="border-color: var(--border-base);">
<div class="flex flex-wrap items-center gap-1.5 border-t px-3 py-2" style="border-color: var(--border-base);">
<For each={attachments()}>
{(attachment) => (
<AttachmentChip
attachment={attachment}
onRemove={() => removeAttachment(props.instanceId, props.sessionId, attachment.id)}
/>
)}
{(attachment) => {
const isText = attachment.source.type === "text"
return (
<div class="attachment-chip" title={attachment.source.type === "file" ? attachment.source.path : undefined}>
<span class="font-mono">{attachment.display}</span>
<Show when={isText}>
<button
type="button"
class="attachment-expand"
onClick={() => handleExpandTextAttachment(attachment)}
aria-label="Expand pasted text"
title="Insert pasted text"
>
<Expand class="h-3 w-3" aria-hidden="true" />
</button>
</Show>
<button
type="button"
class="attachment-remove"
onClick={() => removeAttachment(props.instanceId, props.sessionId, attachment.id)}
aria-label="Remove attachment"
>
×
</button>
</div>
)
}}
</For>
</div>
</Show>
Expand Down