Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

backwards compatible cursor loading + workflow end notification

Brendan Allan8850dcd2b9ab
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index 7a75e59a2..8fee95dbf 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -21,6 +21,8 @@ jobs:
outputs:
version: ${{ steps.read_version.outputs.value }}
needs_release: ${{ steps.create_tag.outputs.tag_existed != 'true' }}
+ cn_release_stdout: ${{ steps.create_cn_release.outputs.stdout }}
+ gh_release_url: ${{ steps.create_gh_release.outputs.url }}
permissions:
contents: write
id-token: write
@@ -80,6 +82,7 @@ jobs:
main();
- name: Create draft CN release
+ id: create_cn_release
uses: crabnebula-dev/cloud-release@v0
with:
command: release draft ${{ env.CN_APPLICATION }} ${{ steps.read_version.outputs.value }} --framework tauri
@@ -235,3 +238,39 @@ jobs:
run: |
curl -sL https://sentry.io/get-cli/ | bash
sentry-cli debug-files upload -o ${{ env.SENTRY_ORG }} -p ${{ env.SENTRY_PROJECT }} Cap.dSYM
+
+ done:
+ needs: [draft, build]
+ runs-on: ubuntu-latest
+ permissions:
+ contents: write
+ id-token: write
+ steps:
+ - name: Send Discord notification
+ if: ${{ inputs.interactionId != '' }}
+ uses: actions/github-script@v7
+ with:
+ script: |
+ async function main() {
+ const token = await core.getIDToken("cap-discord-bot");
+ const cnReleaseId = JSON.parse("${{ needs.draft.outputs.cn_release_stdout }}").id;
+
+ const resp = await fetch("https://cap-discord-bot.brendonovich.workers.dev/github-workflow", {
+ method: "POST",
+ body: JSON.stringify({
+ type: "release-done",
+ interactionId: "${{ inputs.interactionId }}",
+ version: "${{ steps.read_version.outputs.value }}",
+ releaseUrl: "${{ needs.draft.outputs.gh_release_url }}",
+ cnReleaseId
+ }),
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: `Bearer ${token}`,
+ }
+ });
+
+ if(resp.status !== 200) throw new Error(await resp.text());
+ }
+
+ main();
diff --git a/apps/desktop/src-tauri/src/lib.rs b/apps/desktop/src-tauri/src/lib.rs
index ce0e677f9..a69ed9a17 100644
--- a/apps/desktop/src-tauri/src/lib.rs
+++ b/apps/desktop/src-tauri/src/lib.rs
@@ -1601,7 +1601,7 @@ fn list_recordings(app: AppHandle) -> Result<Vec<(String, PathBuf, RecordingMeta
// Try to get recording meta, skip if it fails
match get_recording_meta(app.clone(), id.clone(), "recording".to_string()) {
Ok(meta) => Some((id, path.clone(), meta)),
- Err(_) => None,
+ Err(e) => None,
}
})
.collect::<Vec<_>>();
diff --git a/apps/desktop/src/routes/editor/Header.tsx b/apps/desktop/src/routes/editor/Header.tsx
index de2ed933f..162cfe62c 100644
--- a/apps/desktop/src/routes/editor/Header.tsx
+++ b/apps/desktop/src/routes/editor/Header.tsx
@@ -63,7 +63,6 @@ export interface ExportEstimates {
}
export function Header() {
- const currentWindow = getCurrentWindow();
const license = createLicenseQuery();
const [selectedFps, setSelectedFps] = createSignal(
@@ -128,11 +127,11 @@ export function Header() {
await commands.showWindow("Upgrade");
}
}}
- class={`text-[0.85rem] ${
+ class={`text-[0.8rem] ${
license.data?.type === "pro"
? "bg-[--blue-400] text-gray-50 dark:text-gray-500"
: "bg-gray-200 cursor-pointer hover:bg-gray-300"
- } rounded-lg px-1.5 py-0.5`}
+ } rounded-[0.55rem] px-2 py-1`}
>
{license.data?.type === "commercial"
? "Commercial License"
diff --git a/apps/desktop/src/routes/editor/Timeline.tsx b/apps/desktop/src/routes/editor/Timeline.tsx
index 96de821c4..692e0695a 100644
--- a/apps/desktop/src/routes/editor/Timeline.tsx
+++ b/apps/desktop/src/routes/editor/Timeline.tsx
@@ -253,7 +253,7 @@ function TimelineMarkings() {
<For each={timelineMarkings()}>
{(second) => (
<div
- class="absolute bottom-1 left-0 text-center rounded-full w-1 h-1 bg-gray-400 text-gray-400"
+ class="absolute bottom-1 left-0 text-center rounded-full w-1 h-1 bg-[--text-tertiary] text-[--text-tertiary]"
style={{
left: `${
(second - state.timelineTransform.position) / secsPerPixel() - 1
@@ -262,7 +262,7 @@ function TimelineMarkings() {
>
<Show when={second % 1 === 0}>
<div class="absolute -top-4 -translate-x-1/2">
- 0:{second.toString().padStart(2, "0")}
+ {formatTime(second)}
</div>
</Show>
</div>
diff --git a/apps/desktop/src/styles/theme.css b/apps/desktop/src/styles/theme.css
index 64414c550..86bf3b717 100644
--- a/apps/desktop/src/styles/theme.css
+++ b/apps/desktop/src/styles/theme.css
@@ -9,6 +9,10 @@
--gray-400: #8991a3;
--gray-500: #12161f;
+ --text-primary: rgba(18, 22, 31, 0.95); /* Section titles, headings */
+ --text-secondary: rgba(18, 22, 31, 0.85); /* Important labels */
+ --text-tertiary: rgba(18, 22, 31, 0.65); /* Descriptions */
+
--black-transparent-5: rgba(18, 22, 31, 0.05);
--black-transparent-10: rgba(18, 22, 31, 0.1);
--black-transparent-20: rgba(18, 22, 31, 0.2);
diff --git a/apps/desktop/src/utils/tauri.ts b/apps/desktop/src/utils/tauri.ts
index ab95095d3..c1cdc497d 100644
--- a/apps/desktop/src/utils/tauri.ts
+++ b/apps/desktop/src/utils/tauri.ts
@@ -244,6 +244,7 @@ export type CursorAnimationStyle = "regular" | "slow" | "fast"
export type CursorConfiguration = { hideWhenIdle: boolean; size: number; type: CursorType; animationStyle: CursorAnimationStyle }
export type CursorMeta = { imagePath: string; hotspot: XY<number> }
export type CursorType = "pointer" | "circle"
+export type Cursors = { [key in string]: string } | { [key in string]: CursorMeta }
export type Display = { path: string; fps?: number }
export type EditorStateChanged = { playhead_position: number }
export type ExportEstimates = { duration_seconds: number; estimated_time_seconds: number; estimated_size_mb: number }
@@ -257,7 +258,7 @@ export type HotkeysConfiguration = { show: boolean }
export type HotkeysStore = { hotkeys: { [key in HotkeyAction]: Hotkey } }
export type JsonValue<T> = [T]
export type MultipleSegment = { display: Display; camera?: CameraMeta | null; audio?: AudioMeta | null; cursor?: string | null }
-export type MultipleSegments = { segments: MultipleSegment[]; cursors: { [key in string]: CursorMeta } }
+export type MultipleSegments = { segments: MultipleSegment[]; cursors: Cursors }
export type NewNotification = { title: string; body: string; is_error: boolean }
export type NewRecordingAdded = { path: string }
export type NewScreenshotAdded = { path: string }
diff --git a/apps/discord-bot/src/index.ts b/apps/discord-bot/src/index.ts
index 243f172aa..edd06b8cf 100644
--- a/apps/discord-bot/src/index.ts
+++ b/apps/discord-bot/src/index.ts
@@ -18,6 +18,7 @@ const CHANNEL_MESSAGE_WITH_SOURCE = 4;
type InteractionBody = {
id: string;
token: string;
+ channel_id: string;
member: {
user: {
id: string;
@@ -91,26 +92,35 @@ app.post(
ghActionsOidc,
vValidator(
'json',
- v.object({
- type: v.literal('release-ready'),
- tag: v.string(),
- version: v.string(),
- interactionId: v.string(),
- releaseUrl: v.string(),
- })
+ v.union([
+ v.object({
+ type: v.literal('release-ready'),
+ tag: v.string(),
+ version: v.string(),
+ interactionId: v.string(),
+ releaseUrl: v.string(),
+ }),
+ v.object({
+ type: v.literal('release-done'),
+ version: v.string(),
+ interactionId: v.string(),
+ releaseUrl: v.string(),
+ cnReleaseId: v.string(),
+ }),
+ ])
),
async (c) => {
const body = c.req.valid('json');
- switch (body.type) {
- case 'release-ready': {
- const interactionStr = await c.env.release_discord_interactions.get(body.interactionId);
- if (!interactionStr) return new Response('Interaction not found', { status: 404 });
+ const interactionStr = await c.env.release_discord_interactions.get(body.interactionId);
+ if (!interactionStr) return new Response('Interaction not found', { status: 404 });
- const interaction: InteractionBody = JSON.parse(interactionStr);
+ const interaction: InteractionBody = JSON.parse(interactionStr);
- if (interaction.data.name !== 'release') return new Response('Invalid interaction', { status: 400 });
+ if (interaction.data.name !== 'release') return new Response('Invalid interaction', { status: 400 });
+ switch (body.type) {
+ case 'release-ready': {
await fetch(`https://discord.com/api/v10/webhooks/${DISCORD_APP_ID}/${interaction.token}/messages/@original`, {
method: 'PATCH',
body: JSON.stringify(releaseWorkflowRunningMessageData(body.version, body.releaseUrl, c.get('githubToken').run_id)),
@@ -119,6 +129,21 @@ app.post(
return new Response('Successfully updated message', { status: 200 });
}
+ case 'release-done': {
+ await fetch(`https://discord.com/api/v10/channels/${interaction.channel_id}`, {
+ method: 'POST',
+ body: JSON.stringify(
+ releaseWorkflowDoneMessageData(
+ interaction.member.user.id,
+ body.version,
+ body.releaseUrl,
+ body.cnReleaseId,
+ c.get('githubToken').run_id
+ )
+ ),
+ headers: { 'Content-Type': 'application/json' },
+ });
+ }
default: {
return new Response('Invalid type', { status: 400 });
}
@@ -220,3 +245,34 @@ function releaseWorkflowRunningMessageData(version: string, releaseUrl: string,
],
};
}
+
+function releaseWorkflowDoneMessageData(userId: string, version: string, releaseUrl: string, cnReleaseId: string, workflowRunId: string) {
+ return {
+ content: [`<@${userId}> v${version} has finished building!`],
+ components: [
+ {
+ type: 1,
+ components: [
+ {
+ type: 2,
+ label: 'Release Notes',
+ url: releaseUrl,
+ style: 5,
+ },
+ {
+ type: 2,
+ label: 'CN Cloud Release',
+ url: `https://web.crabnebula.cloud/org/cap/cap/releases/${cnReleaseId}`,
+ style: 5,
+ },
+ {
+ type: 2,
+ label: 'Workflow Run',
+ url: `https://github.com/${GITHUB_ORG}/${GITHUB_REPO}/actions/runs/${workflowRunId}`,
+ style: 5,
+ },
+ ],
+ },
+ ],
+ };
+}
diff --git a/crates/project/src/meta.rs b/crates/project/src/meta.rs
index 100f86d9c..aa6e60db1 100644
--- a/crates/project/src/meta.rs
+++ b/crates/project/src/meta.rs
@@ -144,8 +144,31 @@ pub struct SingleSegment {
#[serde(rename_all = "camelCase")]
pub struct MultipleSegments {
pub segments: Vec<MultipleSegment>,
- #[serde(default, skip_serializing_if = "HashMap::is_empty")]
- pub cursors: HashMap<String, CursorMeta>,
+ #[serde(default, skip_serializing_if = "Cursors::is_empty")]
+ pub cursors: Cursors,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize, Type)]
+#[serde(untagged, rename_all = "camelCase")]
+pub enum Cursors {
+ // needed for backwards compat as i wasn't strict enough with feature flagging 🤦
+ Old(HashMap<String, String>),
+ Correct(HashMap<String, CursorMeta>),
+}
+
+impl Cursors {
+ fn is_empty(&self) -> bool {
+ match self {
+ Cursors::Old(map) => map.is_empty(),
+ Cursors::Correct(map) => map.is_empty(),
+ }
+ }
+}
+
+impl Default for Cursors {
+ fn default() -> Self {
+ Self::Correct(Default::default())
+ }
}
#[derive(Debug, Clone, Serialize, Deserialize, Type)]
@@ -162,8 +185,9 @@ impl MultipleSegments {
}
pub fn cursor_images(&self, meta: &RecordingMeta) -> Result<CursorImages, CursorImage> {
- Ok(CursorImages(
- self.cursors
+ Ok(CursorImages(match &self.cursors {
+ Cursors::Old(_) => Default::default(),
+ Cursors::Correct(map) => map
.iter()
.map(|(k, v)| {
(
@@ -175,7 +199,7 @@ impl MultipleSegments {
)
})
.collect::<_>(),
- ))
+ }))
}
}
diff --git a/crates/recording/src/actor.rs b/crates/recording/src/actor.rs
index 58c22394d..4c1309e7a 100644
--- a/crates/recording/src/actor.rs
+++ b/crates/recording/src/actor.rs
@@ -476,19 +476,21 @@ async fn stop_recording(
})
.collect()
},
- cursors: cursors
- .into_values()
- .map(|cursor| {
- (
- cursor.id.to_string(),
- CursorMeta {
- image_path: RelativePathBuf::from("content/cursors")
- .join(&cursor.file_name),
- hotspot: cursor.hotspot,
- },
- )
- })
- .collect(),
+ cursors: cap_project::Cursors::Correct(
+ cursors
+ .into_values()
+ .map(|cursor| {
+ (
+ cursor.id.to_string(),
+ CursorMeta {
+ image_path: RelativePathBuf::from("content/cursors")
+ .join(&cursor.file_name),
+ hotspot: cursor.hotspot,
+ },
+ )
+ })
+ .collect(),
+ ),
},
},
};