MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / getTaskWithId

Method getTaskWithId

src/core/webview/ClineProvider.ts:1880–1924  ·  view source on GitHub ↗
(id: string)

Source from the content-addressed store, hash-verified

1878 // Task history
1879
1880 async getTaskWithId(id: string): Promise<{
1881 historyItem: HistoryItem
1882 taskDirPath: string
1883 apiConversationHistoryFilePath: string
1884 uiMessagesFilePath: string
1885 apiConversationHistory: Anthropic.MessageParam[]
1886 }> {
1887 const historyItem =
1888 this.taskHistoryStore.get(id) ?? (this.getGlobalState("taskHistory") ?? []).find((item) => item.id === id)
1889
1890 if (!historyItem) {
1891 throw new Error("Task not found")
1892 }
1893
1894 const { getTaskDirectoryPath } = await import("../../utils/storage")
1895 const globalStoragePath = this.contextProxy.globalStorageUri.fsPath
1896 const taskDirPath = await getTaskDirectoryPath(globalStoragePath, id)
1897 const apiConversationHistoryFilePath = path.join(taskDirPath, GlobalFileNames.apiConversationHistory)
1898 const uiMessagesFilePath = path.join(taskDirPath, GlobalFileNames.uiMessages)
1899 const fileExists = await fileExistsAtPath(apiConversationHistoryFilePath)
1900
1901 let apiConversationHistory: Anthropic.MessageParam[] = []
1902
1903 if (fileExists) {
1904 try {
1905 apiConversationHistory = JSON.parse(await fs.readFile(apiConversationHistoryFilePath, "utf8"))
1906 } catch (error) {
1907 console.warn(
1908 `[getTaskWithId] api_conversation_history.json corrupted for task ${id}, returning empty history: ${error instanceof Error ? error.message : String(error)}`,
1909 )
1910 }
1911 } else {
1912 console.warn(
1913 `[getTaskWithId] api_conversation_history.json missing for task ${id}, returning empty history`,
1914 )
1915 }
1916
1917 return {
1918 historyItem,
1919 taskDirPath,
1920 apiConversationHistoryFilePath,
1921 uiMessagesFilePath,
1922 apiConversationHistory,
1923 }
1924 }
1925
1926 async getTaskWithAggregatedCosts(taskId: string): Promise<{
1927 historyItem: HistoryItem

Callers 10

onTaskAbortedMethod · 0.95
removeClineFromStackMethod · 0.95
showTaskWithIdMethod · 0.95
exportTaskWithIdMethod · 0.95
deleteTaskWithIdMethod · 0.95
collectChildIdsMethod · 0.95
cancelTaskMethod · 0.95

Calls 8

getGlobalStateMethod · 0.95
fileExistsAtPathFunction · 0.90
getTaskDirectoryPathFunction · 0.85
parseMethod · 0.80
getMethod · 0.65
warnMethod · 0.65
StringInterface · 0.50
readFileMethod · 0.45

Tested by

no test coverage detected