mirror of
https://wget.la/https://github.com/leookun/cursor-byok
synced 2026-08-18 03:57:06 +08:00
fix(forwarder): preserve Cursor fork context
Store checkpoint turns as validated blobs and restore prefetched parent turns so forked conversations retain their replay history and rewind prefix. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -82,28 +82,30 @@ func (broker *StreamBroker) OpenStream(requestID string, conversationID string,
|
||||
}
|
||||
now := time.Now().UTC()
|
||||
stream := &ActiveStream{
|
||||
RequestID: normalizedRequestID,
|
||||
ConversationID: strings.TrimSpace(conversationID),
|
||||
TurnSeq: turnSeq,
|
||||
ModelID: strings.TrimSpace(modelID),
|
||||
ModelName: strings.TrimSpace(modelName),
|
||||
Mode: normalizedMode,
|
||||
LatestUserText: strings.TrimSpace(latestUserText),
|
||||
Status: StreamStatusCreated,
|
||||
Backlog: make([]StreamEvent, 0, 64),
|
||||
Subscribers: make(map[string]*StreamSubscriber),
|
||||
PendingExecs: make(map[string]runtimecore.PendingExec),
|
||||
PendingInteractions: make(map[string]runtimecore.PendingInteraction),
|
||||
PartialToolCallIDs: make(map[string]struct{}),
|
||||
PatchEditQueues: make(map[string][]queuedPatchEditOperation),
|
||||
MCPToolServers: make(map[string]string),
|
||||
RecentCompletedExecs: make(map[uint32]time.Time),
|
||||
BackgroundShells: make(map[string]*BackgroundShellState),
|
||||
BackgroundShellsByMessageID: make(map[uint32]string),
|
||||
BackgroundShellsByExecID: make(map[string]string),
|
||||
BackgroundShellActions: make(map[string]time.Time),
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
RequestID: normalizedRequestID,
|
||||
ConversationID: strings.TrimSpace(conversationID),
|
||||
TurnSeq: turnSeq,
|
||||
ModelID: strings.TrimSpace(modelID),
|
||||
ModelName: strings.TrimSpace(modelName),
|
||||
Mode: normalizedMode,
|
||||
LatestUserText: strings.TrimSpace(latestUserText),
|
||||
Status: StreamStatusCreated,
|
||||
Backlog: make([]StreamEvent, 0, 64),
|
||||
Subscribers: make(map[string]*StreamSubscriber),
|
||||
PendingExecs: make(map[string]runtimecore.PendingExec),
|
||||
PendingInteractions: make(map[string]runtimecore.PendingInteraction),
|
||||
PartialToolCallIDs: make(map[string]struct{}),
|
||||
PatchEditQueues: make(map[string][]queuedPatchEditOperation),
|
||||
MCPToolServers: make(map[string]string),
|
||||
RecentCompletedExecs: make(map[uint32]time.Time),
|
||||
BackgroundShells: make(map[string]*BackgroundShellState),
|
||||
BackgroundShellsByMessageID: make(map[uint32]string),
|
||||
BackgroundShellsByExecID: make(map[string]string),
|
||||
BackgroundShellActions: make(map[string]time.Time),
|
||||
PendingCheckpointBlobWrites: make(map[uint32]pendingCheckpointBlobWrite),
|
||||
PendingCheckpointBlobRequests: make(map[string]uint32),
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
broker.streams[normalizedRequestID] = stream
|
||||
return stream, nil
|
||||
|
||||
Reference in New Issue
Block a user