| 8884 | } |
| 8885 | |
| 8886 | func refreshChatWorkspaceSnapshot( |
| 8887 | ctx context.Context, |
| 8888 | chat database.Chat, |
| 8889 | loadChat func(context.Context, uuid.UUID) (database.Chat, error), |
| 8890 | ) (database.Chat, error) { |
| 8891 | if chat.WorkspaceID.Valid || loadChat == nil { |
| 8892 | return chat, nil |
| 8893 | } |
| 8894 | |
| 8895 | refreshedChat, err := loadChat(ctx, chat.ID) |
| 8896 | if err != nil { |
| 8897 | return chat, xerrors.Errorf("reload chat workspace state: %w", err) |
| 8898 | } |
| 8899 | |
| 8900 | return refreshedChat, nil |
| 8901 | } |
| 8902 | |
| 8903 | // contextFileAgentID extracts the workspace agent ID from the most |
| 8904 | // recent persisted instruction-file parts. The skill-only sentinel is |