diff --git a/cli.js b/cli.js index cd621a1a..bfd93d8e 100755 --- a/cli.js +++ b/cli.js @@ -5172,6 +5172,7 @@ function createSessionQueryScanState(tokens, options = {}) { count: 0, snippets: [], positions: [], + complete: true, leadingSystem: roleFilter !== 'system' }; } @@ -5210,11 +5211,13 @@ function consumeSessionQueryMessage(state, message) { timestamp: typeof message.timestamp === 'string' ? message.timestamp : '' }); } + if (state.count >= state.maxMatches) state.complete = false; return state.count >= state.maxMatches; } function buildSessionQueryScanResult(state) { return { + complete: !!(state && state.complete), hit: !!(state && state.count > 0), count: state && Number.isFinite(state.count) ? state.count : 0, snippets: state && Array.isArray(state.snippets) ? state.snippets : [], @@ -5259,6 +5262,7 @@ async function scanSessionContentForQuery(session, tokens, options = {}) { const state = createSessionQueryScanState(tokens, options); if (session.source === 'opencode') { const extracted = queryOpencodeSessionMessages(session.sessionId || parseOpencodeVirtualSessionId(filePath), { maxMessages: Infinity }); + state.complete = !!extracted && !extracted.truncated; const messages = extracted && Array.isArray(extracted.messages) ? extracted.messages : []; for (let i = 0; i < messages.length; i += 1) { const message = { ...messages[i], recordLineIndex: i }; @@ -5268,6 +5272,7 @@ async function scanSessionContentForQuery(session, tokens, options = {}) { } if (session.source === 'zed') { const zedExtracted = queryZedSessionMessages(session.sessionId || parseZedVirtualSessionId(filePath), { maxMessages: Infinity }); + state.complete = !!zedExtracted && !zedExtracted.truncated; const zedMessages = zedExtracted && Array.isArray(zedExtracted.messages) ? zedExtracted.messages : []; for (let i = 0; i < zedMessages.length; i += 1) { const message = { ...zedMessages[i], recordLineIndex: i }; @@ -5283,6 +5288,7 @@ async function scanSessionContentForQuery(session, tokens, options = {}) { } catch (_) { json = null; } + state.complete = !!json; const rawMessages = json && Array.isArray(json.messages) ? json.messages : []; for (const entry of rawMessages) { if (!entry || typeof entry !== 'object') continue; @@ -5310,12 +5316,14 @@ async function scanSessionContentForQuery(session, tokens, options = {}) { const buf = Buffer.alloc(targetBytes); const bytes = fs.readSync(fd, buf, 0, targetBytes, 0); fs.closeSync(fd); + state.complete = bytes >= stat.size; text = bytes > 0 ? buf.slice(0, bytes).toString('utf-8') : ''; } catch (_) { try { text = fs.readFileSync(filePath, 'utf-8'); } catch (_) { text = ''; + state.complete = false; } } @@ -5340,6 +5348,7 @@ async function scanSessionContentForQuery(session, tokens, options = {}) { const currentLineIndex = lineIndex; lineIndex += 1; if (maxBytes > 0 && bytesRead >= maxBytes) { + state.complete = false; break; } @@ -5369,6 +5378,7 @@ async function scanSessionContentForQuery(session, tokens, options = {}) { return buildSessionQueryScanResult(state); } catch (e) { + state.complete = false; return scanSessionContentForQueryInRecords(readJsonlRecords(filePath), session.source, state); } finally { if (rl) { @@ -5383,7 +5393,9 @@ async function scanSessionContentForQuery(session, tokens, options = {}) { async function applySessionQueryFilter(sessions, options = {}) { const tokens = Array.isArray(options.tokens) ? options.tokens : []; if (tokens.length === 0) { - return sessions; + const result = sessions.slice(); + Object.defineProperty(result, 'searchInfo', { value: null }); + return result; } const mode = normalizeQueryMode(options.queryMode); @@ -5397,10 +5409,12 @@ async function applySessionQueryFilter(sessions, options = {}) { : 0; let scanned = 0; + let complete = true; const results = []; for (const session of sessions) { if (scope === 'content' && scanned >= contentScanLimit) { + complete = false; break; } @@ -5420,6 +5434,10 @@ async function applySessionQueryFilter(sessions, options = {}) { snippetLimit: 2 }); contentHit = contentInfo.hit; + // 命中已完成候选的存在性判定,无需穷尽匹配或消息。 + if (!contentHit && !contentInfo.complete) complete = false; + } else if (shouldScanContent) { + complete = false; } const hit = scope === 'summary' @@ -5441,6 +5459,9 @@ async function applySessionQueryFilter(sessions, options = {}) { results.push(session); } + Object.defineProperty(results, 'searchInfo', { + value: { scanned, candidates: sessions.length, complete } + }); return results; } function collectRecentJsonlFiles(rootDir, options = {}) { @@ -7632,7 +7653,9 @@ async function listAllSessions(params = {}) { contentScanBytes: params.contentScanBytes }); } + const searchInfo = hasQuery ? result.searchInfo : null; result = mergeAndLimitSessions(result, limit); + Object.defineProperty(result, 'searchInfo', { value: searchInfo }); setSessionListCache(cacheKey, result); return result; } @@ -7665,6 +7688,7 @@ async function listAllSessionsData(params = {}) { delete normalized.__messageCountExact; return normalized; }); + Object.defineProperty(result, 'searchInfo', { value: sessions.searchInfo || null }); if (!hasQuery) { setSessionListCache(cacheKey, result); } @@ -7676,7 +7700,7 @@ async function listSessionBrowse(params = {}) { ...params, browseLightweight: true }); - return Array.isArray(sessions) + const result = Array.isArray(sessions) ? sessions.map((item) => { if (!item || typeof item !== 'object' || Array.isArray(item)) { return item; @@ -7686,6 +7710,8 @@ async function listSessionBrowse(params = {}) { return normalized; }) : []; + Object.defineProperty(result, 'searchInfo', { value: sessions.searchInfo || null }); + return result; } async function listSessionUsage(params = {}) { @@ -10008,8 +10034,7 @@ async function exportSessionData(params = {}) { if (!extracted) { return { error: 'Failed to parse session file' }; } - } - if (source === 'zed') { + } else if (source === 'zed') { const zedSessionId = params.sessionId || parseZedVirtualSessionId(filePath); extracted = queryZedSessionMessages(zedSessionId, { maxMessages }); if (!extracted) { @@ -14760,9 +14785,11 @@ function createWebServer({ htmlPath, assetsDir, webDir, host, port, openBrowser if (source && !isSessionSourceOrAll(source)) { result = { error: 'Invalid source. Must be codex, claude, gemini, codebuddy, workbuddy, pi, opencode, or all' }; } else { + const sessions = await listSessionBrowse(params); result = { - sessions: await listSessionBrowse(params), - source: source || 'all' + sessions, + source: source || 'all', + searchInfo: sessions.searchInfo }; } } diff --git a/desktop/package.json b/desktop/package.json index 438b2591..62bbda68 100644 --- a/desktop/package.json +++ b/desktop/package.json @@ -1,6 +1,6 @@ { "name": "codexmate-desktop", - "version": "0.1.28", + "version": "0.1.29", "description": "Codex Mate 桌面启动器(Electron 壳,内嵌 codexmate Web UI)", "main": "electron.js", "private": true, diff --git a/package.json b/package.json index 8fdb56c7..da2deca6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codexmate", - "version": "0.1.28", + "version": "0.1.29", "description": "Codex/Claude Code/OpenClaw 配置、会话与任务编排 CLI + Web 工具", "main": "cli.js", "bin": { diff --git a/site/guide/sessions.md b/site/guide/sessions.md index 31dfe12f..193aa611 100644 --- a/site/guide/sessions.md +++ b/site/guide/sessions.md @@ -7,9 +7,9 @@ 1. 按[快速开始](/guide/quick-start)启动,进入 Web UI 会话视图。 2. 在「会话来源」选择已有记录的工具,再按项目路径或时间缩小范围。可输入关键词并按回车检索;界面有检索入口不代表所有来源的记录格式都已经验证。 3. 打开会话,核对项目、时间和讨论内容。 -4. 点击「导出记录」,打开下载的 Markdown,检查需要的文字是否完整,并留意截断提示。 +4. 在「导出范围」选择最近 1000 条或全部可提取消息,再点击「导出记录」。打开下载的 Markdown 核对内容;截断说明会保留在当前会话预览中,可选择全部后重新导出。 -没有记录时先确认原工具在本机保存过会话,再清除筛选条件并刷新。配置 Provider 不会生成历史会话。 +关键词查询会显示实际扫描数与本次候选数。未完成时请缩小来源或项目范围;候选范围不等于全部历史记录。筛选无结果时可直接点击「清除筛选」。没有记录时先确认原工具在本机保存过会话,再刷新。配置 Provider 不会生成历史会话。 ## 来源与存储位置 @@ -26,7 +26,7 @@ | `opencode` | OpenCode | 数据目录中的 `opencode.db`,默认 `~/.local/share/opencode` | | `zed` | Zed | Zed 数据目录下的 `threads/threads.db` | -OpenCode 导出分支存在尚未完成运行验证的兼容性疑点,请先用一条样例确认导出结果,不把来源出现在列表中视为导出成功保证。首次体验可先使用已有的 Codex 或 Claude Code 记录。 +OpenCode 导出的来源分支现已互斥,避免数据库读取结果被通用文件读取覆盖。各工具版本的存储格式仍可能不同,先用一条记录核对结果;来源出现在列表中不代表所有版本均已验证。 ## CLI 导出 diff --git a/tests/e2e/test-setup.js b/tests/e2e/test-setup.js index deb1d3f2..1ca59fbf 100644 --- a/tests/e2e/test-setup.js +++ b/tests/e2e/test-setup.js @@ -36,8 +36,8 @@ module.exports = async function testSetup(ctx) { assert(configContent.includes(`base_url = "${mockProviderUrl}"`), 'base_url missing or mismatched'); const authPath = path.join(tmpHome, '.codex', 'auth.json'); - const auth = JSON.parse(fs.readFileSync(authPath, 'utf-8')); - assert(auth.OPENAI_API_KEY === 'sk-test', 'auth api_key mismatch'); + assert(!fs.existsSync(authPath), 'auth.json should not be written in single-file auth mode'); + assert(configContent.includes('experimental_bearer_token = "sk-test"'), 'bearer token missing from config.toml'); const modelsPath = path.join(tmpHome, '.codex', 'models.json'); const models = JSON.parse(fs.readFileSync(modelsPath, 'utf-8')); diff --git a/tests/unit/config-tabs-ui.test.mjs b/tests/unit/config-tabs-ui.test.mjs index 757d4eb2..c98964da 100644 --- a/tests/unit/config-tabs-ui.test.mjs +++ b/tests/unit/config-tabs-ui.test.mjs @@ -432,7 +432,7 @@ test('config template keeps expected config tabs in top and side navigation', () assert.match(openclawModal, / +
+ {{ t('sessions.export.scopeHint') }} +

{{ t('sessions.export.truncated') }}

+
{{ t('sessions.preview.loadingBody') }} diff --git a/web-ui/res/web-ui-render.precompiled.js b/web-ui/res/web-ui-render.precompiled.js index d297ed63..206b535e 100644 --- a/web-ui/res/web-ui-render.precompiled.js +++ b/web-ui/res/web-ui-render.precompiled.js @@ -3857,7 +3857,7 @@ return function render(_ctx, _cache) { : _createCommentVNode("v-if", true), _createCommentVNode(" 会话浏览模式 "), _withDirectives(_createElementVNode("div", { - class: "mode-content", + class: "mode-content session-browser-refined", id: "panel-sessions", role: "tabpanel", "aria-labelledby": 'tab-sessions' @@ -4105,18 +4105,44 @@ return function render(_ctx, _cache) { ], 8 /* PROPS */, ["aria-label"])) : _createCommentVNode("v-if", true) ]), - (_ctx.sessionsLoading && _ctx.sessionsList.length === 0) + (_ctx.sessionSearchInfo && !_ctx.sessionsLoading) ? (_openBlock(), _createElementBlock("div", { key: 0, + class: "session-search-status", + role: "status" + }, [ + _createElementVNode("span", { class: "session-search-count" }, _toDisplayString(_ctx.t('sessions.search.coverage', { scanned: _ctx.sessionSearchInfo.scanned, candidates: _ctx.sessionSearchInfo.candidates })), 1 /* TEXT */), + (!_ctx.sessionSearchInfo.complete) + ? (_openBlock(), _createElementBlock("span", { + key: 0, + class: "session-search-partial" + }, _toDisplayString(_ctx.t('sessions.search.partial')), 1 /* TEXT */)) + : _createCommentVNode("v-if", true), + _createElementVNode("small", { class: "session-search-scope" }, _toDisplayString(_ctx.t('sessions.search.scopeHint')), 1 /* TEXT */) + ])) + : _createCommentVNode("v-if", true), + (_ctx.sessionsLoading && _ctx.sessionsList.length === 0) + ? (_openBlock(), _createElementBlock("div", { + key: 1, class: "state-message" }, _toDisplayString(_ctx.t('sessions.loadingList')), 1 /* TEXT */)) : (!_ctx.sessionsLoading && _ctx.sessionsList.length === 0) ? (_openBlock(), _createElementBlock("div", { - key: 1, - class: "session-empty" - }, _toDisplayString(_ctx.t('sessions.empty')), 1 /* TEXT */)) - : (_openBlock(), _createElementBlock("div", { key: 2, + class: "session-empty session-empty-refined" + }, [ + _createElementVNode("p", null, _toDisplayString(_ctx.t(_ctx.hasActiveSessionFilters() ? 'sessions.empty.filtered' : 'sessions.empty.source')), 1 /* TEXT */), + (_ctx.hasActiveSessionFilters()) + ? (_openBlock(), _createElementBlock("button", { + key: 0, + class: "btn-tool btn-tool-compact", + type: "button", + onClick: _ctx.clearSessionFilters + }, _toDisplayString(_ctx.t('sessions.empty.clearFilters')), 9 /* TEXT, PROPS */, ["onClick"])) + : _createCommentVNode("v-if", true) + ])) + : (_openBlock(), _createElementBlock("div", { + key: 3, class: "session-layout" }, [ (_ctx.sessionListRenderEnabled) @@ -4318,53 +4344,22 @@ return function render(_ctx, _cache) { ])) : _createCommentVNode("v-if", true) ]), - _createElementVNode("div", { class: "session-actions" }, [ - _createElementVNode("button", { - class: "btn-session-refresh has-label", - onClick: _ctx.loadActiveSessionDetail, - disabled: _ctx.sessionDetailLoading || !_ctx.activeSession, - title: _ctx.sessionDetailLoading ? _ctx.t('sessions.preview.loading') : _ctx.t('sessions.preview.refresh'), - "aria-label": _ctx.sessionDetailLoading ? _ctx.t('sessions.preview.loading') : _ctx.t('sessions.preview.refresh') + _createElementVNode("div", { class: "session-export-control" }, [ + _createElementVNode("label", { + class: "session-export-label", + for: "session-export-range" + }, _toDisplayString(_ctx.t('sessions.export.range')), 1 /* TEXT */), + _withDirectives(_createElementVNode("select", { + id: "session-export-range", + "onUpdate:modelValue": $event => ((_ctx.sessionExportRange) = $event), + disabled: _ctx.sessionExporting[_ctx.getSessionExportKey(_ctx.activeSession)], + "aria-describedby": "session-export-scope" }, [ - (_openBlock(), _createElementBlock("svg", { - viewBox: "0 0 16 16", - fill: "none", - stroke: "currentColor", - "stroke-width": "1.8", - "stroke-linecap": "round", - "stroke-linejoin": "round" - }, [ - _createElementVNode("path", { d: "M2.5 8a5.5 5.5 0 0 1 9.4-3.8" }), - _createElementVNode("path", { d: "M13.5 8a5.5 5.5 0 0 1-9.4 3.8" }), - _createElementVNode("polyline", { points: "2.5 2 2.5 5 5.5 5" }), - _createElementVNode("polyline", { points: "13.5 14 13.5 11 10.5 11" }) - ])), - _createElementVNode("span", { class: "session-action-label" }, _toDisplayString(_ctx.t('sessions.preview.refresh')), 1 /* TEXT */) - ], 8 /* PROPS */, ["onClick", "disabled", "title", "aria-label"]), - (_ctx.isDeleteAvailable(_ctx.activeSession)) - ? (_openBlock(), _createElementBlock("button", { - key: 0, - class: "btn-session-delete has-label", - onClick: $event => (_ctx.deleteSession(_ctx.activeSession)), - disabled: !_ctx.activeSession || _ctx.sessionsLoading || _ctx.sessionDeleting[_ctx.getSessionExportKey(_ctx.activeSession)], - title: (_ctx.activeSession && _ctx.sessionDeleting[_ctx.getSessionExportKey(_ctx.activeSession)]) ? (_ctx.sessionTrashEnabled === false ? _ctx.t('sessions.preview.deleting') : _ctx.t('sessions.preview.moving')) : (_ctx.sessionTrashEnabled === false ? _ctx.t('sessions.preview.deleteHard') : _ctx.t('sessions.preview.moveToTrash')), - "aria-label": (_ctx.activeSession && _ctx.sessionDeleting[_ctx.getSessionExportKey(_ctx.activeSession)]) ? (_ctx.sessionTrashEnabled === false ? _ctx.t('sessions.preview.deleting') : _ctx.t('sessions.preview.moving')) : (_ctx.sessionTrashEnabled === false ? _ctx.t('sessions.preview.deleteHard') : _ctx.t('sessions.preview.moveToTrash')) - }, [ - (_openBlock(), _createElementBlock("svg", { - viewBox: "0 0 16 16", - fill: "none", - stroke: "currentColor", - "stroke-width": "1.8", - "stroke-linecap": "round", - "stroke-linejoin": "round" - }, [ - _createElementVNode("polyline", { points: "3 4 4 4 13 4" }), - _createElementVNode("path", { d: "M5.5 4V2.5a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1V4" }), - _createElementVNode("path", { d: "M12 4v9.5a1.5 1.5 0 0 1-1.5 1.5h-5A1.5 1.5 0 0 1 4 13.5V4" }) - ])), - _createElementVNode("span", { class: "session-action-label" }, _toDisplayString((_ctx.activeSession && _ctx.sessionDeleting[_ctx.getSessionExportKey(_ctx.activeSession)]) ? (_ctx.sessionTrashEnabled === false ? _ctx.t('sessions.preview.deleting') : _ctx.t('sessions.preview.moving')) : (_ctx.sessionTrashEnabled === false ? _ctx.t('sessions.preview.deleteHard') : _ctx.t('sessions.preview.moveToTrash'))), 1 /* TEXT */) - ], 8 /* PROPS */, ["onClick", "disabled", "title", "aria-label"])) - : _createCommentVNode("v-if", true), + _createElementVNode("option", { value: "default" }, _toDisplayString(_ctx.t('sessions.export.default')), 1 /* TEXT */), + _createElementVNode("option", { value: "all" }, _toDisplayString(_ctx.t('sessions.export.all')), 1 /* TEXT */) + ], 8 /* PROPS */, ["onUpdate:modelValue", "disabled"]), [ + [_vModelSelect, _ctx.sessionExportRange] + ]), _createElementVNode("button", { class: "btn-session-export has-label", onClick: $event => (_ctx.exportSession(_ctx.activeSession)), @@ -4385,14 +4380,16 @@ return function render(_ctx, _cache) { _createElementVNode("path", { d: "M2.5 12v1.5a1 1 0 0 0 1 1h9a1 1 0 0 0 1-1V12" }) ])), _createElementVNode("span", { class: "session-action-label" }, _toDisplayString((_ctx.activeSession && _ctx.sessionExporting[_ctx.getSessionExportKey(_ctx.activeSession)]) ? _ctx.t('sessions.preview.exporting') : _ctx.t('sessions.preview.export')), 1 /* TEXT */) - ], 8 /* PROPS */, ["onClick", "disabled", "title", "aria-label"]), - _createElementVNode("div", { class: "session-link-group" }, [ + ], 8 /* PROPS */, ["onClick", "disabled", "title", "aria-label"]) + ]), + _createElementVNode("div", { class: "session-actions session-preview-actions" }, [ + _createElementVNode("div", { class: "session-secondary-actions" }, [ _createElementVNode("button", { - class: "btn-session-open", - onClick: $event => (_ctx.copySessionLink(_ctx.activeSession)), - disabled: !_ctx.activeSession || !_ctx.canBuildStandaloneUrl(_ctx.activeSession), - title: _ctx.t('sessions.preview.copyLink'), - "aria-label": _ctx.t('sessions.preview.copyLink') + class: "btn-session-refresh has-label", + onClick: _ctx.loadActiveSessionDetail, + disabled: _ctx.sessionDetailLoading || !_ctx.activeSession, + title: _ctx.sessionDetailLoading ? _ctx.t('sessions.preview.loading') : _ctx.t('sessions.preview.refresh'), + "aria-label": _ctx.sessionDetailLoading ? _ctx.t('sessions.preview.loading') : _ctx.t('sessions.preview.refresh') }, [ (_openBlock(), _createElementBlock("svg", { viewBox: "0 0 16 16", @@ -4402,16 +4399,61 @@ return function render(_ctx, _cache) { "stroke-linecap": "round", "stroke-linejoin": "round" }, [ - _createElementVNode("path", { d: "M6.5 9.5a3.5 3.5 0 0 0 5 0l2-2a3.5 3.5 0 0 0-5-5l-1 1" }), - _createElementVNode("path", { d: "M9.5 6.5a3.5 3.5 0 0 0-5 0l-2 2a3.5 3.5 0 0 0 5 5l1-1" }) - ])) + _createElementVNode("path", { d: "M2.5 8a5.5 5.5 0 0 1 9.4-3.8" }), + _createElementVNode("path", { d: "M13.5 8a5.5 5.5 0 0 1-9.4 3.8" }), + _createElementVNode("polyline", { points: "2.5 2 2.5 5 5.5 5" }), + _createElementVNode("polyline", { points: "13.5 14 13.5 11 10.5 11" }) + ])), + _createElementVNode("span", { class: "session-action-label" }, _toDisplayString(_ctx.t('sessions.preview.refresh')), 1 /* TEXT */) ], 8 /* PROPS */, ["onClick", "disabled", "title", "aria-label"]), + _createElementVNode("div", { class: "session-link-group" }, [ + _createElementVNode("button", { + class: "btn-session-open", + onClick: $event => (_ctx.copySessionLink(_ctx.activeSession)), + disabled: !_ctx.activeSession || !_ctx.canBuildStandaloneUrl(_ctx.activeSession), + title: _ctx.t('sessions.preview.copyLink'), + "aria-label": _ctx.t('sessions.preview.copyLink') + }, [ + (_openBlock(), _createElementBlock("svg", { + viewBox: "0 0 16 16", + fill: "none", + stroke: "currentColor", + "stroke-width": "1.8", + "stroke-linecap": "round", + "stroke-linejoin": "round" + }, [ + _createElementVNode("path", { d: "M6.5 9.5a3.5 3.5 0 0 0 5 0l2-2a3.5 3.5 0 0 0-5-5l-1 1" }), + _createElementVNode("path", { d: "M9.5 6.5a3.5 3.5 0 0 0-5 0l-2 2a3.5 3.5 0 0 0 5 5l1-1" }) + ])) + ], 8 /* PROPS */, ["onClick", "disabled", "title", "aria-label"]), + _createTextVNode(), + _createElementVNode("button", { + class: "btn-session-open", + onClick: $event => (_ctx.openSessionLink(_ctx.activeSession)), + disabled: !_ctx.activeSession || !_ctx.canBuildStandaloneUrl(_ctx.activeSession), + title: _ctx.t('sessions.preview.openLink'), + "aria-label": _ctx.t('sessions.preview.openLink') + }, [ + (_openBlock(), _createElementBlock("svg", { + viewBox: "0 0 16 16", + fill: "none", + stroke: "currentColor", + "stroke-width": "1.8", + "stroke-linecap": "round", + "stroke-linejoin": "round" + }, [ + _createElementVNode("path", { d: "M12 2h-8.5A1.5 1.5 0 0 0 2 3.5v8A1.5 1.5 0 0 0 3.5 13h8a1.5 1.5 0 0 0 1.5-1.5v-3" }), + _createElementVNode("path", { d: "M13 2v4h-4" }), + _createElementVNode("path", { d: "M13 2L7 8" }) + ])) + ], 8 /* PROPS */, ["onClick", "disabled", "title", "aria-label"]) + ]), _createElementVNode("button", { - class: "btn-session-open", - onClick: $event => (_ctx.openSessionLink(_ctx.activeSession)), - disabled: !_ctx.activeSession || !_ctx.canBuildStandaloneUrl(_ctx.activeSession), - title: _ctx.t('sessions.preview.openLink'), - "aria-label": _ctx.t('sessions.preview.openLink') + class: "btn-session-open has-label", + onClick: $event => (_ctx.copySessionPath(_ctx.activeSession)), + disabled: !_ctx.activeSession || !_ctx.getSessionFilePath(_ctx.activeSession), + title: _ctx.t('sessions.preview.copyPath'), + "aria-label": _ctx.t('sessions.preview.copyPath') }, [ (_openBlock(), _createElementBlock("svg", { viewBox: "0 0 16 16", @@ -4421,33 +4463,49 @@ return function render(_ctx, _cache) { "stroke-linecap": "round", "stroke-linejoin": "round" }, [ - _createElementVNode("path", { d: "M12 2h-8.5A1.5 1.5 0 0 0 2 3.5v8A1.5 1.5 0 0 0 3.5 13h8a1.5 1.5 0 0 0 1.5-1.5v-3" }), - _createElementVNode("path", { d: "M13 2v4h-4" }), - _createElementVNode("path", { d: "M13 2L7 8" }) - ])) + _createElementVNode("path", { d: "M2 5.5V12.5a1 1 0 0 0 1 1h10a1 1 0 0 0 1-1V7.5a1 1 0 0 0-1-1H8L6.5 5H3a1 1 0 0 0-1 1z" }) + ])), + _createElementVNode("span", { class: "session-action-label" }, _toDisplayString(_ctx.t('sessions.preview.copyPath')), 1 /* TEXT */) ], 8 /* PROPS */, ["onClick", "disabled", "title", "aria-label"]) ]), - _createElementVNode("button", { - class: "btn-session-open has-label", - onClick: $event => (_ctx.copySessionPath(_ctx.activeSession)), - disabled: !_ctx.activeSession || !_ctx.getSessionFilePath(_ctx.activeSession), - title: _ctx.t('sessions.preview.copyPath'), - "aria-label": _ctx.t('sessions.preview.copyPath') - }, [ - (_openBlock(), _createElementBlock("svg", { - viewBox: "0 0 16 16", - fill: "none", - stroke: "currentColor", - "stroke-width": "1.8", - "stroke-linecap": "round", - "stroke-linejoin": "round" - }, [ - _createElementVNode("path", { d: "M2 5.5V12.5a1 1 0 0 0 1 1h10a1 1 0 0 0 1-1V7.5a1 1 0 0 0-1-1H8L6.5 5H3a1 1 0 0 0-1 1z" }) - ])), - _createElementVNode("span", { class: "session-action-label" }, _toDisplayString(_ctx.t('sessions.preview.copyPath')), 1 /* TEXT */) - ], 8 /* PROPS */, ["onClick", "disabled", "title", "aria-label"]) + _createElementVNode("div", { class: "session-danger-action" }, [ + (_ctx.isDeleteAvailable(_ctx.activeSession)) + ? (_openBlock(), _createElementBlock("button", { + key: 0, + class: "btn-session-delete has-label", + onClick: $event => (_ctx.deleteSession(_ctx.activeSession)), + disabled: !_ctx.activeSession || _ctx.sessionsLoading || _ctx.sessionDeleting[_ctx.getSessionExportKey(_ctx.activeSession)], + title: (_ctx.activeSession && _ctx.sessionDeleting[_ctx.getSessionExportKey(_ctx.activeSession)]) ? (_ctx.sessionTrashEnabled === false ? _ctx.t('sessions.preview.deleting') : _ctx.t('sessions.preview.moving')) : (_ctx.sessionTrashEnabled === false ? _ctx.t('sessions.preview.deleteHard') : _ctx.t('sessions.preview.moveToTrash')), + "aria-label": (_ctx.activeSession && _ctx.sessionDeleting[_ctx.getSessionExportKey(_ctx.activeSession)]) ? (_ctx.sessionTrashEnabled === false ? _ctx.t('sessions.preview.deleting') : _ctx.t('sessions.preview.moving')) : (_ctx.sessionTrashEnabled === false ? _ctx.t('sessions.preview.deleteHard') : _ctx.t('sessions.preview.moveToTrash')) + }, [ + (_openBlock(), _createElementBlock("svg", { + viewBox: "0 0 16 16", + fill: "none", + stroke: "currentColor", + "stroke-width": "1.8", + "stroke-linecap": "round", + "stroke-linejoin": "round" + }, [ + _createElementVNode("polyline", { points: "3 4 4 4 13 4" }), + _createElementVNode("path", { d: "M5.5 4V2.5a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1V4" }), + _createElementVNode("path", { d: "M12 4v9.5a1.5 1.5 0 0 1-1.5 1.5h-5A1.5 1.5 0 0 1 4 13.5V4" }) + ])), + _createElementVNode("span", { class: "session-action-label" }, _toDisplayString((_ctx.activeSession && _ctx.sessionDeleting[_ctx.getSessionExportKey(_ctx.activeSession)]) ? (_ctx.sessionTrashEnabled === false ? _ctx.t('sessions.preview.deleting') : _ctx.t('sessions.preview.moving')) : (_ctx.sessionTrashEnabled === false ? _ctx.t('sessions.preview.deleteHard') : _ctx.t('sessions.preview.moveToTrash'))), 1 /* TEXT */) + ], 8 /* PROPS */, ["onClick", "disabled", "title", "aria-label"])) + : _createCommentVNode("v-if", true) + ]) ]) ], 512 /* NEED_PATCH */), + _createElementVNode("div", { class: "session-export-feedback" }, [ + _createElementVNode("small", { id: "session-export-scope" }, _toDisplayString(_ctx.t('sessions.export.scopeHint')), 1 /* TEXT */), + (_ctx.sessionExportNotice && _ctx.sessionExportNotice.key === _ctx.getSessionExportKey(_ctx.activeSession)) + ? (_openBlock(), _createElementBlock("p", { + key: 0, + class: "session-export-notice", + role: "status" + }, _toDisplayString(_ctx.t('sessions.export.truncated')), 1 /* TEXT */)) + : _createCommentVNode("v-if", true) + ]), (_ctx.sessionDetailLoading && !_ctx.sessionPreviewLoadingMore) ? (_openBlock(), _createElementBlock("div", { key: 0, diff --git a/web-ui/session-helpers.mjs b/web-ui/session-helpers.mjs index b3a4d604..51e6bca7 100644 --- a/web-ui/session-helpers.mjs +++ b/web-ui/session-helpers.mjs @@ -222,6 +222,7 @@ export async function loadSessions(api, options = {}) { const normalizedOptions = normalizeSessionLoadOptions(options); const includeActiveDetail = shouldIncludeActiveSessionDetail(this, normalizedOptions); this.sessionsLoading = true; + this.sessionSearchInfo = null; this.activeSessionDetailError = ''; let loadSucceeded = false; const params = buildSessionListParams({ @@ -257,6 +258,7 @@ export async function loadSessions(api, options = {}) { clearSessionTimelineRefs(this); } else { loadSucceeded = true; + this.sessionSearchInfo = res.searchInfo || null; const rawSessions = Array.isArray(res.sessions) ? res.sessions : []; this.sessionsList = rawSessions.filter(s => s && typeof s === 'object'); if (typeof this.clearSessionBatchSelection === 'function') { @@ -313,6 +315,7 @@ export async function loadSessions(api, options = {}) { } } } catch (e) { + this.sessionSearchInfo = null; emitSessionLoadDebug(this, 'loadSessions:exception', e && e.message ? e.message : String(e)); this.sessionsList = []; if (typeof this.primeSessionListRender === 'function') { diff --git a/web-ui/styles/sessions-preview.css b/web-ui/styles/sessions-preview.css index 4ebf6d69..f755fab4 100644 --- a/web-ui/styles/sessions-preview.css +++ b/web-ui/styles/sessions-preview.css @@ -758,3 +758,80 @@ width: 14px; height: 14px; } + +/* Refined session workspace: preserve the list/detail structure and action contracts. */ +#panel-sessions.session-browser-refined .session-preview-header { + padding: 12px 16px 8px; gap: 8px 16px; + display: grid; grid-template-columns: minmax(0, 1fr) auto; + grid-template-areas: "title export" "actions actions"; + background: var(--color-surface); backdrop-filter: none; +} +#panel-sessions.session-browser-refined .session-preview-title { + font-size: 17px; line-height: 1.5; letter-spacing: -.015em; +} +#panel-sessions.session-browser-refined .session-preview-header > div:first-child { grid-area: title; min-width: 0; } +#panel-sessions .session-preview-actions { grid-area: actions; gap: 10px; justify-content: flex-start; margin-top: 0; } +#panel-sessions .session-export-control { + grid-area: export; justify-self: end; align-self: start; + display: flex; flex-wrap: wrap; align-items: center; gap: 6px; + padding: 2px; border: 1px solid var(--color-border-soft); border-radius: var(--radius-md); + background: var(--color-surface-alt); max-width: 100%; +} +#panel-sessions .session-export-label { font-size: 12px; line-height: 1; color: var(--color-text-secondary); padding-inline: 6px 0; margin-block: 0; } +#panel-sessions #session-export-range { + min-height: 44px; min-width: 0; max-width: 100%; padding: 8px 28px 8px 10px; + border: 0; border-radius: var(--radius-sm); background: var(--color-surface); + color: var(--color-text-primary); font: inherit; font-size: 14px; cursor: pointer; +} +#panel-sessions .session-preview-actions button { + min-width: 44px; min-height: 44px; height: auto; width: auto; padding: 9px 12px; + border-radius: var(--radius-sm); box-shadow: none; + transition: background-color 120ms ease-out, transform 100ms ease-out, color 120ms ease-out; + touch-action: manipulation; +} +#panel-sessions .session-export-control .btn-session-export { + background: var(--color-text-primary); color: var(--color-surface); + border-color: transparent; font-weight: 600; +} +#panel-sessions .session-secondary-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; } +#panel-sessions .session-secondary-actions button { background: transparent; border-color: transparent; color: var(--color-text-secondary); } +#panel-sessions .session-secondary-actions .session-link-group { display: inline-flex; gap: 2px; } +#panel-sessions .session-danger-action { margin-inline-start: auto; padding-inline-start: 12px; border-inline-start: 1px solid var(--color-border-soft); } +#panel-sessions .session-danger-action button { background: transparent; border-color: transparent; } +#panel-sessions .session-preview-actions button:hover:not(:disabled) { transform: none; background: var(--color-surface-alt); } +#panel-sessions .session-export-control .btn-session-export:hover:not(:disabled) { background: var(--color-text-secondary); } +#panel-sessions .session-preview-actions button:active:not(:disabled) { transform: scale(.97); } +#panel-sessions .session-preview-actions :is(button, select):focus-visible, +#panel-sessions .session-empty-refined button:focus-visible { outline: 2px solid var(--color-brand); outline-offset: 3px; } +#panel-sessions .session-preview-actions :disabled { opacity: .5; cursor: not-allowed; } +#panel-sessions .session-export-feedback { padding: 0 16px 16px; color: var(--color-text-secondary); line-height: 1.6; } +#panel-sessions .session-export-feedback small { display: block; font-size: 12px; } +#panel-sessions .session-export-notice { + margin: 10px 0 0; padding: 10px 12px; border: 1px solid var(--color-border-soft); + border-radius: var(--radius-sm); background: var(--color-surface-alt); font-size: 13px; +} +#panel-sessions .session-search-status { + display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; + padding: 10px 2px 14px; font-size: 12px; line-height: 1.6; color: var(--color-text-secondary); +} +#panel-sessions .session-search-count { font-weight: 600; color: var(--color-text-primary); font-variant-numeric: tabular-nums; } +#panel-sessions .session-search-partial { color: var(--color-text-secondary); } +#panel-sessions .session-search-scope { font-size: inherit; margin-inline-start: auto; } +#panel-sessions .session-empty-refined { padding: 40px 20px; border: 1px dashed var(--color-border-soft); background: transparent; } +#panel-sessions .session-empty-refined::before { display: none; } +#panel-sessions .session-empty-refined p { margin: 0 0 16px; line-height: 1.65; } +#panel-sessions .session-empty-refined button { min-height: 44px; padding-inline: 16px; } +@media (max-width: 640px) { + #panel-sessions .session-preview-actions { flex-direction: row; align-items: center; gap: 10px; } + #panel-sessions .session-export-control { justify-self: stretch; } + #panel-sessions #session-export-range { flex: 1 1 120px; } + #panel-sessions .session-secondary-actions { flex: 1 1 180px; } + #panel-sessions .session-preview-actions button { width: auto; } + #panel-sessions .session-search-scope { flex-basis: 100%; margin-inline-start: 0; } + #panel-sessions.session-browser-refined .session-preview-header { padding: 12px 12px 8px; gap: 8px; grid-template-columns: 1fr; grid-template-areas: "title" "export" "actions"; } + #panel-sessions .session-export-feedback { padding-inline: 12px; } +} +@media (prefers-reduced-motion: reduce) { + #panel-sessions .session-preview-actions button { transition: none; } + #panel-sessions .session-preview-actions button:active:not(:disabled) { transform: none; } +}