Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

Merge branch 'dev' into feat/file-attachment

Dinh Long Nguyenff93dc3c5ca2
diff --cc src-tauri/Cargo.lock
index 855542866,ae5dadfca..bef9d5114
--- a/src-tauri/Cargo.lock
+++ b/src-tauri/Cargo.lock
@@@ -1396,12 -1380,14 +1460,20 @@@ dependencies =
]
[[package]]
+name = "euclid"
+version = "0.20.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2bb7ef65b3777a325d1eeefefab5b6d4959da54747e33bd6258e789640f307ad"
+dependencies = [
+ "num-traits",
+ name = "etcetera"
+ version = "0.8.0"
+ source = "registry+https://github.com/rust-lang/crates.io-index"
+ checksum = "136d1b5283a1ab77bd9257427ffd09d8667ced0570b6f938942bc7568ed5b943"
+ dependencies = [
+ "cfg-if",
+ "home",
+ "windows-sys 0.48.0",
]
[[package]]
@@@ -2070,16 -2069,21 +2170,30 @@@ name = "hashbrown
version = "0.15.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5971ac85611da7067dbfcabef3c70ebb5606018acd9e2a3903a0da507521e0d5"
+ dependencies = [
+ "allocator-api2",
+ "equivalent",
+ "foldhash",
+ ]
+
+ [[package]]
+ name = "hashlink"
+ version = "0.10.0"
+ source = "registry+https://github.com/rust-lang/crates.io-index"
+ checksum = "7382cf6263419f2d8df38c55d7da83da5c18aef87fc7a7fc1fb1e344edfe14c1"
+ dependencies = [
+ "hashbrown 0.15.4",
+ ]
+[[package]]
+name = "hashlink"
+version = "0.9.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6ba4ff7128dee98c7dc9794b6a411377e1404dba1c97deb8d1a55297bd25d8af"
+dependencies = [
+ "hashbrown 0.14.5",
+]
+
[[package]]
name = "heck"
version = "0.4.1"
@@@ -3647,18 -3635,12 +3831,24 @@@ dependencies =
]
[[package]]
+name = "pdf-extract"
+version = "0.7.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cbb3a5387b94b9053c1e69d8abfd4dd6dae7afda65a5c5279bc1f42ab39df575"
+dependencies = [
+ "adobe-cmap-parser",
+ "encoding_rs",
+ "euclid",
+ "lopdf",
+ "postscript",
+ "type1-encoding-parser",
+ "unicode-normalization",
+ name = "pem-rfc7468"
+ version = "0.7.0"
+ source = "registry+https://github.com/rust-lang/crates.io-index"
+ checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412"
+ dependencies = [
+ "base64ct",
]
[[package]]
@@@ -4547,17 -4515,23 +4762,34 @@@ dependencies =
]
[[package]]
+name = "rusqlite"
+version = "0.32.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7753b721174eb8ff87a9a0e799e2d7bc3749323e773db92e0984debb00019d6e"
+dependencies = [
+ "bitflags 2.9.1",
+ "fallible-iterator",
+ "fallible-streaming-iterator",
+ "hashlink",
+ "libsqlite3-sys",
+ "smallvec",
+ name = "rsa"
+ version = "0.9.8"
+ source = "registry+https://github.com/rust-lang/crates.io-index"
+ checksum = "78928ac1ed176a5ca1d17e578a1825f3d81ca54cf41053a592584b020cfd691b"
+ dependencies = [
+ "const-oid",
+ "digest",
+ "num-bigint-dig",
+ "num-integer",
+ "num-traits",
+ "pkcs1",
+ "pkcs8",
+ "rand_core 0.6.4",
+ "signature",
+ "spki",
+ "subtle",
+ "zeroize",
]
[[package]]
@@@ -6980,10 -7199,14 +7510,18 @@@ dependencies =
]
[[package]]
+name = "weezl"
+version = "0.1.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a751b3277700db47d3e574514de2eced5e54dc8a5436a3bf7a0b248b2cee16f3"
+ name = "whoami"
+ version = "1.6.1"
+ source = "registry+https://github.com/rust-lang/crates.io-index"
+ checksum = "5d4a4db5077702ca3015d3d02d74974948aba2ad9e12ab7df718ee64ccd7e97d"
+ dependencies = [
+ "libredox",
+ "wasite",
+ ]
[[package]]
name = "winapi"
diff --cc web-app/src/containers/ChatInput.tsx
index bddbbfa86,3d70e93f0..8dc4fda84
--- a/web-app/src/containers/ChatInput.tsx
+++ b/web-app/src/containers/ChatInput.tsx
@@@ -40,13 -38,10 +40,15 @@@ import { TokenCounter } from '@/compone
import { useMessages } from '@/hooks/useMessages'
import { useShallow } from 'zustand/react/shallow'
import { McpExtensionToolLoader } from './McpExtensionToolLoader'
-import { ExtensionTypeEnum, MCPExtension } from '@janhq/core'
+import { ExtensionTypeEnum, MCPExtension, RAGExtension } from '@janhq/core'
import { ExtensionManager } from '@/lib/extension'
+import { useAttachments } from '@/hooks/useAttachments'
+import { open } from '@tauri-apps/plugin-dialog'
+import { toast } from 'sonner'
+import { PlatformFeatures } from '@/lib/platform/const'
+import { PlatformFeature } from '@/lib/platform/types'
+ import { useAnalytic } from '@/hooks/useAnalytic'
+ import posthog from 'posthog-js'
type ChatInputProps = {
className?: string
@@@ -203,37 -187,23 +208,50 @@@ const ChatInput = (
setMessage('Please select a model to start chatting.')
return
}
- if (!prompt.trim() && uploadedFiles.length === 0) {
+ if (!prompt.trim() && uploadedFiles.length === 0 && docFiles.length === 0) {
return
}
+ // If we have pending doc files, index them first
+ if (docFiles.length > 0) {
+ try {
+ setIngestingDocs(true)
+ const rag = extensionManager.get<RAGExtension>(ExtensionTypeEnum.RAG)
+ if (!rag?.ingestAttachments) throw new Error('Retrieval extension not available')
+ for (const f of docFiles) {
+ const id = (toast as any).loading
+ ? (toast as any).loading(`Indexing ${f.name || f.path}…`)
+ : undefined
+ try {
+ await rag.ingestAttachments(currentThreadId!, [{ path: f.path, name: f.name }])
+ if (id) toast.success(`Indexed ${f.name || f.path}`, { id })
+ } catch (err) {
+ if (id) toast.error(`Failed to index ${f.name || f.path}`, { id })
+ throw err
+ }
+ }
+ setDocFiles([])
+ } catch (err) {
+ const desc = err instanceof Error ? err.message : String(err)
+ toast.error('Failed to index attachments', { description: desc })
+ setIngestingDocs(false)
+ return
+ }
+ setIngestingDocs(false)
+ }
setMessage('')
+
+ // Track message send event with PostHog (only if product analytics is enabled)
+ if (productAnalytic && selectedModel && selectedProvider) {
+ try {
+ posthog.capture('message_sent', {
+ model_provider: selectedProvider,
+ model_id: selectedModel.id,
+ })
+ } catch (error) {
+ console.debug('Failed to track message send event:', error)
+ }
+ }
+
sendMessage(
prompt,
true,
@@@ -982,16 -860,11 +1000,16 @@@
: 'default'
}
size="icon"
- disabled={!prompt.trim() && uploadedFiles.length === 0}
+ disabled={
+ (!prompt.trim() &&
+ uploadedFiles.length === 0 &&
+ docFiles.length === 0) ||
+ ingestingDocs
+ }
data-test-id="send-message-button"
- onClick={() => handleSendMesage(prompt)}
+ onClick={() => handleSendMessage(prompt)}
>
- {streamingContent ? (
+ {streamingContent || ingestingDocs ? (
<span className="animate-spin h-4 w-4 border-2 border-current border-t-transparent rounded-full" />
) : (
<ArrowRight className="text-primary-fg" />
diff --cc web-app/src/lib/platform/const.ts
index 5f004235a,9627b61ab..ead0d6751
--- a/web-app/src/lib/platform/const.ts
+++ b/web-app/src/lib/platform/const.ts
@@@ -74,14 -74,10 +74,14 @@@ export const PlatformFeatures: Record<P
// Shortcut
[PlatformFeature.SHORTCUT]: !isPlatformIOS() && !isPlatformAndroid(),
-
- // First message persisted thread - enabled for web only
- [PlatformFeature.FIRST_MESSAGE_PERSISTED_THREAD]: !isPlatformTauri(),
+
+ // First message persisted thread - enabled for web and mobile platforms
+ [PlatformFeature.FIRST_MESSAGE_PERSISTED_THREAD]: !isPlatformTauri() || isPlatformIOS() || isPlatformAndroid(),
- // Temporary chat mode - enabled for web only
+ // Temporary chat mode - enabled for web only
[PlatformFeature.TEMPORARY_CHAT]: !isPlatformTauri(),
+
+ // Attachments/RAG UI and tooling - desktop only for now
+ [PlatformFeature.ATTACHMENTS]:
+ isPlatformTauri() && !isPlatformIOS() && !isPlatformAndroid(),
}