Commit graph

6000 commits

Author SHA1 Message Date
CREDO23
fa75d7c54c fix(desktop): ship multi-size icons so linux launchers can find them
electron-builder was given a single 2048x2048 icon.png and dumped it into
hicolor/2048x2048/apps/, a bucket no Linux desktop environment indexes —
launchers and taskbar fell back to a generic placeholder. Pre-render the
standard sizes (16, 32, 48, 64, 128, 256, 512, 1024) and point linux.icon
at the directory so each PNG lands in the matching hicolor/NxN/apps/ slot.

Tray icon was unaffected (loaded at runtime via Electron's Tray API from
bundled resources, no theme lookup).
2026-05-22 20:04:21 +02:00
CREDO23
d5284b3076 fix(desktop): bind bundled Next.js on localhost to keep window origin stable
Setting HOSTNAME=0.0.0.0 made Next.js standalone canonicalize request.url to
http://0.0.0.0:PORT. The connector OAuth callback's NextResponse.redirect built
its Location from that URL, so navigating it flipped window.location.origin from
http://localhost:PORT to http://0.0.0.0:PORT. The backend CORS allowlist matches
localhost/127.0.0.1 only, blocking every subsequent API call until app restart —
producing the "no internet" / app-down state after connecting any connector.
2026-05-22 19:37:19 +02:00
CREDO23
b9403b1720 feat(desktop): emit PostHog events for OAuth redirect intercept and miss
Adds two diagnostic events to surface OAuth-redirect failures we can't
reproduce on Linux:

- desktop_oauth_redirect_intercepted fires from inside onBeforeRequest
  with the original host, path, and target port — confirms the rewrite
  actually ran.
- desktop_oauth_redirect_missed fires from a read-only onCompleted
  listener when a /dashboard/*/connectors/callback URL lands off-localhost,
  meaning the rewrite filter didn't catch it. This is the smoking-gun
  event for "connector OAuth dies on mac/win" reports.

Read-only; no behavior change.
2026-05-22 18:40:06 +02:00
CREDO23
1b6c238c68 refactor(desktop): harden OAuth redirect rewrite for host variants and self-hosters
The interceptor previously matched a strict `${HOSTED_FRONTEND_URL}/*`
prefix and did a naive String.replace, which broke whenever the backend
NEXT_FRONTEND_URL differed at all (apex vs www, http vs https, or a
self-hosted domain). Now:

- Match by host: apex + www. sibling, both http and https.
- Rewrite via URL parsing so only protocol/host change; query strings
  containing the host as a value are left intact.
- Read HOSTED_FRONTEND_URL through getHostedFrontendUrl() which honors
  a SURFSENSE_HOSTED_FRONTEND_URL_OVERRIDE env var, letting self-hosters
  point their builds at their own frontend without rebuilding.

Default behavior is identical when override is unset and backend host
matches the baked-in value.
2026-05-22 18:39:47 +02:00
CREDO23
fe98c17b1d fix(desktop): declare surfsense:// scheme in macOS Info.plist
Linux registered the scheme via desktop-file MIME, but mac.extendInfo
never declared CFBundleURLTypes, leaving install-time LaunchServices
unaware of the protocol. The runtime app.setAsDefaultProtocolClient
call still runs as a fallback.
2026-05-22 18:39:27 +02:00
CREDO23
6ee7c04d02 fix(desktop): recover deep-link URL from argv on win/linux cold start
setupDeepLinks() only listened for second-instance and open-url events.
On Windows/Linux a fresh launch via `surfsense://` delivers the URL in
argv of the first instance, where it was silently dropped. Scan argv on
setup so the existing handlePendingDeepLink() pass picks it up.
2026-05-22 18:39:22 +02:00
CREDO23
d97b2830c5 fix: resolve desktop KB prompt self-contradiction on chunk_ids
The citations fix (cacb27e0) added a "Chunk citations in your prose"
section to system_prompt_desktop.md telling the KB subagent to always
leave `evidence.chunk_ids` null and emit no `[citation:...]` markers in
desktop mode, but left the pre-existing line declaring that
`chunk_ids` apply to `<priority_documents>` hits. The two rules
contradicted each other; the model picked one per turn.

Strike the stale conditional clause and point at the dedicated section
as the single source of truth. Matches the parallel line in
system_prompt_cloud.md and the already-consistent
system_prompt_readonly_desktop.md.
2026-05-22 17:24:57 +02:00
DESKTOP-RTLN3BA\$punk
fc3b39483b Merge commit '334729754f' into dev 2026-05-21 21:14:15 -07:00
DESKTOP-RTLN3BA\$punk
1990125458 feat: update Privacy Policy with detailed data collection practices and usage information 2026-05-21 21:13:30 -07:00
Rohan Verma
334729754f
Merge pull request #1424 from MODSetter/dev
feat: added adsense on /free page
2026-05-21 21:05:33 -07:00
DESKTOP-RTLN3BA\$punk
c381dd5ba9 Merge commit '49dd8409d8' into dev 2026-05-21 21:04:48 -07:00
DESKTOP-RTLN3BA\$punk
2eaf4fbce1 feat: added adsense on /free page 2026-05-21 21:01:10 -07:00
Rohan Verma
49dd8409d8
Merge pull request #1423 from MODSetter/dev
feat: improved agent speed and fixed it citations
2026-05-21 14:47:13 -07:00
DESKTOP-RTLN3BA\$punk
2e589091d8 feat: bumped version to 0.0.25 2026-05-21 14:44:33 -07:00
DESKTOP-RTLN3BA\$punk
5cfcf4ac82 Merge commit '0f98480096' into dev 2026-05-21 14:43:00 -07:00
DESKTOP-RTLN3BA\$punk
cacb27e007 fix: citations in agent responses 2026-05-21 14:41:32 -07:00
DESKTOP-RTLN3BA\$punk
1a4400c923 refactor(env): streamline BACKEND_URL usage in GoogleLoginButton and DocumentTabContent; update connector-status-config for Composio Google Drive connector maintenance 2026-05-21 13:37:55 -07:00
Rohan Verma
5c4da79da4
Merge pull request #1422 from CREDO23/improvement-agent-speed
[Improvement] Agent: faster turns and lower LLM cost
2026-05-20 14:57:19 -07:00
CREDO23
49da7a57df Merge remote-tracking branch 'upstream/dev' into improvement-agent-speed
Resolves: surfsense_backend/app/agents/new_chat/middleware/memory_injection.py
- Took both imports: upstream moved MEMORY_HARD_LIMIT/SOFT_LIMIT to
  app.services.memory; kept our perf-logger import for timing.

Pulls in upstream changes:
- Memory document feature (services/memory refactor, removal of
  app.agents.new_chat.memory_extraction and background extraction in
  stream_new_chat — agent now drives memory via update_memory tool).
- BACKEND_URL env refactor across web tool-ui/editor/chat/dashboard/lib.
- GitHub Actions backend test workflow + pre-commit biome bump.
- Token-display polish in MessageInfoDropdown; save_memory no-update
  sentinel.

Verified: 1723 unit tests pass, ruff clean. No semantic regression in
stream_new_chat (their memory-extraction deletion and our preflight
removal touch different functions).
2026-05-20 21:23:48 +02:00
Rohan Verma
883ac81ce1
Merge pull request #1420 from AnishSarkar22/fix/pnpm-version-ci
fix: Update CI workflow versions and scoped test triggers
2026-05-20 12:14:47 -07:00
Rohan Verma
54716105d2
Merge pull request #1418 from VarunShukla07/fix/env-config-tool-ui-generators
refactor(env): replace inline process.env reads with BACKEND_URL in tool-ui generators
2026-05-20 12:14:09 -07:00
Rohan Verma
1a6d1ced43
Merge pull request #1417 from VarunShukla07/fix/env-config-editor-chat-dashboard
refactor(env): replace inline process.env reads with BACKEND_URL in editor, chat, dashboard and settings
2026-05-20 12:14:01 -07:00
Rohan Verma
c97bb81126
Merge pull request #1416 from VarunShukla07/fix/env-config-connector-forms
refactor(env): replace inline process.env reads with BACKEND_URL in connector forms and hooks
2026-05-20 12:13:50 -07:00
Rohan Verma
8823574c19
Merge pull request #1415 from VarunShukla07/fix/env-config-lib-files
refactor(env): replace inline process.env reads with BACKEND_URL in lib/
2026-05-20 12:13:12 -07:00
Rohan Verma
55cce4ea59
Merge pull request #1414 from AnishSarkar22/feature/memory-support-document-panel
feat: improve memory extraction & add document-panel memory editing
2026-05-20 12:12:27 -07:00
CREDO23
d5ee8cc4cd Merge remote-tracking branch 'upstream/dev' into improvement-agent-speed 2026-05-20 19:22:49 +02:00
CREDO23
2be3f04df5 chore(scripts): drop one-off MCP session lifetime probe
The probe answered its question (informing the cached_tools persistence
design). Future MCP session-pooling work, if revived, can recreate it.
2026-05-20 19:11:00 +02:00
CREDO23
704d1bf18f refactor(mcp): per-connector cache refresh on lifecycle events
Collapse the invalidate + warmup pair into a single
refresh_mcp_tools_cache_for_connector(connector_id, search_space_id)
helper and scope live discovery to the one connector that changed
instead of the whole search space.

- new mcp_tool.discover_single_mcp_connector: load one connector,
  refresh OAuth if needed, force live MCP discovery so its cached_tools
  row is rewritten; returned wrappers are discarded since the in-process
  LRU is rebuilt lazily on the next user query
- mcp_tools_cache.refresh_mcp_tools_cache_for_connector: synchronously
  evicts the per-space LRU (LRU keys cannot scope finer) and schedules
  the per-connector prefetch via loop.create_task
- routes (OAuth callback, MCP POST, MCP PUT) collapse their two
  back-to-back calls into a single refresh call; DELETE handlers keep
  using bare invalidate_mcp_tools_cache (nothing to prefetch)

No new automated tests: the new functions are I/O glue (DB + network)
where mocked unit tests would test implementation rather than behavior.
The existing 9 unit tests for the cached_tools data shape are unchanged.
2026-05-20 17:43:27 +02:00
Anish Sarkar
58a975205d chore: add workflow file to change detection filters for backend and frontend jobs 2026-05-20 20:06:38 +05:30
Anish Sarkar
a6a0f7a373 chore: streamline GitHub Actions workflow by removing change detection job and simplifying test conditions 2026-05-20 20:03:51 +05:30
Anish Sarkar
844b8ba609 chore: refactor GitHub Actions workflow to improve backend change detection and job dependencies 2026-05-20 19:42:47 +05:30
CREDO23
c0aa4261ac perf(mcp): persist list_tools discovery in connector.config.cached_tools
Skip the ~1-3s MCP initialize + list_tools handshake on every cache miss
by reading tool definitions from the connector row we already load. Lazy
populate on first miss, self-heal on corrupt cache, zero schema migration.
2026-05-20 16:11:07 +02:00
Anish Sarkar
a786574484 chore: simplify job names in GitHub Actions workflow 2026-05-20 19:29:09 +05:30
Anish Sarkar
2de8ea5501 chore: update biome version in pre-commit configuration 2026-05-20 19:25:39 +05:30
Anish Sarkar
20152b1243 chore: update Node.js version to 20 in GitHub Actions workflow 2026-05-20 18:41:05 +05:30
Anish Sarkar
ff2d621185 chore: fix the pnpm version in GitHub Actions workflow 2026-05-20 18:37:21 +05:30
Rohan Verma
0f98480096
Merge pull request #1419 from MODSetter/dev
Release v0.0.24: UI revamp, multi-agent parallelization, citations & HITL improvements
2026-05-20 03:27:24 -07:00
DESKTOP-RTLN3BA\$punk
f5f2456dfd Merge branch 'dev' of https://github.com/MODSetter/SurfSense into dev 2026-05-20 03:01:49 -07:00
DESKTOP-RTLN3BA\$punk
ed22da7b95 feat: bumped version to 0.0.24 2026-05-20 03:01:37 -07:00
Anish Sarkar
39c29d651f feat: enhance token display in MessageInfoDropdown with improved visual separation 2026-05-20 15:29:41 +05:30
CREDO23
db8bffab38 perf(prompt-cache): enable Azure prompt_cache_key routing hint
Splits the OpenAI-family gate into per-param predicates so AZURE and
AZURE_OPENAI configs now receive prompt_cache_key for backend routing
affinity (Microsoft auto-caches GPT-4o+ deployments at >=1024 tokens;
the key clusters same-prefix requests on the same GPU pool and raises
hit rate on turn 2+). prompt_cache_retention stays opted out for Azure
because litellm 1.83.14's Azure transformer would drop it silently;
revisit when Azure's supported params list is updated.
2026-05-20 11:58:15 +02:00
CREDO23
71dead0406 perf(kb-planner): route internal planner calls to dedicated small/fast LLM
Adds an optional planner LLM role wired through KnowledgePriorityMiddleware
so KB query rewriting, date extraction, and recency classification run on a
cheap model (e.g. gpt-4o-mini, Haiku, Azure nano) instead of the user's
chat LLM. Operators opt in by setting is_planner: true on exactly one
global config; without it, behavior is unchanged.
2026-05-20 11:42:52 +02:00
Anish Sarkar
8c9be9796a feat: add no-update sentinel handling to save_memory function and corresponding unit tests 2026-05-20 15:03:35 +05:30
CREDO23
c3db25302b perf(chat): kill auto-pin preflight + speculative build, rely on reactive 429 recovery
The preflight pattern probed the LLM with a 1-token ping before each
cold turn (when requested_llm_config_id==0, llm_config_id<0, and the
45s healthy TTL had expired) to detect 429s before fanning out into
planner/classifier/title-gen. To absorb its ~1-5s RTT cost we built the
agent speculatively in parallel; on 429 we discarded the build and
repinned.

Three problems with that design:

1. False security. Provider rate limits are token-bucket. A 1-token
   ping consumes ~5 tokens; the real request consumes 10-50K. The
   probe can return 200 while the real call still 429s.
2. Pure overhead in the common case. On warm-agent-cache turns the
   probe dominates wall time: ~2.5s of TTFT pure tax for ~99% of users
   who never see a 429.
3. The in-stream recovery loop (catch of _is_provider_rate_limited
   gated by not _first_event_logged) already does the right thing
   reactively: mark_runtime_cooldown -> resolve_or_get_pinned_llm_config_id
   with exclude_config_ids={previous} -> rebuild agent -> retry the
   stream. Preflight was never the only safety net; it was a redundant
   probe in front of one.

Changes:
- Delete _preflight_llm, _settle_speculative_agent_build, and the
  _PREFLIGHT_TIMEOUT_SEC / _PREFLIGHT_MAX_TOKENS constants.
- Drop the parallel agent_build_task / preflight_task plumbing in
  both stream_new_chat and stream_resume_chat; build the agent inline
  with await _build_main_agent_for_thread(...).
- Drop the unused is_recently_healthy / mark_healthy imports here
  (still exported from auto_model_pin_service since OpenRouter
  catalogue refresh and a few tests reference clear_healthy).
- Remove the obsolete preflight + settle-speculative tests from
  test_stream_new_chat_contract.py.

Net: -447 LOC. ~2.5s removed from TTFT on every cold preflight-eligible
turn. 429 recovery path is unchanged - same repin/rebuild/retry, just
not paid in advance on the healthy path.
2026-05-20 11:03:08 +02:00
Anish Sarkar
132e7b3c44 refactor: remove memory extraction functions and related components from the new chat agent 2026-05-20 14:03:28 +05:30
Rohan Verma
4774105015
Merge pull request #1413 from mvanhorn/fix/1359-shared-isMobile-hook
fix: use shared useIsMobile (768px) in SidebarSlideOutPanel (#1359)
2026-05-20 01:32:04 -07:00
DESKTOP-RTLN3BA\$punk
b285293b4e fix: docker one click setup 2026-05-20 01:25:07 -07:00
CREDO23
1791241c0c perf(indexers): offload sync embed_text to thread across background workers
Connector kb_sync_services (gmail, onedrive, google_calendar, jira),
streaming indexers (discord, luma, teams) and the file-processor save
path all called embed_text inside async coroutines, blocking the
background worker's event loop for the duration of the embed. Wrap each
call site in asyncio.to_thread so concurrent indexing tasks stop
serialising on the embed.
2026-05-20 10:09:38 +02:00
CREDO23
a8de98895a perf(revert-service): offload sync embed_texts to thread
_restore_in_place_document and _reinsert_document_from_revision are
async helpers invoked by the synchronous-feeling POST /api/threads/.../revert
route; both ran embed_texts inline, blocking the event loop while the
HTTP client waited.
2026-05-20 10:04:26 +02:00
CREDO23
a3d6fa6196 perf(document-converters): offload sync embed_text/embed_texts to thread
generate_document_summary and create_document_chunks are async helpers
called from the chat path and from many connector indexers. Both wrapped
embed_text/embed_texts directly inside the coroutine, blocking the event
loop for the full duration of the embedding call.
2026-05-20 10:03:42 +02:00