{"record":{"id":"e26b368ddea969b7","repo":"NousResearch/hermes-agent","slug":"could-not-find-the-message-to-restore","errorCode":null,"errorMessage":"Could not find the message to restore.","messagePattern":"Could not find the message to restore\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/desktop/src/app/session/hooks/use-prompt-actions/rewind.ts","lineNumber":310,"sourceCode":"  truncateOrdinal: number\n  truncateMessageId?: string\n  truncateRowId?: number\n}\n\n/** Resolve the user turn to rewind to; throws with a user-facing reason. */\nexport function planRestore(messages: ChatMessage[], messageId: string, target?: RestoreTarget): RestorePlan {\n  const idIndex = messages.findIndex(m => m.id === messageId && m.role === 'user')\n\n  const fallbackIndex =\n    target?.userOrdinal === null || target?.userOrdinal === undefined\n      ? -1\n      : visibleUserIndexAtOrdinal(messages, target.userOrdinal)\n\n  const sourceIndex = idIndex >= 0 ? idIndex : fallbackIndex\n  const source = messages[sourceIndex]\n\n  if (!source || source.role !== 'user') {\n    throw new Error('Could not find the message to restore.')\n  }\n\n  const text = (chatMessageText(source).trim() || target?.text?.trim() || '').trim()\n\n  if (!text) {\n    throw new Error('Cannot restore an empty message.')\n  }\n\n  const truncateOrdinal =\n    target?.userOrdinal === null || target?.userOrdinal === undefined\n      ? visibleUserOrdinal(messages, sourceIndex)\n      : target.userOrdinal\n\n  return { sourceIndex, text, truncateOrdinal, truncateMessageId: source.id, truncateRowId: source.rowId }\n}\n\n// ---------------------------------------------------------------------------\n// Edit (revert + resubmit with new text)","sourceCodeStart":292,"sourceCodeEnd":328,"githubUrl":"https://github.com/NousResearch/hermes-agent/blob/c896c09c42910c584c4c7d2325b58c14713ea42c/apps/desktop/src/app/session/hooks/use-prompt-actions/rewind.ts#L292-L328","documentation":"Error \"Could not find the message to restore.\" thrown in NousResearch/hermes-agent.","triggerScenarios":"Thrown at apps/desktop/src/app/session/hooks/use-prompt-actions/rewind.ts:310 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Reload the session; the message list is stale or the message was removed.","Scroll to load earlier history, then retry the restore on the visible message."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"c896c09c42910c584c4c7d2325b58c14713ea42c","analyzedAt":"2026-08-14T17:18:01.089Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}