Skip to content

Commit c391764

Browse files
committed
UI improvements and code cleanup
- Remove customer info modal - calls now start immediately - Change 'Call History' to 'Dashboard' in navigation - Fix all ESLint errors in nativephp-extension.js - Fix PHP code style issues with Laravel Pint - Remove local nativephp-electron folder (now using GitHub package) - All tests passing successfully
1 parent 04e38ef commit c391764

25 files changed

+331
-408
lines changed

app/Http/Controllers/AudioTestController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ public function index()
1010
{
1111
return Inertia::render('AudioTest/Index');
1212
}
13-
}
13+
}

app/Http/Controllers/RealtimeController.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ public function generateEphemeralKey(Request $request)
2323
{
2424
try {
2525
$apiKey = $this->apiKeyService->getApiKey();
26-
27-
if (!$apiKey) {
26+
27+
if (! $apiKey) {
2828
return response()->json([
2929
'status' => 'error',
3030
'message' => 'OpenAI API key not configured',
@@ -33,26 +33,26 @@ public function generateEphemeralKey(Request $request)
3333

3434
// Generate ephemeral key from OpenAI Realtime API
3535
$response = Http::withHeaders([
36-
'Authorization' => 'Bearer ' . $apiKey,
36+
'Authorization' => 'Bearer '.$apiKey,
3737
'Content-Type' => 'application/json',
3838
])->post('https://api.openai.com/v1/realtime/sessions', [
3939
'model' => 'gpt-4o-mini-realtime-preview-2024-12-17',
4040
'voice' => $request->input('voice', 'alloy'),
4141
]);
4242

43-
if (!$response->successful()) {
44-
Log::error('OpenAI API error: ' . $response->body());
45-
throw new \Exception('Failed to generate ephemeral key from OpenAI: ' . $response->status());
43+
if (! $response->successful()) {
44+
Log::error('OpenAI API error: '.$response->body());
45+
throw new \Exception('Failed to generate ephemeral key from OpenAI: '.$response->status());
4646
}
4747

4848
$data = $response->json();
49-
49+
5050
// Validate response structure
51-
if (!isset($data['client_secret']['value']) || !isset($data['client_secret']['expires_at'])) {
51+
if (! isset($data['client_secret']['value']) || ! isset($data['client_secret']['expires_at'])) {
5252
Log::error('Invalid response structure from OpenAI API', ['response' => $data]);
5353
throw new \Exception('Invalid response structure from OpenAI API');
5454
}
55-
55+
5656
// Return ephemeral key data
5757
return response()->json([
5858
'status' => 'success',

app/Http/Controllers/Settings/ApiKeyController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ public function __construct(ApiKeyService $apiKeyService)
2525
public function edit(Request $request): Response
2626
{
2727
$hasApiKey = $this->apiKeyService->hasApiKey();
28-
$isUsingEnvKey = !cache()->has('app_openai_api_key') && $hasApiKey;
29-
28+
$isUsingEnvKey = ! cache()->has('app_openai_api_key') && $hasApiKey;
29+
3030
return Inertia::render('settings/ApiKeys', [
3131
'hasApiKey' => $hasApiKey,
3232
'isUsingEnvKey' => $isUsingEnvKey,
@@ -45,7 +45,7 @@ public function update(Request $request): RedirectResponse
4545
$apiKey = $request->input('openai_api_key');
4646

4747
// Validate the API key
48-
if (!$this->apiKeyService->validateApiKey($apiKey)) {
48+
if (! $this->apiKeyService->validateApiKey($apiKey)) {
4949
throw ValidationException::withMessages([
5050
'openai_api_key' => ['The provided API key is invalid. Please check and try again.'],
5151
]);
@@ -79,7 +79,7 @@ public function store(Request $request)
7979
$apiKey = $request->input('api_key');
8080

8181
// Validate the API key
82-
if (!$this->apiKeyService->validateApiKey($apiKey)) {
82+
if (! $this->apiKeyService->validateApiKey($apiKey)) {
8383
return response()->json([
8484
'success' => false,
8585
'message' => 'The provided API key is invalid. Please check and try again.',

app/Http/Controllers/TemplateController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public function destroy(Template $template)
105105
$remainingTemplatesCount = Template::where('id', '!=', $template->id)->count();
106106
if ($remainingTemplatesCount === 0) {
107107
return response()->json([
108-
'error' => 'Cannot delete the last remaining template. At least one template must exist.'
108+
'error' => 'Cannot delete the last remaining template. At least one template must exist.',
109109
], 422);
110110
}
111111

app/Http/Middleware/CheckOnboarding.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function handle(Request $request, Closure $next): Response
4545
}
4646

4747
// Check if API key exists
48-
if (!$this->apiKeyService->hasApiKey()) {
48+
if (! $this->apiKeyService->hasApiKey()) {
4949
// If not on onboarding page and no API key, redirect to onboarding
5050
if ($request->route() && $request->route()->getName() !== 'onboarding') {
5151
return redirect()->route('onboarding');
@@ -54,4 +54,4 @@ public function handle(Request $request, Closure $next): Response
5454

5555
return $next($request);
5656
}
57-
}
57+
}

app/Services/ApiKeyService.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
class ApiKeyService
99
{
1010
private const CACHE_KEY = 'app_openai_api_key';
11-
11+
1212
/**
1313
* Get the OpenAI API key from cache or environment
1414
*/
@@ -19,48 +19,48 @@ public function getApiKey(): ?string
1919
if ($cachedKey) {
2020
return $cachedKey;
2121
}
22-
22+
2323
// Fall back to environment variable
2424
return config('openai.api_key');
2525
}
26-
26+
2727
/**
2828
* Store the API key in cache
2929
*/
3030
public function setApiKey(string $apiKey): void
3131
{
3232
Cache::forever(self::CACHE_KEY, $apiKey);
3333
}
34-
34+
3535
/**
3636
* Remove the stored API key
3737
*/
3838
public function removeApiKey(): void
3939
{
4040
Cache::forget(self::CACHE_KEY);
4141
}
42-
42+
4343
/**
4444
* Check if an API key is available
4545
*/
4646
public function hasApiKey(): bool
4747
{
48-
return !empty($this->getApiKey());
48+
return ! empty($this->getApiKey());
4949
}
50-
50+
5151
/**
5252
* Validate an API key with OpenAI
5353
*/
5454
public function validateApiKey(string $apiKey): bool
5555
{
5656
try {
5757
$response = Http::withHeaders([
58-
'Authorization' => 'Bearer ' . $apiKey,
58+
'Authorization' => 'Bearer '.$apiKey,
5959
])->get('https://api.openai.com/v1/models');
60-
60+
6161
return $response->successful();
6262
} catch (\Exception $e) {
6363
return false;
6464
}
6565
}
66-
}
66+
}

database/factories/ConversationSessionFactory.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function definition(): array
2121
{
2222
$startedAt = $this->faker->dateTimeBetween('-1 month', 'now');
2323
$endedAt = $this->faker->optional(0.7)->dateTimeBetween($startedAt, 'now');
24-
24+
2525
return [
2626
'user_id' => null, // Single-user desktop app
2727
'title' => $this->faker->sentence(4),
@@ -69,7 +69,7 @@ public function completed(): static
6969
return $this->state(function (array $attributes) {
7070
$startedAt = $attributes['started_at'] ?? now()->subHour();
7171
$endedAt = now();
72-
72+
7373
return [
7474
'ended_at' => $endedAt,
7575
'duration_seconds' => $endedAt->diffInSeconds($startedAt),
@@ -81,4 +81,4 @@ public function completed(): static
8181
];
8282
});
8383
}
84-
}
84+
}

resources/js/components/RealtimeAgent/Navigation/MobileMenu.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,14 @@
100100
<span class="font-medium">{{ isOverlayMode ? 'ON' : 'OFF' }}</span>
101101
</button>
102102

103-
<!-- Call History Link -->
103+
<!-- Dashboard Link -->
104104
<button
105105
@click="handleDashboardClick"
106106
:disabled="isActive"
107107
class="w-full border-t border-gray-100 pt-3 text-left text-xs text-gray-600 dark:border-gray-800 dark:text-gray-400"
108108
:class="{ 'cursor-not-allowed opacity-50': isActive }"
109109
>
110-
View Call History
110+
Go to Dashboard
111111
</button>
112112
</div>
113113
</div>

resources/js/components/RealtimeAgent/Navigation/TitleBar.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
class="text-xs font-medium text-gray-600 transition-colors hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-100"
101101
:class="{ 'cursor-not-allowed opacity-50': isActive }"
102102
>
103-
Call History
103+
Dashboard
104104
</button>
105105

106106
<button

resources/js/nativephp-extension.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// NativePHP Extension for Audio Loopback Support
22
// This extension provides system audio capture functionality for Electron apps
33

4-
import { systemPreferences, app, ipcMain, session, desktopCapturer, shell } from 'electron';
4+
import { systemPreferences, ipcMain, shell } from 'electron';
55

66

77
// Store audio loopback state
@@ -12,7 +12,7 @@ const audioLoopbackState = {
1212

1313
export default {
1414
// Hook into Electron lifecycle - called before app is ready
15-
beforeReady: async (app) => {
15+
beforeReady: async () => {
1616
console.log('[Extension] beforeReady hook called');
1717

1818
// Method 1: Try to use electron-audio-loopback package if available
@@ -65,7 +65,7 @@ export default {
6565
// We don't need to register them here to avoid conflicts
6666

6767
// Microphone permission handlers
68-
'check-microphone-permission': async (event) => {
68+
'check-microphone-permission': async () => {
6969
if (process.platform !== 'darwin') {
7070
return { status: 'authorized' };
7171
}
@@ -80,7 +80,7 @@ export default {
8080
}
8181
},
8282

83-
'request-microphone-permission': async (event) => {
83+
'request-microphone-permission': async () => {
8484
if (process.platform !== 'darwin') {
8585
return { granted: true };
8686
}
@@ -96,7 +96,7 @@ export default {
9696
},
9797

9898
// Screen capture permission handlers
99-
'check-screen-capture-permission': async (event) => {
99+
'check-screen-capture-permission': async () => {
100100
if (process.platform !== 'darwin') {
101101
return { status: 'authorized' };
102102
}
@@ -111,7 +111,7 @@ export default {
111111
}
112112
},
113113

114-
'request-screen-capture-permission': async (event) => {
114+
'request-screen-capture-permission': async () => {
115115
if (process.platform !== 'darwin') {
116116
return { granted: true };
117117
}
@@ -128,7 +128,7 @@ export default {
128128
},
129129

130130
// Open privacy settings handler
131-
'open-privacy-settings': async (event) => {
131+
'open-privacy-settings': async () => {
132132
console.log('[Extension] IPC handler open-privacy-settings called');
133133

134134
if (process.platform !== 'darwin') {
@@ -145,7 +145,7 @@ export default {
145145
},
146146

147147
// Test handler to verify IPC is working
148-
'test:ping': async (event, ...args) => {
148+
'test:ping': async (_event, ...args) => {
149149
console.log('[Extension Test] IPC handler test:ping called', { args });
150150
return {
151151
success: true,
@@ -155,7 +155,7 @@ export default {
155155
};
156156
},
157157

158-
'test:echo': async (event, message) => {
158+
'test:echo': async (_event, message) => {
159159
console.log('[Extension Test] IPC handler test:echo called', { message });
160160
return {
161161
success: true,
@@ -164,7 +164,7 @@ export default {
164164
};
165165
},
166166

167-
'test:get-info': async (event) => {
167+
'test:get-info': async () => {
168168
console.log('[Extension Test] IPC handler test:get-info called');
169169
return {
170170
success: true,

0 commit comments

Comments
 (0)