mirror of
https://github.com/open-webui/open-webui.git
synced 2026-08-28 05:27:35 +00:00
refac
Some checks are pending
Python CI / Ruff Format (3.11) (push) Waiting to run
Python CI / Ruff Format (3.12) (push) Waiting to run
Create and publish Docker images with specific build args / copy-to-dockerhub (-slim, slim) (push) Blocked by required conditions
Create and publish Docker images with specific build args / copy-to-dockerhub (-ollama, ollama) (push) Blocked by required conditions
Create and publish Docker images with specific build args / build (map[arch:linux/arm64 runner:ubuntu-24.04-arm], map[build_args:USE_OLLAMA=true free_disk:false name:ollama suffix:-ollama]) (push) Waiting to run
Create and publish Docker images with specific build args / build (map[arch:linux/arm64 runner:ubuntu-24.04-arm], map[build_args:USE_SLIM=true free_disk:false name:slim suffix:-slim]) (push) Waiting to run
Create and publish Docker images with specific build args / build (map[arch:linux/amd64 runner:ubuntu-latest], map[build_args: free_disk:false name:main suffix:]) (push) Waiting to run
Create and publish Docker images with specific build args / build (map[arch:linux/amd64 runner:ubuntu-latest], map[build_args:USE_CUDA=true
USE_CUDA_VER=cu126
free_disk:true name:cuda126 suffix:-cuda126]) (push) Waiting to run
Create and publish Docker images with specific build args / build (map[arch:linux/amd64 runner:ubuntu-latest], map[build_args:USE_CUDA=true free_disk:true name:cuda suffix:-cuda]) (push) Waiting to run
Create and publish Docker images with specific build args / build (map[arch:linux/amd64 runner:ubuntu-latest], map[build_args:USE_OLLAMA=true free_disk:false name:ollama suffix:-ollama]) (push) Waiting to run
Create and publish Docker images with specific build args / build (map[arch:linux/amd64 runner:ubuntu-latest], map[build_args:USE_SLIM=true free_disk:false name:slim suffix:-slim]) (push) Waiting to run
Create and publish Docker images with specific build args / build (map[arch:linux/arm64 runner:ubuntu-24.04-arm], map[build_args: free_disk:false name:main suffix:]) (push) Waiting to run
Create and publish Docker images with specific build args / build (map[arch:linux/arm64 runner:ubuntu-24.04-arm], map[build_args:USE_CUDA=true
USE_CUDA_VER=cu126
free_disk:true name:cuda126 suffix:-cuda126]) (push) Waiting to run
Create and publish Docker images with specific build args / build (map[arch:linux/arm64 runner:ubuntu-24.04-arm], map[build_args:USE_CUDA=true free_disk:true name:cuda suffix:-cuda]) (push) Waiting to run
Create and publish Docker images with specific build args / merge (map[name:cuda suffix:-cuda]) (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge (map[name:cuda126 suffix:-cuda126]) (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge (map[name:main suffix:]) (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge (map[name:ollama suffix:-ollama]) (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge (map[name:slim suffix:-slim]) (push) Blocked by required conditions
Create and publish Docker images with specific build args / notify-helm-charts (push) Blocked by required conditions
Create and publish Docker images with specific build args / copy-to-dockerhub (, main) (push) Blocked by required conditions
Create and publish Docker images with specific build args / copy-to-dockerhub (-cuda, cuda) (push) Blocked by required conditions
Create and publish Docker images with specific build args / copy-to-dockerhub (-cuda126, cuda126) (push) Blocked by required conditions
Frontend Build / Format & Build (push) Waiting to run
Frontend Build / Unit Tests (push) Waiting to run
Some checks are pending
Python CI / Ruff Format (3.11) (push) Waiting to run
Python CI / Ruff Format (3.12) (push) Waiting to run
Create and publish Docker images with specific build args / copy-to-dockerhub (-slim, slim) (push) Blocked by required conditions
Create and publish Docker images with specific build args / copy-to-dockerhub (-ollama, ollama) (push) Blocked by required conditions
Create and publish Docker images with specific build args / build (map[arch:linux/arm64 runner:ubuntu-24.04-arm], map[build_args:USE_OLLAMA=true free_disk:false name:ollama suffix:-ollama]) (push) Waiting to run
Create and publish Docker images with specific build args / build (map[arch:linux/arm64 runner:ubuntu-24.04-arm], map[build_args:USE_SLIM=true free_disk:false name:slim suffix:-slim]) (push) Waiting to run
Create and publish Docker images with specific build args / build (map[arch:linux/amd64 runner:ubuntu-latest], map[build_args: free_disk:false name:main suffix:]) (push) Waiting to run
Create and publish Docker images with specific build args / build (map[arch:linux/amd64 runner:ubuntu-latest], map[build_args:USE_CUDA=true
USE_CUDA_VER=cu126
free_disk:true name:cuda126 suffix:-cuda126]) (push) Waiting to run
Create and publish Docker images with specific build args / build (map[arch:linux/amd64 runner:ubuntu-latest], map[build_args:USE_CUDA=true free_disk:true name:cuda suffix:-cuda]) (push) Waiting to run
Create and publish Docker images with specific build args / build (map[arch:linux/amd64 runner:ubuntu-latest], map[build_args:USE_OLLAMA=true free_disk:false name:ollama suffix:-ollama]) (push) Waiting to run
Create and publish Docker images with specific build args / build (map[arch:linux/amd64 runner:ubuntu-latest], map[build_args:USE_SLIM=true free_disk:false name:slim suffix:-slim]) (push) Waiting to run
Create and publish Docker images with specific build args / build (map[arch:linux/arm64 runner:ubuntu-24.04-arm], map[build_args: free_disk:false name:main suffix:]) (push) Waiting to run
Create and publish Docker images with specific build args / build (map[arch:linux/arm64 runner:ubuntu-24.04-arm], map[build_args:USE_CUDA=true
USE_CUDA_VER=cu126
free_disk:true name:cuda126 suffix:-cuda126]) (push) Waiting to run
Create and publish Docker images with specific build args / build (map[arch:linux/arm64 runner:ubuntu-24.04-arm], map[build_args:USE_CUDA=true free_disk:true name:cuda suffix:-cuda]) (push) Waiting to run
Create and publish Docker images with specific build args / merge (map[name:cuda suffix:-cuda]) (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge (map[name:cuda126 suffix:-cuda126]) (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge (map[name:main suffix:]) (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge (map[name:ollama suffix:-ollama]) (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge (map[name:slim suffix:-slim]) (push) Blocked by required conditions
Create and publish Docker images with specific build args / notify-helm-charts (push) Blocked by required conditions
Create and publish Docker images with specific build args / copy-to-dockerhub (, main) (push) Blocked by required conditions
Create and publish Docker images with specific build args / copy-to-dockerhub (-cuda, cuda) (push) Blocked by required conditions
Create and publish Docker images with specific build args / copy-to-dockerhub (-cuda126, cuda126) (push) Blocked by required conditions
Frontend Build / Format & Build (push) Waiting to run
Frontend Build / Unit Tests (push) Waiting to run
This commit is contained in:
parent
2a0274a0a0
commit
5078d987f8
2 changed files with 35 additions and 27 deletions
|
|
@ -765,7 +765,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
if (collaboration && documentId && socket && user) {
|
||||
if (collaboration && editable && documentId && socket && user) {
|
||||
const { SocketIOCollaborationProvider } = await import('./RichTextInput/Collaboration');
|
||||
provider = new SocketIOCollaborationProvider(documentId, socket, user, content);
|
||||
}
|
||||
|
|
@ -909,7 +909,7 @@
|
|||
: []),
|
||||
...(collaboration && provider ? [provider.getEditorExtension()] : [])
|
||||
],
|
||||
content: collaboration ? undefined : content,
|
||||
content: provider ? undefined : content,
|
||||
autofocus: messageInput ? true : false,
|
||||
onTransaction: () => {
|
||||
if (!editor) return;
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ const generateUserColor = () => {
|
|||
export type EditorContentGetter = () => {
|
||||
md: string;
|
||||
html: string;
|
||||
json: string;
|
||||
json: unknown;
|
||||
};
|
||||
|
||||
// Custom Yjs Socket.IO provider
|
||||
|
|
@ -48,7 +48,7 @@ export class SocketIOCollaborationProvider {
|
|||
private readonly documentId: string,
|
||||
private readonly socket: Socket,
|
||||
private readonly user: SessionUser,
|
||||
private readonly initialContent: string | null = null
|
||||
private readonly initialContent: unknown = null
|
||||
) {
|
||||
this.setupEventListeners();
|
||||
}
|
||||
|
|
@ -82,9 +82,30 @@ export class SocketIOCollaborationProvider {
|
|||
public setEditor(editor: Editor, editorContentGetter: EditorContentGetter) {
|
||||
this.editor = editor;
|
||||
this.editorContentGetter = editorContentGetter;
|
||||
|
||||
if (this.socket.connected && !this.isConnected) {
|
||||
this.isConnected = true;
|
||||
}
|
||||
if (this.isConnected) {
|
||||
this.joinDocument();
|
||||
}
|
||||
}
|
||||
|
||||
private applyInitialContent() {
|
||||
if (!this.editor || !this.initialContent) return;
|
||||
|
||||
if (typeof this.initialContent === 'string') {
|
||||
this.editor.commands.setContent(this.initialContent);
|
||||
return;
|
||||
}
|
||||
|
||||
const doc = prosemirrorJSONToYDoc(this.editor.schema, this.initialContent);
|
||||
Y.applyUpdate(this.doc, Y.encodeStateAsUpdate(doc));
|
||||
}
|
||||
|
||||
private joinDocument() {
|
||||
if (!this.editor) return;
|
||||
|
||||
const userColor = generateUserColor();
|
||||
this.socket.emit('ydoc:document:join', {
|
||||
document_id: this.documentId,
|
||||
|
|
@ -124,28 +145,16 @@ export class SocketIOCollaborationProvider {
|
|||
const state = new Uint8Array(data.state);
|
||||
|
||||
if (state.length === 2 && state[0] === 0 && state[1] === 0) {
|
||||
// Empty state, check if we have content to initialize
|
||||
// check if editor empty as well
|
||||
// const editor = await getEditorInstance();
|
||||
|
||||
const isEmptyEditor = !this.editor?.getText().trim();
|
||||
if (isEmptyEditor && this.editor) {
|
||||
if (this.initialContent && (data?.sessions ?? ['']).length === 1) {
|
||||
// Check if initialContent is HTML (string) or JSON (object)
|
||||
if (typeof this.initialContent === 'string') {
|
||||
// HTML content - let the editor parse it, then sync to Yjs
|
||||
this.editor.commands.setContent(this.initialContent);
|
||||
// The Yjs plugin will automatically sync the content
|
||||
} else {
|
||||
// JSON content - use the existing approach
|
||||
const editorYdoc = prosemirrorJSONToYDoc(
|
||||
this.editor.schema,
|
||||
this.initialContent
|
||||
);
|
||||
if (editorYdoc) {
|
||||
Y.applyUpdate(this.doc, Y.encodeStateAsUpdate(editorYdoc));
|
||||
}
|
||||
}
|
||||
if (
|
||||
this.editor &&
|
||||
!this.editor.getText().trim() &&
|
||||
this.doc.getXmlFragment('prosemirror').length === 0
|
||||
) {
|
||||
if (
|
||||
this.initialContent &&
|
||||
[...(data.sessions ?? [])].sort()[0] === this.socket.id
|
||||
) {
|
||||
this.applyInitialContent();
|
||||
}
|
||||
} else {
|
||||
// If the editor already has content, we don't need to send an empty state
|
||||
|
|
@ -233,7 +242,6 @@ export class SocketIOCollaborationProvider {
|
|||
|
||||
if (this.socket.connected) {
|
||||
this.isConnected = true;
|
||||
this.joinDocument();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue