Skip to content

Lost Session Configuration (In-Memory) #533

@haldunbayrak

Description

@haldunbayrak

What happened?

When the Kanban server restarts, its in-memory map lastStartRequestByTaskId is cleared. If you then interact with an existing task (e.g., clicking on it or sending a message), the server fails with: No previous Cline session config is available for task c5c42.

Steps to reproduce

This occurs because restartTaskSession expects the start configuration to be present in lastStartRequestByTaskId. However, the task session history is already persisted inside the session's JSON structure under ~/.cline/data/sessions/.

Expected behavior

Solution & Implementation (by Antigravity Gemini Flash 3.5)

  1. In-Memory Session Restoration
    We patched the restartTaskSession function in the global kanban module (cli.js) to dynamically reconstruct the configuration from the persisted session record if the in-memory entry is missing:

diff

async restartTaskSession(input) {

  •    const lastStartRequest = this.lastStartRequestByTaskId.get(input.taskId);
    
  •    if (!lastStartRequest) {
    
  •      throw new Error(`No previous Cline session config is available for task ${input.taskId}.`);
    
  •    }
    
  •    return await this.startTaskSession({
    
  •      ...lastStartRequest,
    
  •      prompt: input.prompt,
    
  •      initialMessages: input.initialMessages,
    
  •      images: input.images,
    
  •      mode: input.mode ?? lastStartRequest.mode
    
  •    });
    
  •    let lastStartRequest = this.lastStartRequestByTaskId.get(input.taskId);
    
  •    if (!lastStartRequest) {
    
  •      try {
    
  •        const sessionHost = await this.ensureSessionHost();
    
  •        const record2 = await this.findPersistedTaskSessionRecord(input.taskId, sessionHost);
    
  •        if (record2) {
    
  •          lastStartRequest = {
    
  •            taskId: input.taskId,
    
  •            cwd: record2.cwd || record2.workspaceRoot || record2.workspace_root,
    
  •            providerId: record2.provider,
    
  •            modelId: record2.model,
    
  •            mode: record2.mode || input.mode || "act",
    
  •            apiKey: record2.apiKey || "",
    
  •            baseUrl: record2.baseUrl || "",
    
  •            reasoningEffort: record2.reasoningEffort,
    
  •            systemPrompt: record2.systemPrompt,
    
  •            taskTitle: record2.metadata?.title || record2.taskTitle,
    
  •            userInstructionService: record2.userInstructionService,
    
  •            requestToolApproval: record2.requestToolApproval
    
  •          };
    
  •          this.lastStartRequestByTaskId.set(input.taskId, lastStartRequest);
    
  •        }
    
  •      } catch (e) {
    
  •        console.error("Failed to reconstruct start request from persisted session:", e);
        }
      }
    
  •    if (!lastStartRequest) {
    
  •      throw new Error(`No previous Cline session config is available for task ${input.taskId}.`);
    
  •    }
    
  •    return await this.startTaskSession({
    
  •      ...lastStartRequest,
    
  •      prompt: input.prompt,
    
  •      initialMessages: input.initialMessages,
    
  •      images: input.images,
    
  •      mode: input.mode ?? lastStartRequest.mode
    
  •    });
     }
    

Kanban version

0.1.68

Environment

mac OS Tahoe 26.5.1, Node 22.18

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions