fix(chat): attribute shared chat messages to their author, not the viewer (#28274)

This commit is contained in:
G30
2026-08-10 23:40:54 -04:00
committed by GitHub
parent 8edab5020e
commit a3e5d0b362
4 changed files with 29 additions and 3 deletions
+22 -1
View File
@@ -82,7 +82,7 @@
} from '$lib/apis/chats';
import { generateOpenAIChatCompletion } from '$lib/apis/openai';
import { processUrl, processWebSearch } from '$lib/apis/retrieval';
import { getAndUpdateUserLocation, getUserSettings } from '$lib/apis/users';
import { getAndUpdateUserLocation, getUserInfoById, getUserSettings } from '$lib/apis/users';
import {
generateQueries,
chatAction,
@@ -372,6 +372,25 @@
// Read-only when viewing someone else's chat (e.g. via shared folder access)
$: readOnly = chat != null && chat.user_id !== $user?.id;
let chatOwner = null;
const resolveChatOwner = async (userId) => {
if (chatOwner?.id === userId) {
return;
}
chatOwner = await getUserInfoById(localStorage.token, userId).catch((error) => {
console.error(error);
return null;
});
};
$: if (readOnly && chat?.user_id) {
void resolveChatOwner(chat.user_id);
} else {
chatOwner = null;
}
let chatTasks = [];
let history = {
@@ -4067,6 +4086,7 @@
<Messages
bind:this={messagesRef}
chatId={$chatId}
user={chatOwner ?? $user}
{readOnly}
bind:history
bind:autoScroll
@@ -4304,6 +4324,7 @@
bind:files
bind:pane={controlPane}
chatId={$chatId}
chatUser={chatOwner}
modelId={selectedModelIds?.at(0) ?? null}
models={selectedModelIds.reduce((a, e, i, arr) => {
const model = $models.find((m) => m.id === e);
@@ -42,6 +42,7 @@
export let models = [];
export let chatId = null;
export let chatUser = null;
export let chatFiles = [];
export let params = {};
@@ -385,6 +386,7 @@
{#if activeTab === 'overview'}
<Overview
{history}
{chatUser}
onNodeClick={(e) => {
const node = e.node;
showMessage(node.data.message, true);
@@ -529,6 +531,7 @@
{#if activeTab === 'overview'}
<Overview
{history}
{chatUser}
onNodeClick={(e) => {
const node = e.node;
if (node?.data?.message?.favorite) {
+2 -1
View File
@@ -5,8 +5,9 @@
export let history;
export let onNodeClick;
export let chatUser = null;
</script>
<SvelteFlowProvider>
<View {history} {onNodeClick} />
<View {history} {onNodeClick} {chatUser} />
</SvelteFlowProvider>
+2 -1
View File
@@ -23,6 +23,7 @@
export let history;
export let onNodeClick;
export let chatUser = null;
type LayoutDirection = 'vertical' | 'horizontal';
type PositionMapEntry = {
@@ -99,7 +100,7 @@
id: pos.id,
type: 'custom',
data: {
user: $user,
user: chatUser ?? $user,
message: history.messages[id],
model: $models.find((model) => model.id === history.messages[id].model)
},