6584 Commits

Author SHA1 Message Date
Akarshan
ea922ea336
refactor: extract and clean <think> tags in ThreadContent
Add a helper `extractContentAndClean` that pulls out the content between `<think>` tags and removes all auxiliary tags from the final output.
Update the message rendering logic to use this helper for finalized messages that lack explicit stream events, ensuring that reasoning and final output are correctly separated and displayed.

Adjust the reasoning detection to consider extracted reasoning as well as stream events, clean the copy button to use the actual final output, and eliminate duplicate `StreamEvent` type definitions.

These changes improve message parsing accuracy and simplify the component’s handling of legacy messages that embed both reasoning and results in the same string.
2025-10-31 12:36:30 +05:30
Akarshan
388a9f96ea
refactor: reorder postMessageProcessing parameters for clarity
Rearrange the `postMessageProcessing` signature so that `isProactiveMode` now precedes the internal `currentStepCount`.
This change improves the logical flow of the API: the proactive flag is a public flag that callers should set, whereas the step counter is an internal bookkeeping value. The updated order also aligns the JSDoc comment with the implementation.

All related tests were updated to reflect the new parameter order, and comments were adjusted to describe the internal counter in the correct place. No functional behavior changes occur; the change simply makes the API easier to read and maintain.
2025-10-30 12:46:54 +05:30
Akarshan
ef4e8bf353
refactor: allow nullable metadata in MessageMetadataDialog
The metadata prop was previously required, but callers sometimes pass
null or undefined. Updating the type to allow null/undefined prevents
runtime errors and simplifies usage.
2025-10-30 12:36:18 +05:30
Akarshan
74b895c653
test: improve completion.test for proactive screenshot handling and formatting
Add import for `captureProactiveScreenshots`, correct mock response formatting, and update test expectations to match the new API.
Enhance coverage by adding scenarios for screenshot capture errors, abort controller handling, and proactive mode toggling.  These changes provide clearer, more robust tests for the completion logic.
2025-10-30 12:18:49 +05:30
Akarshan
98d81819c5
feat: enhance Message Metadata Dialog with structured display
Previously the dialog simply rendered the raw JSON of the metadata, which made it hard to read and required the CodeEditor dependency. This change replaces the raw viewer with a set of semantic sections that show assistant details, model parameters, token speed, and timestamps in a clean, icon‑rich layout. The component now uses TypeScript interfaces for better type safety, memoized formatting helpers, and removes the unnecessary CodeEditor import. Locale entries were added for all new labels.

The updated UI improves user experience by making metadata more accessible and readable, while simplifying the code base and reducing bundle size.
2025-10-30 12:09:02 +05:30
Akarshan
89d158dc8b
feat: update ScrollToBottom to use message status for button visibility
Use the `MessageStatus` enum to determine when the “Generate AI Response” button should appear.
Previously the visibility logic checked the last message’s role or the presence of tool calls, which could be unreliable since we moved to combined tool call/reasoning block.
By checking that the last message exists and its status is not `Ready` which is that the message is finished generating when an eot token is found, the button is shown only while the AI has stopped generating before it could end properly, improving UX and aligning the UI state with the underlying message state.  The change also imports `MessageStatus` and cleans up formatting for readability.
2025-10-30 11:01:31 +05:30
Akarshan
890e6694c2
feat: add linkComponents prop for Markdown rendering in ThinkingBlock
Adds a `linkComponents` prop that can be supplied to `RenderMarkdown` within
`ThinkingBlock` and propagates this prop to the thread view.  The change
enables custom link rendering (e.g., special handling of URLs or
interactions) without modifying the core component logic.  It also renames
the “Tool Call” label to “Tool Input” to more accurately describe the
content being displayed.
2025-10-30 10:26:16 +05:30
Akarshan
d9b42d4699
Remove defunct condition as tool calls and reasoning are unified 2025-10-30 09:23:34 +05:30
Akarshan
2a3de27cc9
refactor: streamline streaming view logic in ThinkingBlock
Previously the component used an `isStreamingEmpty` flag to display a “thinking” placeholder when the block was loading but had no steps yet. The new implementation handles this case directly in the streaming block by checking `activeStep || N === 0`, removing the unused flag and simplifying the conditional rendering.
In addition, the click and button‑disable logic were clarified, and extraneous comments were removed for cleaner code. These changes improve readability and maintainability without altering external behavior.
2025-10-29 23:20:12 +05:30
Akarshan
0f7994e03b
refactor: streamline ThinkingBlock empty streaming handling
Remove the separate “Thinking…” placeholder component and embed the empty‑streaming state directly inside the main block. Adjust the click handler and button disabled logic to only allow toggling when content is available, preventing accidental collapse during loading. This change simplifies the component, eliminates duplicate markup, and improves UX by consistently showing the thinking indicator within the block.
2025-10-29 22:49:54 +05:30
Akarshan
97c94079a9
fix: correct thinking time and chat translation keys
The update fixes how total thinking time is calculated during a chat message flow.
Previously the elapsed time from the initial completion was incorrectly added to the
overall thinking time, leading to inflated metrics. The new logic splits the
computation into separate phases (initial completion, tool execution, and
follow‑up completions) and accumulates them into `totalThinkingTime`, ensuring
accurate measurement.

Additionally, translation keys for chat components are now namespaced with
`chat:` to avoid collisions and clearly indicate the context in which they
are used. The diff also removes a stray comment line and keeps metadata
updates consistent across recursive calls.
2025-10-29 20:56:18 +05:30
Akarshan
0c80950226
feat: improve ThinkingBlock status messages and i18n
Add more descriptive loading and finished state labels for the ThinkingBlock component. The update:

- Uses new translation keys (`chat:calling_tool`, `chat:thought_and_tool_call`, etc.) for clearer tool‑call and reasoning messages.
- Handles `tool_call`, `tool_output`, and `reasoning` steps explicitly, providing a fallback when no active step is present.
- Adjusts the final label logic to use the new i18n keys and formats durations consistently.
- Adds missing locale entries for all new keys and a trailing newline to the JSON file.

These changes improve user feedback during chat interactions and make the messages easier to maintain and localize.
2025-10-29 20:55:15 +05:30
Akarshan
0a5e107d0f
refactor: simplify reasoning handling in ThreadContent and related hooks
- Remove legacy <think> tag parsing and accumulation of reasoning chunks in the main text buffer.
- Rely exclusively on `streamEvents` to derive reasoning and loading state.
- Update loading logic to account for both tool calls and reasoning events.
- Adjust memo dependencies and return values to avoid stale references.
- Update `useChat` and `completion.ts` to stop mutating the accumulated text with reasoning, keeping the logic purely event‑driven.
- Ensure the ThinkingBlock always renders from the structured steps list, improving consistency and eliminating duplicate content.
2025-10-29 20:55:14 +05:30
Akarshan
37c4a65dbd
fix: disable any type checking in useChat 2025-10-29 20:55:14 +05:30
Akarshan
3c2ba624ed
feat: Add image visualization for tool_output steps
Implement support for displaying images returned in the Multi-Content Part (MCP) format within the `tool_output` step of the ReAct thinking block.

This change:
- Safely parses `tool_output` content to detect and extract image data (base64).
- Renders images as clickable thumbnails using data URLs.
- Integrates `ImageModal` to allow users to view the generated images in full size.
2025-10-29 20:55:14 +05:30
Faisal Amir
a3bfef0f24
chore: updat title block thinking and tool call 2025-10-29 20:55:14 +05:30
Akarshan
d83b569f17
feat: Refactor reasoning/tool parsing and fix infinite tool loop prevention
This commit significantly refactors how assistant message content containing reasoning steps (<think> blocks) and tool calls is parsed and split into final output text and streamed reasoning text in `ThreadContent.tsx`.

It introduces new logic to correctly handle multiple, open, or closed `<think>` tags, ensuring that:
1.  All text outside of `<think>...</think>` tags is correctly extracted as final output text.
2.  Content inside all `<think>` tags is aggregated as streamed reasoning text.
3.  The message correctly determines if reasoning is actively loading during a stream.

Additionally, this commit:

* **Fixes infinite tool loop prevention:** The global `toolStepCounter` in `completion.ts` is replaced with an explicit `currentStepCount` parameter passed recursively in `postMessageProcessing`. This ensures that the tool step limit is correctly enforced per message chain, preventing potential race conditions and correctly resolving the chain.
* **Fixes large step content rendering:** Limits the content of a single thinking step in `ThinkingBlock.tsx` to 1000 characters to prevent UI slowdowns from rendering extremely large JSON or text outputs.
2025-10-29 20:55:12 +05:30
Akarshan
6e46988b03
fix: final text stream rendering 2025-10-29 20:52:00 +05:30
Faisal Amir
9699b4805c
chore: add smooth animation when step inside thinking and tool call 2025-10-29 20:52:00 +05:30
Akarshan
c129757097
chore: Refactor chat flow – remove loop, centralize tool handling, add step limit
* Move the assistant‑loop logic out of `useChat` and into `postMessageProcessing`.
* Eliminate the while‑loop that drove repeated completions; now a single completion is sent and subsequent tool calls are processed recursively.
* Introduce early‑abort checks and guard against missing provider before proceeding.
* Add `ReasoningProcessor` import and use it consistently for streaming reasoning chunks.
* Add `ToolCallEntry` type and a global `toolStepCounter` to track and cap total tool steps (default 20) to prevent infinite loops.
* Extend `postMessageProcessing` signature to accept thread, provider, tools, UI update callback, and max tool steps.
* Update UI‑update logic to use a single `updateStreamingUI` callback and ensure RAF scheduling is cleaned up reliably.
* Refactor token‑speed / progress handling, improve error handling for out‑of‑context situations, and tidy up code formatting.
* Minor clean‑ups: const‑ify `availableTools`, remove unused variables, improve readability.
2025-10-29 20:51:54 +05:30
Akarshan
2f00ae0d33
fix: do not add done after tool call output when there is another reasoning step 2025-10-29 20:30:21 +05:30
Akarshan
6d4d7d371f
fix: don't stream thought steps 2025-10-29 20:30:21 +05:30
Akarshan
44b62a1d19
fix: Refactor ThinkingBlock streaming, unify tool calls
- Replace raw text parsing with step‑based streaming logic in `ThinkingBlock`.
  - Introduced `stepsWithoutDone`, `currentStreamingStepIndex`, and `displayedStepIndex` to drive the streaming UI.
  - Added placeholder UI for empty streaming state and hide block when there is no content after streaming finishes.
  - Simplified expansion handling and bullet‑point rendering, using `renderStepContent` for both streaming and expanded views.
  - Removed unused `extractThinkingContent` import and related code.
  - Updated translation keys and duration formatting.

- Consolidate reasoning and tool‑call presentation in `ThreadContent`.
  - Introduced `shouldShowThinkingBlock` to render a single `ThinkingBlock` when either reasoning or tool calls are present.
  - Adjusted `ThinkingBlock` props (`text`, `steps`, `loading`) and ID generation.
  - Commented out the now‑redundant `ToolCallBlock` import and removed its conditional rendering block.
  - Cleaned up comments, unused variables, and minor formatting/typo fixes.

- General cleanup:
  - Updated comments for clarity.
  - Fixed typo in deletion loop comment.
  - Minor UI tweaks (bullet styling, border handling).
2025-10-29 20:30:21 +05:30
Akarshan
8601a49ff6
feat: enhance thinking UI, support structured steps, and record total thinking time
- **ThinkingBlock**
  - Added `ThoughtStep` type and UI handling for step kinds: `thought`, `tool_call`, `tool_output`, and `done`.
  - Integrated `Check` icon for completed steps and formatted duration (seconds) display.
  - Implemented streaming paragraph extraction, fade‑in/out animation, and improved loading state handling.
  - Updated header to show dynamic titles (thinking/thought + duration) and disabled expand/collapse while loading.
  - Utilized `cn` utility for conditional class names and added relevant imports.

- **ThreadContent**
  - Defined `ToolCall` and `ThoughtStep` types for type safety.
  - Constructed `allSteps` via `useMemo`, extracting thought paragraphs, tool calls/outputs, and a final `done` step with total thinking time.
  - Passed `steps`, `loading`, and `duration` props to `ThinkingBlock`.
  - Introduced `hasReasoning` flag to conditionally render the reasoning block and avoid duplicate tool call rendering.
  - Adjusted rendering logic to hide empty reasoning and ensure tool call blocks only appear when no reasoning is present.

- **useChat**
  - Refactored `getCurrentThread` for clearer async flow while preserving temporary‑chat behavior.
  - Captured `startTime` at message creation and computed `totalThinkingTime` on completion.
  - Included `totalThinkingTime` in message metadata when appropriate.
  - Minor cleanup: improved error handling for image ingestion and formatting adjustments.

Overall, these changes provide a richer, step‑by‑step thinking UI, better state handling during streaming, and expose total thinking duration for downstream components.
2025-10-29 20:30:21 +05:30
Nghia Doan
e7b7ac9e94
Merge pull request #6831 from janhq/feat/proactive_mode
feat: Proactive mode
2025-10-29 21:02:05 +07:00
Nguyen Ngoc Minh
e531eaa4ad
Merge pull request #6836 from janhq/chore/deprecate-webhook-discord
chore: deprecate webhook discord
2025-10-29 12:15:07 +07:00
Minh141120
23b03da714 chore: deprecate webhook discord 2025-10-29 11:48:32 +07:00
Vanalite
22be93807d Merge remote-tracking branch 'origin/dev' into feat/proactive_mode 2025-10-28 17:56:47 +07:00
Nguyen Ngoc Minh
653ecdb494
Merge pull request #6834 from janhq/chore/update-org-name
chore: update org name
2025-10-28 17:56:07 +07:00
Minh141120
15c426aefc chore: update org name 2025-10-28 17:26:27 +07:00
Vanalite
2fa153ac34 fix: Remove unused Proactive icon on chatInput
This icon doesn't do anything on chatInput but just an indicator when the proactive capability is activated. Safely remove since this can be indicated from the model dropdown
2025-10-28 17:04:31 +07:00
Dinh Long Nguyen
62bd91a1e1
fix: model should not include file attachment tools if not supported (#6833) 2025-10-28 16:58:18 +07:00
Vanalite
f7e0e790b6 feat: remove unnecessary TODO 2025-10-28 15:49:17 +07:00
hiento09
c854c54c0c
chore: update api domain to jan.ai (#6832) 2025-10-28 15:45:42 +07:00
Vanalite
a14872666a feat: Add tests for proactive mode 2025-10-28 12:19:00 +07:00
Vanalite
e9f469b623 feat: Proactively take screenshot and snapshot for every browser tool call 2025-10-28 11:48:55 +07:00
utenadev
5a016860aa
feat: Add Japanese translation (#6806)
This commit introduces Japanese as a supported language in the web application.

Key changes include:
- Addition of a new `ja` locale with 15 translated JSON resource files, making the application accessible to Japanese-speaking users.
- Update of the `LanguageSwitcher.tsx` component to include '日本語' in the language selection dropdown menu, allowing users to switch to the new language.
- The localization files were added by creating a new `ja` directory under `web-app/src/locales` and translating the content from the `en` directory.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
2025-10-27 19:53:36 +05:30
Vanalite
c773abb688 feat: Adding proactive button as experimental feature 2025-10-27 18:18:23 +07:00
Akarshan Biswas
2561fcd78a
feat: support multimodal tool results and improve tool message handling (#6816)
* feat: support multimodal tool results and improve tool message handling

- Added a temporary `ToolResult` type that mirrors the structure returned by tools (text, image data, URLs, errors).
- Implemented `convertToolPartToApiContentPart` to translate each tool output part into the format expected by the OpenAI chat completion API.
- Updated `CompletionMessagesBuilder.addToolMessage` to accept a full `ToolResult` instead of a plain string and to:
  - Detect multimodal content (base64 images, image URLs) and build a structured `content` array.
  - Properly handle plain‑text results, tool execution errors, and unexpected formats with sensible fallbacks.
  - Cast the final content to `any` for the `tool` role as required by the API.
- Modified `postMessageProcessing` to pass the raw tool result (`result as any`) to `addToolMessage`, avoiding premature extraction of only the first text part.
- Refactored several formatting and type‑annotation sections:
  - Added multiline guard for empty user messages to insert a placeholder.
  - Split the image URL construction into a clearer multiline object.
  - Adjusted method signatures and added minor line‑breaks for readability.
- Included extensive comments explaining the new logic and edge‑case handling.

These changes enable the chat system to handle richer tool outputs (e.g., images, mixed content) and provide more robust error handling.

* Satisfy ts linter

* Make ts linter happy x2

* chore: update test message creation

---------

Co-authored-by: Faisal Amir <urmauur@gmail.com>
2025-10-24 20:15:15 +05:30
locnguyen1986
28ed5e2af2
Merge pull request #6817 from menloresearch/fix/conversation-saving
we use POST to update now
2025-10-24 14:51:57 +07:00
nguyen.ngo
4c5c8e6aed we use POST to update now 2025-10-24 13:09:35 +07:00
Dinh Long Nguyen
f07e43cfe0
fix: conversation items (#6815) 2025-10-24 09:01:31 +07:00
Dinh Long Nguyen
e46200868e
web: update model capabilites (#6814)
* update model capabilites

* refactor + remove projects
2025-10-24 01:31:21 +07:00
Akarshan Biswas
147cab94a8
fix: Escape dollar signs followed by numbers in Markdown (#6797)
This commit introduces a change to prevent **Markdown** rendering issues where a dollar sign followed by a number (like **`$1`**) is incorrectly interpreted as **LaTeX** by the rendering engine.

---

The `normalizeLatex` function in `RenderMarkdown.tsx` now explicitly escapes these sequences (e.g., **`$1`** becomes **`\$1`**), ensuring they are displayed literally instead of being processed as mathematical expressions. This improves the fidelity of text that might contain currency or similar numerical notations.
2025-10-16 12:15:24 +05:30
Nguyen Ngoc Minh
2fb956ccaf
Merge pull request #6798 from menloresearch/docs/changelog-v0.7.2
docs: update changelog for Jan v0.7.2
2025-10-16 13:26:36 +07:00
Minh141120
4dee0a4ba1 docs: update changelog for Jan v0.7.2 2025-10-16 13:18:20 +07:00
Nguyen Ngoc Minh
418a48ab39
Merge pull request #6790 from menloresearch/chore/happy-dom-update
chore: update happy dom deps version
2025-10-15 02:53:24 -07:00
Minh141120
9bc56f6e30 chore: remove redudant deps in yarn lock file 2025-10-15 15:15:38 +07:00
Minh141120
f0ca9cce35 chore: update happy-dom version 2025-10-15 14:43:58 +07:00
Faisal Amir
746dbc632b
Merge pull request #6766 from menloresearch/feat/file-attachment
feat: file attachment
2025-10-15 11:01:40 +07:00