From 3a50b941f6a66112f201530ab94f407eb2f552f1 Mon Sep 17 00:00:00 2001 From: Dany <89309539+danbenba@users.noreply.github.com> Date: Tue, 6 Jan 2026 19:25:39 +0100 Subject: [PATCH] feat: Implement flexible time display modes for activity status and add a development README. --- package.json | 28 +++++++++++++++- src/README.md | 83 ++++++++++++++++++++++++++++++++++++++++++++++++ src/activity.ts | 44 +++++++++++++++++++++---- src/config.ts | 2 ++ src/constants.ts | 4 +++ 5 files changed, 154 insertions(+), 7 deletions(-) create mode 100644 src/README.md diff --git a/package.json b/package.json index d0f5d07c..2d5218b7 100644 --- a/package.json +++ b/package.json @@ -185,7 +185,33 @@ "vscord.status.showElapsedTime": { "type": "boolean", "default": true, - "description": "Should elapsed time be shown?" + "description": "Should elapsed time be shown?", + "deprecationMessage": "Deprecated: Please use vscord.status.time.mode instead.", + "markdownDeprecationMessage": "**Deprecated**: Please use `#vscord.status.time.mode#` instead." + }, + "vscord.status.time.mode": { + "type": "string", + "enum": [ + "Hidden", + "Elapsed", + "Current Interface", + "Custom", + "Fixed" + ], + "default": "Elapsed", + "description": "Choose the time mode.", + "enumDescriptions": [ + "Hide the timestamp.", + "Show the elapsed time.", + "Show the elapsed time since the start of the day (Local Time).", + "Show the elapsed time since the custom timestamp.", + "Show a fixed timestamp (00:00)." + ] + }, + "vscord.status.time.customTimestamp": { + "type": "number", + "default": 0, + "description": "The custom timestamp to use when `mode` is set to `Custom`." }, "vscord.status.resetElapsedTimePerFile": { "type": "boolean", diff --git a/src/README.md b/src/README.md new file mode 100644 index 00000000..584822db --- /dev/null +++ b/src/README.md @@ -0,0 +1,83 @@ +
+ +# VSCord - Developer Guide + +Development documentation for the [VSCord](https://github.com/LeonardSSH/vscord) extension. + +
+ +
+ +## ๐Ÿš€ Getting Started + +This guide covers how to set up your environment, build, and run the extension locally. + +## ๐Ÿ› ๏ธ Prerequisites + +- [Node.js](https://nodejs.org/) +- [npm](https://www.npmjs.com/) (Node Package Manager) + +## ๐Ÿ“ฅ Installation + +1. Clone the repository: + + ```bash + git clone https://github.com/LeonardSSH/vscord.git + cd vscord + ``` + +2. Install dependencies: + ```bash + npm install + ``` + +## ๐Ÿ’ป Running in Development Mode + +To run the extension in development mode with hot-reloading (watch mode): + +1. Open the project in **Visual Studio Code**. +2. Press **F5** to start debugging. This will compile the extension and open a new **Extension Development Host** window. + +Alternatively, you can run the watch script manually in your terminal if you prefer: + +```bash +npm run watch +``` + +## ๐Ÿ—๏ธ Building the Extension + +To compile the source code: + +```bash +npm run compile +``` + +This runs type checking, linting, and builds the project using `esbuild`. + +## ๐Ÿ“ฆ Packaging + +To create a `.vsix` package for distribution or manual installation: + +```bash +npm run package +``` + +or + +```bash +vsce package +``` + +## ๐Ÿงช Testing + +We recommend running lint checks before pushing changes: + +```bash +npm run lint +``` + +## ๐Ÿ” Development Notes + +- **Source Code**: All source code is located in the `src` directory. +- **Entry Point**: `src/extension.ts` is the main entry point of the extension. +- **Configuration**: Settings are defined in `package.json` under `contributes.configuration` and handled in `src/config.ts`. diff --git a/src/activity.ts b/src/activity.ts index 9f8262c2..c5c59287 100644 --- a/src/activity.ts +++ b/src/activity.ts @@ -98,12 +98,44 @@ export const activity = async ( if (isIdling && !config.get(CONFIG_KEYS.Status.Idle.Enabled)) return {}; - if (config.get(CONFIG_KEYS.Status.ShowElapsedTime)) { - presence.startTimestamp = config.get(CONFIG_KEYS.Status.ResetElapsedTimePerFile) - ? Date.now() - : (previous.startTimestamp ?? Date.now()); - } else { - delete presence.startTimestamp; + const timeMode = config.get(CONFIG_KEYS.Status.Time.Mode); + + switch (timeMode) { + case "Hidden": + delete presence.startTimestamp; + delete presence.endTimestamp; + break; + case "Elapsed": + if (config.get(CONFIG_KEYS.Status.ShowElapsedTime)) { + presence.startTimestamp = config.get(CONFIG_KEYS.Status.ResetElapsedTimePerFile) + ? Date.now() + : (previous.startTimestamp ?? Date.now()); + } else { + delete presence.startTimestamp; + } + break; + case "Current Interface": { + const now = new Date(); + const midnight = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0, 0); + presence.startTimestamp = midnight.getTime(); + break; + } + case "Custom": + presence.startTimestamp = config.get(CONFIG_KEYS.Status.Time.CustomTimestamp); + break; + case "Fixed": + delete presence.startTimestamp; + delete presence.endTimestamp; + break; + default: + if (config.get(CONFIG_KEYS.Status.ShowElapsedTime)) { + presence.startTimestamp = config.get(CONFIG_KEYS.Status.ResetElapsedTimePerFile) + ? Date.now() + : (previous.startTimestamp ?? Date.now()); + } else { + delete presence.startTimestamp; + } + break; } const detailsEnabled = config.get(CONFIG_KEYS.Status.Details.Enabled); diff --git a/src/config.ts b/src/config.ts index f572d3be..c7c1fba4 100644 --- a/src/config.ts +++ b/src/config.ts @@ -97,6 +97,8 @@ export interface ExtensionConfigurationType { "status.idle.disconnectOnIdle": boolean; "status.idle.resetElapsedTime": boolean; "status.idle.timeout": number; + "status.time.mode": "Hidden" | "Elapsed" | "Current Interface" | "Custom" | "Fixed"; + "status.time.customTimestamp": number; "status.showElapsedTime": boolean; "status.resetElapsedTimePerFile": boolean; "ignore.workspaces": Array; diff --git a/src/constants.ts b/src/constants.ts index c4b03cbf..d07343b4 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -180,6 +180,10 @@ export const CONFIG_KEYS = { ResetElapsedTime: "status.idle.resetElapsedTime" as const, Timeout: "status.idle.timeout" as const } as const, + Time: { + Mode: "status.time.mode" as const, + CustomTimestamp: "status.time.customTimestamp" as const + } as const, ShowElapsedTime: "status.showElapsedTime" as const, ResetElapsedTimePerFile: "status.resetElapsedTimePerFile" as const } as const,