Skip to content

Conversation

@icecrasher321
Copy link
Collaborator

@icecrasher321 icecrasher321 commented Jul 7, 2025

Description

  • Fixing folders sharing
  • Fix folder deletions hanging + move to cascade deletes
  • T3 Env Standardization
  • Enhanced Logging System Implemented

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance improvement

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • All tests pass locally and in CI (bun run test)
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules
  • I have updated version numbers as needed (if needed)
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Security Considerations:

  • My changes do not introduce any new security vulnerabilities
  • I have considered the security implications of my changes

waleedlatif1 and others added 4 commits July 6, 2025 20:01
* fix(sharing): fixed folders not appearing when sharing workflows

* cleanup

* fixed error case
… throughout (#620)

* use cascade deletion

* fix lint

---------

Co-authored-by: Vikhyath Mondreti <vikhyathmondreti@vikhyaths-air.lan>
* chore: use t3-env as source of truth

* chore: update mock env for failing tests
* feat(logs): enhanced logging system with cleanup and theme fixes

- Implement enhanced logging cleanup with S3 archival and retention policies
- Fix error propagation in trace spans for manual executions
- Add theme-aware styling for frozen canvas modal
- Integrate enhanced logging system across all execution pathways
- Add comprehensive trace span processing and iteration navigation
- Fix boolean parameter types in enhanced logs API

* add warning for old logs

* fix lint

* added cost for streaming outputs

* fix overflow issue

* fix lint

* fix selection on closing sidebar

* tooltips z index increase

---------

Co-authored-by: Vikhyath Mondreti <vikhyathmondreti@vikhyaths-air.lan>
Co-authored-by: Waleed Latif <walif6@gmail.com>
@vercel
Copy link

vercel bot commented Jul 7, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sim (staging) ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 7, 2025 3:07am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
docs ⬜️ Skipped (Inspect) Jul 7, 2025 3:07am

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

Major update introducing a new tokenization system and improving workspace permissions, with significant security and logging enhancements across the application.

  • Added comprehensive tokenization system in apps/sim/lib/tokenization/ for cost tracking and token estimation across different LLM providers
  • Enhanced workspace security by requiring admin permissions for destructive operations in apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/control-bar/control-bar.tsx
  • Implemented workspace-based folder permissions in apps/sim/app/api/folders/ replacing user-based access control
  • Improved database connection handling in apps/sim/db/index.ts with conservative pool settings to prevent connection exhaustion
  • Replaced legacy logging with EnhancedLoggingSession across execution endpoints for better observability

52 files reviewed, 39 comments
Edit PR Review Bot Settings | Greptile

Comment on lines 30 to +31

const IS_DEV = process.env.NODE_ENV === 'development'
const IS_DEV = env.NODE_ENV === 'development'
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Consider making IS_DEV a memoized value since env.NODE_ENV won't change during runtime

Comment on lines +107 to +108
SOCKET_PORT: z.number().optional(),
PORT: z.number().optional(),
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Missing schema validation constraints. Consider adding min/max values for port numbers to prevent invalid configurations.

Suggested change
SOCKET_PORT: z.number().optional(),
PORT: z.number().optional(),
SOCKET_PORT: z.number().min(1).max(65535).optional(),
PORT: z.number().min(1).max(65535).optional(),

Comment on lines +4 to +11
vi.mock('../env', () => ({
env: {
FREE_TIER_COST_LIMIT: 5,
PRO_TIER_COST_LIMIT: 20,
TEAM_TIER_COST_LIMIT: 40,
ENTERPRISE_TIER_COST_LIMIT: 200,
},
}))
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Consider mocking values as strings to match actual env var types.

Comment on lines 24 to +25
edges: sampleWorkflowState.edges || [],
loops: sampleWorkflowState.loops || {},
parallels: sampleWorkflowState.parallels || {},
parallels: {},
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Consider keeping the optional fallback for parallels consistent with loops and edges to maintain pattern consistency

Comment on lines 516 to +517
const executionId = uuidv4()
await persistExecutionLogs(workflowId, executionId, enrichedResult, 'chat')
logger.debug(`Persisted logs for deployed chat: ${executionId}`)
logger.debug(`Generated execution ID for deployed chat: ${executionId}`)
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: using duplicate executionId - already generated on line 256

Suggested change
const executionId = uuidv4()
await persistExecutionLogs(workflowId, executionId, enrichedResult, 'chat')
logger.debug(`Persisted logs for deployed chat: ${executionId}`)
logger.debug(`Generated execution ID for deployed chat: ${executionId}`)
logger.debug(`Using execution ID for deployed chat: ${executionId}`)

Comment on lines +161 to +166
export function estimateInputTokens(
systemPrompt?: string,
context?: string,
messages?: Array<{ role: string; content: string }>,
providerId?: string
): TokenEstimate {
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Consider grouping optional parameters into a config object for better maintainability as more providers or options are added.

Suggested change
export function estimateInputTokens(
systemPrompt?: string,
context?: string,
messages?: Array<{ role: string; content: string }>,
providerId?: string
): TokenEstimate {
type InputTokensConfig = {
systemPrompt?: string
context?: string
messages?: Array<{ role: string; content: string }>
providerId?: string
}
export function estimateInputTokens(config: InputTokensConfig): TokenEstimate {

Comment on lines +37 to +50
switch (effectiveProviderId) {
case 'openai':
case 'azure-openai':
estimatedTokens = estimateOpenAITokens(text)
break
case 'anthropic':
estimatedTokens = estimateAnthropicTokens(text)
break
case 'google':
estimatedTokens = estimateGoogleTokens(text)
break
default:
estimatedTokens = estimateGenericTokens(text, config.avgCharsPerToken)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

style: As the provider list grows, consider extracting each provider's estimation logic into separate functions in a dedicated config file.


if (messages) {
for (const message of messages) {
totalText += `${message.role}: ${message.content}\n`
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Concatenating role and content with a colon may cause issues if the role or content contains colons. Consider using a more robust separator or different format.

Comment on lines +16 to +23
if (!text || text.length < MIN_TEXT_LENGTH_FOR_ESTIMATION) {
return {
count: 0,
confidence: 'high',
provider: providerId || 'unknown',
method: 'fallback',
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Early return uses 'high' confidence but returns 'fallback' method, which seems inconsistent with the confidence level.

Suggested change
if (!text || text.length < MIN_TEXT_LENGTH_FOR_ESTIMATION) {
return {
count: 0,
confidence: 'high',
provider: providerId || 'unknown',
method: 'fallback',
}
}
if (!text || text.length < MIN_TEXT_LENGTH_FOR_ESTIMATION) {
return {
count: 0,
confidence: 'low',
provider: providerId || 'unknown',
method: 'fallback',
}
}

Comment on lines +718 to +744
const traceSpans = (executionResult.logs || []).map((blockLog: any, index: number) => {
let output = blockLog.output
if (!blockLog.success && blockLog.error) {
output = {
error: blockLog.error,
success: false,
...(blockLog.output || {}),
}
}

// Persist logs for this execution using the standard 'webhook' trigger type
await persistExecutionLogs(foundWorkflow.id, executionId, enrichedResult, 'webhook')
return {
id: blockLog.blockId,
name: `Block ${blockLog.blockName || blockLog.blockType} (${blockLog.blockType || 'unknown'})`,
type: blockLog.blockType || 'unknown',
duration: blockLog.durationMs || 0,
startTime: blockLog.startedAt,
endTime: blockLog.endedAt || blockLog.startedAt,
status: blockLog.success ? 'success' : 'error',
blockId: blockLog.blockId,
input: blockLog.input,
output: output,
tokens: blockLog.output?.tokens?.total || 0,
relativeStartMs: index * 100,
children: [],
toolCalls: (blockLog as any).toolCalls || [],
}
})
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Consider extracting this trace span mapping logic to a separate function for better maintainability.

@delve-auditor
Copy link

delve-auditor bot commented Jul 7, 2025

No security or compliance issues detected. Reviewed everything up to 0bf9ce0.

Security Overview
  • 🔎 Scanned files: 73 changed file(s)
Detected Code Changes

The diff is too large to display a summary of code changes.

Reply to this PR with @delve-auditor followed by a description of what change you want and we'll auto-submit a change to this PR to implement it.

@icecrasher321 icecrasher321 merged commit f3bc1fc into main Jul 7, 2025
8 of 9 checks passed
arenadeveloper02 pushed a commit to arenadeveloper02/p2-sim that referenced this pull request Sep 19, 2025
* fix(sharing): fixed folders not appearing when sharing workflows (simstudioai#616)

* fix(sharing): fixed folders not appearing when sharing workflows

* cleanup

* fixed error case

* fix(deletions): folder deletions were hanging + use cascade deletions throughout  (simstudioai#620)

* use cascade deletion

* fix lint

---------

Co-authored-by: Vikhyath Mondreti <vikhyathmondreti@vikhyaths-air.lan>

* fix(envvars): t3-env standardization (simstudioai#606)

* chore: use t3-env as source of truth

* chore: update mock env for failing tests

* feat(enhanced logs): integration + log visualizer canvas (simstudioai#618)

* feat(logs): enhanced logging system with cleanup and theme fixes

- Implement enhanced logging cleanup with S3 archival and retention policies
- Fix error propagation in trace spans for manual executions
- Add theme-aware styling for frozen canvas modal
- Integrate enhanced logging system across all execution pathways
- Add comprehensive trace span processing and iteration navigation
- Fix boolean parameter types in enhanced logs API

* add warning for old logs

* fix lint

* added cost for streaming outputs

* fix overflow issue

* fix lint

* fix selection on closing sidebar

* tooltips z index increase

---------

Co-authored-by: Vikhyath Mondreti <vikhyathmondreti@vikhyaths-air.lan>
Co-authored-by: Waleed Latif <walif6@gmail.com>

---------

Co-authored-by: Waleed Latif <walif6@gmail.com>
Co-authored-by: Vikhyath Mondreti <vikhyathmondreti@vikhyaths-air.lan>
Co-authored-by: Aditya Tripathi <aditya@climactic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants