Commit Graph
100 Commits
Author SHA1 Message Date
diguaandClaude Fable 5 82ce9dcc2f feat(owner): auto-apply owner profile after pull sync and CLI import
PullEngine gains an onSessionImported hook (hook errors never fail the
pull), wired in both the CLI server and Electron main to silently fill
session owner from the stored platform profile. The chatlab import CLI
command does the same after a successful import.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-13 13:16:52 +08:00
diguaandClaude Fable 5 502762bcf5 feat(owner): add owner prompt modal and unify owner selection UI
Opening an unowned session first tries to auto-apply the platform
owner profile; only when that fails (and the session is not dismissed)
a lightweight searchable prompt pops up with Later / Don't remind /
Save actions. Member management now uses an entry card opening the
same modal, replacing the embedded OwnerSelector dropdown. Imports in
the session store silently retry profile application per session.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-13 13:16:52 +08:00
diguaandClaude Fable 5 a75d17e310 feat(owner): add owner profile service and shared web routes
Shared node-runtime service writes session owner, maintains the
per-platform profile in preferences.json, and batch-applies it to
other unowned same-platform sessions (unique match only, never
overriding an existing owner). Exposed via /_web/sessions/:id/owner/
{apply-profile,select,dismiss-prompt} for both Electron and CLI Web.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-13 13:16:52 +08:00
diguaandClaude Fable 5 7589515eeb feat(owner): add platform-level owner profile types and matching
Add deterministic owner matching in core (exact platformId first, then
normalized-name fallback limited to whatsapp/line/instagram), plus
OwnerProfile preferences fields shared across Electron and CLI Web.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-13 13:16:52 +08:00
digua 82a6be4fcb fix(sync): delete imported session files completely 2026-06-13 13:16:52 +08:00
digua 848a44310c fix(ai): preserve render chart order 2026-06-11 22:35:07 +08:00
digua 3725a5bbea fix(ai): remove empty render-only chart rows 2026-06-12 11:36:46 +08:00
digua fc2ecf7b27 fix(capture): resize charts before screenshots 2026-06-12 11:36:46 +08:00
digua 56693685fa fix(ai): stabilize chart rendering during streaming 2026-06-12 11:36:46 +08:00
digua eea7ed88b9 fix(ai): show chart generation progress 2026-06-12 11:36:46 +08:00
diguaandClaude Opus 4.8 bd1bc037b3 fix(ai): clarify last_message_time is data coverage end, not group activity time
AI was treating last_message_time as "when the group last had activity"
and drawing inferences like "the group has been quiet for two months,
maybe send a message to revive it." In reality, the timestamp only
reflects the end of imported data — the user may simply not have
imported newer records yet.

Add an inline parenthetical to the last_message_time field in all four
locale templates, and append a dedicated usage rule in
dataSnapshotUsageRules (zh-CN, en-US, zh-TW, ja-JP) explicitly
prohibiting inferences about group inactivity based on this value.
Also add the same note to formatDataSnapshotForPlanner's notes section
in data-snapshot.ts.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-12 11:36:46 +08:00
diguaandClaude Opus 4.8 7316a09823 fix(ai): fix stale overview and analysis caches after incremental import
Overview cache had no self-invalidation: once written it would return
stale lastMessageTs forever if the postImportHook failed silently.
Analysis query cache (17 chart/stats queries) was never cleared on
import, so charts showed stale data until the user triggered a manual
invalidate.

Add MAX(message.id) fingerprint to OverviewCache and introduce
getValidatedOverviewCache(), which recomputes automatically when new
messages are inserted. Update resolveOverview() in the Electron worker
to use this instead of bare getCache().

In both postImportHooks (incrementalImport, streamImport) also call
deleteSessionCache against the query cache directory so chart data is
fresh after every import.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-12 11:36:46 +08:00
digua ce5e6c2d4a release: v0.26.1 2026-06-10 22:28:51 +08:00
diguaandClaude Sonnet 4.6 76acbabcc2 fix(ai): preserve tool-only turns in history replay and fix export regressions
- Include assistant messages with tool content blocks in getHistoryForAgent
  even when text content is empty, so multi-turn tool results are not lost
- Append Date.now() timestamp to export filenames to prevent silent overwrites
- Pass 600s timeout to exportFilterResultToFile worker call to match the
  actual upper bound of large-session exports

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-10 22:18:20 +08:00
diguaandCursor 39700b95b7 feat(ai): display cache hit/miss token usage in chat status bar
Extend TokenUsage types across the full data pipeline to include
cacheReadTokens and cacheWriteTokens. The ChatStatusBar tooltip now
shows cache hit information when available. This is a generic
implementation that works with any API provider reporting cache metrics,
not limited to DeepSeek.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-10 22:18:20 +08:00
diguaandCursor 2b6aed52c9 fix(ai): replay reasoning_content for DeepSeek tool-call turns
DeepSeek API requires reasoning_content to be retransmitted on assistant
messages that precede tool results. Add ReplayOptions to history replay
so thinking blocks are included as ThinkingContent when the model uses
DeepSeek-format thinking, preventing 400 errors in multi-turn tool-call
conversations.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-10 22:18:20 +08:00
digua 42649d835d fix(ai): count replayed tool results in compression token accounting 2026-06-10 22:18:20 +08:00
diguaandClaude Fable 5 9c7778f7e3 fix(ai): keep rawMessages out of LLM-facing tool result text
Message-retrieval tools mirror rawMessages inside data, and the
preprocessing pipeline rendered that array into the tool result text as
"rawMessages: [object Object], [object Object], ..." — roughly 1.7KB of
junk per call (~400-500 wasted tokens) that also polluted the truncated
result text persisted for history replay.

- formatToolResultAsText skips the rawMessages key (raw message objects
  are already rendered via the formatted messages list)
- CLI tool adapter strips rawMessages from extraDetails before invoking
  the pipeline, matching the existing desktop adapter behavior

Regression tests fail without the fix at both the format layer and the
CLI adapter layer.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 22:18:20 +08:00
diguaandClaude Fable 5 ad96dca7ac fix(ai): persist and replay tool calls in chat history
Multi-turn agent conversations rebuilt history as plain text, dropping
all tool calls and results. Later turns could not see what the model
had actually retrieved, so it imitated tool-free answers and
hallucinated chat records instead of re-querying (worse after
incremental imports and in long conversations).

- Persist provider-issued toolCallId, truncated result text and isError
  on tool content blocks (written by the shared frontend store from
  stream chunks; pi-agent-core events already carry these fields)
- Replay persisted tool blocks as real toolCall/toolResult message
  pairs in toPiHistoryMessages: stable ids keep requests byte-identical
  across turns (prompt cache friendly), unfinished blocks are skipped
  so no toolCall is left unanswered, errors map to isError, results are
  capped at 4000 chars, runtime-injected underscore params are stripped
- Legacy messages without persisted tool data fall back to the old
  plain-text replay; no migration needed

Verified on a real CLI web session: 25+ replayed tool pairs accepted by
the provider across turns with zero API errors.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 22:18:20 +08:00
digua 6ec736c05a feat(export): simplify message export and support multiple formats 2026-06-10 22:18:20 +08:00
digua 4f1aac55b6 refactor(layout): share session page header 2026-06-10 22:18:20 +08:00
digua bbcc350d97 fix(layout): close tools panel on outside click 2026-06-10 22:18:20 +08:00
digua b831c4ead8 release: v0.26.0 2026-06-10 00:25:22 +08:00
diguaandClaude Sonnet 4.6 7f6b8238e4 fix(ai): keep render_chart when chart skill is explicitly selected
In explicit chart auto mode, the filter at agent/index.ts removed
render_chart whenever the user message lacked chart keywords. This
caused failures when a user manually selected the built-in chart skill
with a message like "analyze message trends" — the skill prompt
instructed the AI to produce charts but the tool was unavailable.

Add an isExplicitChartSkill guard so the filter is skipped when
skillCtx.skillDef.id === CHART_CAPABILITY_SKILL_ID.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-10 00:15:25 +08:00
diguaandClaude Sonnet 4.6 7239589146 fix(charts): migrate ECharts 6 containLabel and hide redundant pie legend
- Replace `containLabel: true` with `outerBoundsMode: 'same'` in
  EChartLine, EChartBar, EChartHeatmap to suppress the ECharts 6
  deprecation warning; `outerBoundsMode: 'same'` is the semantic
  equivalent (outer boundary equals the grid rect, labels fit inside)
- In EChartPie, auto-hide the right-side legend when outer labels
  (indicator lines + text) are already visible, and center the chart
  accordingly to avoid redundant information

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-10 00:15:25 +08:00
diguaandClaude Sonnet 4.6 842866aff3 fix(settings): reorder nav, rename skillSettings key, fix SubTabs wrapping
- AISettingsTab: move 对话偏好 above 工具设置 in left nav to match content order
- Rename i18n key skillSettings → chatPreferences across all locales and
  components; the section covers general chat preferences, not just skills
- SubTabs: add whitespace-nowrap + shrink-0 to tab buttons and overflow-x-auto
  to horizontal container so labels never wrap at narrow desktop widths

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-10 00:15:25 +08:00
diguaandClaude Sonnet 4.6 0ae7ab0c18 fix(ai): fix tool availability gap in explicit chart mode and plan status after error
- agent-stream-runner: add fallback allowedBuiltinTools in explicit chart
  auto-skill path so unrestricted assistants still load analysis tools when
  skill menu advertises skills that require them
- aiChat: guard updatePlanBlockStatus('done') with !hasStreamError in both
  SSE and edit-stream handlers so failed plans stay visibly failed instead
  of being overwritten by the terminal done event

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-10 00:15:25 +08:00
diguaandClaude Sonnet 4.6 56ad4a9578 feat(ai): prefer high-level tools over raw SQL when rendering charts
Add optional `rows` parameter to render_chart so AI can pass pre-fetched
data arrays (e.g. from get_time_stats, member_stats) directly instead of
rewriting SQL from scratch. Update chart capability prompts and all locale
files to guide AI to check high-level tools first before falling back to SQL.
Remove debug console.debug log from agent-core thinkingLevel resolution.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-10 00:15:25 +08:00
digua e71956ae3c fix(ai): let assistant messages fill chat width 2026-06-10 00:15:25 +08:00
digua 1290ae6569 feat(ai): add chart auto mode preference 2026-06-10 00:15:25 +08:00
digua 84a3b13017 feat(ai): improve analysis and chart behavior 2026-06-10 00:15:25 +08:00
digua 6594e586d3 feat(ai): guide planner with startup context 2026-06-10 00:15:25 +08:00
digua 718735a748 feat(ai): build extended data snapshots 2026-06-10 00:15:25 +08:00
digua 383af0b13a feat(ai): enrich session data snapshot prompt 2026-06-10 00:15:25 +08:00
digua f578c3597a fix(ai): polish plan generation block 2026-06-10 00:15:25 +08:00
digua 77d0f5b407 feat(ui): add copy id actions 2026-06-10 00:15:25 +08:00
digua 0801ccf940 feat(ai): stream structured analysis plans 2026-06-10 00:15:25 +08:00
digua 9ad012680d feat(ai): integrate chart planning support 2026-06-10 00:15:25 +08:00
digua 6f54dcc62b feat(cli): expose full agent stream events 2026-06-10 00:15:25 +08:00
digua 2d413f4202 feat(ai): render analysis plan blocks 2026-06-10 00:15:25 +08:00
digua b61974136e feat(ai): emit analysis plan guidance 2026-06-10 00:15:25 +08:00
digua 645f0c6789 feat(ai): add analysis planner core 2026-06-10 00:15:25 +08:00
digua 8ca3f0be8b feat(ai): add llm fallback for shadow routing 2026-06-10 00:15:25 +08:00
digua 712d5212c2 feat(ai): log shadow agent route decisions 2026-06-10 00:15:25 +08:00
digua bd19512f92 test(ai): add agent routing evaluation set 2026-06-10 00:15:25 +08:00
diguaandClaude Sonnet 4.6 f5e83748ff fix(ai): register execute_sql tool in Electron tool registry
sqlQueryTool (execute_sql) was listed in BUILTIN_TOOL_CATALOG and
available in the CLI AGENT_TOOL_REGISTRY, but was never imported or
registered in the Electron-specific TOOL_REGISTRY. Users who enabled
the tool via the assistant config panel would trigger a missing-tool
error at inference time.

Add sqlQueryTool to the Electron registry following the same
adaptSharedTool pattern used by all other analysis tools. Add a
catalog/registry drift guard test (name + category) covering all
BUILTIN_TOOL_CATALOG entries, enabled via
--experimental-test-module-mocks to mock Electron runtime deps.
Document the general-over-specific assertion rule in AGENTS.md.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-10 00:15:25 +08:00
diguaandClaude Opus 4.8 7af7fb1f10 fix: persist thinking level selection across restarts
thinkingLevels was excluded from the mergeDefaults whitelist in
PreferencesManager, so user choices were silently dropped on every
save/load cycle and never written to preferences.json.

Add the field to the Preferences interface, DEFAULTS, and mergeDefaults
so the existing backendPersist → savePreferences pipeline can write and
restore it correctly. Adds regression tests covering the save/load
round-trip, multi-save merge, and legacy-file backward compatibility.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 00:15:25 +08:00
digua 44cc22817b release: v0.25.1 2026-06-08 00:03:58 +08:00
diguaandClaude Sonnet 4.6 c3a5d22a43 fix: enforce data directory compatibility gate at runtime boundaries
MCP server checks the gate at startup and exits before opening stdio if
the data directory requires a newer runtime. Desktop HTTP API maps
DataDirCompatibilityError (including wrapped causes) to a 409 response
so the renderer can surface a clear upgrade prompt.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-08 10:14:42 +08:00
diguaandClaude Sonnet 4.6 e7561e224e fix: write data directory compatibility gate on migration and import
Harden the startup migration path: fail fast and show an error dialog if
schema migration cannot complete. Repair the gate retroactively for
databases that were already migrated before the gate system existed.

Raise the gate after every import path (full import, incremental import,
stream import) and after opening any database that already carries a
current-segment schema. Centralise gate-raising inside DatabaseManager so
call sites cannot accidentally skip it.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-08 10:14:42 +08:00
diguaandClaude Sonnet 4.6 1c7781d85b fix: establish runtime identity for data directory gates
Use the packaged app version (not Electron's dev-mode 0.0.0) across all
compatibility checks. Make DatabaseManager require a RuntimeIdentity so
every gate write carries a verified version and kind.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-08 10:14:42 +08:00
digua 3f96d31819 docs: document data directory compatibility gate 2026-06-08 10:14:42 +08:00
digua 6ae32e8b57 feat(http): report incompatible data directories 2026-06-08 10:14:42 +08:00
digua ad8181d6f4 feat(desktop): enforce data directory compatibility 2026-06-08 10:14:42 +08:00
digua 84b42a68f7 feat(cli): block incompatible data directories at startup 2026-06-08 10:14:42 +08:00
digua c518a4d968 feat(runtime): gate database access by data dir compatibility 2026-06-08 10:14:42 +08:00
digua c0885ba053 feat(runtime): add data directory compatibility gate 2026-06-08 10:14:42 +08:00
digua 2111abae5f docs: refine test maintenance guidance 2026-06-08 10:14:42 +08:00
digua 6b29c07326 test(routes,tools): cover high-risk analysis paths 2026-06-08 10:14:42 +08:00
digua 187268d8a5 test(core,import): rebalance database coverage 2026-06-08 10:14:42 +08:00
digua 2887f1cb73 test(parser,config): cover representative fixtures and migrations 2026-06-08 10:14:42 +08:00
digua 2d88215d63 test: add default test runner 2026-06-08 10:14:42 +08:00
diguaandClaude Sonnet 4.6 33353be9e2 docs(agents): expand development guidelines in AGENTS.md
Add review/judgment principles, project map, test strategy,
commands/validation guide, code conventions, architecture boundaries,
compatibility/migration rules, and security/release checklist.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-07 20:27:27 +08:00
diguaandClaude Sonnet 4.6 62ad3c6248 fix: normalize legacy tool names and harden cli chat command
- Add normalizeBuiltinToolNames() to map old session-based tool names
  (search_sessions, get_session_messages, get_session_summaries) to
  current segment names; applied in assistant parser, agent-stream-runner,
  and desktop tool-filter so existing assistant configs keep working
- Propagate agent stream error chunks as thrown Errors in CLI chat command
- Pass assistantId through ResolvedAIChatTarget to agent stream
- Preserve legacy chat_session rows in v6 migration when segment table
  already exists (INSERT OR IGNORE + DROP); revert v3/v5 DDL to chat_session
- Rename session_id alias to segment_id in relationship query
- Add tests: assistant-parser normalization, tool-filter legacy names,
  agent-stream-runner legacy allowlist, REPL error resilience, migration paths

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-07 20:27:27 +08:00
digua 9b17b09354 feat: add cli ai chat command 2026-06-07 20:27:27 +08:00
digua c2295e317f refactor: align ai chat and segment identifiers 2026-06-07 20:27:27 +08:00
digua 82bad3a23a release: v0.25.0 2026-06-07 15:21:12 +08:00
digua 093fdd1f2d chore(skills): remove maintainer skills from public repo 2026-06-07 14:38:50 +08:00
digua 4347c596ca docs: update iMessage export guide 2026-06-05 11:12:42 +08:00
digua 31f3c610ce fix(ai): increase default tool rounds 2026-06-05 11:12:42 +08:00
digua 9b1f359699 fix(ai): register chart tool for electron auto skills 2026-06-05 11:12:42 +08:00
digua f825c0734b refactor(ai): deduplicate skill menu and manager 2026-06-05 11:12:42 +08:00
digua 953471a514 fix(dev): clean up web backend lifecycle 2026-06-05 11:12:42 +08:00
digua 296573ed5c refactor(ai): centralize chart runtime policy 2026-06-05 11:12:42 +08:00
digua dbc377854a fix(desktop): reset titlebar overlay cache on theme change 2026-06-05 11:12:42 +08:00
digua 0bd4d31dd2 fix(ui): adjust preset chip stacking 2026-06-05 11:12:42 +08:00
digua 483907f1ac release: v0.24.1 2026-06-04 14:44:48 +08:00
digua 5144c8070a fix(update): suppress cli dev update badge 2026-06-04 14:37:12 +08:00
digua 8b2e6de479 fix: harden preferences and update notice checks 2026-06-04 14:37:12 +08:00
digua f4580c55f1 fix(ai): ensure builtin masking rules before preprocessing 2026-06-04 14:37:12 +08:00
digua cd9f297124 fix(update): harden update notice checks 2026-06-04 14:37:12 +08:00
digua 2a44f8b69e fix(preferences): preserve legacy builtin masking overrides 2026-06-04 14:37:12 +08:00
digua 9030d6b0c3 feat(update): add in-app update notice 2026-06-04 14:37:12 +08:00
digua 218c3c9ee9 feat(ai): group desensitize rules 2026-06-04 14:37:12 +08:00
digua 0c82a300e8 feat(ai): enable preprocess defaults 2026-06-04 14:37:12 +08:00
digua a780517539 docs: add contributor development guide 2026-06-04 14:37:12 +08:00
digua a42c23af15 ci(release): link markdown changelog 2026-06-04 14:37:12 +08:00
digua fbfe635838 release: v0.24.0 2026-06-03 13:37:02 +08:00
digua 6e016837bc fix(data): harden directory and database migrations 2026-06-03 00:46:34 +08:00
digua f234a25ff6 fix(storage): require legacy data before showing migrate hint 2026-06-03 00:46:34 +08:00
digua 42837278fa fix(data): migrate legacy chat database columns before reads 2026-06-03 00:46:34 +08:00
digua bb4986d703 fix(storage): reset legacy data hint after directory changes 2026-06-03 00:46:34 +08:00
digua e68ce77266 feat(data): support CLI web data directory migration 2026-06-03 00:46:34 +08:00
digua a94986f117 feat(storage): allow ignoring legacy data prompt 2026-06-03 00:46:34 +08:00
digua 04c97ca9cf fix(data): defer data directory migration until restart 2026-06-03 00:46:34 +08:00
diguaandClaude Sonnet 4.6 f978845dde fix(layout): migrate isSidebarCollapsed persistence from sessionStorage to localStorage
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-03 00:46:34 +08:00
diguaandClaude Opus 4.8 f09d40f436 feat(changelog): generate per-language markdown from JSON
Add scripts/changelog-to-markdown.mjs that renders changelogs/{cn,en,tw,ja}.json
into readable Markdown files. Runs idempotently; output passes Prettier without
changes.

Wire the script into the sync-changelog skill (step 4, before the release commit)
and update commit_release_changelogs.sh to include the four .md files in the
release: v<version> commit, with a preflight guard that errors if the md files
are missing.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-03 00:46:34 +08:00
diguaandClaude Opus 4.8 2f8591fb8c perf(build): minify main process and lazy-load tiktoken rank table
Enable esbuild minification for main/preload (was renderer-only by default),
reducing main process bundle by ~55%. Extract cl100k_base BPE rank table out
of the synchronous startup path via dynamic import — it now lands in its own
chunk and is loaded on first agent run instead of at app startup.

Also fix Windows CI step to use PowerShell syntax for version injection.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-03 00:46:34 +08:00
digua 3ff9437510 chore(tsconfig): align node type-check projects 2026-06-02 15:41:21 +08:00
digua 40d7d9e840 fix(ai): harden validation and db handle reuse 2026-06-02 15:41:21 +08:00