@@ -12,19 +12,7 @@ import { useHistory } from "./hooks/useHistory"
1212import { HistoryItem , Tab , AuthConfig } from "./types"
1313import { Panel , PanelGroup , PanelResizeHandle } from "react-resizable-panels"
1414import { Toaster } from "sonner"
15-
16- // Utility function to get clean tab name from URL
17- const getCleanTabName = ( url : string ) : string => {
18- try {
19- // Remove query parameters
20- const urlWithoutQuery = url . split ( '?' ) [ 0 ]
21- // Get last part of path
22- const lastPart = urlWithoutQuery . split ( '/' ) . pop ( )
23- return lastPart || "New Request"
24- } catch ( error ) {
25- return "New Request"
26- }
27- }
15+ import { getRequestNameFromUrl } from "./utils/url"
2816
2917const defaultAuth : AuthConfig = {
3018 type : 'none' ,
@@ -101,7 +89,7 @@ function App() {
10189
10290 const handleHistorySelect = ( item : HistoryItem ) => {
10391 const newTab = createNewTab ( {
104- name : getCleanTabName ( item . url ) ,
92+ name : getRequestNameFromUrl ( item . url ) ,
10593 method : item . method ,
10694 url : item . url ,
10795 rawUrl : item . rawUrl ,
@@ -119,7 +107,13 @@ function App() {
119107 < div className = "dark h-screen overflow-hidden" >
120108 < Toaster theme = "dark" position = "bottom-right" />
121109 < div className = "h-full flex flex-col bg-background text-foreground min-w-0" >
122- < TitleBar />
110+ < TitleBar
111+ currentRequest = { currentTab }
112+ onRequestSelect = { ( request ) => {
113+ setTabs ( ( prev : Tab [ ] ) => [ ...prev , request ] )
114+ setActiveTab ( request . id )
115+ } }
116+ />
123117 < div className = "flex-1 min-h-0 min-w-0" >
124118 < PanelGroup direction = "horizontal" >
125119 < Panel defaultSize = { 20 } minSize = { 15 } >
@@ -160,17 +154,27 @@ function App() {
160154 contentType = { currentTab . contentType }
161155 auth = { currentTab . auth }
162156 cookies = { currentTab . cookies }
157+ response = { currentTab . response }
158+ testScripts = { currentTab . testScripts }
159+ testAssertions = { currentTab . testAssertions }
160+ testResults = { currentTab . testResults }
163161 onMethodChange = { ( method ) => updateTab ( currentTab . id , { method } ) }
164162 onUrlChange = { ( rawUrl ) => {
165- const name = getCleanTabName ( rawUrl )
166- updateTab ( currentTab . id , { rawUrl, url : rawUrl , name } )
163+ updateTab ( currentTab . id , {
164+ rawUrl,
165+ url : rawUrl ,
166+ name : getRequestNameFromUrl ( rawUrl )
167+ } )
167168 } }
168169 onParamsChange = { ( params ) => updateTab ( currentTab . id , { params } ) }
169170 onHeadersChange = { ( headers ) => updateTab ( currentTab . id , { headers } ) }
170171 onBodyChange = { ( body ) => updateTab ( currentTab . id , { body } ) }
171172 onContentTypeChange = { ( contentType ) => updateTab ( currentTab . id , { contentType } ) }
172173 onAuthChange = { ( auth ) => updateTab ( currentTab . id , { auth } ) }
173174 onCookiesChange = { ( cookies ) => updateTab ( currentTab . id , { cookies } ) }
175+ onTestScriptsChange = { ( testScripts ) => updateTab ( currentTab . id , { testScripts } ) }
176+ onTestAssertionsChange = { ( testAssertions ) => updateTab ( currentTab . id , { testAssertions } ) }
177+ onTestResultsChange = { ( testResults ) => updateTab ( currentTab . id , { testResults } ) }
174178 onSend = { ( ) => handleSend ( currentTab . id ) }
175179 />
176180 </ Panel >
0 commit comments