mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-12-05 01:29:32 +01:00
fix(preview): COD-152 resolve abbreviated Codex file tabs
This commit is contained in:
1 parent
6de846ba9a
commit
1835b39e2c
3 files changed
+35
-2
No files matched your search
+10
-1
@@ -3222,6 +3222,8 @@ class CodemanApp {
|
||||
}
|
||||
|
||||
_findCodexResponseFile(messages, label, session, sidebar = false) {
|
||||
const [prefix, suffix, ...extra] = sidebar ? label.split('…') : [];
|
||||
const abbreviated = Boolean(prefix && suffix && extra.length === 0);
|
||||
let match = null;
|
||||
for (const message of messages) {
|
||||
if (message.role !== 'assistant' || typeof message.text !== 'string' || (!sidebar && !message.text.includes(label))) continue;
|
||||
@@ -3235,7 +3237,14 @@ class CodemanApp {
|
||||
this._linkifyFilePaths(rendered.content);
|
||||
for (const link of links) {
|
||||
const path = resolveLinkedFilePath(link.dataset.path, session.workingDir);
|
||||
if (sidebar && path.split('/').pop() !== label) continue;
|
||||
if (sidebar) {
|
||||
const basename = path.split('/').pop();
|
||||
// Codex preserves both ends of a filename when it shortens the tab.
|
||||
const matchesEnds =
|
||||
abbreviated && basename.length > prefix.length + suffix.length &&
|
||||
basename.startsWith(prefix) && basename.endsWith(suffix);
|
||||
if (basename !== label && !matchesEnds) continue;
|
||||
}
|
||||
// Ambiguity includes web URLs and unsupported files with the same label.
|
||||
if (!link.dataset.linkified || link.dataset.folder || !/^\/(?!\/)/.test(path) || !previewsInFileViewer(path)) {
|
||||
return null;
|
||||
|
||||
@@ -526,7 +526,7 @@ function codexSidebarFileRow(terminal, row) {
|
||||
to--;
|
||||
}
|
||||
const label = line.translateToString(false, from, to).trim();
|
||||
if (label && !label.includes('…') && previewsInFileViewer(label)) entries.push({ label, start: from, end: to });
|
||||
if (label && previewsInFileViewer(label)) entries.push({ label, start: from, end: to });
|
||||
};
|
||||
if (row === headerRow) {
|
||||
let from = divider + 1;
|
||||
|
||||
@@ -427,6 +427,30 @@ describe('Codex terminal response link matching', () => {
|
||||
).toBeNull();
|
||||
});
|
||||
|
||||
it('resolves an abbreviated native tab only when one path matches both visible ends', () => {
|
||||
const app = appForTranscript();
|
||||
const session = { workingDir: '/work/project' };
|
||||
const name = 'Interview panel plan - requisition 2026943.docx';
|
||||
const exact = { role: 'assistant', text: `[Download](<out/${name}>)` };
|
||||
const near = { role: 'assistant', text: '[Wrong extension](<out/Interview draft 2026943.pdf>)' };
|
||||
const label = 'Interview…26943.docx';
|
||||
expect(app._findCodexResponseFile([exact, near], label, session, true)).toBe(`/work/project/out/${name}`);
|
||||
expect(
|
||||
app._findCodexResponseFile(
|
||||
[
|
||||
exact,
|
||||
{
|
||||
role: 'assistant',
|
||||
text: '[Another draft](<other/Interview alternate 2026943.docx>)',
|
||||
},
|
||||
],
|
||||
label,
|
||||
session,
|
||||
true
|
||||
)
|
||||
).toBeNull();
|
||||
});
|
||||
|
||||
it.each([
|
||||
'[Word brief](out/different.docx)',
|
||||
'[Word brief](https://example.test/report.docx)',
|
||||
|
||||
Reference in new issue
Block a user