Skip to content

LocalAI-Chat-v1.20

Latest

Choose a tag to compare

@LMLK-seal LMLK-seal released this 25 Jun 16:11
c4ae38a

Changelog

v1.2.0 — Agentic IDE features (tool use, syntax highlighting, command palette)

This release transforms the extension from a chat-with-code into a real
agentic IDE — comparable to Cursor, Cline, and Aider. Six major features
added, all 100% offline, no new external network dependencies.

1. Tool use / function calling (agent mode)

Files: src/tools.js (new), src/chat-manager.js (agent loop)

The model can now actually do things — not just suggest code. Toggle
agent mode with the 💬/🤖 button in the topbar (or ⌘/). In agent mode,
the model is prompted to emit <tool_call> blocks that invoke one of:

Tool Category Description
read_file read Read a file's contents
list_directory read List a directory's contents
grep_search read Regex search across files (with line numbers)
glob_find read Find files matching a glob pattern
write_file write Write content to a file (requires user approval)

Read tools execute immediately and show a tool-call card with the
result. Write tools show an approval card with Approve/Reject buttons
— the agent loop pauses until the user decides.

The agent loop continues until the model stops calling tools or hits the
step cap (10 by default, prevents infinite loops). Each tool call is
visible in the chat as a card showing the tool name, arguments, and
result — fully transparent.

2. Syntax highlighting (highlight.js)

Files: src/highlight.js (new), src/markdown.js, lib/highlight/* (new)

Code blocks and the file viewer now have proper syntax highlighting via
highlight.js (BSD-3-Clause, bundled — no
network fetch). 17 languages included: Python, JavaScript, TypeScript,
XML/HTML, CSS, JSON, Bash, SQL, YAML, Markdown, Go, Rust, Java, C, C++,
Ruby, PHP.

The github-dark theme is used by default and matches the extension's
dark mode.

3. @-mention autocomplete

Files: src/ide-features.js (new), src/app.js

Typing @ in the composer now shows a fuzzy-searchable dropdown of files
in the workspace. Arrow keys to navigate, Enter to insert @file:path.
This is the Cursor-style mention experience — no need to know exact paths.

4. File finder (Cmd+P) + Command palette (Cmd+Shift+P)

Files: src/ide-features.js (CommandPalette class), src/app.js

VSCode's signature features:

  • ⌘P (or Ctrl+P) — fuzzy file finder. Type a few letters, get
    matching files in the workspace. Enter to open in the file viewer.
  • ⌘⇧P (or Ctrl+Shift+P) — command palette. Fuzzy-searchable list of
    all extension commands: new chat, open workspace, toggle theme, toggle
    agent mode, export, reload model, etc.

Both use a custom fuzzy matcher that scores by word-boundary matches,
substring position, and target length.

5. Plan/Act mode toggle

Files: src/chat-manager.js, src/app.js, newtab.html

The 💬 Chat / 🤖 Agent toggle in the topbar switches between:

  • Chat mode — standard back-and-forth, no tool use. Faster, simpler.
  • Agent mode — tool use enabled, model can read/write files via
    tool calls. Write tools require approval.

Keyboard shortcut: ⌘/ (or Ctrl+/).

6. Multi-tab file viewer

Files: src/ide-features.js (TabManager class), src/app.js

The file viewer now supports multiple open files in tabs — like VSCode.
Double-click a file in the tree to open it in a new tab. Click tabs to
switch. × to close. Tabs persist for the session. Syntax highlighting
is applied per-tab based on file extension.

Keyboard shortcuts

Shortcut Action
⌘P / Ctrl+P File finder
⌘⇧P / Ctrl+Shift+P Command palette
⌘K / Ctrl+K Focus composer
⌘B / Ctrl+B Toggle sidebar
⌘/ / Ctrl+/ Toggle agent mode
Enter Send message
Shift+Enter Newline in composer
Escape Close modal / dropdown

Files changed

  • New: src/tools.js, src/highlight.js, src/ide-features.js
  • Modified: src/app.js, src/chat-manager.js, src/markdown.js, newtab.html, newtab.css, PRIVACY.md, privacy-policy.html
  • New bundled library: lib/highlight/ (highlight.js core + 17 language packs + github-dark theme, ~224 KB total)

v1.1.2 — Critical fix: promoted code fences were not rendering

Bug: In v1.1.1, when the model used a markdown code fence instead of
a <file> block, the code-fence-to-file-block promotion logic correctly
computed the promoted blocks and replaced the code fence with a pointer
text ("Code promoted to file block: X — see card below") — but the file-
block card itself was never rendered due to a variable-shadowing bug.

Root cause: _renderMessage in src/chat-manager.js computed the
fileBlocks array (including promoted code fences) at the top of the
function, then re-declared const fileBlocks = parseFileBlocks(...) in
the assistant-only rendering block below. The inner declaration shadowed
the outer one, and parseFileBlocks only finds real <file> blocks —
so when no real <file> blocks existed, the rendering loop never ran,
and the user saw the pointer text but no card (effectively losing the
code from view).

Fix: Removed the inner const fileBlocks = parseFileBlocks(...)
re-declaration. The outer fileBlocks (which already includes promoted
code fences when applicable) is now used for the rendering loop.

Files changed: src/chat-manager.js (one block of code rewritten).


v1.1.1 — Code-fence-to-file-block promotion (fixes "no Apply button")

Problem: When the model wrapped its code in a markdown code fence
(```python ... ```) instead of the <file path="..."> block format the
system prompt asks for, the extension only showed a "💾 Save" button (which
prompts for a filename one at a time, with no diff, no undo, no Apply-all).
The proper Apply / Preview / Undo / Apply-all UI only appeared when the model
used <file> blocks — which smaller models (Qwen 0.5B/1.5B, Llama-3.2-1B,
etc.) often don't follow.

Fix: When an assistant message contains NO <file> blocks but DOES
contain code fences with a language tag (and a workspace is open), the code
fences are now automatically promoted to first-class file-block cards with
the full Apply / Preview / Undo / Apply-all UI.

Files changed:

  • src/file-renderer.js — new parseCodeFences, guessFilenameFromPrompt,
    promoteCodeFencesToFileBlocks exports; renderFileBlock now supports
    editable paths (click the path to rename before applying) and a "guessed"
    badge for promoted blocks.
  • src/chat-manager.js_renderMessage and send() auto-apply now use
    the promotion logic when no real <file> blocks are found.
  • newtab.css — styles for promoted file blocks (accent left-border),
    the "guessed" badge, and the editable path input.

Filename guessing strategy:

  1. If the user's prompt contains "save as X" / "name it X" / "call it X",
    use that filename.
  2. Else, extract the first 1–4 words from the prompt (after stripping
    filler like "write me a", "in python", etc.) and slugify them.
    Example: @workspace write me a tic tac toe game in python
    tic_tac_toe_game.py.
  3. Fallback: snippet-<N>.<ext>.

Minimum fence size: Code fences must have at least 3 content lines to
be promoted. Shorter fences (e.g. print("hello")) are treated as inline
examples and left as-is.

Editable path: The path on a promoted file-block card is clickable.
Click it → it becomes a text input → type a new path → Enter to confirm
or Escape to cancel. The path is re-sanitized on commit (absolute paths
and .. traversal are rejected).


v1.1.0 — Tier 1 strategic additions

This release ships 8 major feature areas on top of the v1.0.1 Tier 0
robustness fixes. All features are 100% offline, add no new external
dependencies, and preserve backward compatibility with existing user data.

1. Model persistence via IndexedDB blobs

Files: src/model-store.js (new), src/app.js

Reload the tab → your model survives. Models are saved to IndexedDB
as Blobs (one record per model + optional mmproj companion) and listed
on the drop overlay under "Recent models". One-click reload without
re-picking the file.

A "Clear" button removes the cached blobs (the original files on disk
are not affected).

2. Model library & metadata

Files: src/model-loader.js (parseGgufHeader, _buildDisplayMeta), src/app.js, newtab.html

The model card in the sidebar now shows architecture · parameter count ·
quantization · file size, parsed directly from the GGUF binary header
(no network call, no external library). Examples:

  • llama · 1.5B · Q4_K_M · 950 MB · vision
  • qwen2 · 7B · Q5_K_M · 5.2 GB
  • gemma · 2B · F16 · 5.0 GB

A memory-budget indicator on the drop overlay shows the tab's available
JS heap (via performance.memory) and color-codes it green / amber / red
based on whether a typical small model will fit.

3. Token-aware context management

Files: src/token-counter.js (new), src/chat-manager.js, newtab.html

The old naive slice(-8, -1) truncation is gone. The new
fitToTokenBudget function:

  • Estimates tokens per message using a chars/4 heuristic for ASCII and
    chars/1.5 for CJK (covers English, code, and Chinese text within ±20%).
  • Reserves space for the system prompt + max_tokens + a 512-token
    safety margin for the chat template's special tokens.
  • Always keeps the system message(s) and the most recent turns; drops
    older middle messages first.
  • Reports how many messages were dropped via the context-usage bar in
    the topbar.

The context-usage bar (ctx used / ctx size) color-codes green < 60%,
amber 60–85%, red > 85%, so the user knows when their conversation is
about to start losing history.

4. Conversation management power features

Files: src/chat-manager.js, src/app.js, newtab.html

  • Search: a search box at the top of the chats sidebar filters by
    title or message content (case-insensitive substring match).
  • Rename: double-click any chat title to rename it.
  • Per-message Delete: every message now has a Delete button (with
    confirmation). The conversation is re-persisted immediately.
  • Edit & resend: user messages have an "Edit & resend" button that
    truncates the conversation to just before that message, loads the
    original text into the composer, and re-attaches any images that
    were on the message.
  • Fork: assistant messages have a Fork button that creates a new
    conversation cloned with everything up to (and including) that
    message, so the user can explore an alternative branch without
    losing the original.
  • Export Markdown: one click downloads the current chat as a
    formatted .md file (speaker headings, file-block summaries, etc.).
  • Export JSON (backup): downloads all conversations as a single
    JSON file with a localai-chat-export envelope.
  • Import JSON: merge a previously-exported JSON backup into the
    current list (duplicate IDs are auto-renamed).

5. Prompt library & slash commands

Files: src/prompt-library.js (new), src/app.js, newtab.html

Built-in slash commands (always available):

Command Action
/clear Start a new chat
/summarize Summarize the conversation in 5 bullets
/translate <lang> [text] Translate the selected text or last message
/review Review code in @workspace or attached file
/tests Generate unit tests for the most recently discussed code
/explain Explain the previous answer in simpler terms
/rename <new title> Rename the current chat
/export Export the current chat as Markdown
/help Show all available commands

User snippets are stored in chrome.storage.local and edited via a
collapsible snippet editor in the Settings panel. Snippets support
{{selection}}, {{args}}, and {{date}} variable substitution.

A floating autocomplete dropdown appears above the composer when the
user types /, with arrow-key navigation and Enter to complete.

6. File editing workflow v2

Files: src/file-history.js (new), src/file-renderer.js, src/workspace.js, src/app.js, newtab.html

  • Undo for Apply: every Apply (single or Apply-all) snapshots the
    existing file content to IndexedDB before overwriting. An Undo button
    appears on each file-block card after Apply; clicking it restores the
    previous version (or deletes the file if it didn't exist before Apply).
    Up to 10 snapshots per file path are kept.
  • Diff preview modal: a Preview button on each file-block opens a
    full-screen modal showing the line-by-line diff (or all-green "new
    file" content), with context-collapse for long unchanged runs and a
    stats footer (+adds −dels).
  • In-app file viewer: double-click any file in the workspace tree
    to open it in a read-only modal. A @ Mention button in the header
    inserts @file:path into the composer.
  • Polling file watcher: every 5 seconds (when the tab is visible),
    the workspace tree is re-scanned and compared to a signature; if it
    changed externally, the file tree is re-rendered and any open file
    viewer is refreshed. A manual ⟳ refresh button is also available.

7. Document parsing upgrades

Files: src/document-parser.js, newtab.html

New supported formats (in addition to PDF, DOCX, DOC, TXT, MD):

Format Parser Notes
CSV / TSV Built-in Renders as a markdown table, capped at 200 rows
HTML / HTM DOMParser Strips script/style, preserves block structure
RTF Built-in Strips control words, decodes \uN and \'XX escapes
JSON JSON.parse Pretty-printed, capped to 100K chars

Size caps (prevent context-window blowups):

  • PDFs: extract at most 100 pages. Larger PDFs are truncated with a note.
  • All other formats: cap at 100K characters (~25K tokens). Truncation
    marker is appended.

PDF text extraction now uses includeMarkedContent-aware joining with
newlines on hasEOL, giving better reading order for most PDFs.

The file-input accept attribute is updated to include all new formats.

8. Accessibility

Files: newtab.html, newtab.css, all source files

  • ARIA roles: role="region", role="navigation", role="tablist"
    / role="tab" / role="tabpanel", role="list" / role="listitem",
    role="dialog" + aria-modal="true" for modals, role="status" for
    the toast, role="listbox" / role="option" for the slash dropdown.
  • aria-live regions: toast, drop-status, TPS badge, context-usage
    bar, file-viewer title — all announce changes to screen readers.
  • aria-label on every icon-only button (theme toggle, sidebar
    toggle, settings, attach image, upload doc, close, etc.).
  • Skip-link: a "Skip to chat" link is the first focusable element;
    pressing Enter jumps focus to the messages container.
  • prefers-reduced-motion: disables the cursor-blink animation,
    the load-progress spinner, and all CSS transitions.
  • prefers-contrast: more: increases border and dim-text contrast.
  • prefers-color-scheme: on first run, auto-detects the system
    theme (light or dark). Subsequent explicit toggles are respected.
  • Focus-visible: all interactive elements show a 2px accent-colored
    outline on keyboard focus.
  • Keyboard nav: ESC closes modals (file viewer, diff preview);
    ArrowUp/ArrowDown + Enter navigates the slash command dropdown.

v1.0.1 — Tier 0 robustness fixes

12 fixes addressing bugs and gaps in v1.0.0. See the v1.0.1 section of
the git history (or the inline FIX #N comments throughout the source)
for details. Highlights:

  • CPU threads setting honored (was hardcoded to 1)
  • Stream toggle actually toggles
  • maxTokens default synced (512 → 2048)
  • Single apply panel (no more stacking)
  • Regenerate uses stashed metadata, not string-split
  • Debounced streaming re-render via requestAnimationFrame
  • Diff capped at 800 lines, falls back to plain content
  • Multi-template prompt fallback (Llama-3, Llama-2, Mistral, Gemma, Qwen, Phi, DeepSeek, Yi)
  • Path sanitization on file-block Apply (rejects .. and absolute paths)
  • CSP enforces offline-ness (connect-src 'self')
  • web_accessible_resources restricted
  • Per-conversation storage + unlimitedStorage permission + auto-migration