feat: phase 1 of python scripting

This commit is contained in:
2026-02-22 22:12:30 +01:00
parent ce050f98c3
commit 3ec8819d6d
43 changed files with 2329 additions and 14 deletions

View File

@@ -5,6 +5,7 @@ import {
getGitDiffCommitTabSpec,
getGitDiffFileTabSpec,
getImportTabSpec,
getScriptTabSpec,
parseGitDiffTabId,
openChatTab,
getSingletonToolTabSpec,
@@ -12,6 +13,7 @@ import {
openGitDiffCommitTab,
openGitDiffFileTab,
openImportTab,
openScriptTab,
openSingletonToolTab,
} from '../../../src/renderer/navigation/tabPolicy';
@@ -20,6 +22,7 @@ describe('tabPolicy', () => {
expect(getSingletonToolTabSpec('settings')).toEqual({ type: 'settings', id: 'settings', isTransient: false });
expect(getSingletonToolTabSpec('tags')).toEqual({ type: 'tags', id: 'tags', isTransient: false });
expect(getSingletonToolTabSpec('style')).toEqual({ type: 'style', id: 'style', isTransient: false });
expect(getSingletonToolTabSpec('scripts')).toEqual({ type: 'scripts', id: 'scripts', isTransient: false });
expect(getSingletonToolTabSpec('menu-editor')).toEqual({ type: 'menu-editor', id: 'menu-editor', isTransient: false });
expect(getSingletonToolTabSpec('documentation')).toEqual({ type: 'documentation', id: 'documentation', isTransient: false });
expect(getSingletonToolTabSpec('metadata-diff')).toEqual({ type: 'metadata-diff', id: 'metadata-diff', isTransient: false });
@@ -93,6 +96,35 @@ describe('tabPolicy', () => {
]);
});
it('provides canonical script tab spec for preview and pin intents', () => {
expect(getScriptTabSpec('script-1', 'preview')).toEqual({
type: 'scripts',
id: 'script-1',
isTransient: true,
});
expect(getScriptTabSpec('script-1', 'pin')).toEqual({
type: 'scripts',
id: 'script-1',
isTransient: false,
});
});
it('opens script tabs from shared policy', () => {
const opened: Array<{ type: string; id: string; isTransient: boolean }> = [];
const openTab = (tab: { type: string; id: string; isTransient: boolean }) => {
opened.push(tab);
};
openScriptTab(openTab, 'script-preview', 'preview');
openScriptTab(openTab, 'script-pin', 'pin');
expect(opened).toEqual([
{ type: 'scripts', id: 'script-preview', isTransient: true },
{ type: 'scripts', id: 'script-pin', isTransient: false },
]);
});
it('builds and parses git-diff file and commit tab specs', () => {
expect(getGitDiffFileTabSpec('posts/first.md', 'preview')).toEqual({
type: 'git-diff',