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
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { NextRequest, NextResponse } from 'next/server';

// [Velt] API key and auth token from environment variables
const NEXT_PUBLIC_VELT_API_KEY = process.env.NEXT_PUBLIC_VELT_API_KEY || process.env.VELT_API_KEY || '';
const VELT_AUTH_TOKEN = process.env.VELT_AUTH_TOKEN;
const NEXT_PUBLIC_VELT_API_KEY = "6xTcUFtlYAlCdh11zrKB";
const VELT_AUTH_TOKEN = "bd4d5226050470b6c658054fcdf1092a";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Hardcoded API credentials exposed in source code

The API key and auth token were changed from reading environment variables to hardcoded string values. The VELT_AUTH_TOKEN (bd4d5226050470b6c658054fcdf1092a) is particularly sensitive as it's used to generate authentication tokens via the Velt API. Committing secrets to source control exposes them to anyone with repository access and makes credential rotation difficult.

Additional Locations (1)

Fix in Cursor Fix in Web


export async function POST(req: NextRequest) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ export function useCurrentDocument(): CurrentDocument {
localStorage.setItem('velt-demo-document-id', docId);
} else {
// 2. Check localStorage for existing document
const stored = localStorage.getItem('velt-demo-document-id');
const stored = localStorage.getItem('velt-inline-comments-demo-doc-id');
if (stored) {
docId = stored;
} else {
// 3. Generate new document ID
docId = `doc-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
localStorage.setItem('velt-demo-document-id', docId);
localStorage.setItem('velt-inline-comments-demo-doc-id', docId);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: localStorage key mismatch causes document ID loss

When a document ID comes from a URL parameter, it's stored using the old key 'velt-demo-document-id' (line 48), but when reading from localStorage, the code checks the new key 'velt-inline-comments-demo-doc-id' (line 51). This mismatch means document IDs saved from URL parameters are never retrieved on subsequent visits without the URL parameter, causing a new document ID to be generated instead of using the previously stored one.

Fix in Cursor Fix in Web

}

// Update URL with document ID for shareability
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Metadata } from 'next'
import '../styles/globals.css'
import { AppProviders } from "@/app/userAuth/AppProviders"

export const metadata: Metadata = {
title: 'Dashboard Inline Demo',
Expand All @@ -13,7 +14,9 @@ export default function RootLayout({
}) {
return (
<html lang="en">
<body>{children}</body>
<body>
<AppProviders>{children}</AppProviders>
</body>
</html>
)
}
Original file line number Diff line number Diff line change
@@ -1,33 +1,25 @@
'use client'

"use client";
// [Velt] Provider + collaboration
import { VeltProvider } from "@veltdev/react";
import { useVeltAuthProvider } from "@/components/velt/VeltInitializeUser";
import { VeltCollaboration } from "@/components/velt/VeltCollaboration";
import DocumentCanvas from '@/components/document/document-canvas'
import { VeltProvider } from '@veltdev/react'
import { VeltCollaboration } from '@/components/velt/VeltCollaboration'
import { AppProviders } from './userAuth/AppProviders'
import { useVeltAuthProvider } from '@/components/velt/VeltInitializeUser'

function VeltWrapper({ children }: { children: React.ReactNode }) {
const { authProvider } = useVeltAuthProvider()
// [Velt] Replace with your own API key from https://console.velt.dev
const NEXT_PUBLIC_VELT_API_KEY = "6xTcUFtlYAlCdh11zrKB";

export default function Home() {
// [Velt] Auth provider (reads from app/userAuth/useAppUser)
const { authProvider } = useVeltAuthProvider();

return (
// [Velt] Wrap app with VeltProvider
<VeltProvider
apiKey={process.env.NEXT_PUBLIC_VELT_API_KEY || '6xTcUFtlYAlCdh11zrKB'}
apiKey={NEXT_PUBLIC_VELT_API_KEY}
authProvider={authProvider}
>
<VeltCollaboration />
{children}
<DocumentCanvas />
</VeltProvider>
)
}

export default function Home() {
return (
<AppProviders>
<VeltWrapper>
<main className="flex h-screen w-screen">
<DocumentCanvas />
</main>
</VeltWrapper>
</AppProviders>
)
}
);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use client'

import { useState } from 'react'
import { VeltCommentTool } from '@veltdev/react'

interface ActionModalProps {
jobId: string
Expand Down Expand Up @@ -190,11 +189,6 @@ export default function ActionModal({ jobId, actionType, actionLabel, onClose, o
)}
</div>

{/* Hidden Velt comment tool for creating the action comment */}
<div className="hidden">
<VeltCommentTool targetElementId={actionTargetId} />
</div>

{/* Info about action comments */}
<div className="bg-amber-50 border border-amber-200 rounded-lg p-3">
<p className="text-xs text-amber-800">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const CommentsSidebar = ({ isOpen, onClose, selectedJob }: CommentsSideba
return (
<div className="w-[400px] h-full flex flex-col bg-white border-l border-gray-200">
{/* Header */}
<div className="h-[56px] px-4 flex items-center justify-between border-b border-gray-200">
<div className="h-[56px] px-4 flex items-center justify-between border-b border-gray-200 flex-shrink-0">
<div className="flex items-center gap-3">
<button onClick={onClose} className="p-1 hover:bg-gray-100 rounded">
<ChevronLeftIcon />
Expand All @@ -26,12 +26,13 @@ export const CommentsSidebar = ({ isOpen, onClose, selectedJob }: CommentsSideba
</div>
</div>

{/* VeltInlineCommentsSection for per-row thread */}
<div className="flex-1 overflow-y-auto" data-id={`job-${selectedJob.id}`}>
{/* VeltInlineCommentsSection for each line item */}
<div className="flex-1 overflow-y-auto px-6 py-6" id={`job-${selectedJob.id}`}>
<VeltInlineCommentsSection
multiThread={false}
context={{jobId: `job-${selectedJob.id}`, jobStatus: selectedJob.status}}
targetElementId={`job-${selectedJob.id}`}
shadowDom={false}
composerPosition="bottom"
/>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client'

import { useState } from 'react'
import { VeltCommentTool, VeltCommentBubble, VeltInlineCommentsSection } from '@veltdev/react'
import { VeltInlineCommentsSection } from '@veltdev/react'
import type { Job, JobLineItem } from './document-canvas'
import ActionModal from './ActionModal'

Expand Down Expand Up @@ -39,25 +39,7 @@ function LineItemRow({ lineItem, jobId }: { lineItem: JobLineItem; jobId: string
<div className="w-28 text-right">
<span className="text-sm font-medium text-gray-900">${lineItem.total.toFixed(2)}</span>
</div>
<div className="w-24 flex items-center justify-end" id={targetId} data-id={targetId}>
<div className="flex items-center justify-center min-w-[64px]">
<VeltCommentTool targetElementId={targetId} />
<VeltCommentBubble targetElementId={targetId} />
</div>
</div>
</div>

{/* Inline comments section for this line item */}
{showComments && (
<div className="px-4 py-3 bg-gray-50 border-t border-gray-100">
<div className="text-xs text-gray-500 mb-2">Comments for: {lineItem.description}</div>
<VeltInlineCommentsSection
targetElementId={targetId}
multiThread={false}
shadowDom={false}
/>
</div>
)}
</div>
)
}
Expand All @@ -67,8 +49,6 @@ export default function JobDetailModal({ job, isOpen, onClose }: JobDetailModalP

if (!isOpen) return null

const jobTargetId = `job-${job.id}`

// Calculate totals
const subtotal = job.lineItems.reduce((sum, item) => sum + item.total, 0)
const tax = subtotal * 0.08 // 8% tax
Expand Down Expand Up @@ -174,18 +154,13 @@ export default function JobDetailModal({ job, isOpen, onClose }: JobDetailModalP
<div className="mb-6">
<div className="flex items-center justify-between mb-3">
<h3 className="text-sm font-semibold text-gray-900">Job Comments</h3>
<div className="flex items-center gap-2" id={jobTargetId} data-id={jobTargetId}>
<div className="flex items-center justify-center min-w-[64px]">
<VeltCommentTool targetElementId={jobTargetId} />
<VeltCommentBubble targetElementId={jobTargetId} />
</div>
</div>
</div>
<div className="bg-gray-50 rounded-lg p-4">
<div className="bg-gray-50 rounded-lg p-4" id={`job-${job.id}`}>
<VeltInlineCommentsSection
targetElementId={jobTargetId}
multiThread={false}
context={{jobId: `job-${job.id}`, jobStatus: job.status}}
targetElementId={`job-${job.id}`}
shadowDom={false}
composerPosition='bottom'
/>
</div>
</div>
Expand All @@ -200,7 +175,6 @@ export default function JobDetailModal({ job, isOpen, onClose }: JobDetailModalP
<div className="w-20 text-right text-xs font-medium text-gray-500">Qty</div>
<div className="w-28 text-right text-xs font-medium text-gray-500">Unit Price</div>
<div className="w-28 text-right text-xs font-medium text-gray-500">Total</div>
<div className="w-24 text-right text-xs font-medium text-gray-500">Comments</div>
</div>

{/* Line Items */}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const JobsTable = ({ jobs, onJobClick, onRowClick }: JobsTableProps) => {
className="flex items-center justify-center min-w-[64px] relative overflow-visible"
onClick={(e) => e.stopPropagation()}
>
<VeltCommentTool targetElementId={`job-${job.id}`} />
<VeltCommentTool targetElementId={`job-${job.id}`} context={{jobId: `job-${job.id}`, jobStatus: job.status}} />
<VeltCommentBubble
targetElementId={`job-${job.id}`}
shadowDom={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ export default function DocumentCanvas() {
}

return (
<div className="flex flex-col w-full h-full">
<div className="flex flex-col w-full h-screen">
<Header />
<div className="flex flex-1 overflow-hidden">
<div className="flex flex-1 overflow-hidden h-[calc(100vh-45px)]">
<Sidebar />
<div className="flex-1 flex overflow-hidden">
{/* Main Content Area */}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import VeltTools from '@/components/velt/VeltTools'

export default function Header() {
return (
<div className="flex items-center justify-between gap-2 p-2 px-4 border-b bg-background">
<div className="sticky top-0 z-50 flex items-center justify-between gap-2 p-2 px-4 border-b bg-background">
<h1 className="text-lg font-semibold">Dashboard Inline Demo</h1>
<div className="flex items-center gap-3">
<VeltTools />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';

import { VeltNotificationsTool, useNotificationUtils, useUnreadNotificationsCount } from '@veltdev/react';
import { VeltNotificationsTool } from '@veltdev/react';

// Sidebar icon assets
const imgLogo = "/icons/sidebar/open-envoy-logo.svg";
Expand Down Expand Up @@ -81,16 +81,6 @@ function SectionHeader({ label }: SectionHeaderProps) {
}

export default function Sidebar() {
const notificationUtils = useNotificationUtils();
const unreadCount = useUnreadNotificationsCount();

const handleNotificationsClick = () => {
notificationUtils?.openNotificationsPanel();
};

// Get the count for "For You" tab (default), fallback to 0
const notificationCount = unreadCount?.forYou ?? 0;

return (
<div className="flex h-full">
<aside
Expand Down Expand Up @@ -133,30 +123,9 @@ export default function Sidebar() {
icon={imgSearch}
label="Search"
/>
{/* Notifications - entire row clickable */}
<div className="relative">
<button
onClick={handleNotificationsClick}
className="w-full h-8 flex items-center gap-3 px-2 py-1 rounded-[3px] hover:bg-[#F2F4FF]/40 transition-colors duration-150"
>
<img src={imgNotifications} alt="" className="w-4 h-4 flex-shrink-0 block" />
<span
className="flex-1 text-left text-sm leading-[21px] text-[#4A4947] tracking-[-0.105px]"
style={{ fontFamily: 'Inter, sans-serif' }}
>
Notifications
</span>
<span
className="flex items-center justify-center min-w-[18px] h-[18px] px-[5px] bg-[#BD323C] rounded-[5px] text-white text-xs font-medium leading-[18px] tracking-[0.25px]"
style={{ fontFamily: 'Inter, sans-serif' }}
>
{notificationCount}
</span>
</button>
{/* VeltNotificationsTool positioned at end of row for panel placement */}
<div className="absolute right-0 top-0 h-full flex items-center opacity-0 pointer-events-none">
<VeltNotificationsTool />
</div>
<div className="relative w-100">
{/* [Velt] Notifications Tool */}
<VeltNotificationsTool shadowDom={false} />
</div>
<NavItem
icon={imgHome}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";
import { useVeltClient, VeltComments, VeltCommentsSidebar } from "@veltdev/react";
import VeltInitializeDocument from "./VeltInitializeDocument";
import VeltCustomization from "./ui-customization";
import { VeltCustomization } from "./ui-customization/VeltCustomization";
import { useEffect } from "react";
import { useAppUser } from "@/app/userAuth/AppUserContext";

Expand All @@ -24,7 +24,6 @@ export function VeltCollaboration() {
return (
<>
<VeltInitializeDocument />
<VeltCustomization />
<VeltComments
popoverTriangleComponent={false}
popoverMode={true}
Expand All @@ -33,9 +32,10 @@ export function VeltCollaboration() {
commentPinHighlighter={false}
dialogOnHover={false}
groupMatchedComments={true}
priority={true}
/>
<VeltCommentsSidebar groupConfig={groupConfig} pageMode={true} />

<VeltCustomization />
</>
);
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
'use client';
"use client";
import { useEffect } from 'react';
import { useSetDocuments } from '@veltdev/react';
import { useCurrentDocument } from '@/app/document/useCurrentDocument';
import { useAppUser } from '@/app/userAuth/useAppUser';

export default function VeltInitializeDocument() {
const { documentId, documentName } = useCurrentDocument();
const { user } = useAppUser();

// [Velt] Get document setter hook
const { setDocuments } = useSetDocuments();

// [Velt] Set document in Velt. This is the resource where all Velt collaboration data will be scoped.
useEffect(() => {
if (!user || !documentId || !documentName) return;
if (!documentId || !documentName) return;

setDocuments([
{ id: documentId, metadata: { documentName: documentName || 'Untitled' } },
{ id: documentId, metadata: { documentName: documentName } },
]);
}, [user, setDocuments, documentId, documentName]);
}, [setDocuments, documentId, documentName]);

return null;
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"use client";
import { VeltCommentBubbleWireframe } from '@veltdev/react';
import { MessageSquare } from 'lucide-react';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"use client";
import { VeltCommentToolWireframe } from '@veltdev/react';
import { MessageSquare } from 'lucide-react';

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"use client";
import { VeltWireframe } from '@veltdev/react';
import VeltCommentBubbleWf from "./VeltCommentBubbleWf";
import VeltCommentToolWf from "./VeltCommentToolWf";
import VeltNotificationsToolWf from "./VeltNotificationsToolWf";
import VeltSidebarButtonWf from "./VeltSidebarButtonWf";
import "./styles.css";

export function VeltCustomization() {

return (
<VeltWireframe>
<VeltSidebarButtonWf />
<VeltCommentToolWf />
<VeltCommentBubbleWf />
<VeltNotificationsToolWf />
</VeltWireframe>
);
}
Loading
Loading