Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 16 additions & 19 deletions apps/desktop/src-tauri/src/recording.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,18 @@ impl InProgressRecording {
}
}

pub async fn pause(&self) -> Result<(), RecordingError> {
todo!()
// match self {
// Self::Instant { handle, .. } => handle.pause().await,
// Self::Studio { handle, .. } => handle.pause().await,
// }
pub async fn pause(&self) -> anyhow::Result<()> {
match self {
Self::Instant { handle, .. } => handle.pause().await,
Self::Studio { handle, .. } => handle.pause().await,
}
}

pub async fn resume(&self) -> Result<(), String> {
todo!()
// match self {
// Self::Instant { handle, .. } => handle.resume().await.map_err(|e| e.to_string()),
// Self::Studio { handle, .. } => handle.resume().await.map_err(|e| e.to_string()),
// }
pub async fn resume(&self) -> anyhow::Result<()> {
match self {
Self::Instant { handle, .. } => handle.resume().await,
Self::Studio { handle, .. } => handle.resume().await,
}
}

pub fn recording_dir(&self) -> &PathBuf {
Expand Down Expand Up @@ -140,12 +138,11 @@ impl InProgressRecording {
}
}

pub async fn cancel(self) -> Result<(), RecordingError> {
todo!()
// match self {
// Self::Instant { handle, .. } => handle.cancel().await,
// Self::Studio { handle, .. } => handle.cancel().await,
// }
pub async fn cancel(self) -> anyhow::Result<()> {
match self {
Self::Instant { handle, .. } => handle.cancel().await,
Self::Studio { handle, .. } => handle.cancel().await,
}
}

pub fn mode(&self) -> RecordingMode {
Expand Down Expand Up @@ -673,7 +670,7 @@ pub async fn restart_recording(app: AppHandle, state: MutableState<'_, App>) ->

let inputs = recording.inputs().clone();

// let _ = recording.cancel().await;
let _ = recording.cancel().await;

Comment on lines +673 to 674
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Propagate cancel failure during restart

We now discard recording.cancel().await errors, so a failed cancel silently falls through to a new start_recording while the previous pipeline may still be alive. That can leak temp dirs and confuse state. Please propagate the error (e.g. return Err(err.to_string())) before continuing.

-    let _ = recording.cancel().await;
+    if let Err(err) = recording.cancel().await {
+        return Err(err.to_string());
+    }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let _ = recording.cancel().await;
if let Err(err) = recording.cancel().await {
return Err(err.to_string());
}
🤖 Prompt for AI Agents
In apps/desktop/src-tauri/src/recording.rs around lines 673-674, the call `let _
= recording.cancel().await;` currently discards any error; change it to
propagate failures instead of ignoring them by checking the result and returning
an error (for example: `recording.cancel().await.map_err(|e| e.to_string())?` or
match on the Result and return `Err(e.to_string())`) so that if cancel fails the
function returns early with an Err and does not proceed to start a new
recording.

tokio::time::sleep(Duration::from_millis(1000)).await;

Expand Down
4 changes: 3 additions & 1 deletion apps/web/app/(org)/dashboard/_components/Navbar/Items.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,9 @@ const NavItem = ({
{name}
</p>
{extraText && !sidebarCollapsed && (
<p className="ml-auto text-xs text-gray-11">{extraText}</p>
<p className="ml-auto text-xs font-medium text-gray-11">
{extraText}
</p>
)}
</Link>
</Tooltip>
Expand Down
3 changes: 1 addition & 2 deletions apps/web/app/(org)/dashboard/caps/Caps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ export const Caps = ({
data.error === 1 ? "" : "s"
}`;
}
router.refresh();
return `Successfully deleted ${data.success} cap${
data.success === 1 ? "" : "s"
}`;
Expand Down Expand Up @@ -267,7 +266,7 @@ export const Caps = ({
[data, isUploading, uploadingCapId],
);

if (count === 0 && folders.length === 0) return <EmptyCapState />;
if (count === 0) return <EmptyCapState />;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Reconsider empty state condition.

The empty state now displays when count === 0 regardless of folders, showing "Record your first Cap" even when folders exist. This could confuse users who have organized their workspace with folders but haven't added videos yet. The previous condition count === 0 && folders.length === 0 was more accurate for a truly empty state.

Consider restoring the original condition:

-if (count === 0) return <EmptyCapState />;
+if (count === 0 && folders.length === 0) return <EmptyCapState />;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (count === 0) return <EmptyCapState />;
if (count === 0 && folders.length === 0) return <EmptyCapState />;
🤖 Prompt for AI Agents
In apps/web/app/(org)/dashboard/caps/Caps.tsx around line 269, the empty-state
check uses `count === 0` which shows the "Record your first Cap" message even
when folders exist; restore the previous logic by changing the condition to
require both no caps and no folders (i.e., `count === 0 && folders.length ===
0`) so the empty state only appears when the workspace is truly empty.


return (
<div className="flex relative flex-col w-full h-full">
Expand Down
8 changes: 3 additions & 5 deletions apps/web/app/(org)/dashboard/caps/components/Folder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,9 @@ const FolderCard = ({
<Link
prefetch={false}
href={
deleteFolder.isPending
? "#"
: spaceId
? `/dashboard/spaces/${spaceId}/folder/${id}`
: `/dashboard/folder/${id}`
spaceId
? `/dashboard/spaces/${spaceId}/folder/${id}`
: `/dashboard/folder/${id}`
}
>
<div
Expand Down
57 changes: 15 additions & 42 deletions apps/web/app/s/[videoId]/_components/ShareHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
import type { userSelectProps } from "@cap/database/auth/session";
import type { videos } from "@cap/database/schema";
import { buildEnv, NODE_ENV } from "@cap/env";
import { Avatar, Button } from "@cap/ui";
import { Button } from "@cap/ui";
import { userIsPro } from "@cap/utils";
import { faChevronDown, faLock } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import clsx from "clsx";
import { Check, Copy, Globe2 } from "lucide-react";
import moment from "moment";
import Image from "next/image";
import { useRouter } from "next/navigation";
import { useEffect, useState } from "react";
import { toast } from "sonner";
Expand All @@ -30,10 +29,7 @@ export const ShareHeader = ({
sharedSpaces = [],
spacesData = null,
}: {
data: typeof videos.$inferSelect & {
organizationIconUrl?: string | null;
organizationName?: string | null;
};
data: typeof videos.$inferSelect;
user: typeof userSelectProps | null;
customDomain?: string | null;
domainVerified?: boolean;
Expand Down Expand Up @@ -74,11 +70,9 @@ export const ShareHeader = ({

const handleBlur = async () => {
setIsEditing(false);
const next = title.trim();
if (next === "" || next === data.name) return;

try {
await editTitle(data.id, next);
setTitle(next);
await editTitle(data.id, title);
toast.success("Video title updated");
refresh();
} catch (error) {
Expand All @@ -87,7 +81,6 @@ export const ShareHeader = ({
} else {
toast.error("Failed to update title - please try again.");
}
setTitle(data.name);
}
};

Expand Down Expand Up @@ -143,7 +136,7 @@ export const ShareHeader = ({

const renderSharedStatus = () => {
const baseClassName =
"text-sm text-gray-10 justify-center lg:justify-start transition-colors duration-200 flex items-center";
"text-sm text-gray-10 transition-colors duration-200 flex items-center";

if (isOwner) {
const hasSpaceSharing =
Expand Down Expand Up @@ -205,37 +198,17 @@ export const ShareHeader = ({
/>
<div className="mt-8">
<div className="flex flex-col gap-6 lg:flex-row lg:items-center lg:justify-between lg:gap-0">
<div className="justify-center items-center mb-3 w-full md:flex lg:justify-between md:space-x-6 md:mb-0">
<div className="flex flex-col gap-5 md:gap-10 lg:flex-row">
<div className="flex flex-col flex-1 justify-center items-center w-full lg:justify-evenly">
{data.organizationIconUrl ? (
<Image
className="rounded-full size-9"
src={data.organizationIconUrl}
alt="Organization icon"
width={36}
height={36}
/>
) : (
<Avatar
className="rounded-full size-9"
name={data.organizationName ?? "Organization"}
letterClass="text-sm"
/>
)}
<p className="text-sm font-medium text-gray-12">
{data.organizationName}
</p>
</div>
<div className="flex flex-col justify-center text-center lg:text-left lg:justify-start">
<div className="items-center md:flex md:justify-between md:space-x-6">
<div className="mb-3 md:mb-0">
<div className="flex items-center space-x-3 lg:min-w-[400px]">
{isEditing ? (
<input
value={title}
onChange={(e) => setTitle(e.target.value)}
onBlur={handleBlur}
onKeyDown={handleKeyDown}
autoFocus
className="w-full text-xl sm:text-2xl"
className="w-full text-xl font-semibold sm:text-2xl"
/>
) : (
<h1
Expand All @@ -249,16 +222,16 @@ export const ShareHeader = ({
{title}
</h1>
)}
{user && renderSharedStatus()}
<p className="mt-1 text-sm text-gray-10">
{moment(data.createdAt).fromNow()}
</p>
</div>
{user && renderSharedStatus()}
<p className="mt-1 text-sm text-gray-10">
{moment(data.createdAt).fromNow()}
</p>
</div>
</div>
{user !== null && (
<div className="flex justify-center space-x-2 w-full lg:justify-end">
<div className="w-fit">
<div className="flex space-x-2">
<div>
<div className="flex gap-2 items-center">
{data.password && (
<FontAwesomeIcon
Expand Down
10 changes: 0 additions & 10 deletions apps/web/app/s/[videoId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ type VideoWithOrganization = typeof videos.$inferSelect & {
hasPassword?: boolean;
ownerIsPro?: boolean;
orgSettings?: OrganizationSettings | null;
organizationIconUrl?: string | null;
organizationName?: string | null;
};

const ALLOWED_REFERRERS = [
Expand Down Expand Up @@ -289,8 +287,6 @@ export default async function ShareVideoPage(props: PageProps<"/s/[videoId]">) {
duration: videos.duration,
fps: videos.fps,
hasPassword: sql`${videos.password} IS NOT NULL`.mapWith(Boolean),
organizationIconUrl: organizations.iconUrl,
organizationName: organizations.name,
sharedOrganization: {
organizationId: sharedVideos.organizationId,
},
Expand Down Expand Up @@ -363,8 +359,6 @@ async function AuthorizedContent({
ownerIsPro?: boolean;
orgSettings?: OrganizationSettings | null;
videoSettings?: OrganizationSettings | null;
organizationIconUrl?: string | null;
organizationName?: string | null;
};
searchParams: { [key: string]: string | string[] | undefined };
}) {
Expand Down Expand Up @@ -483,8 +477,6 @@ async function AuthorizedContent({
sharedOrganization: {
organizationId: sharedVideos.organizationId,
},
organizationIconUrl: organizations.iconUrl,
organizationName: organizations.name,
orgSettings: organizations.settings,
videoSettings: videos.settings,
})
Expand Down Expand Up @@ -686,8 +678,6 @@ async function AuthorizedContent({
folderId: null,
orgSettings: video.orgSettings || null,
settings: video.videoSettings || null,
organizationIconUrl: video.organizationIconUrl ?? undefined,
organizationName: video.organizationName ?? undefined,
};

return (
Expand Down
3 changes: 1 addition & 2 deletions apps/web/components/forms/NewOrganization.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface NewOrganizationProps {

export const NewOrganization: React.FC<NewOrganizationProps> = (props) => {
const formSchema = z.object({
name: z.string().min(1).max(25),
name: z.string().min(1),
});

const form = useForm<z.infer<typeof formSchema>>({
Expand Down Expand Up @@ -77,7 +77,6 @@ export const NewOrganization: React.FC<NewOrganizationProps> = (props) => {
render={({ field }) => (
<FormControl>
<Input
maxLength={25}
placeholder="Your organization name"
{...field}
onChange={(e) => {
Expand Down
Loading
Loading