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
42 changes: 32 additions & 10 deletions bun.lock

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

3 changes: 2 additions & 1 deletion desktop/pi-desktop-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ async function persistHostThreadUpdate(event: Extract<DesktopEvent, { type: 'thr
}
setThreadRunningState(
event.sessionPath,
event.reason === 'update' ||
event.thread.isStreaming ||
event.thread.isCompacting ||
event.reason === 'compaction-start' ||
(event.reason === 'start' && event.thread.messages.length > 0),
)
Expand Down
2 changes: 1 addition & 1 deletion desktop/pi-threads/session-index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ export function mapSessionSummaryToRecord(cwd: string, session: SessionSummary)
id: session.id,
cwd: session.cwd || cwd,
sessionPath: session.path,
title: normalizeThreadTitle(session.firstMessage || session.name),
title: normalizeThreadTitle(session.name || session.firstMessage),
lastModifiedMs: session.modified.getTime(),
}
}
Expand Down
20 changes: 20 additions & 0 deletions desktop/pi-threads/thread-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
import { deleteArtifactsForConversation } from '../artifact-state-db.ts'
import { deleteChatThread } from '../chat-state-db.ts'
import { openThreadRuntime, startNewThread } from '../pi-desktop-runtime.ts'
import { invokeRuntimeHost } from '../runtime-host/client-bridge.ts'
import {
addProjectUsageTotals,
archiveThread,
Expand All @@ -26,6 +27,7 @@ import {
getThreadDeletionSnapshot,
getThreadSessionPath,
markInboxThreadRead,
renameThreadTitle,
restoreThread,
restoreThreads,
toggleThreadPinned,
Expand Down Expand Up @@ -201,6 +203,23 @@ async function deleteManyThreadsFromPayload(payload: AnyDesktopActionPayload) {
return handledAction({ deletedThreadIds: deleteResult.deletedThreadIds })
}

function getRenameValue(payload: AnyDesktopActionPayload) {
return typeof payload.value === 'string' ? payload.value.trim() : ''
}

async function renameThreadFromPayload(payload: AnyDesktopActionPayload) {
const threadId = getThreadId(payload)
const name = getRenameValue(payload)
if (!(threadId && name)) return handledAction()

const sessionPath = getSessionPath(payload) ?? getThreadSessionPath(threadId)
if (!sessionPath) return handledAction({ error: 'Thread session not found.' })

const result = await invokeRuntimeHost('renameThreadSession', { sessionPath, name })
renameThreadTitle(threadId, result.title)
return handledAction({ ...result, sessionPath, threadId })
}

const threadActionHandlers = {
'thread.pin': (payload) => {
const threadId = getThreadId(payload)
Expand Down Expand Up @@ -246,6 +265,7 @@ const threadActionHandlers = {
return handledAction()
},
'thread.delete-many': deleteManyThreadsFromPayload,
'thread.rename': renameThreadFromPayload,
'thread.new': async (payload) => {
const result = await startNewThread(getComposerRequest(payload))
const branchName = getBranchName(payload)
Expand Down
6 changes: 5 additions & 1 deletion desktop/runtime-host/host-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,8 @@ export {
} from './skill-creator-service.ts'
export { loadPiThemeStateInHost as loadPiThemeState } from './theme-service.ts'
export { loadThreadPreviewAtEntry } from './thread-preview-service.ts'
export { loadThreadSnapshot, searchThreadSnapshot } from './thread-snapshot-service.ts'
export {
loadThreadSnapshot,
renameThreadSession,
searchThreadSnapshot,
} from './thread-snapshot-service.ts'
4 changes: 2 additions & 2 deletions desktop/runtime-host/live-runtime-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export async function createLiveRuntime(
ProjectTrustStore,
createAgentSession,
getAgentDir,
hasProjectTrustInputs,
hasTrustRequiringProjectResources,
} = await getPiModule()
const agentDir = getAgentDir()
const defaultProjectTrust = getRuntimeDefaultProjectTrust({
Expand All @@ -59,7 +59,7 @@ export async function createLiveRuntime(
agentDir,
cwd: options.cwd,
defaultProjectTrust,
hasProjectTrustInputs,
hasTrustRequiringProjectResources,
settingsCwd: options.settingsCwd,
})
const authStorage = AuthStorage.create()
Expand Down
1 change: 1 addition & 0 deletions desktop/runtime-host/live-thread-publisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ function buildLiveThreadData(runtime: PiRuntime) {
return buildThreadData({
sessionPath,
sourceMessages,
sessionName: runtime.session.sessionManager.getSessionName(),
previousMessageCount: historySlice.previousMessageCount,
isStreaming: runtime.session.isStreaming,
isCompacting: runtime.session.isCompacting,
Expand Down
2 changes: 2 additions & 0 deletions desktop/runtime-host/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export type RuntimeHostRequestMap = {
historyCompactions?: number | undefined
}
searchThreadSnapshot: { sessionPath: string; query: string }
renameThreadSession: { sessionPath: string; name: string }
startSkillCreatorSession: {
prompt: string
local?: boolean | undefined
Expand Down Expand Up @@ -188,6 +189,7 @@ export type RuntimeHostResponseMap = {
thread: ThreadData
}
searchThreadSnapshot: ThreadSearchResult
renameThreadSession: { projectId: string; threadId: string; title: string }
startSkillCreatorSession: SkillCreatorSessionState
continueSkillCreatorSession: SkillCreatorSessionState
closeSkillCreatorSession: { ok: boolean }
Expand Down
2 changes: 2 additions & 0 deletions desktop/runtime-host/request-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
openThreadRuntime,
removePiPackage,
removePiSkill,
renameThreadSession,
searchThreadSnapshot,
selectProjectRuntime,
sendComposerPrompt,
Expand Down Expand Up @@ -75,6 +76,7 @@ const runtimeHostRequestHandlers = {
openThreadRuntime: (payload) => openThreadRuntime(payload.request),
removePiPackage: (payload) => removePiPackage(payload),
removePiSkill: (payload) => removePiSkill(payload),
renameThreadSession: (payload) => renameThreadSession(payload),
searchThreadSnapshot: (payload) => searchThreadSnapshot(payload),
selectProjectRuntime: (payload) => selectProjectRuntime(payload.request),
sendComposerPrompt: (payload) => sendComposerPrompt(payload),
Expand Down
Loading