-
-
Notifications
You must be signed in to change notification settings - Fork 20
feat: implement auto-proceed functionality with controls for pause/re… #404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import { TreeView, window } from 'vscode'; | ||
| import { | ||
| QuickActionsTreeviewProvider, | ||
| QuickActionTreeItem, | ||
| } from '../providers/QuickActionsTreeviewProvider'; | ||
|
|
||
| export class QuickActionsPanel { | ||
| private static treeView: TreeView<QuickActionTreeItem>; | ||
| private static quickActionsProvider: QuickActionsTreeviewProvider; | ||
|
|
||
| public static register() { | ||
| QuickActionsPanel.quickActionsProvider = new QuickActionsTreeviewProvider(); | ||
| QuickActionsPanel.treeView = window.createTreeView('demo-time-quick-actions', { | ||
| treeDataProvider: QuickActionsPanel.quickActionsProvider, | ||
| }); | ||
| } | ||
|
|
||
| public static update() { | ||
| QuickActionsPanel.quickActionsProvider.update(); | ||
| } | ||
|
|
||
| public static updatePresentationMode(isPresentationMode: boolean) { | ||
| QuickActionsPanel.quickActionsProvider.setPresentationMode(isPresentationMode); | ||
| QuickActionsPanel.quickActionsProvider.update(); | ||
| } | ||
|
|
||
| public static updateAutoProceed(isActive: boolean, isPaused: boolean, countdown: number) { | ||
| QuickActionsPanel.quickActionsProvider.setAutoProceedState(isActive, isPaused, countdown); | ||
| QuickActionsPanel.quickActionsProvider.update(); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,179 @@ | ||
| import { | ||
| Event, | ||
| EventEmitter, | ||
| ProviderResult, | ||
| ThemeColor, | ||
| ThemeIcon, | ||
| TreeDataProvider, | ||
| TreeItem, | ||
| TreeItemCollapsibleState, | ||
| } from 'vscode'; | ||
| import { COMMAND } from '@demotime/common'; | ||
|
|
||
| type QuickAction = { | ||
| label: string; | ||
| description: string; | ||
| icon: string; | ||
| color?: string; | ||
| command: string; | ||
| }; | ||
|
|
||
| export class QuickActionsTreeviewProvider implements TreeDataProvider<QuickActionTreeItem> { | ||
| private isPresentationMode = false; | ||
| private isAutoProceedActive = false; | ||
| private isAutoProceedPaused = false; | ||
| private autoProceedCountdown = 0; | ||
| private _onDidChangeTreeData = new EventEmitter<QuickActionTreeItem | undefined>(); | ||
|
Check warning on line 26 in apps/vscode-extension/src/providers/QuickActionsTreeviewProvider.ts
|
||
| public readonly onDidChangeTreeData: Event<QuickActionTreeItem | undefined> = | ||
| this._onDidChangeTreeData.event; | ||
|
|
||
| public setPresentationMode(isPresentationMode: boolean): void { | ||
| this.isPresentationMode = isPresentationMode; | ||
| } | ||
|
|
||
| public setAutoProceedState(isActive: boolean, isPaused: boolean, countdown: number): void { | ||
| this.isAutoProceedActive = isActive; | ||
| this.isAutoProceedPaused = isPaused; | ||
| this.autoProceedCountdown = countdown; | ||
| } | ||
|
|
||
| getTreeItem(element: QuickActionTreeItem): TreeItem | Thenable<TreeItem> { | ||
| return element; | ||
| } | ||
|
|
||
| getChildren(): ProviderResult<QuickActionTreeItem[]> { | ||
| const presentationAction: QuickAction = this.isPresentationMode | ||
| ? { | ||
| label: 'Stop Presentation Mode', | ||
| description: 'Leave presentation mode', | ||
| icon: 'debug-stop', | ||
| color: 'charts.red', | ||
| command: COMMAND.togglePresentationMode, | ||
| } | ||
| : { | ||
| label: 'Start Presentation Mode', | ||
| description: 'Enter presentation mode', | ||
| icon: 'play', | ||
| color: 'charts.green', | ||
| command: COMMAND.togglePresentationMode, | ||
| }; | ||
|
|
||
| const autoProceedAction: QuickAction | null = this.isAutoProceedActive | ||
| ? this.isAutoProceedPaused | ||
| ? { | ||
| label: 'Resume Auto-Proceed', | ||
| description: 'Resume auto-advance countdown', | ||
| icon: 'play-circle', | ||
| color: 'charts.green', | ||
| command: COMMAND.resumeAutoProceed, | ||
| } | ||
| : { | ||
| label: `Pause Auto-Proceed`, | ||
| description: `Next scene in ${this.autoProceedCountdown}s — click to pause`, | ||
| icon: 'debug-pause', | ||
| color: 'charts.yellow', | ||
| command: COMMAND.pauseAutoProceed, | ||
| } | ||
|
Check warning on line 76 in apps/vscode-extension/src/providers/QuickActionsTreeviewProvider.ts
|
||
| : null; | ||
|
|
||
| const actions: QuickAction[] = [ | ||
| presentationAction, | ||
| ...(autoProceedAction ? [autoProceedAction] : []), | ||
| { | ||
| label: 'Start Timer', | ||
| description: 'Start countdown timer for your session', | ||
| icon: 'watch', | ||
| color: 'charts.yellow', | ||
| command: COMMAND.startCountdown, | ||
| }, | ||
| { | ||
| label: 'Open Presenter View', | ||
| description: 'Show presenter notes and controls', | ||
| icon: 'open-preview', | ||
| command: COMMAND.showPresenterView, | ||
| }, | ||
| { | ||
| label: 'Reset Demo State', | ||
| description: 'Clear highlights and reset runner state', | ||
| icon: 'discard', | ||
| color: 'charts.orange', | ||
| command: COMMAND.reset, | ||
| }, | ||
| { | ||
| label: 'Export Slides to PDF', | ||
| description: 'Export your presentation to a PDF file', | ||
| icon: 'file-pdf', | ||
| command: COMMAND.exportToPdf, | ||
| }, | ||
| { | ||
| label: 'Find in Acts & Scenes', | ||
| description: 'Focus and search in the Acts & Scenes tree', | ||
| icon: 'search', | ||
| command: COMMAND.treeviewFind, | ||
| }, | ||
| { | ||
| label: 'Create Act File', | ||
| description: 'Create a new act file in the .demo folder', | ||
| icon: 'new-file', | ||
| command: COMMAND.createDemoFile, | ||
| }, | ||
| { | ||
| label: 'Open Overview', | ||
| description: 'Open the Demo Time overview panel', | ||
| icon: 'home', | ||
| command: COMMAND.showOverview, | ||
| }, | ||
| { | ||
| label: 'Open Settings', | ||
| description: 'Open Demo Time settings panel', | ||
| icon: 'settings-gear', | ||
| command: COMMAND.showSettings, | ||
| }, | ||
| { | ||
| label: 'Open PRO Features', | ||
| description: 'Discover or unlock PRO capabilities', | ||
| icon: 'lock', | ||
| color: 'charts.red', | ||
| command: COMMAND.showProFeatures, | ||
| }, | ||
| { | ||
| label: 'Open Documentation', | ||
| description: 'Read docs, guides, and references', | ||
| icon: 'book', | ||
| command: COMMAND.documentation, | ||
| }, | ||
| { | ||
| label: 'Support the Project', | ||
| description: 'Sponsor Demo Time development', | ||
| icon: 'heart', | ||
| color: 'charts.red', | ||
| command: COMMAND.openSupportTheProject, | ||
| }, | ||
| ]; | ||
|
|
||
| return actions.map((action) => new QuickActionTreeItem(action)); | ||
| } | ||
|
|
||
| update(): void { | ||
| this._onDidChangeTreeData.fire(undefined); | ||
| } | ||
| } | ||
|
|
||
| export class QuickActionTreeItem extends TreeItem { | ||
| constructor(action: QuickAction) { | ||
| super(action.label, TreeItemCollapsibleState.None); | ||
|
|
||
| this.label = action.label; | ||
| this.description = action.description; | ||
| this.tooltip = action.description; | ||
| this.iconPath = new ThemeIcon( | ||
| action.icon, | ||
| action.color ? new ThemeColor(action.color) : undefined, | ||
| ); | ||
| this.command = { | ||
| command: action.command, | ||
| title: action.label, | ||
| }; | ||
| this.contextValue = 'demo-time.quick-action'; | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: estruyf/vscode-demo-time
Length of output: 9170
🏁 Script executed:
sed -n '45,70p' apps/vscode-extension/src/extension.tsRepository: estruyf/vscode-demo-time
Length of output: 769
🏁 Script executed:
Repository: estruyf/vscode-demo-time
Length of output: 1568
🏁 Script executed:
cat -n apps/vscode-extension/src/services/Extension.ts | head -80Repository: estruyf/vscode-demo-time
Length of output: 2326
🏁 Script executed:
sed -n '235,250p' apps/vscode-extension/src/panels/DemoPanel.tsRepository: estruyf/vscode-demo-time
Length of output: 515
🏁 Script executed:
sed -n '210,235p' apps/vscode-extension/src/panels/DemoPanel.tsRepository: estruyf/vscode-demo-time
Length of output: 683
🏁 Script executed:
grep -n "public static register" apps/vscode-extension/src/panels/DemoPanel.tsRepository: estruyf/vscode-demo-time
Length of output: 100
🏁 Script executed:
sed -n '18,45p' apps/vscode-extension/src/panels/DemoPanel.tsRepository: estruyf/vscode-demo-time
Length of output: 886
🏁 Script executed:
sed -n '180,215p' apps/vscode-extension/src/panels/DemoPanel.tsRepository: estruyf/vscode-demo-time
Length of output: 830
🏁 Script executed:
sed -n '1,40p' apps/vscode-extension/src/panels/ResourcesPanel.tsRepository: estruyf/vscode-demo-time
Length of output: 697
Subscribe the TreeView to extension lifecycle via the Extension singleton.
createTreeViewreturns a disposable resource that should be registered withExtension.getInstance().subscriptionsto ensure proper cleanup on extension deactivation, consistent with command and provider registration patterns used throughout the codebase.The proposed refactor's approach of adding a context parameter doesn't align with this extension's singleton pattern. Instead, add the subscription using the Extension class's existing accessor:
Corrected refactor
public static register() { QuickActionsPanel.quickActionsProvider = new QuickActionsTreeviewProvider(); QuickActionsPanel.treeView = window.createTreeView('demo-time-quick-actions', { treeDataProvider: QuickActionsPanel.quickActionsProvider, }); + Extension.getInstance().subscriptions.push(QuickActionsPanel.treeView); }Note: This same issue affects
DemoPanelandResourcesPanel, which also create TreeViews without subscribing them.📝 Committable suggestion
🤖 Prompt for AI Agents